Skip to content

Commit

Permalink
Break Result doGet into two methods to match lsst-tap-service version
Browse files Browse the repository at this point in the history
  • Loading branch information
stvoutsin committed Jun 22, 2024
1 parent 7844d3a commit 372551a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tap/src/main/java/ca/nrc/cadc/sample/ResultsServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,23 @@ public class ResultsServlet extends HttpServlet {
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String path = request.getPathInfo();
try {
String path = request.getPathInfo();
String redirectUrl = generateRedirectUrl(bucketURL, path);
response.sendRedirect(redirectUrl);
} catch (Exception e) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "An error occurred while processing the request.");
}
}

/**
* Generates the redirect URL based on a path.
*
* @param path the request path
* @return the redirect URL constructed using the bucket URL and results file
*/
private String generateRedirectUrl(String bucketUrlString, String path) {
String resultsFile = path.substring(1);
String redirectUrl = bucketURL + "/" + resultsFile;
log.debug("Redirect URL: " + redirectUrl);
response.sendRedirect(redirectUrl);
return bucketUrlString + "/" + resultsFile;
}
}

0 comments on commit 372551a

Please sign in to comment.