Skip to content

Commit

Permalink
deegree#892 - implemented configuration of gml application schema per…
Browse files Browse the repository at this point in the history
… gml version
  • Loading branch information
lgoltz committed Oct 21, 2019
1 parent ea5d1da commit 6f39c17
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static org.deegree.protocol.wfs.getfeature.ResultType.RESULTS;

import java.io.IOException;
import java.net.URL;
import java.util.List;

import javax.xml.bind.JAXBElement;
Expand All @@ -52,12 +53,14 @@
import org.deegree.geometry.io.DecimalCoordinateFormatter;
import org.deegree.geometry.linearization.MaxErrorCriterion;
import org.deegree.gml.GMLVersion;
import org.deegree.gml.schema.GMLSchemaInfoSet;
import org.deegree.protocol.wfs.describefeaturetype.DescribeFeatureType;
import org.deegree.protocol.wfs.getfeature.GetFeature;
import org.deegree.protocol.wfs.getfeature.ResultType;
import org.deegree.protocol.wfs.getgmlobject.GetGmlObject;
import org.deegree.protocol.wfs.getpropertyvalue.GetPropertyValue;
import org.deegree.services.controller.utils.HttpResponseBuffer;
import org.deegree.services.jaxb.wfs.GMLFormat;
import org.deegree.services.jaxb.wfs.GMLFormat.GetFeatureResponse;
import org.deegree.services.jaxb.wfs.GMLFormat.GetFeatureResponse.PrebindNamespace;
import org.deegree.services.jaxb.wfs.GeometryLinearization;
Expand Down Expand Up @@ -117,7 +120,7 @@ public GmlFormat( WebFeatureService master, GMLVersion gmlVersion ) {
this.master = master;
this.options = new GmlFormatOptions( gmlVersion, null, null, null, false, false, master.getQueryMaxFeatures(),
master.getCheckAreaOfUse(), null, null, gmlVersion.getMimeType(), false,
null, null, master.isEnableResponsePaging() );
null, null, master.isEnableResponsePaging(), null );
this.dftHandler = new GmlDescribeFeatureTypeHandler( this );
this.gfHandler = new GmlGetFeatureHandler( this );
this.gpvHandler = new GmlGetPropertyValueHandler( this );
Expand All @@ -136,6 +139,7 @@ public GmlFormat( WebFeatureService master, GMLVersion gmlVersion ) {
public GmlFormat( WebFeatureService master, org.deegree.services.jaxb.wfs.GMLFormat formatDef )
throws ResourceInitException {
this.master = master;
final GMLVersion gmlVersion = GMLVersion.valueOf( formatDef.getGmlVersion().value() );

boolean generateBoundedByForFeatures = false, disableStreaming = false;
if ( formatDef.isGenerateBoundedByForFeatures() != null ) {
Expand All @@ -144,6 +148,7 @@ public GmlFormat( WebFeatureService master, org.deegree.services.jaxb.wfs.GMLFor

QName responseContainerEl = null, responseFeatureMemberEl = null;
String schemaLocation = null, appSchemaBaseURL = null;
GMLSchemaInfoSet originalSchemaLocation = null;

GetFeatureResponse responseConfig = formatDef.getGetFeatureResponse();
boolean exportOriginalSchema = false;
Expand Down Expand Up @@ -171,6 +176,9 @@ public GmlFormat( WebFeatureService master, org.deegree.services.jaxb.wfs.GMLFor
appSchemaBaseURL = null;
}
}
if ( responseConfig.getSchemaLocation() != null ) {
originalSchemaLocation = createGmlSchemaInfoSet(gmlVersion, responseConfig);
}
prebindNamespaces = getNamespaceBindings( responseConfig.getPrebindNamespace() );
}

Expand Down Expand Up @@ -198,14 +206,13 @@ public GmlFormat( WebFeatureService master, org.deegree.services.jaxb.wfs.GMLFor
throw new ResourceInitException( "Error initializing coordinate formatter: " + e.getMessage(), e );
}

final GMLVersion gmlVersion = GMLVersion.valueOf( formatDef.getGmlVersion().value() );
final String mimeType = trim( formatDef.getMimeType().get( 0 ) );
final SFSProfiler geometrySimplifier = getSfsProfiler( formatDef.getGeometryLinearization() );
this.options = new GmlFormatOptions( gmlVersion, responseContainerEl, responseFeatureMemberEl, schemaLocation,
disableStreaming, generateBoundedByForFeatures, queryMaxFeatures,
checkAreaOfUse, formatter, appSchemaBaseURL, mimeType,
exportOriginalSchema, geometrySimplifier, prebindNamespaces,
master.isEnableResponsePaging() );
master.isEnableResponsePaging(), originalSchemaLocation );

this.dftHandler = new GmlDescribeFeatureTypeHandler( this );
this.gfHandler = new GmlGetFeatureHandler( this );
Expand Down Expand Up @@ -293,4 +300,15 @@ public WebFeatureService getMaster() {
public GmlFormatOptions getGmlFormatOptions() {
return options;
}

private GMLSchemaInfoSet createGmlSchemaInfoSet( GMLVersion gmlVersion,
GetFeatureResponse responseConfig ) {
try {
URL url = this.master.getMetadata().getLocation().resolveToUrl( responseConfig.getSchemaLocation() );
return new GMLSchemaInfoSet( gmlVersion, url.toString() );
} catch ( Exception e ) {
throw new ResourceInitException( "Error resolving of initializing schema location: " + e.getMessage(), e );
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.deegree.geometry.SFSProfiler;
import org.deegree.geometry.io.CoordinateFormatter;
import org.deegree.gml.GMLVersion;
import org.deegree.gml.schema.GMLSchemaInfoSet;

/**
* Configuration options for {@link GmlFormat}.
Expand Down Expand Up @@ -82,6 +83,9 @@ public class GmlFormatOptions {

private final boolean enableResponsePaging;

private final GMLSchemaInfoSet originalSchemaLocation;


/**
* Creates a new {@link GmlFormatOptions} instance.
*
Expand Down Expand Up @@ -114,7 +118,8 @@ public GmlFormatOptions( final GMLVersion gmlVersion, final QName responseContai
final int queryMaxFeatures, final boolean checkAreaOfUse,
final CoordinateFormatter formatter, final String appSchemaBaseURL, final String mimeType,
final boolean exportOriginalSchema, final SFSProfiler geometrySimplifier,
final NamespaceBindings prebindNamespaces, final boolean enableResponsePaging ) {
final NamespaceBindings prebindNamespaces, final boolean enableResponsePaging,
final GMLSchemaInfoSet originalSchemaLocation ) {
this.gmlVersion = gmlVersion;
this.responseContainerEl = responseContainerEl;
this.responseFeatureMemberEl = responseFeatureMemberEl;
Expand All @@ -130,6 +135,7 @@ public GmlFormatOptions( final GMLVersion gmlVersion, final QName responseContai
this.geometrySimplifier = geometrySimplifier;
this.prebindNamespaces = prebindNamespaces;
this.enableResponsePaging = enableResponsePaging;
this.originalSchemaLocation = originalSchemaLocation;
}

/**
Expand Down Expand Up @@ -239,4 +245,9 @@ public boolean isEnableResponsePaging() {
return enableResponsePaging;
}


public GMLSchemaInfoSet getOriginalSchemaLocation() {
return originalSchemaLocation;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,16 @@ private void doDescribeFeatureType( DescribeFeatureType request, GMLVersion vers
Collection<String> namespaces = determineRequiredNamespaces( request );
String targetNs = namespaces.iterator().next();
if ( options.isExportOriginalSchema() ) {
GMLSchemaInfoSet gmlSchema = findGmlSchema( namespaces, version );
if ( gmlSchema != null ) {
exportOriginalInfoSet( writer, gmlSchema, targetNs );
if (options.getOriginalSchemaLocation() != null) {
exportOriginalInfoSet(writer, options.getOriginalSchemaLocation(), targetNs);
} else {
LOG.warn( "Could not find original schema corresponding to the requested schema, try to reencode the schema!" );
reencodeSchema( request, writer, targetNs, namespaces, version );
GMLSchemaInfoSet gmlSchema = findGmlSchema(namespaces, version);
if (gmlSchema != null) {
exportOriginalInfoSet(writer, gmlSchema, targetNs);
} else {
LOG.warn("Could not find original schema corresponding to the requested schema, try to reencode the schema!");
reencodeSchema(request, writer, targetNs, namespaces, version);
}
}
} else {
reencodeSchema( request, writer, targetNs, namespaces, version );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
</simpleContent>
</complexType>
</element>
<element name="SchemaLocation" type="string" minOccurs="0" />
<element name="DisableStreaming" type="boolean" minOccurs="0" default="false" />
<element name="PrebindNamespace" minOccurs="0" maxOccurs="unbounded">
<complexType>
Expand Down

0 comments on commit 6f39c17

Please sign in to comment.