use of com.emc.storageos.model.auth.RoleAssignmentEntry in project coprhd-controller by CoprHD.
the class PermissionsHelper method convertToRoleAssignments.
/**
* Converts StringSetMap of permissions into a list of assignment entries as used by the API
*
* @param roleAssignments
* @param forZone
* @return
*/
public ArrayList<RoleAssignmentEntry> convertToRoleAssignments(StringSetMap roleAssignments, boolean forZone) {
ArrayList<RoleAssignmentEntry> assignments = new ArrayList<RoleAssignmentEntry>();
if (roleAssignments != null && !roleAssignments.isEmpty()) {
for (Map.Entry<String, AbstractChangeTrackingSet<String>> roleAssignment : roleAssignments.entrySet()) {
PermissionsKey rowKey = new PermissionsKey();
rowKey.parseFromString(roleAssignment.getKey());
RoleAssignmentEntry entry = new RoleAssignmentEntry();
if (rowKey.getType().equals(PermissionsKey.Type.GROUP)) {
entry.setGroup(rowKey.getValue());
} else if (rowKey.getType().equals(PermissionsKey.Type.SID)) {
entry.setSubjectId(rowKey.getValue());
}
for (String role : roleAssignment.getValue()) {
if ((forZone && isRoleZoneLevel(role)) || (!forZone && isRoleTenantLevel(role))) {
entry.getRoles().add(role);
}
}
if (!entry.getRoles().isEmpty()) {
assignments.add(entry);
}
}
}
return assignments;
}
Aggregations