public String getMimeType(Object value, Operation operation) throws ServiceException { return getOutputFormat(); // return "text/xml; subtype=gml/3.1.1"; }
/** * Creates a new configuration. * * @generated */ public WFSVConfiguration(Data catalog, FeatureTypeSchemaBuilder schemaBuilder) { super(catalog, schemaBuilder); addDependency(new WFSConfiguration(catalog, schemaBuilder)); }
WFSConfiguration configuration() { FeatureTypeSchemaBuilder sb = new FeatureTypeSchemaBuilder.GML3(getGeoServer()); return new WFSConfiguration(getGeoServer(), sb, new WFS(sb)); }
switch (ver) { case V_10: schemaEncoder = new XmlSchemaEncoder.V10(geoServer); break; case V_11: schemaEncoder = new XmlSchemaEncoder.V11(geoServer); break; case V_20: default: schemaEncoder = new XmlSchemaEncoder.V20(geoServer); new Object[] {request.getAdaptee()}); ByteArrayOutputStream bout = new ByteArrayOutputStream(); schemaEncoder.write(featureTypes, bout, op);
@Test public void testSingle() throws Exception { FeatureTypeInfo meta = getFeatureTypeInfo(CiteTestData.BASIC_POLYGONS); ByteArrayOutputStream output = new ByteArrayOutputStream(); XmlSchemaEncoder response = new XmlSchemaEncoder.V11(getGeoServer()); response.write(new FeatureTypeInfo[] {meta}, output, request()); Element schema = ReaderUtils.parse(new StringReader(new String(output.toByteArray()))); assertEquals("xsd:schema", schema.getNodeName()); NodeList types = schema.getElementsByTagName("xsd:complexType"); assertEquals(1, types.getLength()); }
public WFSConfiguration( GeoServer geoServer, FeatureTypeSchemaBuilder schemaBuilder, final WFS wfs) { super(wfs); this.catalog = geoServer.getCatalog(); this.schemaBuilder = schemaBuilder; addDependency(new OGCConfiguration()); addDependency(new OWSConfiguration()); addDependency(new GMLConfiguration()); // OGC and OWS add two extra GML configurations in the mix, make sure to configure them // all... CurvedGeometryFactory gf = new CurvedGeometryFactory(Double.MAX_VALUE); for (Object configuration : allDependencies()) { if (configuration instanceof GMLConfiguration) { GMLConfiguration gml = (GMLConfiguration) configuration; gml.setGeometryFactory(gf); } } }
protected void configureContext(MutablePicoContainer context) { super.configureContext(context); context.registerComponentInstance(WfsFactory.eINSTANCE); context.registerComponentInstance(new WFSHandlerFactory(catalog, schemaBuilder)); context.registerComponentInstance(catalog); context.registerComponentImplementation(PropertyTypePropertyExtractor.class); context.registerComponentInstance(getSrsSyntax()); // seed the cache with entries from the catalog context.registerComponentInstance( FeatureTypeCache.class, new CatalogFeatureTypeCache(getCatalog())); context.registerComponentInstance(new CurvedGeometryFactory(Double.MAX_VALUE)); }
protected void write( FeatureTypeInfo[] featureTypeInfos, OutputStream output, Operation describeFeatureType) throws IOException { // hack for SOAP request, when encoding as SOAP response the schema is actually required // to be encoded in base64 if (Dispatcher.REQUEST.get() != null && Dispatcher.REQUEST.get().isSOAP()) { output.write( ("<wfs:DescribeFeatureTypeResponse xmlns:wfs='" + getWFSNamespaceURI() + "'>") .getBytes()); ByteArrayOutputStream bout = new ByteArrayOutputStream(); doWrite(featureTypeInfos, bout, describeFeatureType); output.write(Base64.encodeBase64(bout.toByteArray())); output.write("</wfs:DescribeFeatureTypeResponse>".getBytes()); } else { // normal write doWrite(featureTypeInfos, output, describeFeatureType); } }
NameSpaceInfo[] namespaces = configuration.getCatalog().getNameSpaces(); for ( int i = 0; i < namespaces.length; i++) { if ( namespaces[i].isDefault() )
configuration.getProperties().remove(GMLConfiguration.NO_FEATURE_BOUNDS); } else { configuration.getProperties().add(GMLConfiguration.NO_FEATURE_BOUNDS); configuration.getProperties().add(GMLConfiguration.NO_SRS_DIMENSION); } else { configuration.getProperties().remove(GMLConfiguration.NO_SRS_DIMENSION); configuration.getProperties().add(GMLConfiguration.OPTIMIZED_ENCODING); } else { configuration.getProperties().remove(GMLConfiguration.OPTIMIZED_ENCODING); configuration.setSrsSyntax( wfs.getGML().get(WFSInfo.Version.V_11).getSrsNameStyle().toSrsSyntax()); configuration.getProperties().add(GMLConfiguration.ENCODE_FEATURE_MEMBER); } else { configuration.getProperties().remove(GMLConfiguration.ENCODE_FEATURE_MEMBER);
void write1_1(LockFeatureResponseType lockResponse, OutputStream output, Operation operation) throws IOException { Encoder encoder = new Encoder(configuration, configuration.schema()); encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset())); LockFeatureType req = (LockFeatureType) operation.getParameters()[0]; encoder.setSchemaLocation( org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE, buildSchemaURL(req.getBaseUrl(), "schemas/wfs/1.1.0/wfs.xsd")); encoder.encode(lockResponse, org.geoserver.wfs.xml.v1_1_0.WFS.LOCKFEATURERESPONSE, output); output.flush(); } }
String location = super.resolveSchemaLocation(xsdSchema, namespaceURI, schemaLocationURI);
public void configureContext(MutablePicoContainer context) { super.configureContext(context); context.registerComponentInstance(WfsvFactory.eINSTANCE); context.registerComponentInstance(new VersionedFeaturePropertyExtractor(catalog)); } }
private Object handleFeatureCollection(FeatureCollectionType featureCollection) { FeatureCollection result = null; if (featureCollection.getFeature().size() > 1) { // wrap in a single result = new CompositeFeatureCollection(featureCollection.getFeature()); } else { // just return the single result = (FeatureCollection) featureCollection.getFeature().iterator().next(); } if (isSimpleFeatureCollection(result) && encoder.getConfiguration().hasProperty(GMLConfiguration.OPTIMIZED_ENCODING)) { return new GML3FeatureCollectionEncoderDelegate( (SimpleFeatureCollection) result, encoder); } else { return result; } }
return handleFeatureCollection(featureCollection); return handleFeatureCollection(featureCollection);
protected Encoder createEncoder( Configuration configuration, Map<String, Set<ResourceInfo>> resources, Object request) { // reuse the WFS configuration feature builder, otherwise build a new one FeatureTypeSchemaBuilder schemaBuilder; if (configuration instanceof WFSConfiguration) { schemaBuilder = ((WFSConfiguration) configuration).getSchemaBuilder(); } else { schemaBuilder = new FeatureTypeSchemaBuilder.GML3(geoServer); } // create this request specific schema ApplicationSchemaXSD1 schema = new ApplicationSchemaXSD1(schemaBuilder); schema.setBaseURL(GetFeatureRequest.adapt(request).getBaseURL()); schema.setResources(resources); if (schema.getFeatureTypes().isEmpty()) { // no feature types so let's use the base WFS schema return new Encoder(configuration, configuration.schema()); } try { // let's just instantiate the encoder return new Encoder(configuration, schema.getSchema()); } catch (IOException exception) { throw new RuntimeException( "Error generating the XSD schema during the encoder instantiation.", exception); } }
@Test public void testWithDifferntNamespaces() throws Exception { FeatureTypeInfo meta1 = getFeatureTypeInfo(CiteTestData.BASIC_POLYGONS); FeatureTypeInfo meta2 = getFeatureTypeInfo(CiteTestData.POLYGONS); ByteArrayOutputStream output = new ByteArrayOutputStream(); XmlSchemaEncoder response = new XmlSchemaEncoder.V11(getGeoServer()); response.write(new FeatureTypeInfo[] {meta1, meta2}, output, request()); Element schema = ReaderUtils.parse(new StringReader(new String(output.toByteArray()))); assertEquals("xsd:schema", schema.getNodeName()); NodeList imprts = schema.getElementsByTagName("xsd:import"); assertEquals(2, imprts.getLength()); } }
GML3OutputFormat producer() { FeatureTypeSchemaBuilder sb = new FeatureTypeSchemaBuilder.GML3(getGeoServer()); WFSConfiguration configuration = new WFSConfiguration(getGeoServer(), sb, new WFS(sb)); return new GML3OutputFormat(getGeoServer(), configuration); }
public void v_1_1(TransactionResponseType response, OutputStream output, Operation operation) throws IOException, ServiceException { if (!response.getTransactionResults().getAction().isEmpty()) { // since we do atomic transactions, an action failure means all we rolled back // spec says to throw exception ActionType action = (ActionType) response.getTransactionResults().getAction().iterator().next(); throw new WFSException(action.getMessage(), action.getCode(), action.getLocator()); } Encoder encoder = new Encoder(configuration, configuration.schema()); encoder.setEncoding(Charset.forName(getInfo().getGeoServer().getSettings().getCharset())); TransactionType req = (TransactionType) operation.getParameters()[0]; encoder.setSchemaLocation( org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE, buildSchemaURL(req.getBaseUrl(), "wfs/1.1.0/wfs.xsd")); encoder.encode(response, org.geoserver.wfs.xml.v1_1_0.WFS.TRANSACTIONRESPONSE, output); } }
@Test public void testListStoredQueries() throws Exception { MockHttpServletResponse response = getAsServletResponse("wfs?request=ListStoredQueries&service=wfs&version=2.0.0"); Document dom = dom(new ByteArrayInputStream(response.getContentAsByteArray())); XMLAssert.assertXpathExists( "//wfs:StoredQuery[@id = '" + StoredQuery.DEFAULT.getName() + "']", dom); // schema validate the response FeatureTypeSchemaBuilder sb = new FeatureTypeSchemaBuilder.GML3(getGeoServer()); WFSConfiguration configuration = new WFSConfiguration(getGeoServer(), sb, new org.geoserver.wfs.xml.v1_1_0.WFS(sb)); Parser parser = new Parser(configuration); parser.parse(new ByteArrayInputStream(response.getContentAsByteArray())); assertEquals(0, parser.getValidationErrors().size()); }