Skip to content

Commit

Permalink
Merge pull request #9138 from GlobalDataverseCommunityConsortium/5.12…
Browse files Browse the repository at this point in the history
…_hotfix_for_direct_download

5.12 Fix - misplaced paren disabling direct download
  • Loading branch information
landreev authored Nov 4, 2022
2 parents 3ced8df + 1c688f2 commit 11abccf
Showing 1 changed file with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,37 +217,37 @@ public void writeTo(DownloadInstance di, Class<?> clazz, Type type, Annotation[]
}
}
}
if (redirect_url_str!=null) {
}
if (redirect_url_str != null) {

logger.fine("Data Access API: redirect url: " + redirect_url_str);
URI redirect_uri;
logger.fine("Data Access API: redirect url: " + redirect_url_str);
URI redirect_uri;

try {
redirect_uri = new URI(redirect_url_str);
} catch (URISyntaxException ex) {
logger.info("Data Access API: failed to create redirect url (" + redirect_url_str + ")");
redirect_uri = null;
}
if (redirect_uri != null) {
// increment the download count, if necessary:
if (di.getGbr() != null && !(isThumbnailDownload(di) || isPreprocessedMetadataDownload(di))) {
try {
logger.fine("writing guestbook response, for a download redirect.");
Command<?> cmd = new CreateGuestbookResponseCommand(di.getDataverseRequestService().getDataverseRequest(), di.getGbr(), di.getGbr().getDataFile().getOwner());
di.getCommand().submit(cmd);
MakeDataCountEntry entry = new MakeDataCountEntry(di.getRequestUriInfo(), di.getRequestHttpHeaders(), di.getDataverseRequestService(), di.getGbr().getDataFile());
mdcLogService.logEntry(entry);
} catch (CommandException e) {
}
try {
redirect_uri = new URI(redirect_url_str);
} catch (URISyntaxException ex) {
logger.info("Data Access API: failed to create redirect url (" + redirect_url_str + ")");
redirect_uri = null;
}
if (redirect_uri != null) {
// increment the download count, if necessary:
if (di.getGbr() != null && !(isThumbnailDownload(di) || isPreprocessedMetadataDownload(di))) {
try {
logger.fine("writing guestbook response, for a download redirect.");
Command<?> cmd = new CreateGuestbookResponseCommand(di.getDataverseRequestService().getDataverseRequest(), di.getGbr(), di.getGbr().getDataFile().getOwner());
di.getCommand().submit(cmd);
MakeDataCountEntry entry = new MakeDataCountEntry(di.getRequestUriInfo(), di.getRequestHttpHeaders(), di.getDataverseRequestService(), di.getGbr().getDataFile());
mdcLogService.logEntry(entry);
} catch (CommandException e) {
}

// finally, issue the redirect:
Response response = Response.seeOther(redirect_uri).build();
logger.fine("Issuing redirect to the file location.");
throw new RedirectionException(response);
}
throw new ServiceUnavailableException();

// finally, issue the redirect:
Response response = Response.seeOther(redirect_uri).build();
logger.fine("Issuing redirect to the file location.");
throw new RedirectionException(response);
}
throw new ServiceUnavailableException();
}

if (di.getConversionParam() != null) {
Expand Down

0 comments on commit 11abccf

Please sign in to comment.