Skip to content

Commit

Permalink
Force JDK 1.8 for CADC server compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
at88mph committed Sep 19, 2024
1 parent 194c727 commit d156585
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion cadc-download-manager-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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,)'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -81,25 +82,35 @@ void doRedirect(final HttpServletRequest request, final HttpServletResponse resp

private Map<String, Object> getPayload(final HttpServletRequest request) {
final Map<String, Object> payload = new HashMap<>();
final Map<String, String[]> 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=<URI>.");
}

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=<TAR,ZIP>");
} 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;
}

Expand Down

0 comments on commit d156585

Please sign in to comment.