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

Iqss/4952 file download issues #4953

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -3052,8 +3052,11 @@ public void setDatasetVersionDifference(DatasetVersionDifference datasetVersionD
}

public void startMultipleFileDownload (Boolean writeGuestbook){

fileDownloadService.callDownloadServlet(getDownloadableFilesIdsString(), writeGuestbook);
if(getDownloadableFilesIdsString().split(",").length ==1) {
fileDownloadService.callDownloadServlet("Download", Long.parseLong(getDownloadableFilesIdsString()), writeGuestbook);
} else {
fileDownloadService.callDownloadServlet(getDownloadableFilesIdsString(), writeGuestbook);
}

}

Expand All @@ -3076,6 +3079,15 @@ public void modifyGuestbookMultipleResponse(){
}

this.guestbookResponse = this.guestbookResponseService.modifySelectedFileIds(guestbookResponse, getSelectedDownloadableFilesIdsString());
if(this.selectedDownloadableFiles.size()<2) {
if(this.selectedDownloadableFiles.size()==1) {
Long id = selectedDownloadableFiles.get(0).getId();
DataFile df = datafileService.findCheapAndEasy(id);
guestbookResponse.setDataFile(df);
}
} else {
guestbookResponse.setDataFile(null);
}
this.guestbookResponse.setDownloadtype("Download");
this.guestbookResponse.setFileFormat("Download");
RequestContext requestContext = RequestContext.getCurrentInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,20 @@ public class FileDownloadServiceBean implements java.io.Serializable {


public void writeGuestbookAndStartDownload(GuestbookResponse guestbookResponse){

if (guestbookResponse != null && guestbookResponse.getDataFile() != null ){
if (guestbookResponse.getSelectedFileIds() != null) {
String[] fileIds = guestbookResponse.getSelectedFileIds().split(",");
if (fileIds.length == 1) {
DataFile df = datafileService.findCheapAndEasy(Long.parseLong(fileIds[0]));
guestbookResponse.setDataFile(df);
}
}
if (guestbookResponse != null && guestbookResponse.getDataFile() != null ){
writeGuestbookResponseRecord(guestbookResponse);
// Make sure to set the "do not write Guestbook response" flag to TRUE when calling the Access API:
callDownloadServlet(guestbookResponse.getFileFormat(), guestbookResponse.getDataFile().getId(), true);
}

if (guestbookResponse != null && guestbookResponse.getSelectedFileIds() != null ){
if (guestbookResponse != null && guestbookResponse.getDataFile() == null && guestbookResponse.getSelectedFileIds() != null ){
List<String> list = new ArrayList<>(Arrays.asList(guestbookResponse.getSelectedFileIds().split(",")));

for (String idAsString : list) {
Expand All @@ -92,11 +98,8 @@ public void writeGuestbookAndStartDownload(GuestbookResponse guestbookResponse){
writeGuestbookResponseRecord(guestbookResponse);
}
}

callDownloadServlet(guestbookResponse.getSelectedFileIds(), true);
}


}

public void writeGuestbookResponseRecord(GuestbookResponse guestbookResponse) {
Expand Down