private CRole buildRole( Entry<String, ContentClass> entry, String method ) { String content = entry.getKey(); CRole view = new CRole(); view.setId( content + "-all-" + method ); String contentClassName = entry.getValue().getName(); if ( entry.getValue() instanceof RootContentClass ) { // NXCM-3544 set name to empty string to generate 'All Repositories' role name/description contentClassName = ""; } view.setDescription( "Gives access to " + method + " ALL " + contentClassName + " Repositories in Nexus." ); method = StringUtils.capitalizeFirstLetter( method ); view.setName( "Repo: All " + contentClassName + " Repositories (" + method + ")" ); view.setSessionTimeout( 60 ); List<? extends Repository> repos = getRepositoriesWithContentClass( entry.getValue() ); for ( Repository repo : repos ) { view.addPrivilege( "repository-" + repo.getId() ); } return view; }
public static CRole toCRole(RoleResource resource) { CRole role = new CRole(); role.setId(resource.getId()); role.setDescription(resource.getDescription()); role.setName(resource.getName()); role.setSessionTimeout(resource.getSessionTimeout()); role.getRoles().clear(); for (String roleId : (List<String>) resource.getRoles()) { role.addRole(roleId); } role.getPrivileges().clear(); for (String privId : (List<String>) resource.getPrivileges()) { role.addPrivilege(privId); } return role; } }
protected CRole toRole( Role role ) { CRole secRole = new CRole(); secRole.setId( role.getRoleId() ); secRole.setName( role.getName() ); secRole.setDescription( role.getDescription() ); secRole.setReadOnly( role.isReadOnly() ); // null check if ( role.getPrivileges() != null ) { secRole.setPrivileges( new ArrayList<String>( role.getPrivileges() ) ); } else { secRole.setPrivileges( new ArrayList<String>() ); } // null check if ( role.getRoles() != null ) { secRole.setRoles( new ArrayList<String>( role.getRoles() ) ); } else { secRole.setRoles( new ArrayList<String>() ); } return secRole; }
newRole.setId( roleA.getId() ); newRole.setRoles( new ArrayList<String>( roles ) ); newRole.setPrivileges( new ArrayList<String>( privs ) );