Search in sources :

Example 1 with Query

use of org.geotoolkit.wfs.xml.Query in project geotoolkit by Geomatys.

the class AbstractGetFeature method getResponseStream.

/**
 * {@inheritDoc }
 */
@Override
public InputStream getResponseStream() throws IOException {
    final List<QName> typeNames = new ArrayList<>();
    final List<String> propNames;
    if (typeName != null) {
        typeNames.add(typeName);
        propNames = preparePropertyNames(typeName.getPrefix(), typeName.getNamespaceURI()).collect(Collectors.toList());
    } else {
        propNames = preparePropertyNames(null, null).collect(Collectors.toList());
    }
    final XMLFilter xmlFilter = prepareFilter().orElse(null);
    final Query query = WFSXmlFactory.buildQuery(version.getCode(), xmlFilter, typeNames, null, null, null, propNames);
    final GetFeature request = WFSXmlFactory.buildGetFeature(version.getCode(), "WFS", null, null, maxFeatures, query, ResultTypeType.RESULTS, outputFormat);
    final URL url = new URL(serverURL);
    URLConnection conec = url.openConnection();
    conec = security.secure(conec);
    conec.setDoOutput(true);
    conec.setRequestProperty("Content-Type", "text/xml");
    OutputStream stream = conec.getOutputStream();
    stream = security.encrypt(stream);
    try (final OutputStream toClose = stream) {
        Marshaller marshaller = WFSMarshallerPool.getInstance(version).acquireMarshaller();
        marshaller.marshal(request, stream);
        WFSMarshallerPool.getInstance().recycle(marshaller);
    } catch (JAXBException ex) {
        throw new IOException(ex);
    }
    return security.decrypt(conec.getInputStream());
}
Also used : GetFeature(org.geotoolkit.wfs.xml.GetFeature) Marshaller(javax.xml.bind.Marshaller) Query(org.geotoolkit.wfs.xml.Query) QName(javax.xml.namespace.QName) OutputStream(java.io.OutputStream) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) XMLFilter(org.geotoolkit.ogc.xml.XMLFilter) IOException(java.io.IOException) URL(java.net.URL) URLConnection(java.net.URLConnection)

Aggregations

IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 ArrayList (java.util.ArrayList)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1 QName (javax.xml.namespace.QName)1 XMLFilter (org.geotoolkit.ogc.xml.XMLFilter)1 GetFeature (org.geotoolkit.wfs.xml.GetFeature)1 Query (org.geotoolkit.wfs.xml.Query)1