List of usage examples for com.liferay.portal.kernel.model Role isTeam
public boolean isTeam();
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 ww w .j a v a2 s .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;//w w w.j a va 2 s .c o m } 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.roles.admin.internal.exportimport.data.handler.RolesAdminPortletDataHandler.java
License:Open Source License
@Override protected PortletPreferences doDeleteData(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception { if (portletDataContext.addPrimaryKey(RolesAdminPortletDataHandler.class, "deleteData")) { return portletPreferences; }//from w w w . ja v a 2s . c o m List<Role> roles = _roleLocalService.getRoles(portletDataContext.getCompanyId()); for (Role role : roles) { if (!role.isSystem() && !role.isTeam()) { _roleLocalService.deleteRole(role); } } return portletPreferences; }