throws OwsException, XPathExpressionException {
// parse the sort option
LOGGER.finer("Parsing sort by for "+sortByNode.getNodeName());
DiscoveryQuery query = this.getDiscoveryContext().getDiscoveryQuery();
Sortables sortables = new Sortables();
NodeList nlProps = null;
if (sortByNode != null) {
nlProps = (NodeList)xpath.evaluate("ogc:SortProperty",sortByNode,XPathConstants.NODESET);
}
if ((nlProps != null) && (nlProps.getLength() > 0)) {
for (int i=0; i<nlProps.getLength(); i++) {
Sortable sortable = this.parsePropertyName(nlProps.item(i),xpath).asSortable();
Node ndDir = (Node)xpath.evaluate("ogc:SortOrder",nlProps.item(i),XPathConstants.NODE);
if (ndDir != null) {
String sSortDir = ndDir.getTextContent();
try {
LOGGER.finer("Setting sort direction:"+sSortDir);
sortable.setDirection(Sortable.SortDirection.from(sSortDir));
} catch (IllegalArgumentException e) {
String msg = "This parameter value is not supported: "+sSortDir;
throw new OwsException(OwsException.OWSCODE_InvalidParameterValue,"SortOrder",msg);
}
}
sortables.add(sortable);
}
}
if (sortables.size() > 0) {
query.setSortables(sortables);
}
}