Search in sources :

Example 1 with ProjectRole

use of com.enonic.xp.project.ProjectRole in project xp by enonic.

the class CreateProjectRolesCommand method doCreateRoles.

private void doCreateRoles() {
    for (ProjectRole projectRole : ProjectRole.values()) {
        final PrincipalKey roleKey = ProjectAccessHelper.createRoleKey(projectName, projectRole);
        final String roleDisplayName = createRoleDisplayName(projectRole);
        securityService.getRole(roleKey).orElseGet(() -> doCreateRole(roleKey, roleDisplayName));
    }
}
Also used : ProjectRole(com.enonic.xp.project.ProjectRole) PrincipalKey(com.enonic.xp.security.PrincipalKey)

Example 2 with ProjectRole

use of com.enonic.xp.project.ProjectRole in project xp by enonic.

the class UpdateProjectRoleNamesCommand method doUpdateRoles.

private void doUpdateRoles() {
    for (ProjectRole projectRole : ProjectRole.values()) {
        final PrincipalKey roleKey = ProjectAccessHelper.createRoleKey(projectName, projectRole);
        final String newRoleDisplayName = createRoleDisplayName(projectRole);
        securityService.getRole(roleKey).filter(role -> !newRoleDisplayName.equals(role.getDisplayName())).ifPresent((roleValue) -> doUpdateRoleDisplayName(roleValue, newRoleDisplayName));
    }
}
Also used : UpdateRoleParams(com.enonic.xp.security.UpdateRoleParams) ProjectRole(com.enonic.xp.project.ProjectRole) PrincipalKey(com.enonic.xp.security.PrincipalKey) Preconditions(com.google.common.base.Preconditions) Role(com.enonic.xp.security.Role) ProjectRole(com.enonic.xp.project.ProjectRole) PrincipalKey(com.enonic.xp.security.PrincipalKey)

Aggregations

ProjectRole (com.enonic.xp.project.ProjectRole)2 PrincipalKey (com.enonic.xp.security.PrincipalKey)2 Role (com.enonic.xp.security.Role)1 UpdateRoleParams (com.enonic.xp.security.UpdateRoleParams)1 Preconditions (com.google.common.base.Preconditions)1