From 7237c4f6a44ffc72943e1d978a5f3eb599fb7edf Mon Sep 17 00:00:00 2001 From: Stephen Kraffmiller Date: Tue, 4 Feb 2020 10:29:28 -0500 Subject: [PATCH] #6524 allow user with view draft permission to get size of download --- .../harvard/iq/dataverse/DatasetServiceBean.java | 14 ++++---------- .../command/impl/GetDatasetStorageSizeCommand.java | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/DatasetServiceBean.java index 661b3cda448..74f99416db7 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetServiceBean.java @@ -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 filesToTalley = new ArrayList(); if (version == null || (mode != null && mode.equals("storage"))){ filesToTalley = dataset.getFiles(); } else { List 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? diff --git a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/GetDatasetStorageSizeCommand.java b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/GetDatasetStorageSizeCommand.java index 65882648669..c167c513955 100644 --- a/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/GetDatasetStorageSizeCommand.java +++ b/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/GetDatasetStorageSizeCommand.java @@ -73,7 +73,7 @@ public Map> getRequiredPermissions() { // for data file check permission on owning dataset return Collections.singletonMap("", mode != null && mode.equals("storage") ? Collections.singleton(Permission.ViewUnpublishedDataset) - : Collections.emptySet()); + : version !=null && version.isDraft() ? Collections.singleton(Permission.ViewUnpublishedDataset) : Collections.emptySet()); } }