Skip to content

Commit

Permalink
#6524 allow user with view draft permission to get size of download
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Feb 4, 2020
1 parent 8885157 commit 7237c4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions src/main/java/edu/harvard/iq/dataverse/DatasetServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -893,24 +893,18 @@ public long findStorageSize(Dataset dataset, boolean countCachedExtras, String m
if (dataset.isHarvested()) {
return 0L;
}

System.out.print("mode: " + mode);
System.out.print("dataset: " + dataset);
System.out.print("version: " + version);

List<DataFile> filesToTalley = new ArrayList();

if (version == null || (mode != null && mode.equals("storage"))){
filesToTalley = dataset.getFiles();
} else {
List <FileMetadata> fmds = version.getFileMetadatas();
System.out.print("FileMetadata: " + fmds.size());
for (FileMetadata fmd : fmds){
filesToTalley.add(fmd.getDataFile());
}

filesToTalley.add(fmd.getDataFile());
}
}

System.out.print("filesToTalley: " + filesToTalley.size());


//CACHED EXTRAS FOR DOWNLOAD?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Map<String, Set<Permission>> getRequiredPermissions() {
// for data file check permission on owning dataset
return Collections.singletonMap("",
mode != null && mode.equals("storage") ? Collections.singleton(Permission.ViewUnpublishedDataset)
: Collections.<Permission>emptySet());
: version !=null && version.isDraft() ? Collections.singleton(Permission.ViewUnpublishedDataset) : Collections.<Permission>emptySet());
}

}

0 comments on commit 7237c4f

Please sign in to comment.