From 191ed3a852c6ea0b5c65a300d6180c9136971352 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Tue, 17 Sep 2024 12:51:30 -0700 Subject: [PATCH 01/14] First pass at adding TAR and ZIP. --- cadc-download-manager-server/build.gradle | 4 +- .../cadc/dlm/server/DispatcherServlet.java | 12 ++- .../nrc/cadc/dlm/server/PackageServlet.java | 100 ++++++++++++++++++ .../resources/META-INF/resources/chooser.jsp | 38 ++++++- .../src/org.opencadc.dlm-server.properties | 3 + 5 files changed, 147 insertions(+), 10 deletions(-) create mode 100644 cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java diff --git a/cadc-download-manager-server/build.gradle b/cadc-download-manager-server/build.gradle index fcc3a8fb..1ce185c0 100644 --- a/cadc-download-manager-server/build.gradle +++ b/cadc-download-manager-server/build.gradle @@ -10,9 +10,9 @@ repositories { mavenLocal() } -version = '1.5.0' +version = '1.6.0' group = 'org.opencadc' -sourceCompatibility = 1.8 +sourceCompatibility = 11 description = 'OpenCADC DownloadManager server library' def git_url = 'https://github.com/opencadc/apps' diff --git a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/DispatcherServlet.java b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/DispatcherServlet.java index b2624ecd..c5a24c00 100644 --- a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/DispatcherServlet.java +++ b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/DispatcherServlet.java @@ -114,6 +114,8 @@ public class DispatcherServlet extends HttpServlet { public static String HTMLLIST = "HTML List"; public static String WEBSTART = "Java Webstart"; public static String SHELL_SCRIPT = "Shell Script"; + public static String TAR_PACKAGE = "TAR"; + public static String ZIP_PACKAGE = "ZIP"; /// Used during JSP compilation @@ -205,7 +207,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) } - private class DownloadAction implements PrivilegedExceptionAction { + private static class DownloadAction implements PrivilegedExceptionAction { HttpServletRequest request; HttpServletResponse response; @@ -218,14 +220,14 @@ public Object run() throws Exception { // forward DownloadRequest downloadReq = (DownloadRequest) request.getAttribute(INTERNAL_FORWARD_PARAMETER); - // Set up input handling - DLMInputHandler inputHandler = new DLMInputHandler(request); - if (downloadReq == null) { + // Set up input handling + DLMInputHandler inputHandler = new DLMInputHandler(request); + // external post inputHandler.parseInput(); - downloadReq = inputHandler.getDownloadRequest(); + downloadReq = DLMInputHandler.getDownloadRequest(); Set tupleList = downloadReq.getTuples(); List validationErrList = downloadReq.getValidationErrors(); diff --git a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java new file mode 100644 index 00000000..2c357d1c --- /dev/null +++ b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java @@ -0,0 +1,100 @@ +package ca.nrc.cadc.dlm.server; + +import ca.nrc.cadc.auth.AuthMethod; +import ca.nrc.cadc.auth.AuthenticationUtil; +import ca.nrc.cadc.config.ApplicationConfiguration; +import ca.nrc.cadc.net.HttpPost; +import ca.nrc.cadc.reg.Standards; +import ca.nrc.cadc.reg.client.RegistryClient; +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.security.PrivilegedAction; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; +import javax.security.auth.Subject; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class PackageServlet extends HttpServlet { + private static final String PACKAGE_SERVICE_RESOURCE_ID_KEY = "org.opencadc.dlm.package-download.service.id"; + private static final String RESPONSE_FORMAT_PAYLOAD_KEY = "RESPONSEFORMAT"; + private static final String ID_PAYLOAD_KEY = "ID"; + private static final String REQUEST_PARAM_URI_KEY = "tuple"; + private static final String REQUEST_PARAM_METHOD_KEY = "method"; + private static final Map METHOD_TO_CONTENT_TYPE_MAP = new HashMap<>(); + + private final ApplicationConfiguration configuration = new ApplicationConfiguration(DispatcherServlet.DEFAULT_CONFIG_FILE_PATH); + static { + PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.put(DispatcherServlet.TAR_PACKAGE, "application/x-tar"); + PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.put(DispatcherServlet.ZIP_PACKAGE, "application/zip"); + } + + + /** + * Handle POSTed download request from an external page. + * + * @param request The HTTP Request + * @param response The HTTP Response + * @throws IOException if stream processing fails + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + final URI packageServiceURI = this.configuration.lookupServiceURI(PackageServlet.PACKAGE_SERVICE_RESOURCE_ID_KEY, null); + if (packageServiceURI == null) { + throw new IllegalStateException("No service configured to perform Package Downloads"); + } else { + doRedirect(request, response, packageServiceURI); + } + } + + void doRedirect(final HttpServletRequest request, final HttpServletResponse response, final URI packageServiceURI) { + final Subject currentSubject = AuthenticationUtil.getCurrentSubject(); + final URL packageServiceURL = lookupServiceURL(packageServiceURI, currentSubject); + + Subject.doAs(currentSubject, (PrivilegedAction) () -> { + final HttpPost httpPost = new HttpPost(packageServiceURL, getPayload(request), false); + + try { + httpPost.prepare(); + } catch (Exception exception) { + throw new RuntimeException(exception.getMessage(), exception); + } + + final URL redirect = httpPost.getRedirectURL(); + if (redirect == null) { + throw new IllegalArgumentException("Unable to complete download (no redirect)."); + } else { + try { + response.sendRedirect(redirect.toExternalForm()); + } catch (IOException ioException) { + throw new IllegalStateException("Redirect is invalid: " + redirect); + } + } + + return null; + }); + } + + private Map getPayload(final HttpServletRequest request) { + final Map payload = request.getParameterMap().entrySet().stream() + .filter(entry -> entry.getKey().equals(PackageServlet.REQUEST_PARAM_URI_KEY)) + .collect(Collectors.toMap(entry -> PackageServlet.ID_PAYLOAD_KEY, Map.Entry::getValue)); + + payload.put(PackageServlet.RESPONSE_FORMAT_PAYLOAD_KEY, + PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.get(request.getParameter(PackageServlet.REQUEST_PARAM_METHOD_KEY))); + + return payload; + } + + private URL lookupServiceURL(URI packageServiceURI, Subject currentSubject) { + final RegistryClient registryClient = new RegistryClient(); + final AuthMethod authMethod = currentSubject == null ? AuthMethod.ANON : AuthenticationUtil.getAuthMethod(currentSubject); + return registryClient.getServiceURL(packageServiceURI, Standards.PKG_10, authMethod); + } + + +} diff --git a/cadc-download-manager-server/src/main/resources/META-INF/resources/chooser.jsp b/cadc-download-manager-server/src/main/resources/META-INF/resources/chooser.jsp index 74e45f29..c79ae0c2 100644 --- a/cadc-download-manager-server/src/main/resources/META-INF/resources/chooser.jsp +++ b/cadc-download-manager-server/src/main/resources/META-INF/resources/chooser.jsp @@ -88,8 +88,6 @@ Set tupleList = downloadReq.getTuples(); List validationErrList = downloadReq.getValidationErrors(); - String runid = downloadReq.runID; - String requestHeaderLang = request.getHeader("Content-Language"); if (requestHeaderLang == null) { requestHeaderLang = "en"; @@ -156,7 +154,7 @@ var="langBundle" scope="request"/>
<%-- Display any validation errors found --%> -<% if ( validationErrList.size() > 0 ) { +<% if (!validationErrList.isEmpty()) { %>

@@ -175,6 +173,40 @@ var="langBundle" scope="request"/> <% } %> +

CAOM-2 download options

+
" method="POST"> + + + + + + + + +
+
+ +
+
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+ +

General download options

" method="POST"> diff --git a/cadc-download-manager-server/src/org.opencadc.dlm-server.properties b/cadc-download-manager-server/src/org.opencadc.dlm-server.properties index 1cb39a07..c27f6c7b 100644 --- a/cadc-download-manager-server/src/org.opencadc.dlm-server.properties +++ b/cadc-download-manager-server/src/org.opencadc.dlm-server.properties @@ -4,3 +4,6 @@ # Default is true # org.opencadc.dlm.webstart.enable=true +# Use the caom2ops service to perform a package download +# org.opencadc.dlm.package-download.service.id=ivo://cadc.nrc.ca/caom2ops + From 81708acdc0f26f7b7c207de9cf4a73396e243e7a Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Tue, 17 Sep 2024 16:29:57 -0700 Subject: [PATCH 02/14] Update redirect. --- .../nrc/cadc/dlm/server/PackageServlet.java | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java index 2c357d1c..1ad995c9 100644 --- a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java +++ b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java @@ -10,15 +10,15 @@ import java.net.URI; import java.net.URL; import java.security.PrivilegedAction; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.stream.Collectors; import javax.security.auth.Subject; -import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + public class PackageServlet extends HttpServlet { private static final String PACKAGE_SERVICE_RESOURCE_ID_KEY = "org.opencadc.dlm.package-download.service.id"; private static final String RESPONSE_FORMAT_PAYLOAD_KEY = "RESPONSEFORMAT"; @@ -39,10 +39,9 @@ public class PackageServlet extends HttpServlet { * * @param request The HTTP Request * @param response The HTTP Response - * @throws IOException if stream processing fails */ @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void doPost(HttpServletRequest request, HttpServletResponse response) { final URI packageServiceURI = this.configuration.lookupServiceURI(PackageServlet.PACKAGE_SERVICE_RESOURCE_ID_KEY, null); if (packageServiceURI == null) { throw new IllegalStateException("No service configured to perform Package Downloads"); @@ -80,12 +79,25 @@ void doRedirect(final HttpServletRequest request, final HttpServletResponse resp } private Map getPayload(final HttpServletRequest request) { - final Map payload = request.getParameterMap().entrySet().stream() - .filter(entry -> entry.getKey().equals(PackageServlet.REQUEST_PARAM_URI_KEY)) - .collect(Collectors.toMap(entry -> PackageServlet.ID_PAYLOAD_KEY, Map.Entry::getValue)); + final Map payload = new HashMap<>(); + + final String[] publisherIDs = request.getParameterValues(PackageServlet.REQUEST_PARAM_URI_KEY); + if (publisherIDs == null || publisherIDs.length == 0) { + throw new IllegalArgumentException("Nothing specified to download. Use tuple=."); + } - payload.put(PackageServlet.RESPONSE_FORMAT_PAYLOAD_KEY, - PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.get(request.getParameter(PackageServlet.REQUEST_PARAM_METHOD_KEY))); + payload.put(PackageServlet.ID_PAYLOAD_KEY, Arrays.asList(publisherIDs)); + + final String requestedDeliveryMethod = request.getParameter(PackageServlet.REQUEST_PARAM_METHOD_KEY); + + if (requestedDeliveryMethod == null) { + throw new IllegalArgumentException("Delivery method is mandatory. Use method="); + } else if (!PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.containsKey(requestedDeliveryMethod.toUpperCase())) { + throw new IllegalArgumentException("Unknown method " + requestedDeliveryMethod + ". Use " + + Arrays.toString(PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.keySet().toArray(new String[0]))); + } + + payload.put(PackageServlet.RESPONSE_FORMAT_PAYLOAD_KEY, PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.get(requestedDeliveryMethod.toUpperCase())); return payload; } @@ -95,6 +107,4 @@ private URL lookupServiceURL(URI packageServiceURI, Subject currentSubject) { final AuthMethod authMethod = currentSubject == null ? AuthMethod.ANON : AuthenticationUtil.getAuthMethod(currentSubject); return registryClient.getServiceURL(packageServiceURI, Standards.PKG_10, authMethod); } - - } From 3fe2166ba7cc19a24eda8548bfc0fa5615c56a51 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 06:49:39 -0700 Subject: [PATCH 03/14] Use JDK 11 in build. --- .github/workflows/gradle.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f785bc58..1ebb4cb3 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -10,12 +10,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 with: - java-version: 1.8 - + distribution: 'temurin' + java-version: 11 + - name: build and test cadc-app-kit run: cd cadc-app-kit && ../gradlew --info clean build javadoc checkstyleMain install From a0be710bbdf0954826b28d77cb82e962542e492d Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 06:56:41 -0700 Subject: [PATCH 04/14] JDK 11 compatibilities --- cadc-download-manager/build.gradle | 2 +- cadc-upload-manager/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cadc-download-manager/build.gradle b/cadc-download-manager/build.gradle index f7a42814..98bf05e7 100644 --- a/cadc-download-manager/build.gradle +++ b/cadc-download-manager/build.gradle @@ -13,7 +13,7 @@ repositories { version = '1.5.2' group = 'org.opencadc' -sourceCompatibility = 1.8 +sourceCompatibility = 11 description = 'OpenCADC DownloadManager client' def git_url = 'https://github.com/opencadc/apps' diff --git a/cadc-upload-manager/build.gradle b/cadc-upload-manager/build.gradle index 634757cf..9e1074dc 100644 --- a/cadc-upload-manager/build.gradle +++ b/cadc-upload-manager/build.gradle @@ -12,7 +12,7 @@ repositories { version = '1.0.16' group = 'org.opencadc' -sourceCompatibility = 1.8 +sourceCompatibility = 11 description = 'OpenCADC UploadManager client' def git_url = 'https://github.com/opencadc/apps' From a5841a10c4ace26d878b9b086c97f643699c7c7d Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 07:12:40 -0700 Subject: [PATCH 05/14] Minimal compatibility changes. --- cadc-download-manager-server/build.gradle | 1 - cadc-download-manager/build.gradle | 5 ++--- cadc-upload-manager/build.gradle | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cadc-download-manager-server/build.gradle b/cadc-download-manager-server/build.gradle index 1ce185c0..26553b73 100644 --- a/cadc-download-manager-server/build.gradle +++ b/cadc-download-manager-server/build.gradle @@ -33,7 +33,6 @@ dependencies { implementation 'commons-io:commons-io:[2.7,)' testImplementation 'junit:junit:4.13' - testImplementation 'org.easymock:easymock:3.6' } apply from: '../opencadc.gradle' diff --git a/cadc-download-manager/build.gradle b/cadc-download-manager/build.gradle index 98bf05e7..e10077a9 100644 --- a/cadc-download-manager/build.gradle +++ b/cadc-download-manager/build.gradle @@ -13,7 +13,7 @@ repositories { version = '1.5.2' group = 'org.opencadc' -sourceCompatibility = 11 +sourceCompatibility = 1.8 description = 'OpenCADC DownloadManager client' def git_url = 'https://github.com/opencadc/apps' @@ -24,13 +24,12 @@ dependencies { implementation 'org.opencadc:cadc-util:[1.6,)' implementation 'org.opencadc:cadc-registry:[1.1.1,)' implementation 'org.opencadc:cadc-app-kit:[1.0,)' - implementation 'org.opencadc:cadc-vos:[1.0,)' + implementation 'org.opencadc:cadc-vos:1.2.3' implementation 'org.opencadc:cadc-dali:[1.2.15,)' implementation 'org.opencadc:cadc-datalink:[1.0.0,1.1.0)' implementation 'org.opencadc:caom2-artifact-resolvers:[1.2.10,1.3.0)' testImplementation 'junit:junit:[4.13,)' - testImplementation 'org.easymock:easymock:[3.0,)' } configurations { diff --git a/cadc-upload-manager/build.gradle b/cadc-upload-manager/build.gradle index 9e1074dc..0909ec93 100644 --- a/cadc-upload-manager/build.gradle +++ b/cadc-upload-manager/build.gradle @@ -12,7 +12,7 @@ repositories { version = '1.0.16' group = 'org.opencadc' -sourceCompatibility = 11 +sourceCompatibility = 1.8 description = 'OpenCADC UploadManager client' def git_url = 'https://github.com/opencadc/apps' @@ -24,12 +24,12 @@ dependencies { implementation 'org.opencadc:cadc-registry:[1.5,2.0)' implementation 'org.opencadc:cadc-util:[1.6,2.0)' implementation 'org.opencadc:cadc-uws:[1.0,2.0)' - implementation 'org.opencadc:cadc-vos:[1.2.2,2.0)' + implementation 'org.opencadc:cadc-vos:1.2.3' // cadc-uws-server used only for a random string generator testImplementation 'org.opencadc:cadc-uws-server:[1.1,)' testImplementation 'junit:junit:[4.0,)' - testImplementation 'org.easymock:easymock:3.6' + testImplementation 'org.easymock:easymock:[5.4,6.0)' } // exclude stuff not needed for a client application but pulled in by cadc-util From 194c727743e2cfd03b8200bc378f973116b2495b Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 07:32:27 -0700 Subject: [PATCH 06/14] fix: Hush the linter --- .../src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java | 1 + 1 file changed, 1 insertion(+) diff --git a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java index 1ad995c9..0bc8eb53 100644 --- a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java +++ b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java @@ -28,6 +28,7 @@ public class PackageServlet extends HttpServlet { private static final Map METHOD_TO_CONTENT_TYPE_MAP = new HashMap<>(); private final ApplicationConfiguration configuration = new ApplicationConfiguration(DispatcherServlet.DEFAULT_CONFIG_FILE_PATH); + static { PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.put(DispatcherServlet.TAR_PACKAGE, "application/x-tar"); PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.put(DispatcherServlet.ZIP_PACKAGE, "application/zip"); From d156585a33c229fe5c84d3ae966c41948dd214f3 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 10:54:06 -0700 Subject: [PATCH 07/14] Force JDK 1.8 for CADC server compatibility. --- .github/workflows/gradle.yml | 5 ++-- cadc-download-manager-server/build.gradle | 3 ++- .../nrc/cadc/dlm/server/PackageServlet.java | 23 ++++++++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 1ebb4cb3..bd470851 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -11,11 +11,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 11 + - name: Set up JDK 1.8 uses: actions/setup-java@v3 with: - distribution: 'temurin' - java-version: 11 + java-version: 1.8 - name: build and test cadc-app-kit run: cd cadc-app-kit && ../gradlew --info clean build javadoc checkstyleMain install diff --git a/cadc-download-manager-server/build.gradle b/cadc-download-manager-server/build.gradle index 26553b73..ceb8455b 100644 --- a/cadc-download-manager-server/build.gradle +++ b/cadc-download-manager-server/build.gradle @@ -12,7 +12,7 @@ repositories { version = '1.6.0' group = 'org.opencadc' -sourceCompatibility = 11 +sourceCompatibility = 1.8 description = 'OpenCADC DownloadManager server library' def git_url = 'https://github.com/opencadc/apps' @@ -29,6 +29,7 @@ dependencies { implementation 'org.opencadc:cadc-registry:[1.0,)' implementation 'org.opencadc:cadc-rest:[1.3.3,)' implementation 'org.opencadc:cadc-util:[1.6,)' + implementation 'org.opencadc:cadc-vos:1.2.3' implementation 'org.opencadc:cadc-web-util:[1.2.10,)' implementation 'commons-io:commons-io:[2.7,)' diff --git a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java index 0bc8eb53..dad2ad42 100644 --- a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java +++ b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java @@ -13,6 +13,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Properties; import javax.security.auth.Subject; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -81,25 +82,35 @@ void doRedirect(final HttpServletRequest request, final HttpServletResponse resp private Map getPayload(final HttpServletRequest request) { final Map payload = new HashMap<>(); + final Map requestParameters = request.getParameterMap(); - final String[] publisherIDs = request.getParameterValues(PackageServlet.REQUEST_PARAM_URI_KEY); + final String[] publisherIDs = requestParameters.get(PackageServlet.REQUEST_PARAM_URI_KEY); if (publisherIDs == null || publisherIDs.length == 0) { throw new IllegalArgumentException("Nothing specified to download. Use tuple=."); } payload.put(PackageServlet.ID_PAYLOAD_KEY, Arrays.asList(publisherIDs)); - final String requestedDeliveryMethod = request.getParameter(PackageServlet.REQUEST_PARAM_METHOD_KEY); + final String[] requestedDeliveryMethodValues = requestParameters.get(PackageServlet.REQUEST_PARAM_METHOD_KEY); + final String requestedDeliveryMethod; - if (requestedDeliveryMethod == null) { + if (requestedDeliveryMethodValues == null || requestedDeliveryMethodValues.length != 1) { throw new IllegalArgumentException("Delivery method is mandatory. Use method="); - } else if (!PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.containsKey(requestedDeliveryMethod.toUpperCase())) { - throw new IllegalArgumentException("Unknown method " + requestedDeliveryMethod + ". Use " - + Arrays.toString(PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.keySet().toArray(new String[0]))); + } else { + requestedDeliveryMethod = requestedDeliveryMethodValues[0]; + if (!PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.containsKey(requestedDeliveryMethod.toUpperCase())) { + throw new IllegalArgumentException("Unknown method " + requestedDeliveryMethod + ". Use " + + Arrays.toString(PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.keySet().toArray(new String[0]))); + } } payload.put(PackageServlet.RESPONSE_FORMAT_PAYLOAD_KEY, PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.get(requestedDeliveryMethod.toUpperCase())); + // Add whatever is leftover. + requestParameters.keySet().stream() + .filter(key -> !Arrays.asList(PackageServlet.REQUEST_PARAM_METHOD_KEY, PackageServlet.REQUEST_PARAM_URI_KEY).contains(key)) + .forEach(key -> payload.put(key, requestParameters.get(key))); + return payload; } From 3b710748611b07cbc4d5a6019ec7c3909fea6fc5 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 10:55:35 -0700 Subject: [PATCH 08/14] fix: added distribution --- .github/workflows/gradle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index bd470851..e55e9812 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -15,6 +15,7 @@ jobs: uses: actions/setup-java@v3 with: java-version: 1.8 + distribution: temurin - name: build and test cadc-app-kit run: cd cadc-app-kit && ../gradlew --info clean build javadoc checkstyleMain install From 0b5ea4feab8c1bd177dee8dd49c2f763f93af53c Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 10:56:29 -0700 Subject: [PATCH 09/14] fix: JDK version setting --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index e55e9812..5818c614 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -14,7 +14,7 @@ jobs: - name: Set up JDK 1.8 uses: actions/setup-java@v3 with: - java-version: 1.8 + java-version: 8 distribution: temurin - name: build and test cadc-app-kit From ac1e3b89ed953426938296d7cd658bf7184e3a67 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 12:41:30 -0700 Subject: [PATCH 10/14] fix: refactor tar and zip downloads to funnel through dispatcher servlet --- .../cadc/dlm/server/TARPackageServlet.java | 71 +++++++++++++++++++ .../cadc/dlm/server/ZIPPackageServlet.java | 71 +++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/TARPackageServlet.java create mode 100644 cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/ZIPPackageServlet.java diff --git a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/TARPackageServlet.java b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/TARPackageServlet.java new file mode 100644 index 00000000..82de93bd --- /dev/null +++ b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/TARPackageServlet.java @@ -0,0 +1,71 @@ +/* +************************************************************************ +******************* CANADIAN ASTRONOMY DATA CENTRE ******************* +************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** +* +* (c) 2024. (c) 2024. +* Government of Canada Gouvernement du Canada +* National Research Council Conseil national de recherches +* Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 +* All rights reserved Tous droits réservés +* +* NRC disclaims any warranties, Le CNRC dénie toute garantie +* expressed, implied, or énoncée, implicite ou légale, +* statutory, of any kind with de quelque nature que ce +* respect to the software, soit, concernant le logiciel, +* including without limitation y compris sans restriction +* any warranty of merchantability toute garantie de valeur +* or fitness for a particular marchande ou de pertinence +* purpose. NRC shall not be pour un usage particulier. +* liable in any event for any Le CNRC ne pourra en aucun cas +* damages, whether direct or être tenu responsable de tout +* indirect, special or general, dommage, direct ou indirect, +* consequential or incidental, particulier ou général, +* arising from the use of the accessoire ou fortuit, résultant +* software. Neither the name de l'utilisation du logiciel. Ni +* of the National Research le nom du Conseil National de +* Council of Canada nor the Recherches du Canada ni les noms +* names of its contributors may de ses participants ne peuvent +* be used to endorse or promote être utilisés pour approuver ou +* products derived from this promouvoir les produits dérivés +* software without specific prior de ce logiciel sans autorisation +* written permission. préalable et particulière +* par écrit. +* +* This file is part of the Ce fichier fait partie du projet +* OpenCADC project. OpenCADC. +* +* OpenCADC is free software: OpenCADC est un logiciel libre ; +* you can redistribute it and/or vous pouvez le redistribuer ou le +* modify it under the terms of modifier suivant les termes de +* the GNU Affero General Public la “GNU Affero General Public +* License as published by the License” telle que publiée +* Free Software Foundation, par la Free Software Foundation +* either version 3 of the : soit la version 3 de cette +* License, or (at your option) licence, soit (à votre gré) +* any later version. toute version ultérieure. +* +* OpenCADC is distributed in the OpenCADC est distribué +* hope that it will be useful, dans l’espoir qu’il vous +* but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE +* without even the implied GARANTIE : sans même la garantie +* warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ +* or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF +* PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence +* General Public License for Générale Publique GNU Affero +* more details. pour plus de détails. +* +* You should have received Vous devriez avoir reçu une +* a copy of the GNU Affero copie de la Licence Générale +* General Public License along Publique GNU Affero avec +* with OpenCADC. If not, see OpenCADC ; si ce n’est +* . pas le cas, consultez : +* . +* +* +************************************************************************ +*/ + +package ca.nrc.cadc.dlm.server; +public class TARPackageServlet { +} diff --git a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/ZIPPackageServlet.java b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/ZIPPackageServlet.java new file mode 100644 index 00000000..68ceeb0d --- /dev/null +++ b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/ZIPPackageServlet.java @@ -0,0 +1,71 @@ +/* +************************************************************************ +******************* CANADIAN ASTRONOMY DATA CENTRE ******************* +************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** +* +* (c) 2024. (c) 2024. +* Government of Canada Gouvernement du Canada +* National Research Council Conseil national de recherches +* Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 +* All rights reserved Tous droits réservés +* +* NRC disclaims any warranties, Le CNRC dénie toute garantie +* expressed, implied, or énoncée, implicite ou légale, +* statutory, of any kind with de quelque nature que ce +* respect to the software, soit, concernant le logiciel, +* including without limitation y compris sans restriction +* any warranty of merchantability toute garantie de valeur +* or fitness for a particular marchande ou de pertinence +* purpose. NRC shall not be pour un usage particulier. +* liable in any event for any Le CNRC ne pourra en aucun cas +* damages, whether direct or être tenu responsable de tout +* indirect, special or general, dommage, direct ou indirect, +* consequential or incidental, particulier ou général, +* arising from the use of the accessoire ou fortuit, résultant +* software. Neither the name de l'utilisation du logiciel. Ni +* of the National Research le nom du Conseil National de +* Council of Canada nor the Recherches du Canada ni les noms +* names of its contributors may de ses participants ne peuvent +* be used to endorse or promote être utilisés pour approuver ou +* products derived from this promouvoir les produits dérivés +* software without specific prior de ce logiciel sans autorisation +* written permission. préalable et particulière +* par écrit. +* +* This file is part of the Ce fichier fait partie du projet +* OpenCADC project. OpenCADC. +* +* OpenCADC is free software: OpenCADC est un logiciel libre ; +* you can redistribute it and/or vous pouvez le redistribuer ou le +* modify it under the terms of modifier suivant les termes de +* the GNU Affero General Public la “GNU Affero General Public +* License as published by the License” telle que publiée +* Free Software Foundation, par la Free Software Foundation +* either version 3 of the : soit la version 3 de cette +* License, or (at your option) licence, soit (à votre gré) +* any later version. toute version ultérieure. +* +* OpenCADC is distributed in the OpenCADC est distribué +* hope that it will be useful, dans l’espoir qu’il vous +* but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE +* without even the implied GARANTIE : sans même la garantie +* warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ +* or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF +* PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence +* General Public License for Générale Publique GNU Affero +* more details. pour plus de détails. +* +* You should have received Vous devriez avoir reçu une +* a copy of the GNU Affero copie de la Licence Générale +* General Public License along Publique GNU Affero avec +* with OpenCADC. If not, see OpenCADC ; si ce n’est +* . pas le cas, consultez : +* . +* +* +************************************************************************ +*/ + +package ca.nrc.cadc.dlm.server; +public class ZIPPackageServlet { +} From 903d2dd5b08f8d3cafed3e11a035c517dd03a685 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 12:41:55 -0700 Subject: [PATCH 11/14] fix: add missing staged items --- .../cadc/dlm/server/DispatcherServlet.java | 7 +- .../nrc/cadc/dlm/server/PackageServlet.java | 72 +++++---- .../cadc/dlm/server/TARPackageServlet.java | 143 ++++++++++-------- .../cadc/dlm/server/ZIPPackageServlet.java | 143 ++++++++++-------- .../resources/META-INF/resources/chooser.jsp | 19 +-- 5 files changed, 198 insertions(+), 186 deletions(-) diff --git a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/DispatcherServlet.java b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/DispatcherServlet.java index c5a24c00..085bb9b0 100644 --- a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/DispatcherServlet.java +++ b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/DispatcherServlet.java @@ -141,6 +141,10 @@ public static String getDownloadMethod(HttpServletRequest request) { target = "/wget.jsp"; } else if (SHELL_SCRIPT.equals(method)) { target = ShellScriptServlet.SCRIPT_TARGET; + } else if (DispatcherServlet.TAR_PACKAGE.equals(method)) { + target = TARPackageServlet.TAR_PACKAGE_TARGET; + } else if (DispatcherServlet.ZIP_PACKAGE.equals(method)) { + target = ZIPPackageServlet.ZIP_PACKAGE_TARGET; } else { return null; } @@ -196,8 +200,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) throw ex; } catch (Exception e) { if (e instanceof RuntimeException) { - RuntimeException rex = (RuntimeException) e; - throw rex; + throw (RuntimeException) e; } } finally { Long dt = System.currentTimeMillis() - start; diff --git a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java index dad2ad42..2b661056 100644 --- a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java +++ b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/PackageServlet.java @@ -3,37 +3,32 @@ import ca.nrc.cadc.auth.AuthMethod; import ca.nrc.cadc.auth.AuthenticationUtil; import ca.nrc.cadc.config.ApplicationConfiguration; +import ca.nrc.cadc.dlm.DownloadRequest; import ca.nrc.cadc.net.HttpPost; import ca.nrc.cadc.reg.Standards; import ca.nrc.cadc.reg.client.RegistryClient; +import ca.nrc.cadc.util.StringUtil; import java.io.IOException; import java.net.URI; import java.net.URL; import java.security.PrivilegedAction; -import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; -import java.util.Properties; +import java.util.stream.Collectors; import javax.security.auth.Subject; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -public class PackageServlet extends HttpServlet { +public abstract class PackageServlet extends HttpServlet { private static final String PACKAGE_SERVICE_RESOURCE_ID_KEY = "org.opencadc.dlm.package-download.service.id"; private static final String RESPONSE_FORMAT_PAYLOAD_KEY = "RESPONSEFORMAT"; private static final String ID_PAYLOAD_KEY = "ID"; - private static final String REQUEST_PARAM_URI_KEY = "tuple"; - private static final String REQUEST_PARAM_METHOD_KEY = "method"; - private static final Map METHOD_TO_CONTENT_TYPE_MAP = new HashMap<>(); + private static final String RUN_ID_PAYLOAD_KEY = "runid"; - private final ApplicationConfiguration configuration = new ApplicationConfiguration(DispatcherServlet.DEFAULT_CONFIG_FILE_PATH); - - static { - PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.put(DispatcherServlet.TAR_PACKAGE, "application/x-tar"); - PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.put(DispatcherServlet.ZIP_PACKAGE, "application/zip"); - } + final ApplicationConfiguration configuration = new ApplicationConfiguration(DispatcherServlet.DEFAULT_CONFIG_FILE_PATH); /** @@ -52,6 +47,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) } } + /** + * Handle creating a payload and obtaining a redirect URL from the main service. + * @param request The HTTP Request. + * @param response The HTTP Response. + * @param packageServiceURI The URI of the configured + */ void doRedirect(final HttpServletRequest request, final HttpServletResponse response, final URI packageServiceURI) { final Subject currentSubject = AuthenticationUtil.getCurrentSubject(); final URL packageServiceURL = lookupServiceURL(packageServiceURI, currentSubject); @@ -81,35 +82,29 @@ void doRedirect(final HttpServletRequest request, final HttpServletResponse resp } private Map getPayload(final HttpServletRequest request) { + final DownloadRequest downloadRequest = getDownloadRequest(request); + final Map payload = new HashMap<>(); - final Map requestParameters = request.getParameterMap(); - final String[] publisherIDs = requestParameters.get(PackageServlet.REQUEST_PARAM_URI_KEY); - if (publisherIDs == null || publisherIDs.length == 0) { + final List publisherIDs = + downloadRequest.getTuples().stream().map(downloadTuple -> downloadTuple.getID().toString()).collect(Collectors.toList()); + + if (publisherIDs.isEmpty()) { throw new IllegalArgumentException("Nothing specified to download. Use tuple=."); } - payload.put(PackageServlet.ID_PAYLOAD_KEY, Arrays.asList(publisherIDs)); + payload.put(PackageServlet.ID_PAYLOAD_KEY, publisherIDs); - final String[] requestedDeliveryMethodValues = requestParameters.get(PackageServlet.REQUEST_PARAM_METHOD_KEY); - final String requestedDeliveryMethod; - - if (requestedDeliveryMethodValues == null || requestedDeliveryMethodValues.length != 1) { - throw new IllegalArgumentException("Delivery method is mandatory. Use method="); - } else { - requestedDeliveryMethod = requestedDeliveryMethodValues[0]; - if (!PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.containsKey(requestedDeliveryMethod.toUpperCase())) { - throw new IllegalArgumentException("Unknown method " + requestedDeliveryMethod + ". Use " - + Arrays.toString(PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.keySet().toArray(new String[0]))); - } + final String contentType = getContentType(); + if (!StringUtil.hasText(contentType)) { + throw new IllegalStateException("Poorly configured package type (no content type specified)"); } - payload.put(PackageServlet.RESPONSE_FORMAT_PAYLOAD_KEY, PackageServlet.METHOD_TO_CONTENT_TYPE_MAP.get(requestedDeliveryMethod.toUpperCase())); + payload.put(PackageServlet.RESPONSE_FORMAT_PAYLOAD_KEY, contentType); - // Add whatever is leftover. - requestParameters.keySet().stream() - .filter(key -> !Arrays.asList(PackageServlet.REQUEST_PARAM_METHOD_KEY, PackageServlet.REQUEST_PARAM_URI_KEY).contains(key)) - .forEach(key -> payload.put(key, requestParameters.get(key))); + if (StringUtil.hasText(downloadRequest.runID)) { + payload.put(PackageServlet.RUN_ID_PAYLOAD_KEY, downloadRequest.runID); + } return payload; } @@ -119,4 +114,17 @@ private URL lookupServiceURL(URI packageServiceURI, Subject currentSubject) { final AuthMethod authMethod = currentSubject == null ? AuthMethod.ANON : AuthenticationUtil.getAuthMethod(currentSubject); return registryClient.getServiceURL(packageServiceURI, Standards.PKG_10, authMethod); } + + private DownloadRequest getDownloadRequest(final HttpServletRequest request) { + final DownloadRequest downloadReq = (DownloadRequest) request.getAttribute("downloadRequest"); + downloadReq.runID = (String) request.getAttribute("runid"); + + return downloadReq; + } + + /** + * Pull the specific content type to set in the payload. + * @return String content-type, never null. + */ + abstract String getContentType(); } diff --git a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/TARPackageServlet.java b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/TARPackageServlet.java index 82de93bd..796a27b7 100644 --- a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/TARPackageServlet.java +++ b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/TARPackageServlet.java @@ -1,71 +1,80 @@ /* -************************************************************************ -******************* CANADIAN ASTRONOMY DATA CENTRE ******************* -************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** -* -* (c) 2024. (c) 2024. -* Government of Canada Gouvernement du Canada -* National Research Council Conseil national de recherches -* Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 -* All rights reserved Tous droits réservés -* -* NRC disclaims any warranties, Le CNRC dénie toute garantie -* expressed, implied, or énoncée, implicite ou légale, -* statutory, of any kind with de quelque nature que ce -* respect to the software, soit, concernant le logiciel, -* including without limitation y compris sans restriction -* any warranty of merchantability toute garantie de valeur -* or fitness for a particular marchande ou de pertinence -* purpose. NRC shall not be pour un usage particulier. -* liable in any event for any Le CNRC ne pourra en aucun cas -* damages, whether direct or être tenu responsable de tout -* indirect, special or general, dommage, direct ou indirect, -* consequential or incidental, particulier ou général, -* arising from the use of the accessoire ou fortuit, résultant -* software. Neither the name de l'utilisation du logiciel. Ni -* of the National Research le nom du Conseil National de -* Council of Canada nor the Recherches du Canada ni les noms -* names of its contributors may de ses participants ne peuvent -* be used to endorse or promote être utilisés pour approuver ou -* products derived from this promouvoir les produits dérivés -* software without specific prior de ce logiciel sans autorisation -* written permission. préalable et particulière -* par écrit. -* -* This file is part of the Ce fichier fait partie du projet -* OpenCADC project. OpenCADC. -* -* OpenCADC is free software: OpenCADC est un logiciel libre ; -* you can redistribute it and/or vous pouvez le redistribuer ou le -* modify it under the terms of modifier suivant les termes de -* the GNU Affero General Public la “GNU Affero General Public -* License as published by the License” telle que publiée -* Free Software Foundation, par la Free Software Foundation -* either version 3 of the : soit la version 3 de cette -* License, or (at your option) licence, soit (à votre gré) -* any later version. toute version ultérieure. -* -* OpenCADC is distributed in the OpenCADC est distribué -* hope that it will be useful, dans l’espoir qu’il vous -* but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE -* without even the implied GARANTIE : sans même la garantie -* warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ -* or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF -* PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence -* General Public License for Générale Publique GNU Affero -* more details. pour plus de détails. -* -* You should have received Vous devriez avoir reçu une -* a copy of the GNU Affero copie de la Licence Générale -* General Public License along Publique GNU Affero avec -* with OpenCADC. If not, see OpenCADC ; si ce n’est -* . pas le cas, consultez : -* . -* -* -************************************************************************ -*/ + ************************************************************************ + ******************* CANADIAN ASTRONOMY DATA CENTRE ******************* + ************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** + * + * (c) 2024. (c) 2024. + * Government of Canada Gouvernement du Canada + * National Research Council Conseil national de recherches + * Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 + * All rights reserved Tous droits réservés + * + * NRC disclaims any warranties, Le CNRC dénie toute garantie + * expressed, implied, or énoncée, implicite ou légale, + * statutory, of any kind with de quelque nature que ce + * respect to the software, soit, concernant le logiciel, + * including without limitation y compris sans restriction + * any warranty of merchantability toute garantie de valeur + * or fitness for a particular marchande ou de pertinence + * purpose. NRC shall not be pour un usage particulier. + * liable in any event for any Le CNRC ne pourra en aucun cas + * damages, whether direct or être tenu responsable de tout + * indirect, special or general, dommage, direct ou indirect, + * consequential or incidental, particulier ou général, + * arising from the use of the accessoire ou fortuit, résultant + * software. Neither the name de l'utilisation du logiciel. Ni + * of the National Research le nom du Conseil National de + * Council of Canada nor the Recherches du Canada ni les noms + * names of its contributors may de ses participants ne peuvent + * be used to endorse or promote être utilisés pour approuver ou + * products derived from this promouvoir les produits dérivés + * software without specific prior de ce logiciel sans autorisation + * written permission. préalable et particulière + * par écrit. + * + * This file is part of the Ce fichier fait partie du projet + * OpenCADC project. OpenCADC. + * + * OpenCADC is free software: OpenCADC est un logiciel libre ; + * you can redistribute it and/or vous pouvez le redistribuer ou le + * modify it under the terms of modifier suivant les termes de + * the GNU Affero General Public la “GNU Affero General Public + * License as published by the License” telle que publiée + * Free Software Foundation, par la Free Software Foundation + * either version 3 of the : soit la version 3 de cette + * License, or (at your option) licence, soit (à votre gré) + * any later version. toute version ultérieure. + * + * OpenCADC is distributed in the OpenCADC est distribué + * hope that it will be useful, dans l’espoir qu’il vous + * but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE + * without even the implied GARANTIE : sans même la garantie + * warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ + * or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF + * PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence + * General Public License for Générale Publique GNU Affero + * more details. pour plus de détails. + * + * You should have received Vous devriez avoir reçu une + * a copy of the GNU Affero copie de la Licence Générale + * General Public License along Publique GNU Affero avec + * with OpenCADC. If not, see OpenCADC ; si ce n’est + * . pas le cas, consultez : + * . + * + * + ************************************************************************ + */ package ca.nrc.cadc.dlm.server; -public class TARPackageServlet { + +public class TARPackageServlet extends PackageServlet { + public static final String TAR_PACKAGE_TARGET = "/tar-package"; + private static final String TAR_CONTENT_TYPE = "application/x-tar"; + + + @Override + String getContentType() { + return TARPackageServlet.TAR_CONTENT_TYPE; + } } diff --git a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/ZIPPackageServlet.java b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/ZIPPackageServlet.java index 68ceeb0d..5d1b2db1 100644 --- a/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/ZIPPackageServlet.java +++ b/cadc-download-manager-server/src/main/java/ca/nrc/cadc/dlm/server/ZIPPackageServlet.java @@ -1,71 +1,80 @@ /* -************************************************************************ -******************* CANADIAN ASTRONOMY DATA CENTRE ******************* -************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** -* -* (c) 2024. (c) 2024. -* Government of Canada Gouvernement du Canada -* National Research Council Conseil national de recherches -* Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 -* All rights reserved Tous droits réservés -* -* NRC disclaims any warranties, Le CNRC dénie toute garantie -* expressed, implied, or énoncée, implicite ou légale, -* statutory, of any kind with de quelque nature que ce -* respect to the software, soit, concernant le logiciel, -* including without limitation y compris sans restriction -* any warranty of merchantability toute garantie de valeur -* or fitness for a particular marchande ou de pertinence -* purpose. NRC shall not be pour un usage particulier. -* liable in any event for any Le CNRC ne pourra en aucun cas -* damages, whether direct or être tenu responsable de tout -* indirect, special or general, dommage, direct ou indirect, -* consequential or incidental, particulier ou général, -* arising from the use of the accessoire ou fortuit, résultant -* software. Neither the name de l'utilisation du logiciel. Ni -* of the National Research le nom du Conseil National de -* Council of Canada nor the Recherches du Canada ni les noms -* names of its contributors may de ses participants ne peuvent -* be used to endorse or promote être utilisés pour approuver ou -* products derived from this promouvoir les produits dérivés -* software without specific prior de ce logiciel sans autorisation -* written permission. préalable et particulière -* par écrit. -* -* This file is part of the Ce fichier fait partie du projet -* OpenCADC project. OpenCADC. -* -* OpenCADC is free software: OpenCADC est un logiciel libre ; -* you can redistribute it and/or vous pouvez le redistribuer ou le -* modify it under the terms of modifier suivant les termes de -* the GNU Affero General Public la “GNU Affero General Public -* License as published by the License” telle que publiée -* Free Software Foundation, par la Free Software Foundation -* either version 3 of the : soit la version 3 de cette -* License, or (at your option) licence, soit (à votre gré) -* any later version. toute version ultérieure. -* -* OpenCADC is distributed in the OpenCADC est distribué -* hope that it will be useful, dans l’espoir qu’il vous -* but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE -* without even the implied GARANTIE : sans même la garantie -* warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ -* or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF -* PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence -* General Public License for Générale Publique GNU Affero -* more details. pour plus de détails. -* -* You should have received Vous devriez avoir reçu une -* a copy of the GNU Affero copie de la Licence Générale -* General Public License along Publique GNU Affero avec -* with OpenCADC. If not, see OpenCADC ; si ce n’est -* . pas le cas, consultez : -* . -* -* -************************************************************************ -*/ + ************************************************************************ + ******************* CANADIAN ASTRONOMY DATA CENTRE ******************* + ************** CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES ************** + * + * (c) 2024. (c) 2024. + * Government of Canada Gouvernement du Canada + * National Research Council Conseil national de recherches + * Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6 + * All rights reserved Tous droits réservés + * + * NRC disclaims any warranties, Le CNRC dénie toute garantie + * expressed, implied, or énoncée, implicite ou légale, + * statutory, of any kind with de quelque nature que ce + * respect to the software, soit, concernant le logiciel, + * including without limitation y compris sans restriction + * any warranty of merchantability toute garantie de valeur + * or fitness for a particular marchande ou de pertinence + * purpose. NRC shall not be pour un usage particulier. + * liable in any event for any Le CNRC ne pourra en aucun cas + * damages, whether direct or être tenu responsable de tout + * indirect, special or general, dommage, direct ou indirect, + * consequential or incidental, particulier ou général, + * arising from the use of the accessoire ou fortuit, résultant + * software. Neither the name de l'utilisation du logiciel. Ni + * of the National Research le nom du Conseil National de + * Council of Canada nor the Recherches du Canada ni les noms + * names of its contributors may de ses participants ne peuvent + * be used to endorse or promote être utilisés pour approuver ou + * products derived from this promouvoir les produits dérivés + * software without specific prior de ce logiciel sans autorisation + * written permission. préalable et particulière + * par écrit. + * + * This file is part of the Ce fichier fait partie du projet + * OpenCADC project. OpenCADC. + * + * OpenCADC is free software: OpenCADC est un logiciel libre ; + * you can redistribute it and/or vous pouvez le redistribuer ou le + * modify it under the terms of modifier suivant les termes de + * the GNU Affero General Public la “GNU Affero General Public + * License as published by the License” telle que publiée + * Free Software Foundation, par la Free Software Foundation + * either version 3 of the : soit la version 3 de cette + * License, or (at your option) licence, soit (à votre gré) + * any later version. toute version ultérieure. + * + * OpenCADC is distributed in the OpenCADC est distribué + * hope that it will be useful, dans l’espoir qu’il vous + * but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE + * without even the implied GARANTIE : sans même la garantie + * warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ + * or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF + * PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence + * General Public License for Générale Publique GNU Affero + * more details. pour plus de détails. + * + * You should have received Vous devriez avoir reçu une + * a copy of the GNU Affero copie de la Licence Générale + * General Public License along Publique GNU Affero avec + * with OpenCADC. If not, see OpenCADC ; si ce n’est + * . pas le cas, consultez : + * . + * + * + ************************************************************************ + */ package ca.nrc.cadc.dlm.server; -public class ZIPPackageServlet { + +public class ZIPPackageServlet extends PackageServlet { + public static final String ZIP_PACKAGE_TARGET = "/zip-package"; + private static final String ZIP_CONTENT_TYPE = "application/zip"; + + + @Override + String getContentType() { + return ZIPPackageServlet.ZIP_CONTENT_TYPE; + } } diff --git a/cadc-download-manager-server/src/main/resources/META-INF/resources/chooser.jsp b/cadc-download-manager-server/src/main/resources/META-INF/resources/chooser.jsp index c79ae0c2..804c3921 100644 --- a/cadc-download-manager-server/src/main/resources/META-INF/resources/chooser.jsp +++ b/cadc-download-manager-server/src/main/resources/META-INF/resources/chooser.jsp @@ -173,8 +173,7 @@ var="langBundle" scope="request"/> <% } %> -

CAOM-2 download options

- " method="POST"> + " method="POST"> @@ -202,22 +201,6 @@ var="langBundle" scope="request"/>

- -
- - -

General download options

-
" method="POST"> - - - - - - - - - -
From 2d71919eac9cf8cd6165f620813dfaea48031f71 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 13:02:10 -0700 Subject: [PATCH 12/14] docs: update build.gradle change --- cadc-download-manager-server/build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cadc-download-manager-server/build.gradle b/cadc-download-manager-server/build.gradle index ceb8455b..2e8497a0 100644 --- a/cadc-download-manager-server/build.gradle +++ b/cadc-download-manager-server/build.gradle @@ -29,7 +29,11 @@ dependencies { implementation 'org.opencadc:cadc-registry:[1.0,)' implementation 'org.opencadc:cadc-rest:[1.3.3,)' implementation 'org.opencadc:cadc-util:[1.6,)' + + // Locking down cadc-vos to a version that is JDK 1.8 compatible. + // Use version >= 2.x when JDK 11 is supported. implementation 'org.opencadc:cadc-vos:1.2.3' + implementation 'org.opencadc:cadc-web-util:[1.2.10,)' implementation 'commons-io:commons-io:[2.7,)' From ff1e678be4939aa067ac74682a1509ca31a2d1d4 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 13:04:08 -0700 Subject: [PATCH 13/14] docs: document locked cadc-vos --- cadc-download-manager/build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cadc-download-manager/build.gradle b/cadc-download-manager/build.gradle index e10077a9..6569a3c4 100644 --- a/cadc-download-manager/build.gradle +++ b/cadc-download-manager/build.gradle @@ -24,7 +24,11 @@ dependencies { implementation 'org.opencadc:cadc-util:[1.6,)' implementation 'org.opencadc:cadc-registry:[1.1.1,)' implementation 'org.opencadc:cadc-app-kit:[1.0,)' + + // Locking down cadc-vos to a version that is JDK 1.8 compatible. + // Use version >= 2.x when JDK 11 is supported. implementation 'org.opencadc:cadc-vos:1.2.3' + implementation 'org.opencadc:cadc-dali:[1.2.15,)' implementation 'org.opencadc:cadc-datalink:[1.0.0,1.1.0)' implementation 'org.opencadc:caom2-artifact-resolvers:[1.2.10,1.3.0)' From bb747dfa8580464a1bd872baf21727487e52d9ba Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 19 Sep 2024 13:04:43 -0700 Subject: [PATCH 14/14] docs: documetn locked cadc-vos --- cadc-upload-manager/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cadc-upload-manager/build.gradle b/cadc-upload-manager/build.gradle index 0909ec93..81cd1e99 100644 --- a/cadc-upload-manager/build.gradle +++ b/cadc-upload-manager/build.gradle @@ -24,6 +24,9 @@ dependencies { implementation 'org.opencadc:cadc-registry:[1.5,2.0)' implementation 'org.opencadc:cadc-util:[1.6,2.0)' implementation 'org.opencadc:cadc-uws:[1.0,2.0)' + + // Locking down cadc-vos to a version that is JDK 1.8 compatible. + // Use version >= 2.x when JDK 11 is supported. implementation 'org.opencadc:cadc-vos:1.2.3' // cadc-uws-server used only for a random string generator