Skip to content

Commit

Permalink
#3331 - Add GB Response for "bundle" download
Browse files Browse the repository at this point in the history
  • Loading branch information
sekmiller committed Feb 14, 2018
1 parent 54848fc commit f280525
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/api/Access.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ public class Access extends AbstractApiBean {
@Path("datafile/bundle/{fileId}")
@GET
@Produces({"application/zip"})
public BundleDownloadInstance datafileBundle(@PathParam("fileId") Long fileId, @QueryParam("key") String apiToken, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) /*throws NotFoundException, ServiceUnavailableException, PermissionDeniedException, AuthorizationRequiredException*/ {
public BundleDownloadInstance datafileBundle(@PathParam("fileId") Long fileId, @QueryParam("gbrecs") Boolean gbrecs, @QueryParam("key") String apiToken, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) /*throws NotFoundException, ServiceUnavailableException, PermissionDeniedException, AuthorizationRequiredException*/ {

DataFile df = dataFileService.find(fileId);
GuestbookResponse gbr = null;

if (df == null) {
logger.warning("Access: datafile service could not locate a DataFile object for id "+fileId+"!");
Expand All @@ -146,6 +147,13 @@ public BundleDownloadInstance datafileBundle(@PathParam("fileId") Long fileId, @
// exit code, if access isn't authorized:
checkAuthorization(df, apiToken);

if (gbrecs == null && df.isReleased()){
// Write Guestbook record if not done previously and file is released
User apiTokenUser = findAPITokenUser(apiToken);
gbr = guestbookResponseService.initAPIGuestbookResponse(df.getOwner(), df, session, apiTokenUser);
guestbookResponseService.save(gbr);
}

DownloadInfo dInfo = new DownloadInfo(df);
BundleDownloadInstance downloadInstance = new BundleDownloadInstance(dInfo);

Expand Down

0 comments on commit f280525

Please sign in to comment.