Skip to content

Commit

Permalink
#3331 - add guestbook responses when downloading multiple files
Browse files Browse the repository at this point in the history
via api or ui
  • Loading branch information
sekmiller committed Feb 13, 2018
1 parent e796935 commit 54848fc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/api/Access.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public DownloadInstance tabularDatafileMetadataPreprocessed(@PathParam("fileId")
@Path("datafiles/{fileIds}")
@GET
@Produces({"application/zip"})
public /*ZippedDownloadInstance*/ Response datafiles(@PathParam("fileIds") String fileIds, @QueryParam("key") String apiTokenParam, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) throws WebApplicationException /*throws NotFoundException, ServiceUnavailableException, PermissionDeniedException, AuthorizationRequiredException*/ {
public /*ZippedDownloadInstance*/ Response datafiles(@PathParam("fileIds") String fileIds, @QueryParam("gbrecs") Boolean gbrecs, @QueryParam("key") String apiTokenParam, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) throws WebApplicationException /*throws NotFoundException, ServiceUnavailableException, PermissionDeniedException, AuthorizationRequiredException*/ {
// create a Download Instance without, without a primary Download Info object:
//ZippedDownloadInstance downloadInstance = new ZippedDownloadInstance();

Expand All @@ -461,6 +461,8 @@ public DownloadInstance tabularDatafileMetadataPreprocessed(@PathParam("fileId")
? headers.getHeaderString(API_KEY_HEADER)
: apiTokenParam;

User apiTokenUser = findAPITokenUser(apiToken); //for use in adding gb records if necessary

StreamingOutput stream = new StreamingOutput() {

@Override
Expand Down Expand Up @@ -495,7 +497,10 @@ public void write(OutputStream os) throws IOException,
}
logger.fine("adding datafile (id=" + file.getId() + ") to the download list of the ZippedDownloadInstance.");
//downloadInstance.addDataFile(file);

if (gbrecs == null && file.isReleased()){
GuestbookResponse gbr = guestbookResponseService.initAPIGuestbookResponse(file.getOwner(), file, session, apiTokenUser);
guestbookResponseService.save(gbr);
}
if (zipper == null) {
// This is the first file we can serve - so we now know that we are going to be able
// to produce some output.
Expand Down

0 comments on commit 54848fc

Please sign in to comment.