public Request read(Reader reader, HttpServletRequest req) throws WfsException {
// translate string into a proper SAX input source
InputSource requestSource = new InputSource(reader);
// instantiante parsers and content handlers
FeatureHandler contentHandler = new FeatureHandler();
FilterFilter filterParser = new FilterFilter(contentHandler, null);
GMLFilterGeometry geometryFilter = new GMLFilterGeometry(filterParser);
GMLFilterDocument documentFilter = new GMLFilterDocument(geometryFilter);
// read in XML file and parse to content handler
try {
LOGGER.finest("about to create parser");
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
ParserAdapter adapter = new ParserAdapter(parser.getParser());
LOGGER.finest("setting the content handler");
LOGGER.finest("content handler = " + documentFilter);
adapter.setContentHandler(documentFilter);
LOGGER.finest("about to parse");
LOGGER.finest("calling parse on " + requestSource);
adapter.parse(requestSource);
LOGGER.fine("just parsed: " + requestSource);
} catch (SAXException e) {
e.printStackTrace(System.out);
throw new WfsException(e,
"XML getFeature request SAX parsing error",
XmlRequestReader.class.getName());
} catch (IOException e) {
throw new WfsException(e, "XML get feature request input error",
XmlRequestReader.class.getName());
} catch (ParserConfigurationException e) {
throw new WfsException(e, "Some sort of issue creating parser",
XmlRequestReader.class.getName());
}
Request r = contentHandler.getRequest(req);
return r;
}