List of usage examples for com.liferay.portal.kernel.service RoleLocalServiceUtil fetchRole
public static com.liferay.portal.kernel.model.Role fetchRole(long roleId)
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 .j a va 2s . com*/ } } } 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); } } }
From source file:com.liferay.exportimport.lar.PortletDataContextImpl.java
License:Open Source License
@Override public void addPermissions(String resourceName, long resourcePK) { if (!MapUtil.getBoolean(_parameterMap, PortletDataHandlerKeys.PERMISSIONS)) { return;/*from w ww . ja va 2s .com*/ } Map<Long, Set<String>> roleIdsToActionIds = ExportImportPermissionUtil.getRoleIdsToActionIds(_companyId, resourceName, resourcePK); List<KeyValuePair> permissions = new ArrayList<>(); for (Map.Entry<Long, Set<String>> entry : roleIdsToActionIds.entrySet()) { long roleId = entry.getKey(); Set<String> availableActionIds = entry.getValue(); Role role = RoleLocalServiceUtil.fetchRole(roleId); if (role == null) { continue; } String roleName = role.getName(); if (role.isTeam()) { try { roleName = ExportImportPermissionUtil.getTeamRoleName(role.getDescriptiveName()); } catch (PortalException pe) { _log.error(pe, pe); } } KeyValuePair permission = new KeyValuePair(roleName, StringUtil.merge(availableActionIds)); permissions.add(permission); } if (permissions.isEmpty()) { return; } _permissionsMap.put(getPrimaryKeyString(resourceName, resourcePK), permissions); }
From source file:com.liferay.users.admin.web.internal.display.context.UserDisplayContext.java
License:Open Source License
private boolean _isOrganizationRole(UserGroupRole userGroupRole) { long roleId = userGroupRole.getRoleId(); Role role = RoleLocalServiceUtil.fetchRole(roleId); if ((role != null) && (role.getType() == RoleConstants.TYPE_ORGANIZATION)) { return true; }//w w w. j av a 2 s. co m return false; }
From source file:com.liferay.users.admin.web.internal.display.context.UserDisplayContext.java
License:Open Source License
private boolean _isSiteRole(UserGroupRole userGroupRole) { long roleId = userGroupRole.getRoleId(); Role role = RoleLocalServiceUtil.fetchRole(roleId); if ((role != null) && (role.getType() == RoleConstants.TYPE_SITE)) { return true; }//from w w w . j a va 2 s.c o m return false; }