-
Notifications
You must be signed in to change notification settings - Fork 2
Accept filename FormParam on queue endpoints #70
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -877,7 +877,8 @@ private long submitDownload(IdsClient idsClient, Download download, DownloadStat | |
| @Path("/queue/visit") | ||
| public Response queueVisitId(@FormParam("facilityName") String facilityName, | ||
| @FormParam("sessionId") String sessionId, @FormParam("transport") String transport, | ||
| @FormParam("email") String email, @FormParam("visitId") String visitId) throws TopcatException { | ||
| @FormParam("fileName") String fileName, @FormParam("email") String email, | ||
| @FormParam("visitId") String visitId) throws TopcatException { | ||
|
|
||
| logger.info("queueVisitId called"); | ||
|
||
| validateTransport(transport); | ||
|
|
@@ -927,9 +928,12 @@ public Response queueVisitId(@FormParam("facilityName") String facilityName, | |
| downloads.add(newDownload); | ||
|
|
||
| int part = 1; | ||
| if (fileName == null) { | ||
| fileName = facilityName + "_" + visitId; | ||
| } | ||
| for (Download download : downloads) { | ||
| String filename = formatQueuedFilename(facilityName, visitId, part, downloads.size()); | ||
| download.setFileName(filename); | ||
| String partFilename = formatQueuedFilename(fileName, part, downloads.size()); | ||
| download.setFileName(partFilename); | ||
| downloadId = submitDownload(idsClient, download, DownloadStatus.PAUSED); | ||
| jsonArrayBuilder.add(downloadId); | ||
| part += 1; | ||
|
|
@@ -955,7 +959,8 @@ public Response queueVisitId(@FormParam("facilityName") String facilityName, | |
| @Path("/queue/files") | ||
| public Response queueFiles(@FormParam("facilityName") String facilityName, | ||
| @FormParam("sessionId") String sessionId, @FormParam("transport") String transport, | ||
| @FormParam("email") String email, @FormParam("files") List<String> files) throws TopcatException, UnsupportedEncodingException { | ||
| @FormParam("fileName") String fileName, @FormParam("email") String email, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again fileName needs adding to the javadoc comment |
||
| @FormParam("files") List<String> files) throws TopcatException, UnsupportedEncodingException { | ||
|
|
||
| logger.info("queueFiles called"); | ||
|
||
| validateTransport(transport); | ||
|
|
@@ -1000,9 +1005,12 @@ public Response queueFiles(@FormParam("facilityName") String facilityName, | |
| downloads.add(newDownload); | ||
|
|
||
| int part = 1; | ||
| if (fileName == null) { | ||
| fileName = facilityName + "_files"; | ||
| } | ||
| for (Download download : downloads) { | ||
| String filename = formatQueuedFilename(facilityName, "files", part, downloads.size()); | ||
| download.setFileName(filename); | ||
| String partFilename = formatQueuedFilename(fileName, part, downloads.size()); | ||
| download.setFileName(partFilename); | ||
| downloadId = submitDownload(idsClient, download, DownloadStatus.PAUSED); | ||
| jsonArrayBuilder.add(downloadId); | ||
| part += 1; | ||
|
|
@@ -1014,13 +1022,12 @@ public Response queueFiles(@FormParam("facilityName") String facilityName, | |
| /** | ||
| * Format the filename for a queued Download, possibly one part of many. | ||
| * | ||
| * @param facilityName ICAT Facility.name | ||
| * @param visitId ICAT Investigation.visitId | ||
| * @param part 1 indexed part of the overall request | ||
| * @param size Number of parts in the overall request | ||
| * @param filename Root of the formatted filename, either user specified or defaulted. | ||
| * @param part 1 indexed part of the overall request | ||
| * @param size Number of parts in the overall request | ||
| * @return Formatted filename | ||
| */ | ||
| private static String formatQueuedFilename(String facilityName, String visitId, int part, int size) { | ||
| private static String formatQueuedFilename(String filename, int part, int size) { | ||
| String partString = String.valueOf(part); | ||
| String sizeString = String.valueOf(size); | ||
| StringBuilder partBuilder = new StringBuilder(); | ||
|
|
@@ -1030,9 +1037,7 @@ private static String formatQueuedFilename(String facilityName, String visitId, | |
| partBuilder.append(partString); | ||
|
|
||
| StringBuilder filenameBuilder = new StringBuilder(); | ||
| filenameBuilder.append(facilityName); | ||
| filenameBuilder.append("_"); | ||
| filenameBuilder.append(visitId); | ||
| filenameBuilder.append(filename); | ||
| filenameBuilder.append("_part_"); | ||
| filenameBuilder.append(partBuilder); | ||
| filenameBuilder.append("_of_"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also need an entry for filename in the method javadoc