Skip to content

Commit

Permalink
further improve separation of download/transfer and messages
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Mar 29, 2024
1 parent 08fdc2c commit a902547
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 50 deletions.
73 changes: 49 additions & 24 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -1234,8 +1234,17 @@ public boolean canDownloadFiles() {
canDownloadFiles = false;
for (FileMetadata fmd : workingVersion.getFileMetadatas()) {
if (fileDownloadHelper.canDownloadFile(fmd)) {
canDownloadFiles = true;
break;
if (isVersionHasGlobus()) {
String driverId = DataAccess
.getStorageDriverFromIdentifier(fmd.getDataFile().getStorageIdentifier());
if (StorageIO.isDataverseAccessible(driverId)) {
canDownloadFiles = true;
break;
}
} else {
canDownloadFiles = true;
break;
}
}
}
}
Expand Down Expand Up @@ -3260,7 +3269,7 @@ public void startDownloadSelectedOriginal() {

private void startDownload(boolean downloadOriginal){
boolean guestbookRequired = isDownloadPopupRequired();
boolean validate = validateFilesForDownload(downloadOriginal);
boolean validate = validateFilesForDownload(downloadOriginal, false);
if (validate) {
updateGuestbookResponse(guestbookRequired, downloadOriginal, false);
if(!guestbookRequired && !getValidateFilesOutcome().equals("Mixed")){
Expand All @@ -3283,7 +3292,7 @@ public void setValidateFilesOutcome(String validateFilesOutcome) {
this.validateFilesOutcome = validateFilesOutcome;
}

public boolean validateFilesForDownload(boolean downloadOriginal){
public boolean validateFilesForDownload(boolean downloadOriginal, boolean isGlobusTransfer){
if (this.selectedFiles.isEmpty()) {
PrimeFaces.current().executeScript("PF('selectFilesForDownload').show()");
return false;
Expand All @@ -3300,33 +3309,39 @@ public boolean validateFilesForDownload(boolean downloadOriginal){
return false;
}

for (FileMetadata fmd : getSelectedDownloadableFiles()) {
DataFile dataFile = fmd.getDataFile();
if (downloadOriginal && dataFile.isTabularData()) {
bytes += dataFile.getOriginalFileSize() == null ? 0 : dataFile.getOriginalFileSize();
} else {
bytes += dataFile.getFilesize();
if (!isGlobusTransfer) {
for (FileMetadata fmd : getSelectedDownloadableFiles()) {
DataFile dataFile = fmd.getDataFile();
if (downloadOriginal && dataFile.isTabularData()) {
bytes += dataFile.getOriginalFileSize() == null ? 0 : dataFile.getOriginalFileSize();
} else {
bytes += dataFile.getFilesize();
}
}
}

//if there are two or more files, with a total size
//over the zip limit, post a "too large" popup
if (bytes > settingsWrapper.getZipDownloadLimit() && selectedDownloadableFiles.size() > 1) {
setValidateFilesOutcome("FailSize");
return false;
// if there are two or more files, with a total size
// over the zip limit, post a "too large" popup
if (bytes > settingsWrapper.getZipDownloadLimit() && selectedDownloadableFiles.size() > 1) {
setValidateFilesOutcome("FailSize");
return false;
}
}

// If some of the files were restricted and we had to drop them off the
// list, and NONE of the files are left on the downloadable list
// - we show them a "you're out of luck" popup:
if (getSelectedDownloadableFiles().isEmpty() && getSelectedGlobusTransferableFiles().isEmpty() && !getSelectedNonDownloadableFiles().isEmpty()) {
// - we show them a "you're out of luck" popup
// Same for globus transfer
if ((!isGlobusTransfer
&& (getSelectedDownloadableFiles().isEmpty() && !getSelectedNonDownloadableFiles().isEmpty()))
|| (isGlobusTransfer && (getSelectedGlobusTransferableFiles().isEmpty()
&& !getSelectedNonGlobusTransferableFiles().isEmpty()))) {
setValidateFilesOutcome("FailRestricted");
return false;
}

//Some are selected and there are non-downloadable ones or there are both downloadable and globus transferable files
if (((!getSelectedDownloadableFiles().isEmpty() && !getSelectedGlobusTransferableFiles().isEmpty())
|| (!getSelectedNonDownloadableFiles().isEmpty()) && (!getSelectedDownloadableFiles().isEmpty() || !getSelectedGlobusTransferableFiles().isEmpty()))) {
//For download or transfer, there are some that can be downloaded/transferred and some that can't
if ((!isGlobusTransfer && (!getSelectedNonDownloadableFiles().isEmpty() && !getSelectedDownloadableFiles().isEmpty())) ||
(isGlobusTransfer && (!getSelectedNonGlobusTransferableFiles().isEmpty() && !getSelectedGlobusTransferableFiles().isEmpty()))) {
setValidateFilesOutcome("Mixed");
return true;
}
Expand Down Expand Up @@ -6284,12 +6299,18 @@ public void clearSelectionEmbargo() {
PrimeFaces.current().resetInputs("datasetForm:embargoInputs");
}

public boolean isCantDownloadDueToEmbargo() {
public boolean isCantDownloadDueToEmbargoOrDVAccess() {
if (getSelectedNonDownloadableFiles() != null) {
for (FileMetadata fmd : getSelectedNonDownloadableFiles()) {
if (FileUtil.isActivelyEmbargoed(fmd)) {
return true;
}
if (isVersionHasGlobus()) {
if (StorageIO.isDataverseAccessible(
DataAccess.getStorageDriverFromIdentifier(fmd.getDataFile().getStorageIdentifier()))) {
return true;
}
}
}
}
return false;
Expand Down Expand Up @@ -6381,7 +6402,11 @@ public void startGlobusTransfer(boolean transferAll, boolean popupShown) {
}
boolean guestbookRequired = isDownloadPopupRequired();

boolean validated = validateFilesForDownload(true);
boolean validated = validateFilesForDownload(true, true);

logger.info("SGT valid: " + validated);
logger.info("SGT outcome: " + getValidateFilesOutcome());
logger.info("SGT popupshown: " + popupShown);
if (validated) {
globusTransferRequested = true;
boolean mixed = "Mixed".equals(getValidateFilesOutcome());
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1665,17 +1665,19 @@ dataset.noSelectedFiles=Please select one or more files.
dataset.noSelectedFilesForDownload=Please select a file or files to be downloaded.
dataset.noSelectedFilesForRequestAccess=Please select a file or files for access request.
dataset.embargoedSelectedFilesForRequestAccess=Embargoed files cannot be accessed. Please select an unembargoed file or files for your access request.
dataset.inValidSelectedFilesForDownload=Restricted Files Selected
dataset.inValidSelectedFilesForDownloadWithEmbargo=Embargoed and/or Restricted Files Selected
dataset.noValidSelectedFilesForDownload=The selected file(s) may not be downloaded because you have not been granted access.
dataset.inValidSelectedFilesForDownload=Restricted Files, or Files only Acessible Via Globus Selected
dataset.inValidSelectedFilesForDownloadWithEmbargo=Embargoed and/or Restricted Files, or Files only acessible via Globus Selected
dataset.inValidSelectedFilesForTransferWithEmbargo=Embargoed and/or Restricted Files, or Files that are not Globus accessible Selected
dataset.noValidSelectedFilesForDownload=The selected file(s) may not be downloaded because you have not been granted access or the files can only be transferred via Globus.
dataset.noValidSelectedFilesForTransfer=The selected file(s) may not be transferred because you have not been granted access or the files are not Globus accessible.
dataset.mixedSelectedFilesForDownload=The restricted file(s) selected may not be downloaded because you have not been granted access.
dataset.mixedSelectedFilesForDownloadWithEmbargo=The embargoed and/or restricted file(s) selected may not be downloaded because you have not been granted access.
dataset.mixedSelectedFilesForDownloadWithEmbargo=Any embargoed and/or restricted file(s) selected may not be downloaded because you have not been granted access. Some files may only be accessible via Globus.
dataset.mixedSelectedFilesForTransfer=Some file(s) cannot be transferred. (They are restricted, embargoed, or not Globus accessible.)
dataset.inValidSelectedFilesForTransfer=Ineligible Files Selected
dataset.downloadUnrestricted=Click Continue to download the files you have access to download.
dataset.transferUnrestricted=Click Continue to transfer the elligible files.

dataset.requestAccessToRestrictedFiles=You may request access to the restricted file(s) by clicking the Request Access button.
dataset.requestAccessToRestrictedFiles=You may request access any restricted file(s) by clicking the Request Access button.
dataset.requestAccessToRestrictedFilesWithEmbargo=Embargoed files cannot be accessed during the embargo period. If your selection contains restricted files, you may request access to them by clicking the Request Access button.
dataset.privateurl.infoMessageAuthor=Privately share this dataset before it is published: {0}
dataset.privateurl.infoMessageReviewer=This unpublished dataset is being privately shared.
Expand Down
54 changes: 35 additions & 19 deletions src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
and !permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)}"/>
<ui:param name="showReturnToAuthorLink" value="#{DatasetPage.dataset.latestVersion.versionState=='DRAFT' and DatasetPage.dataset.latestVersion.inReview
and permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)}"/>
<ui:param name="showAccessDatasetButtonGroup" value="#{DatasetPage.canDownloadFiles()
<ui:param name="showAccessDatasetButtonGroup" value="#{(DatasetPage.canDownloadFiles() or DatasetPage.versionHasGlobus)
and (!DatasetPage.workingVersion.deaccessioned
or (DatasetPage.workingVersion.deaccessioned and DatasetPage.canUpdateDataset()))}"/>
<!-- TO-DO FIX RSYNC LOGIC !fileMetadata.dataFile.filePackage or
Expand Down Expand Up @@ -235,20 +235,21 @@
<h:outputText value="#{bundle['dataset.accessBtn.too.big']}">
</h:outputText>
</ui:fragment>
<ui:fragment rendered="#{settingsWrapper.globusDownload and settingsWrapper.isGlobusEnabledStorageDriver(DatasetPage.dataset.effectiveStorageDriverId)}">
<li>
<p:commandLink update="@form" oncomplete="showPopup(true);"
actionListener="#{DatasetPage.startGlobusTransfer(true, false)}" styleClass="btn-download">
#{bundle.transfer}
<h:outputFormat value="#{bundle['dataset.accessBtn.transfer.size']}">
<f:param value="#{DatasetPage.sizeOfDataset}" />
</h:outputFormat>
<f:actionListener binding="#{DatasetPage.setTermsGuestbookPopupAction(bundle.download)}"/>
</p:commandLink>
</li>
</ui:fragment>

</ui:fragment>
<ui:fragment rendered="#{DatasetPage.versionHasGlobus}">
<li>
<p:commandLink update="@form" oncomplete="showPopup(true);"
actionListener="#{DatasetPage.startGlobusTransfer(true, false)}" styleClass="btn-download">
#{bundle.transfer}
<h:outputFormat value="#{bundle['dataset.accessBtn.transfer.size']}">
<f:param value="#{DatasetPage.sizeOfDataset}" />
</h:outputFormat>
<f:actionListener binding="#{DatasetPage.setTermsGuestbookPopupAction(bundle.download)}"/>
</p:commandLink>
</li>
</ui:fragment>



<!-- END: DOWNLOAD -->

Expand Down Expand Up @@ -1053,17 +1054,28 @@
</button>
</div>
</p:dialog>
<p:dialog id="downloadInvalid" styleClass="smallPopUp" header="#{DatasetPage.cantDownloadDueToEmbargo ? bundle['dataset.inValidSelectedFilesForDownloadWithEmbargo'] : bundle['dataset.inValidSelectedFilesForDownload']}" widgetVar="downloadInvalid" modal="true">
<p:dialog id="downloadInvalid" styleClass="smallPopUp" header="#{DatasetPage.cantDownloadDueToEmbargoOrDVAccess ? bundle['dataset.inValidSelectedFilesForDownloadWithEmbargo'] : bundle['dataset.inValidSelectedFilesForDownload']}" widgetVar="downloadInvalid" modal="true">
<p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noValidSelectedFilesForDownload']}</p>
<ui:fragment rendered="#{DatasetPage.dataset.fileAccessRequest}">
<p class="help-block">#{DatasetPage.cantDownloadDueToEmbargo ? bundle['dataset.requestAccessToRestrictedFilesWithEmbargo'] : bundle['dataset.requestAccessToRestrictedFiles']}</p>
<p class="help-block">#{DatasetPage.cantDownloadDueToEmbargoOrDVAccess ? bundle['dataset.requestAccessToRestrictedFilesWithEmbargo'] : bundle['dataset.requestAccessToRestrictedFiles']}</p>
</ui:fragment>
<div class="button-block">
<button class="btn btn-default" onclick="PF('downloadInvalid').hide();" type="button">
#{bundle.close}
</button>
</div>
</p:dialog>
<p:dialog id="transferInvalid" styleClass="smallPopUp" header="#{bundle['dataset.inValidSelectedFilesForTransfer']}" widgetVar="transferInvalid" modal="true">
<p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noValidSelectedFilesForTransfer']}</p>
<ui:fragment rendered="#{DatasetPage.dataset.fileAccessRequest}">
<p class="help-block">#{DatasetPage.cantDownloadDueToEmbargoOrDVAccess ? bundle['dataset.requestAccessToRestrictedFilesWithEmbargo'] : bundle['dataset.requestAccessToRestrictedFiles']}</p>
</ui:fragment>
<div class="button-block">
<button class="btn btn-default" onclick="PF('transferInvalid').hide();" type="button">
#{bundle.close}
</button>
</div>
</p:dialog>
<p:dialog id="downloadTooLarge" styleClass="smallPopUp" header="#{bundle['file.zip.download.exceeds.limit.header']}" widgetVar="downloadTooLarge" modal="true">
<p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['file.zip.download.exceeds.limit.info']}</p>

Expand All @@ -1085,8 +1097,8 @@
</button>
</div>
</p:dialog>
<p:dialog id="downloadMixed" styleClass="smallPopUp" header="#{DatasetPage.cantDownloadDueToEmbargo ? bundle['dataset.inValidSelectedFilesForDownloadWithEmbargo'] : bundle['dataset.inValidSelectedFilesForDownload']}" widgetVar="downloadMixed" modal="true">
<p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{DatasetPage.cantDownloadDueToEmbargo ? bundle['dataset.mixedSelectedFilesForDownloadWithEmbargo'] : bundle['dataset.mixedSelectedFilesForDownload']}</p>
<p:dialog id="downloadMixed" styleClass="smallPopUp" header="#{DatasetPage.cantDownloadDueToEmbargoOrDVAccess ? bundle['dataset.inValidSelectedFilesForDownloadWithEmbargo'] : bundle['dataset.inValidSelectedFilesForDownload']}" widgetVar="downloadMixed" modal="true">
<p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{DatasetPage.cantDownloadDueToEmbargoOrDVAccess ? bundle['dataset.mixedSelectedFilesForDownloadWithEmbargo'] : bundle['dataset.mixedSelectedFilesForDownload']}</p>
<table>
<ui:repeat var="resFile" value="#{DatasetPage.selectedNonDownloadableFiles}" >
<tr>
Expand Down Expand Up @@ -1970,7 +1982,11 @@
PF('downloadTooLarge').show();
}
if (outcome ==='FailRestricted'){
PF('downloadInvalid').show();
if(isTransfer) {
PF('transferInvalid').show();
} else {
PF('downloadInvalid').show();
}
}
if (outcome ==='GuestbookRequired'){
PF('guestbookAndTermsPopup').show();
Expand Down
Loading

0 comments on commit a902547

Please sign in to comment.