Skip to content

Commit

Permalink
IQSS#8417 Only show permissions that are available for the dvobject
Browse files Browse the repository at this point in the history
  • Loading branch information
haarli committed Feb 11, 2022
1 parent 3adc129 commit 4a03b49
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,11 @@ public List<RoleAssignmentRow> initRoleAssignments() {
List<RoleAssignmentRow> raList = null;
if (dvObject != null && dvObject.getId() != null) {
Set<RoleAssignment> ras = roleService.rolesAssignments(dvObject);
List<DataverseRole> availableRoles = getAvailableRoles();
raList = new ArrayList<>(ras.size());
for (RoleAssignment roleAssignment : ras) {
//do not display DatasetCreator roles on dataset permission level, as it only makes sense on Dataverse level
boolean isDatasetCreatorOnDataverse = dvObject instanceof Dataset && DataverseRole.DS_CONTRIBUTOR.equals(roleAssignment.getRole().getAlias());
// for files, only show role assignments which can download
if ((!(dvObject instanceof DataFile) || roleAssignment.getRole().permissions().contains(Permission.DownloadFile)) && !isDatasetCreatorOnDataverse) {
// only show roles that are available for this DVObject
if (availableRoles.contains(roleAssignment.getRole())) {
RoleAssignee roleAssignee = roleAssigneeService.getRoleAssignee(roleAssignment.getAssigneeIdentifier());
if (roleAssignee != null) {
raList.add(new RoleAssignmentRow(roleAssignment, roleAssignee.getDisplayInfo()));
Expand Down

0 comments on commit 4a03b49

Please sign in to comment.