throws Exception {
// initialize
LOGGER.finer("Handling csw:GetRecords request XML...");
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();
// service and version are parsed by the parent RequestHandler
// TODO requestId
// output format
locator = "@outputFormat";
parsed = pHelper.getParameterValues(root,xpath,locator);
supported = svcProps.getSupportedValues(CswConstants.Parameter_OutputFormat);
context.getOperationResponse().setOutputFormat(
vHelper.validateValue(supported,locator,parsed,false));
// output schema
locator = "@outputSchema";
parsed = pHelper.getParameterValues(root,xpath,locator);
supported = svcProps.getSupportedValues(CswConstants.Parameter_OutputSchema);
qOptions.setOutputSchema(vHelper.validateValue(supported,locator,parsed,false));
// start and max records
qOptions.setStartRecord(Math.max(Val.chkInt(xpath.evaluate("@startPosition",root),1),1));
qOptions.setMaxRecords(Val.chkInt(xpath.evaluate("@maxRecords",root),10));
// result type
locator = "@resultType";
parsed = pHelper.getParameterValues(root,xpath,locator);
supported = svcProps.getSupportedValues(CswConstants.Parameter_ResultType);
qOptions.setResultType(vHelper.validateValue(supported,locator,parsed,false));
if (qOptions.getResultType() == null) {
qOptions.setResultType(CswConstants.ResultType_Hits);
}
// find the query node
locator = "csw:Query";
Node ndQuery = (Node)xpath.evaluate(locator,root,XPathConstants.NODE);
if (ndQuery != null) {
// query type names
locator = "csw:Query/@typeNames";
parsed = pHelper.getParameterValues(root,xpath,"@typeNames");
qOptions.setQueryTypeNames(vHelper.validateValues(locator,parsed,false));
// response element set type
locator = "csw:ElementSetName";
parsed = pHelper.getParameterValues(ndQuery,xpath,locator);
supported = svcProps.getSupportedValues(CswConstants.Parameter_ElementSetType);
qOptions.setElementSetType(vHelper.validateValue(supported,locator,parsed,false));
// response element set type names
String elementSetType = qOptions.getElementSetType();
if (elementSetType != null) {
locator = "csw:ElementSetName/@typeNames";
parsed = pHelper.getParameterValues(ndQuery,xpath,locator);
qOptions.setElementSetTypeNames(vHelper.validateValues(locator,parsed,false));
}
// response element names
if (elementSetType == null) {
// TODO supported ElementNames
locator = "csw:ElementName";
parsed = pHelper.getParameterValues(ndQuery,xpath,locator);
supported = svcProps.getSupportedValues(CswConstants.Parameter_ElementName);
qOptions.setElementNames(vHelper.validateValues(supported,locator,parsed,false));
}
// find the constraint node
Node ndConstraint = (Node)xpath.evaluate("csw:Constraint",ndQuery,XPathConstants.NODE);