// initialize
LOGGER.finer("Handling csw:GetRecords request URL...");
QueryOptions qOptions = context.getRequestOptions().getQueryOptions();
ServiceProperties svcProps = context.getServiceProperties();
ParseHelper pHelper = new ParseHelper();
ValidationHelper vHelper = new ValidationHelper();
String locator;
String[] parsed;
ISupportedValues supported;
IProviderFactory factory = context.getProviderFactory();
CswNamespaces ns = new CswNamespaces();
XPath xpath = XPathFactory.newInstance().newXPath();
xpath.setNamespaceContext(ns.makeNamespaceContext());
// service and version are parsed by the parent RequestHandler
// TODO typeNames requestId distributedSearch hopCount responseHandler
// TODO resultype validate is not applicable for a GET request?
// output format
locator = "outputFormat";
parsed = pHelper.getParameterValues(request,locator);
supported = svcProps.getSupportedValues(CswConstants.Parameter_OutputFormat);
context.getOperationResponse().setOutputFormat(
vHelper.validateValue(supported,locator,parsed,false));
// output schema
locator = "outputSchema";
parsed = pHelper.getParameterValues(request,locator);
supported = svcProps.getSupportedValues(CswConstants.Parameter_OutputSchema);
qOptions.setOutputSchema(vHelper.validateValue(supported,locator,parsed,false));
// start and max records
parsed = pHelper.getParameterValues(request,"startPosition");
if ((parsed != null) && (parsed.length) > 0) {
qOptions.setStartRecord(Math.max(Val.chkInt(parsed[0],1),1));
}
parsed = pHelper.getParameterValues(request,"maxRecords");
if ((parsed != null) && (parsed.length) > 0) {
qOptions.setMaxRecords(Val.chkInt(parsed[0],10));
}
// result type
locator = "resultType";
parsed = pHelper.getParameterValues(request,locator);
supported = svcProps.getSupportedValues(CswConstants.Parameter_ResultType);
qOptions.setResultType(vHelper.validateValue(supported,locator,parsed,false));
if (qOptions.getResultType() == null) {
qOptions.setResultType(CswConstants.ResultType_Hits);
}
// query type names
locator = "typeNames";
parsed = pHelper.getParameterValues(request,locator);
qOptions.setQueryTypeNames(vHelper.validateValues(locator,parsed,false));
// response element set type
locator = "ElementSetName";
parsed = pHelper.getParameterValues(request,locator);
supported = svcProps.getSupportedValues(CswConstants.Parameter_ElementSetType);
qOptions.setElementSetType(vHelper.validateValue(supported,locator,parsed,false));
// response element names
if (qOptions.getElementSetType() == null) {
// TODO supported ElementNames this for GetRecordById as well?
locator = "ElementName";
parsed = pHelper.getParameterValues(request,locator,",");
supported = svcProps.getSupportedValues(CswConstants.Parameter_ElementName);
qOptions.setElementNames(vHelper.validateValues(supported,locator,parsed,false));
}
// constraint language
locator = "constraintLanguage";
parsed = pHelper.getParameterValues(request,locator);
supported = new SupportedValues("CQL_TEXT,FILTER",",");
String constraintLanguage = vHelper.validateValue(supported,locator,parsed,false);
// constraint version
locator = "constraint_language_version";
parsed = pHelper.getParameterValues(request,locator);
String constraintVersion = vHelper.validateValue(locator,parsed,false);
qOptions.setQueryConstraintVersion(constraintVersion);
// constraint text
locator = "constraint";
parsed = pHelper.getParameterValues(request,locator);
String constraint = vHelper.validateValue(locator,parsed,false);
// csw:CqlText
if ((constraintLanguage != null) && constraintLanguage.equalsIgnoreCase("CQL_TEXT")) {
String cql = Val.chkStr(constraint);
qOptions.setQueryConstraintCql(cql);
ICqlParser parser = factory.makeCqlParser(context,constraintVersion);
if (parser == null) {
String msg = "IProviderFactory.makeCqlParser: instantiation failed.";
throw new OwsException(OwsException.OWSCODE_NoApplicableCode,locator,msg);
} else {
parser.parseCql(context,cql);
}
}
// ogc:Filter
if ((constraintLanguage == null) || constraintLanguage.equalsIgnoreCase("FILTER")) {
Node ndFilter = null;
IFilterParser parser = factory.makeFilterParser(context,constraintVersion);
if (parser == null) {
String msg = "IProviderFactory.makeFilterParser: instantiation failed.";
throw new OwsException(OwsException.OWSCODE_NoApplicableCode,locator,msg);
}
String constraintFilter = Val.chkStr(constraint);
if (constraintFilter.length() > 0) {
String[] namespace = pHelper.getParameterValues(request,"namespace",",");
ndFilter = this.buildFilterNode(namespace,constraintFilter);
parser.parseFilter(context,ndFilter,xpath);
}
}
// ogc:SortBy
locator = "sortBy";
String[] sortBy = pHelper.getParameterValues(request,"sortBy",",");
if (sortBy != null) {
Node ndSortBy = this.buildSortByNode(sortBy);
if (ndSortBy != null) {
ISortByParser parser = factory.makeSortByParser(context);
if (parser == null) {