/** * Returns the role ID of this role. * * @return the role ID of this role */ @Override public long getRoleId() { return _role.getRoleId(); }
@Override public int compare(Role role1, Role role2) { int value = 0; if (role1.getType() > role2.getType()) { value = 1; } else if (role1.getType() < role2.getType()) { value = -1; } if (value == 0) { String name1 = role1.getName(); String name2 = role2.getName(); value = name1.compareTo(name2); } if (_ascending) { return value; } return -value; }
@Override public int compare(Role role1, Role role2) { String description1 = role1.getDescription(); String description2 = role2.getDescription(); int value = description1.compareTo(description2); if (value == 0) { String name1 = role1.getName(); String name2 = role2.getName(); value = name1.compareTo(name2); } if (_ascending) { return value; } return -value; }
public static RoleSoap toSoapModel(Role model) { RoleSoap soapModel = new RoleSoap(); soapModel.setMvccVersion(model.getMvccVersion()); soapModel.setUuid(model.getUuid()); soapModel.setRoleId(model.getRoleId()); soapModel.setCompanyId(model.getCompanyId()); soapModel.setUserId(model.getUserId()); soapModel.setUserName(model.getUserName()); soapModel.setCreateDate(model.getCreateDate()); soapModel.setModifiedDate(model.getModifiedDate()); soapModel.setClassNameId(model.getClassNameId()); soapModel.setClassPK(model.getClassPK()); soapModel.setName(model.getName()); soapModel.setTitle(model.getTitle()); soapModel.setDescription(model.getDescription()); soapModel.setType(model.getType()); soapModel.setSubtype(model.getSubtype()); return soapModel; }
String roleName = role.getName(); if (role.isTeam()) { try { roleName = ExportImportPermissionUtil.getTeamRoleName( role.getDescriptiveName()); 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());
private SearchPermissionContext( Set<Role> roles, List<UsersGroupIdRoles> usersGroupIdsRoles) { _usersGroupIdsRoles = usersGroupIdsRoles; List<Long> roleIds = new ArrayList<>(roles.size()); List<Long> regularRoleIds = new ArrayList<>(); for (Role role : roles) { roleIds.add(role.getRoleId()); if (role.getType() == RoleConstants.TYPE_REGULAR) { regularRoleIds.add(role.getRoleId()); } _rolesTermsFilter.addValue(String.valueOf(role.getRoleId())); } _roleIds = ArrayUtil.toLongArray(roleIds); _regularRoleIds = ArrayUtil.toLongArray(regularRoleIds); for (UsersGroupIdRoles usersGroupIdRoles : _usersGroupIdsRoles) { long groupId = usersGroupIdRoles._groupId; List<Role> groupRoles = usersGroupIdRoles._groupRoles; for (Role groupRole : groupRoles) { _groupRolesTermsFilter.addValue( groupId + StringPool.DASH + groupRole.getRoleId()); } } }
@Override public boolean isRoleProtected( PermissionChecker permissionChecker, long userId, long organizationId, long roleId) throws PortalException { if (permissionChecker.isOrganizationOwner(organizationId)) { return false; } Role role = RoleLocalServiceUtil.getRole(roleId); String roleName = role.getName(); if (!roleName.equals(RoleConstants.ORGANIZATION_ADMINISTRATOR) && !roleName.equals(RoleConstants.ORGANIZATION_OWNER)) { return false; } Organization organization = OrganizationLocalServiceUtil.getOrganization(organizationId); Group group = organization.getGroup(); if (UserGroupRoleLocalServiceUtil.hasUserGroupRole( userId, group.getGroupId(), role.getRoleId())) { return true; } return false; }
public static List<Role> getRoles(ThemeDisplay themeDisplay) throws Exception { List<Role> filteredRoles = new ArrayList<>(); List<Role> roles = RoleLocalServiceUtil.getRoles( themeDisplay.getCompanyId()); for (Role role : roles) { if (role.isTeam()) { Team team = TeamLocalServiceUtil.getTeam(role.getClassPK()); if (GroupPermissionUtil.contains( themeDisplay.getPermissionChecker(), team.getGroupId(), ActionKeys.MANAGE_ANNOUNCEMENTS) && RolePermissionUtil.contains( themeDisplay.getPermissionChecker(), team.getGroupId(), role.getRoleId(), ActionKeys.MANAGE_ANNOUNCEMENTS)) { filteredRoles.add(role); } } else if (RolePermissionUtil.contains( themeDisplay.getPermissionChecker(), role.getRoleId(), ActionKeys.MANAGE_ANNOUNCEMENTS)) { filteredRoles.add(role); } } return filteredRoles; }
/** * Returns the type of this role. * * @return the type of this role */ @Override public int getType() { return _role.getType(); }
String roleName = role.getName(); if (role.isTeam()) { try { roleName = ExportImportPermissionUtil.getTeamRoleName( role.getDescriptiveName());
/** * Returns the title of this role. * * @return the title of this role */ @Override public String getTitle() { return _role.getTitle(); }
/** * Returns the name of this role. * * @return the name of this role */ @Override public String getName() { return _role.getName(); }
/** * Returns the localized description of this role in the language. Uses the default language if no localization exists for the requested language. * * @param locale the locale of the language * @return the localized description of this role */ @Override public String getDescription(java.util.Locale locale) { return _role.getDescription(locale); }
@Override public String getDescriptiveName() throws com.liferay.portal.kernel.exception.PortalException { return _role.getDescriptiveName(); }
/** * Returns the uuid of this role. * * @return the uuid of this role */ @Override public String getUuid() { return _role.getUuid(); }
@Override public boolean isTeam() { return _role.isTeam(); }
/** * Returns the subtype of this role. * * @return the subtype of this role */ @Override public String getSubtype() { return _role.getSubtype(); }
public static Role getRole( String name, int roleType, boolean autoCreate, ServiceContext serviceContext) throws PortalException { Role role = null; try { role = RoleLocalServiceUtil.getRole( serviceContext.getCompanyId(), name); if (role.getType() != roleType) { throw new DuplicateRoleException( "Role already exists with name " + name); } } catch (NoSuchRoleException nsre) { if (!autoCreate) { throw nsre; } Map<Locale, String> descriptionMap = new HashMap<>(); descriptionMap.put( LocaleUtil.getDefault(), "This is an autogenerated role from the workflow definition."); role = RoleLocalServiceUtil.addRole( serviceContext.getUserId(), null, 0, name, null, descriptionMap, roleType, null, null); } return role; }