Skip to content

Commit

Permalink
remove validation checks we don't need #6919
Browse files Browse the repository at this point in the history
We've switched to Bean Validation, which is done centrally instead of
being only in the UI.
  • Loading branch information
pdurbin committed Oct 26, 2020
1 parent 6b62d0d commit e73d2f4
Showing 1 changed file with 26 additions and 44 deletions.
70 changes: 26 additions & 44 deletions src/main/java/edu/harvard/iq/dataverse/FileDownloadHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,42 +122,31 @@ private boolean validateGuestbookResponse(GuestbookResponse guestbookResponse){
return valid;

}

// This helper method is called from the Download terms/guestbook/etc. popup,
// when the user clicks the "ok" button. We use it, instead of calling
// downloadServiceBean directly, in order to differentiate between single
// file downloads and multiple (batch) downloads - sice both use the same
// terms/etc. popup.
public void writeGuestbookAndStartDownload(GuestbookResponse guestbookResponse) {
//RequestContext requestContext = RequestContext.getCurrentInstance();
boolean valid = validateGuestbookResponse(guestbookResponse);

if (!valid) {
// FIXME: This never validation error shows in the UI (even if you add a bundle entry).
JH.addMessage(FacesMessage.SEVERITY_ERROR, BundleUtil.getStringFromBundle("dataset.message.validationError"));
} else {
//requestContext.execute("PF('downloadPopup').hide()");
PrimeFaces.current().executeScript("PF('downloadPopup').hide()");
guestbookResponse.setDownloadtype("Download");

// Note that this method is only ever called from the file-download-popup -
// meaning we know for the fact that we DO want to save this
// guestbookResponse permanently in the database.
if (guestbookResponse.getSelectedFileIds() != null) {
// this is a batch (multiple file) download.
// Although here's a chance that this is not really a batch download - i.e.,
// there may only be one file on the file list. But the fileDownloadService
// method below will check for that, and will redirect to the single download, if
// that's the case. -- L.A.
fileDownloadService.writeGuestbookAndStartBatchDownload(guestbookResponse);
} else if (guestbookResponse.getDataFile() != null) {
// this a single file download:
fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse);
}
}

// This helper method is called from the Download terms/guestbook/etc. popup,
// when the user clicks the "ok" button. We use it, instead of calling
// downloadServiceBean directly, in order to differentiate between single
// file downloads and multiple (batch) downloads - sice both use the same
// terms/etc. popup.
public void writeGuestbookAndStartDownload(GuestbookResponse guestbookResponse) {
PrimeFaces.current().executeScript("PF('downloadPopup').hide()");
guestbookResponse.setDownloadtype("Download");
// Note that this method is only ever called from the file-download-popup -
// meaning we know for the fact that we DO want to save this
// guestbookResponse permanently in the database.
if (guestbookResponse.getSelectedFileIds() != null) {
// this is a batch (multiple file) download.
// Although here's a chance that this is not really a batch download - i.e.,
// there may only be one file on the file list. But the fileDownloadService
// method below will check for that, and will redirect to the single download, if
// that's the case. -- L.A.
fileDownloadService.writeGuestbookAndStartBatchDownload(guestbookResponse);
} else if (guestbookResponse.getDataFile() != null) {
// this a single file download:
fileDownloadService.writeGuestbookAndStartFileDownload(guestbookResponse);
}
}

public void writeGuestbookAndOpenSubset(GuestbookResponse guestbookResponse) {
//RequestContext requestContext = RequestContext.getCurrentInstance();
boolean valid = validateGuestbookResponse(guestbookResponse);
Expand Down Expand Up @@ -255,16 +244,9 @@ public String startWorldMapDownloadLink(GuestbookResponse guestbookResponse, Fil
* Writes a guestbook entry for either popup scenario: guestbook or terms.
*/
public boolean writeGuestbookAndShowPreview(GuestbookResponse guestbookResponse) {
// We've already validated guestbooks on the front end but we validate again
// on the backend (that's what older methods do).
boolean valid = validateGuestbookResponse(guestbookResponse);
if (!valid) {
return false;
} else {
guestbookResponse.setDownloadtype("Explore");
fileDownloadService.writeGuestbookResponseRecord(guestbookResponse);
return true;
}
guestbookResponse.setDownloadtype("Explore");
fileDownloadService.writeGuestbookResponseRecord(guestbookResponse);
return true;
}

private List<DataFile> filesForRequestAccess;
Expand Down

0 comments on commit e73d2f4

Please sign in to comment.