Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6587 deleted files shown on grant permission #6659

Merged
merged 27 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0c1f53f
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 10, 2020
a016b12
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 11, 2020
1d5983a
#6587 check file status before adding to map
sekmiller Feb 11, 2020
ba0c7f7
#6587 add boolean for show deleted files
sekmiller Feb 11, 2020
641a0e1
#6587 Add toggle for Include Deleted Files
sekmiller Feb 12, 2020
b3e8ccf
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 12, 2020
b9ba76e
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 12, 2020
d83c881
#6587 add file directory label to manage permissions
sekmiller Feb 12, 2020
3556433
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 13, 2020
b56df57
#6587 add status annotation to file list
sekmiller Feb 13, 2020
0d1a726
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 13, 2020
38f4885
#6587 add notations for deleted files
sekmiller Feb 18, 2020
64bca69
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 18, 2020
86b7aee
#6587 cleanup formatting of Grant Access popup
sekmiller Feb 18, 2020
7112a83
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 18, 2020
8fbc2b4
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 18, 2020
faceebc
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 18, 2020
e6276d7
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 19, 2020
32d5fef
#6587 move "Deleted" to after file name
sekmiller Feb 19, 2020
222bf50
#6587 remove directory label
sekmiller Feb 19, 2020
7aca3e8
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 19, 2020
c279350
#6587 include deleted on both panels
sekmiller Feb 19, 2020
76c393e
#6587 suppress deleted files for assign access
sekmiller Feb 20, 2020
1aaa01f
Merge branch 'develop' into 6587-deleted-files-shown-on-grant-permission
sekmiller Feb 20, 2020
f2748b7
Added text-muted styles to file path in Manage Restricted Files pg [r…
mheppler Feb 20, 2020
61b24ee
#6587 fix refresh - default show deleted
sekmiller Feb 20, 2020
c682249
#6587 remove stray ;
sekmiller Feb 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/DataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Pattern;
import org.hibernate.validator.constraints.NotBlank;

Expand Down Expand Up @@ -227,8 +228,24 @@ public DataFile(String contentType) {
this.fileMetadatas = new ArrayList<>();
initFileReplaceAttributes();
}



/*
Used in manage file permissions UI
to easily display those files that have been deleted in the current draft
or previous version which may have roles assigned or pending requests for access
*/

@Transient
private boolean deleted;

public boolean isDeleted() {
return deleted;
}

public void setDeleted(boolean deleted) {
this.deleted = deleted;
}

/**
* All constructors should use this method
* to initialize this file replace attributes
Expand Down Expand Up @@ -751,6 +768,10 @@ public String getDisplayName() {
return getLatestFileMetadata().getLabel();
}

public String getDirectoryLabel() {
return getLatestFileMetadata().getDirectoryLabel();
}

@Override
public String getCurrentName(){
return getLatestFileMetadata().getLabel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,16 @@ public class ManageFilePermissionsPage implements java.io.Serializable {
Dataset dataset = new Dataset();
private final TreeMap<RoleAssignee,List<RoleAssignmentRow>> roleAssigneeMap = new TreeMap<>();
private final TreeMap<DataFile,List<RoleAssignmentRow>> fileMap = new TreeMap<>();
private final TreeMap<AuthenticatedUser,List<DataFile>> fileAccessRequestMap = new TreeMap<>();
private final TreeMap<AuthenticatedUser,List<DataFile>> fileAccessRequestMap = new TreeMap<>();
private boolean showDeleted = true;

public boolean isShowDeleted() {
return showDeleted;
}

public void setShowDeleted(boolean showDeleted) {
this.showDeleted = showDeleted;
}

public Dataset getDataset() {
return dataset;
Expand Down Expand Up @@ -130,20 +139,27 @@ private void initMaps() {
fileAccessRequestMap.clear();

for (DataFile file : dataset.getFiles()) {
// only include if the file is restricted (or it's draft version is restricted)

boolean fileIsDeleted = !((dataset.getLatestVersion().isDraft() && file.getFileMetadata().getDatasetVersion().isDraft())
|| (dataset.getLatestVersion().isReleased() && file.getFileMetadata().getDatasetVersion().equals(dataset.getLatestVersion())));
// only include if the file is restricted (or its draft version is restricted)
//Added a null check in case there are files that have no metadata records SEK
if (file.getFileMetadata() != null && (file.isRestricted() || file.getFileMetadata().isRestricted())) {
//for 6587 make sure that a file is in the current version befor adding to the fileMap SEK 2/11/2020
if (file.getFileMetadata() != null && (file.isRestricted() || file.getFileMetadata().isRestricted())
&& (!fileIsDeleted || isShowDeleted())) {
// we get the direct role assignments assigned to the file
List<RoleAssignment> ras = roleService.directRoleAssignments(file);
List<RoleAssignmentRow> raList = new ArrayList<>(ras.size());
for (RoleAssignment ra : ras) {
// for files, only show role assignments which can download
if (ra.getRole().permissions().contains(Permission.DownloadFile)) {
raList.add(new RoleAssignmentRow(ra, roleAssigneeService.getRoleAssignee(ra.getAssigneeIdentifier(), true).getDisplayInfo()));
addFileToRoleAssignee(ra);
raList.add(new RoleAssignmentRow(ra, roleAssigneeService.getRoleAssignee(ra.getAssigneeIdentifier(), true).getDisplayInfo(), fileIsDeleted));
addFileToRoleAssignee(ra, fileIsDeleted);
}
}

file.setDeleted(fileIsDeleted);

fileMap.put(file, raList);

// populate the file access requests map
Expand All @@ -166,15 +182,15 @@ public String getAuthProviderFriendlyName(String authProviderId){
return AuthenticationProvider.getFriendlyName(authProviderId);
}

private void addFileToRoleAssignee(RoleAssignment assignment) {
private void addFileToRoleAssignee(RoleAssignment assignment, boolean fileDeleted) {
RoleAssignee ra = roleAssigneeService.getRoleAssignee(assignment.getAssigneeIdentifier());
List<RoleAssignmentRow> assignments = roleAssigneeMap.get(ra);
if (assignments == null) {
assignments = new ArrayList<>();
roleAssigneeMap.put(ra, assignments);
}

assignments.add(new RoleAssignmentRow(assignment, ra.getDisplayInfo()));
assignments.add(new RoleAssignmentRow(assignment, ra.getDisplayInfo(), fileDeleted));
}

/*
Expand Down Expand Up @@ -299,13 +315,19 @@ public AuthenticatedUser getFileRequester() {


public void initAssignDialog(ActionEvent ae) {

showDeleted = false;
initMaps();

fileRequester = null;
selectedRoleAssignees = null;
selectedFiles.clear();
showUserGroupMessages();
}

public void initAssignDialogByFile(DataFile file) {
showDeleted = false;
initMaps();
fileRequester = null;
selectedRoleAssignees = null;
selectedFiles.clear();
Expand Down Expand Up @@ -466,11 +488,27 @@ public static class RoleAssignmentRow {

private final RoleAssigneeDisplayInfo assigneeDisplayInfo;
private final RoleAssignment ra;
//Used when a file to which there has been a role assignment added is deleted

private final boolean deleted;

public boolean isDeleted() {
return deleted;
}

public RoleAssignmentRow(RoleAssignment anRa, RoleAssigneeDisplayInfo disInf) {
this.ra = anRa;
this.assigneeDisplayInfo = disInf;
}
this.deleted = false;
}

public RoleAssignmentRow(RoleAssignment anRa, RoleAssigneeDisplayInfo disInf, boolean deleted) {

this.ra = anRa;
this.assigneeDisplayInfo = disInf;
this.deleted = deleted;

}


public RoleAssigneeDisplayInfo getAssigneeDisplayInfo() {
Expand All @@ -485,6 +523,7 @@ public DvObject getDefinitionPoint() {
public Long getId() {
return ra.getId();
}


}
}
1 change: 1 addition & 0 deletions src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ dataverse.permissionsFiles.files.assignBtn=Assign Access
dataverse.permissionsFiles.files.invalidMsg=There are no restricted files in this dataset.
dataverse.permissionsFiles.files.requested=Requested Files
dataverse.permissionsFiles.files.selected=Selecting {0} of {1} {2}
dataverse.permissionsFiles.files.includeDeleted=Include Deleted Files
dataverse.permissionsFiles.viewRemoveDialog.header=File Access
dataverse.permissionsFiles.viewRemoveDialog.removeBtn=Remove Access
dataverse.permissionsFiles.viewRemoveDialog.removeBtn.confirmation=Are you sure you want to remove access to this file? Once access has been removed, the user or group will no longer be able to download this file.
Expand Down
Loading