List of usage examples for com.liferay.portal.kernel.security.permission ResourceActionsUtil getPortletResourceActions
public static List<String> getPortletResourceActions(String name)
From source file:com.liferay.application.list.my.account.permissions.internal.PanelAppMyAccountPermissions.java
License:Open Source License
public void initPermissions(long companyId, List<Portlet> portlets) { Role userRole = _getUserRole(companyId); if (userRole == null) { return;// w w w . j a v a 2 s. c om } for (Portlet portlet : portlets) { try { List<String> actionIds = ResourceActionsUtil.getPortletResourceActions(portlet.getRootPortletId()); _initPermissions(companyId, portlet.getPortletId(), portlet.getRootPortletId(), userRole, actionIds); } catch (Exception e) { _log.error(StringBundler.concat("Unable to initialize My Account panel permissions ", "for portlet ", portlet.getPortletId(), " in company ", String.valueOf(companyId)), e); } } }
From source file:com.liferay.application.list.user.personal.site.permissions.internal.UserPersonalSitePermissions.java
License:Open Source License
protected void initPermissions(long companyId, long powerUserRoleId, String rootPortletId, long userPersonalSiteGroupId) throws PortalException { String primaryKey = String.valueOf(userPersonalSiteGroupId); if (_resourcePermissionLocalService.getResourcePermissionsCount(companyId, rootPortletId, ResourceConstants.SCOPE_GROUP, primaryKey) == 0) { List<String> portletActionIds = ResourceActionsUtil.getPortletResourceActions(rootPortletId); _resourcePermissionLocalService.setResourcePermissions(companyId, rootPortletId, ResourceConstants.SCOPE_GROUP, String.valueOf(userPersonalSiteGroupId), powerUserRoleId, portletActionIds.toArray(new String[0])); }/* ww w . j a v a2 s . c o m*/ String modelName = ResourceActionsUtil.getPortletRootModelResource(rootPortletId); if (Validator.isBlank(modelName)) { return; } if (_resourcePermissionLocalService.getResourcePermissionsCount(companyId, modelName, ResourceConstants.SCOPE_GROUP, primaryKey) == 0) { List<String> modelActionIds = ResourceActionsUtil.getModelResourceActions(modelName); _resourcePermissionLocalService.setResourcePermissions(companyId, modelName, ResourceConstants.SCOPE_GROUP, String.valueOf(userPersonalSiteGroupId), powerUserRoleId, modelActionIds.toArray(new String[0])); } }
From source file:com.liferay.exportimport.lar.PermissionExporter.java
License:Open Source License
protected void exportPermissions(PortletDataContext portletDataContext, String resourceName, String resourcePrimKey, Element permissionsElement) throws Exception { List<String> actionIds = ResourceActionsUtil.getPortletResourceActions(resourceName); Map<Long, Set<String>> roleToActionIds = ExportImportPermissionUtil .getRoleIdsToActionIds(portletDataContext.getCompanyId(), resourceName, resourcePrimKey, actionIds); for (Map.Entry<Long, Set<String>> entry : roleToActionIds.entrySet()) { long roleId = entry.getKey(); Role role = RoleLocalServiceUtil.fetchRole(roleId); String roleName = role.getName(); if (role.isTeam()) { try { roleName = ExportImportPermissionUtil.getTeamRoleName(role.getDescriptiveName()); } catch (PortalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe);//from w w w. ja v a 2s. c o m } } } Element roleElement = permissionsElement.addElement("role"); roleElement.addAttribute("uuid", role.getUuid()); roleElement.addAttribute("name", roleName); roleElement.addAttribute("title", role.getTitle()); roleElement.addAttribute("description", role.getDescription()); roleElement.addAttribute("type", String.valueOf(role.getType())); roleElement.addAttribute("subtype", role.getSubtype()); Set<String> availableActionIds = entry.getValue(); for (String actionId : availableActionIds) { Element actionKeyElement = roleElement.addElement("action-key"); actionKeyElement.addText(actionId); } } }