From 73d72167eb3ba1d5017b6108dd76b5627bf108dc Mon Sep 17 00:00:00 2001 From: Gustavo Durand Date: Fri, 11 Feb 2022 16:08:51 -0500 Subject: [PATCH] Update ManagePermissionsPage.java --- .../harvard/iq/dataverse/ManagePermissionsPage.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/ManagePermissionsPage.java b/src/main/java/edu/harvard/iq/dataverse/ManagePermissionsPage.java index 889656ff8b5..06291e8a6ad 100644 --- a/src/main/java/edu/harvard/iq/dataverse/ManagePermissionsPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/ManagePermissionsPage.java @@ -420,9 +420,15 @@ public List getAvailableRoles() { } } else if (dvObject instanceof DataFile) { - // TODO: consider changing the logic here to be more like for Dataset - // in order to capture new roles that get added having only File scoped permissions - roles.add(roleService.findBuiltinRoleByAlias(DataverseRole.FILE_DOWNLOADER)); + // only show roles that have File level permissions + // current the available roles for a file are gotten from its parent's parent + for (DataverseRole role : roleService.availableRoles(dvObject.getOwner().getOwner().getId())) { + for (Permission permission : role.permissions()) { + if (permission.appliesTo(DataFile.class)) { + roles.add(role); + break; + } + } } Collections.sort(roles, DataverseRole.CMP_BY_NAME);