forked from icatproject/topcat
-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -868,6 +868,8 @@ private long submitDownload(IdsClient idsClient, Download download, DownloadStat | |
| * @param facilityName ICAT Facility.name | ||
| * @param sessionId ICAT sessionId | ||
| * @param transport Transport mechanism to use | ||
| * @param fileName Optional name to use as the root for each individual part | ||
| * Download. Defaults to facilityName_visitId. | ||
| * @param email Optional email to notify upon completion | ||
| * @param visitId ICAT Investigation.visitId to submit | ||
| * @return Array of Download ids | ||
|
|
@@ -877,9 +879,10 @@ 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"); | ||
| logger.info("queueVisitId called for {}", visitId); | ||
| validateTransport(transport); | ||
|
|
||
| String icatUrl = getIcatUrl(facilityName); | ||
|
|
@@ -927,9 +930,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; | ||
|
|
@@ -945,6 +951,8 @@ public Response queueVisitId(@FormParam("facilityName") String facilityName, | |
| * @param facilityName ICAT Facility.name | ||
| * @param sessionId ICAT sessionId | ||
| * @param transport Transport mechanism to use | ||
| * @param fileName Optional name to use as the root for each individual part | ||
| * Download. Defaults to facilityName_visitId. | ||
| * @param email Optional email to notify upon completion | ||
| * @param files ICAT Datafile.locations to download | ||
| * @return Array of Download ids | ||
|
|
@@ -955,13 +963,14 @@ 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); | ||
| if (files.size() == 0) { | ||
| if (files == null || files.size() == 0) { | ||
| throw new BadRequestException("At least one Datafile.location required"); | ||
| } | ||
| logger.info("queueFiles called for {} files", files.size()); | ||
| validateTransport(transport); | ||
|
|
||
| String icatUrl = getIcatUrl(facilityName); | ||
| IcatClient icatClient = new IcatClient(icatUrl, sessionId); | ||
|
|
@@ -1000,9 +1009,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 +1026,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 +1041,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_"); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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