From fab300faec52a32c76a35a29e40b475efb5f93ad Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Tue, 20 Feb 2024 07:28:47 -0800 Subject: [PATCH] Fix local compilation errors. --- .../conesearch/ConeParameterValidator.java | 15 +++++++++++++++ .../opencadc/conesearch/TAPQueryGenerator.java | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cadc-conesearch/src/main/java/org/opencadc/conesearch/ConeParameterValidator.java b/cadc-conesearch/src/main/java/org/opencadc/conesearch/ConeParameterValidator.java index 2f951846..f02601ab 100644 --- a/cadc-conesearch/src/main/java/org/opencadc/conesearch/ConeParameterValidator.java +++ b/cadc-conesearch/src/main/java/org/opencadc/conesearch/ConeParameterValidator.java @@ -76,6 +76,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * Validator for Cone Search parameters. @@ -85,6 +86,9 @@ public class ConeParameterValidator extends CommonParamValidator { public static final String RA_PARAM = "RA"; public static final String DEC_PARAM = "DEC"; public static final String SR_PARAM = "SR"; + + public static final String MAXREC = "MAXREC"; + static final int MIN_VERB_VALUE = 1; static final int MID_VERB_VALUE = 2; static final int MAX_VERB_VALUE = 3; @@ -126,6 +130,17 @@ public int validateVERB(final Map> parameters) { } } + int getMaxRec(final Map> parameters, final int defaultValue, final int maxValue) { + return validateInteger(ConeParameterValidator.MAXREC, parameters).stream().filter(i -> i > maxValue) + .findFirst().orElse(defaultValue); + } + + private List validateInteger(final String verbParam, final Map> parameters, + final List validValues) { + return super.validateInteger(verbParam, parameters).stream().filter(validValues::contains) + .collect(Collectors.toList()); + } + private String getFirstParameter(final String key, final Map> requestParameters) { final List values = requestParameters.get(key); return (values == null || values.isEmpty()) ? null : values.get(0); diff --git a/cadc-conesearch/src/main/java/org/opencadc/conesearch/TAPQueryGenerator.java b/cadc-conesearch/src/main/java/org/opencadc/conesearch/TAPQueryGenerator.java index 8e156f49..f5f0b1f6 100644 --- a/cadc-conesearch/src/main/java/org/opencadc/conesearch/TAPQueryGenerator.java +++ b/cadc-conesearch/src/main/java/org/opencadc/conesearch/TAPQueryGenerator.java @@ -69,7 +69,6 @@ package org.opencadc.conesearch; import ca.nrc.cadc.dali.Circle; -import ca.nrc.cadc.dali.tables.votable.VOTableWriter; import ca.nrc.cadc.util.StringUtil; import java.util.HashMap; @@ -139,7 +138,7 @@ public Map getParameterMap() { // Obtain and, if necessary, provide a default RESPONSEFORMAT. queryParameterMap.put(ConeParameterValidator.RESPONSEFORMAT, - coneParameterValidator.getResponseFormat(parameters, VOTableWriter.CONTENT_TYPE)); + coneParameterValidator.getResponseFormat(parameters)); // Obtain and validate the VERB (verbosity) output. final int outputVerbosity = coneParameterValidator.validateVERB(parameters);