118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/gs-web-iso/src/main/java/org/geoserver/wfs/web/publish/WFSLayerConfig.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/gs-web-iso/src/main/java/org/geoserver/wfs/web/publish/WFSLayerConfig.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.web.publish;
7 |
8 | import java.util.List;
9 |
10 | import org.apache.wicket.ajax.AjaxRequestTarget;
11 | import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
12 | import org.apache.wicket.ajax.markup.html.AjaxLink;
13 | import org.apache.wicket.markup.html.WebMarkupContainer;
14 | import org.apache.wicket.markup.html.border.Border;
15 | import org.apache.wicket.markup.html.form.CheckBox;
16 | import org.apache.wicket.markup.html.form.TextArea;
17 | import org.apache.wicket.markup.html.form.TextField;
18 | import org.apache.wicket.markup.html.form.validation.FormComponentFeedbackBorder;
19 | import org.apache.wicket.model.IModel;
20 | import org.apache.wicket.model.PropertyModel;
21 | import org.apache.wicket.model.StringResourceModel;
22 | import org.apache.wicket.validation.validator.RangeValidator;
23 | import org.geoserver.catalog.LayerInfo;
24 | import org.geoserver.web.publish.PublishedConfigurationPanel;
25 | import org.geoserver.web.wicket.GeoServerDialog;
26 | import org.geoserver.web.wicket.LiveCollectionModel;
27 | import org.geoserver.web.wicket.SRSListTextArea;
28 |
29 | public class WFSLayerConfig extends PublishedConfigurationPanel {
30 |
31 | private static final long serialVersionUID = 4264296611272179367L;
32 |
33 | protected GeoServerDialog dialog;
34 |
35 | public WFSLayerConfig(String id, IModel model){
36 | super(id, model);
37 |
38 | TextField maxFeatures = new TextField("perReqFeatureLimit",
39 | new PropertyModel(model, "resource.maxFeatures"));
40 | maxFeatures.add(RangeValidator.minimum(0));
41 | Border mfb = new FormComponentFeedbackBorder("perReqFeaturesBorder");
42 | mfb.add(maxFeatures);
43 | add(mfb);
44 | TextField maxDecimals = new TextField("maxDecimals", new PropertyModel(model, "resource.numDecimals"));
45 | maxFeatures.add(RangeValidator.minimum(0));
46 | Border mdb = new FormComponentFeedbackBorder("maxDecimalsBorder");
47 | mdb.add(maxDecimals);
48 | add(mdb);
49 | CheckBox skipNumberMatched = new CheckBox("skipNumberMatched", new PropertyModel(model, "resource.skipNumberMatched"));
50 | add(skipNumberMatched);
51 |
52 | // other srs list
53 | dialog = new GeoServerDialog("wfsDialog");
54 | add(dialog);
55 | PropertyModel overrideServiceSRSModel = new PropertyModel(model, "resource.overridingServiceSRS");
56 | final CheckBox overrideServiceSRS = new CheckBox("overridingServiceSRS", overrideServiceSRSModel);
57 | add(overrideServiceSRS);
58 | final WebMarkupContainer otherSrsContainer = new WebMarkupContainer("otherSRSContainer");
59 | otherSrsContainer.setOutputMarkupId(true);
60 | add(otherSrsContainer);
61 | final TextArea> srsList = new SRSListTextArea("srs", LiveCollectionModel.list(
62 | new PropertyModel>(model, "resource.responseSRS")));
63 | srsList.setOutputMarkupId(true);
64 | srsList.setVisible(Boolean.TRUE.equals(overrideServiceSRSModel.getObject()));
65 | otherSrsContainer.add(srsList);
66 | overrideServiceSRS.add(new AjaxFormComponentUpdatingBehavior("change") {
67 | private static final long serialVersionUID = -6590810763209350915L;
68 |
69 | @Override
70 | protected void onUpdate(AjaxRequestTarget target) {
71 | Boolean visible = overrideServiceSRS.getConvertedInput();
72 | srsList.setVisible(visible);
73 | target.add(otherSrsContainer);
74 | }
75 | });
76 | add(new AjaxLink("skipNumberMatchedHelp") {
77 | private static final long serialVersionUID = 9222171216768726057L;
78 |
79 | @Override
80 | public void onClick(AjaxRequestTarget target) {
81 | dialog.showInfo(target,
82 | new StringResourceModel("skipNumberMatched", WFSLayerConfig.this, null),
83 | new StringResourceModel("skipNumberMatched.message", WFSLayerConfig.this, null));
84 | }
85 | });
86 | add(new AjaxLink("otherSRSHelp") {
87 | private static final long serialVersionUID = -1239179491855142211L;
88 |
89 | @Override
90 | public void onClick(AjaxRequestTarget target) {
91 | dialog.showInfo(target,
92 | new StringResourceModel("otherSRS", WFSLayerConfig.this, null),
93 | new StringResourceModel("otherSRS.message", WFSLayerConfig.this, null));
94 | }
95 | });
96 |
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/gs-web-iso/src/main/java/org/geoserver/wfs/web/server_vector.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/STEMLab/geoserver-3d-extension/213660deaa9c246dad5c7488f4dc88179b27dfe4/gs-web-iso/src/main/java/org/geoserver/wfs/web/server_vector.png
--------------------------------------------------------------------------------
/gs-web-iso/src/main/resources/GeoServerApplication.properties:
--------------------------------------------------------------------------------
1 | category.data3d = Data 3D
2 |
3 | ISOStorePage.title = 3D Stores
4 | ISOStorePage.description = Manage the stores providing 3d data to GeoServer
5 | ISOStorePage.addNew = Add new 3D Store
6 | ISOStorePage.removeSelected = Remove selected Stores
7 | ISOStorePage.th.enabled = Enabled?
8 | ISOStorePage.th.name = Store Name
9 | ISOStorePage.th.datatype = Data Type
10 | ISOStorePage.th.type = Type
11 | ISOStorePage.th.workspace = Workspace
12 |
13 | ISOLayerPage.addNew = Add a new layer
14 | ISOLayerPage.description = Manage the layers being published by GeoServer
15 | ISOLayerPage.layerList = Layer List
16 | ISOLayerPage.removeSelected = Remove selected layers
17 | ISOLayerPage.th.SRS = Native SRS
18 | ISOLayerPage.th.enabled = Enabled
19 | ISOLayerPage.th.name = Name
20 | ISOLayerPage.th.remove = Remove
21 | ISOLayerPage.th.store = Store
22 | ISOLayerPage.th.title = Title
23 | ISOLayerPage.th.type = Type
24 | ISOLayerPage.th.workspace = Workspace
25 | ISOLayerPage.title = 3D Layers
26 |
27 | # WFS ================================================================================
28 | wfs.description=Web Feature Service 3D
29 | wfs.title=3D WFS
30 |
31 | WFSAdminPage.basic=Basic
32 | WFSAdminPage.canonicalSchemaLocation=Encode canonical WFS schema location
33 | WFSAdminPage.complete=Complete
34 | WFSAdminPage.conformance=Conformance
35 | WFSAdminPage.description=Manage the publishing of feature data.
36 | WFSAdminPage.encodeFeatureMember=Encode response with
37 | WFSAdminPage.featureBounding=Return bounding box with every feature
38 | WFSAdminPage.featureMembers=One "featureMembers" element
39 | WFSAdminPage.featureMember=Multiple "featureMember" elements
40 | WFSAdminPage.features=Features
41 | WFSAdminPage.gml2.title=GML 2
42 | WFSAdminPage.gml3.title=GML 3
43 | WFSAdminPage.gml32.title=GML 3.2
44 | WFSAdminPage.hitsIgnoreMaxFeatures=Ignore maximum number of features when calculating hits
45 | WFSAdminPage.maxNumberOfFeatures=Maximum number of features
46 | WFSAdminPage.maxNumberOfFeaturesForPreview=Maximum number of features for preview (Values <= 0 use the maximum number of features)
47 | WFSAdminPage.title=Web Feature Service
48 | WFSAdminPage.transactional=Transactional
49 | WFSAdminPage.serviceLevel=Service Level
50 | WFSAdminPage.shapeOutputFormat=SHAPE\u002DZIP output format
51 | WFSAdminPage.shapeZipPrjFormat=Use ESRI WKT format for SHAPE\u002DZIP generated .prj files
52 |
53 | otherSRS=Extra SRS codes for WFS capabilities generation
54 |
55 | WFSAdminPage$GMLPanel.srsStyle=SRS Style
56 | WFSAdminPage$GMLPanel.overrideGMLAttributes=Override GML Attributes
57 | WFSAdminPage.otherSRS.message=A comma separated list of EPSG codes, e.g. 4326,3857,3003. The \
58 | corresponding codes will be added to each FeatureType declaration in the GetCapabilities \
59 | response.
60 |
61 | WFSLayerConfig.maxDecimals=Maximum number of decimals
62 | WFSLayerConfig.perReqFeatureLimit=Per-Request Feature Limit
63 | WFSLayerConfig.wfsSettings=WFS Settings
64 | WFSLayerConfig.featureSettings=Feature Settings
65 | WFSLayerConfig.overridingServiceSRS=Override WFS wide SRS list
66 | WFSLayerConfig.skipNumberMatched=Skip the counting of the numberMatched attribute
67 | WFSLayerConfig.skipNumberMatchedTitle=NumberMatched skip
68 | WFSLayerConfig.skipNumberMatched.message=To enhance the performance of large queries, it is possible to skip the counting \
69 | of the numberMatched attribute in a GetFeature WFS request. Although enabling this can minimize the query time, it can \
70 | also break pagination for client applications, since numberMatched will always evaluate to 'unknown'.
71 | WFSLayerConfig.otherSRS.message=A comma separated list of EPSG codes, e.g. 4326,3857,3003. The \
72 | corresponding codes will be added to each FeatureType declaration in the GetCapabilities \
73 | response. The list can be left empty to have no extra SRS declared for this specific type, in \
74 | override to a list of values specified in the WFS service configuration.
75 |
76 |
77 | SrsNameStyle.NORMAL=EPSG Code
78 | SrsNameStyle.XML=OGC HTTP URL
79 | SrsNameStyle.URN=OGC Experimental URN
80 | SrsNameStyle.URN2=OGC URN
81 | SrsNameStyle.URL=OGC HTTP URI
82 |
--------------------------------------------------------------------------------
/gs-wfs-iso/.gitignore:
--------------------------------------------------------------------------------
1 | /.classpath
2 | /.project
3 |
--------------------------------------------------------------------------------
/gs-wfs-iso/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/main/java=UTF-8
3 |
--------------------------------------------------------------------------------
/gs-wfs-iso/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.geoserver
7 | geoserver-iso
8 | 2.9-SNAPSHOT
9 | ../
10 |
11 | gs-wfs-iso
12 |
13 |
14 |
15 |
16 | org.geoserver
17 | gs-ows
18 | 2.9-SNAPSHOT
19 |
20 |
21 | org.geoserver
22 | gs-wfs
23 | 2.9-SNAPSHOT
24 |
25 |
26 | org.geoserver
27 | gs-platform
28 | 2.9-SNAPSHOT
29 |
30 |
31 |
32 | org.geotools
33 | gt-main-iso
34 | 15-SNAPSHOT
35 |
36 |
37 |
38 | org.geotools.xsd
39 | gt-xsd-filter-iso
40 | 15-SNAPSHOT
41 |
42 |
43 |
44 | org.geotools.xsd
45 | gt-xsd-gml3-iso
46 | 15-SNAPSHOT
47 |
48 |
49 |
50 | org.geoserver
51 | gs-main-iso
52 | 2.9-SNAPSHOT
53 |
54 |
55 |
56 |
57 | javax.servlet
58 | javax.servlet-api
59 | ${servlet-api.version}
60 | provided
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/META-INF/services/org.geotools.filter.ExtendedOperatorFactory:
--------------------------------------------------------------------------------
1 | org.geoserver.wfs.WFSExtendedOperatorFactory
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/META-INF/services/org.vfny.geoserver.wfs.FeatureResponseDelegateProducerSpi:
--------------------------------------------------------------------------------
1 | org.vfny.geoserver.wfs.responses.GML2FeatureResponseDelegateFactory
2 | org.vfny.geoserver.wfs.responses.ShapefileFeatureResponseDelegateFactory
3 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/GetCapabilities3D.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs;
7 |
8 | import java.nio.charset.Charset;
9 | import java.util.ArrayList;
10 | import java.util.Collection;
11 | import java.util.List;
12 |
13 | import org.geoserver.catalog.Catalog;
14 | import org.geoserver.ows.util.RequestUtils;
15 | import org.geoserver.wfs.request.GetCapabilitiesRequest3D;
16 |
17 | /**
18 | * Web Feature Service GetCapabilities operation.
19 | *
20 | * This operation returns a {@link org.geotools.xml.transform.TransformerBase} instance
21 | * which will serialize the wfs capabilities document. This class uses ows version negotiation
22 | * to determine which version of the wfs capabilities document to return.
23 | *
24 | *
25 | * @author Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
26 | *
27 | */
28 | public class GetCapabilities3D {
29 | /**
30 | * WFS service configuration
31 | */
32 | WFSInfo wfs;
33 |
34 | /**
35 | * The catalog
36 | */
37 | Catalog catalog;
38 |
39 | private final Collection extendedCapabilitiesProviders;
40 |
41 | /**
42 | * Creates a new wfs 1.0/1.1 GetCapabilitis operation.
43 | *
44 | * @param wfs The wfs configuration
45 | * @param catalog The geoserver catalog.
46 | * @param extendedCapabilitiesProviders the providers for adding extra metadata to the capabilities documents
47 | */
48 | public GetCapabilities3D(WFSInfo wfs, Catalog catalog, Collection extendedCapabilitiesProviders) {
49 | this.wfs = wfs;
50 | this.catalog = catalog;
51 | this.extendedCapabilitiesProviders = extendedCapabilitiesProviders;
52 | }
53 |
54 | public CapabilitiesTransformer3D run(GetCapabilitiesRequest3D request)
55 | throws WFSException {
56 | //cite requires that we fail when we see an "invalid" update sequence,
57 | // since we dont support update sequences, all are invalid, but we take
58 | // our more lax approach and just ignore it when not doint the cite thing
59 | if (wfs.isCiteCompliant()) {
60 | if (request.getUpdateSequence() != null) {
61 | throw new WFSException(request, "Invalid update sequence", "InvalidUpdateSequence");
62 | }
63 | }
64 |
65 | //TODO: the rest of this routine should be done by the dispatcher
66 | //make sure service is set, cite conformance thing
67 | //JD - We wrap this in a cite conformance check because cite stricly
68 | // tests that every request includes the 'service=WFS' key value pair.
69 | // However often the the context of the request is good enough to
70 | // determine what the service is, like in 'geoserver/wfs?request=GetCapabilities'
71 | if (wfs.isCiteCompliant()) {
72 | if (!request.isSetService()) {
73 | //give up
74 | throw new WFSException("Service not set", "MissingParameterValue", "service");
75 | }
76 | }
77 |
78 | String version = version(request);
79 |
80 | String baseUrl = request.getBaseUrl();
81 | final CapabilitiesTransformer3D capsTransformer;
82 | if ("1.0.0".equals(version)) {
83 | capsTransformer = new CapabilitiesTransformer3D.WFS1_0(wfs, catalog);
84 | } else {
85 | if ("1.1.0".equals(version)) {
86 | capsTransformer = new CapabilitiesTransformer3D.WFS1_1(wfs, baseUrl, catalog,
87 | extendedCapabilitiesProviders);
88 | } else if ("2.0.0".equals(version)) {
89 | capsTransformer = new CapabilitiesTransformer3D.WFS2_0(wfs, baseUrl, catalog,
90 | extendedCapabilitiesProviders);
91 | } else {
92 | throw new WFSException(request, "Could not understand version:" + version);
93 | }
94 | }
95 | capsTransformer.setEncoding(Charset.forName(wfs.getGeoServer().getSettings().getCharset()));
96 | return capsTransformer;
97 | }
98 |
99 | public static String version(GetCapabilitiesRequest3D request) {
100 | // do the version negotiation dance
101 | List provided = new ArrayList();
102 | provided.add("1.0.0");
103 | provided.add("1.1.0");
104 |
105 | if (request instanceof GetCapabilitiesRequest3D.WFS20) {
106 | provided.add("2.0.0");
107 | }
108 |
109 | List accepted = request.getAcceptVersions();
110 |
111 | String version = RequestUtils.getVersionPreOws(provided, accepted);
112 | return version;
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/ISOAbstractTransactionElementHandler.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs;
7 |
8 | import org.geoserver.config.GeoServer;
9 |
10 | /**
11 | * Base class for transaction element handlers.
12 | *
13 | * @author Justin Deoliveira, OpenGeo
14 | *
15 | */
16 | public abstract class ISOAbstractTransactionElementHandler implements ISOTransactionElementHandler {
17 |
18 | protected GeoServer geoServer;
19 |
20 | protected ISOAbstractTransactionElementHandler(GeoServer geoServer) {
21 | this.geoServer = geoServer;
22 | }
23 |
24 | protected WFSInfo getInfo() {
25 | return geoServer.getService(WFSInfo.class);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/ISONativeElementHandler.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs;
7 |
8 | import java.util.Map;
9 | import java.util.logging.Logger;
10 |
11 | import javax.xml.namespace.QName;
12 |
13 | import net.opengis.wfs.NativeType;
14 | import net.opengis.wfs.TransactionResponseType;
15 | import net.opengis.wfs.TransactionType;
16 |
17 | import org.eclipse.emf.ecore.EObject;
18 | import org.geoserver.catalog.FeatureTypeInfo;
19 | import org.geotools.data.FeatureStore;
20 | import org.geoserver.wfs.request.Native;
21 | import org.geoserver.wfs.request.TransactionElement;
22 | import org.geoserver.wfs.request.TransactionRequest;
23 | import org.geoserver.wfs.request.TransactionRequest3D;
24 | import org.geoserver.wfs.request.TransactionResponse;
25 |
26 | /**
27 | * Processes native elements as unrecognized ones, and checks wheter they can be
28 | * safely ignored on not.
29 | *
30 | * @author Andrea Aime - TOPP
31 | */
32 | public class ISONativeElementHandler implements ISOTransactionElementHandler {
33 | /**
34 | * logger
35 | */
36 | static Logger LOGGER = org.geotools.util.logging.Logging.getLogger("org.geoserver.wfs");
37 |
38 | /**
39 | * Empty array of QNames
40 | */
41 | protected static final QName[] EMPTY_QNAMES = new QName[0];
42 |
43 | public ISONativeElementHandler() {
44 | }
45 |
46 | public void checkValidity(TransactionElement element, Map featureTypeInfos)
47 | throws WFSTransactionException {
48 |
49 | Native nativ = (Native) element;
50 | if (!nativ.isSafeToIgnore()) {
51 | throw new WFSTransactionException("Native element:" + nativ.getVendorId()
52 | + " unsupported but marked as" + " unsafe to ignore", "InvalidParameterValue");
53 | }
54 | }
55 |
56 | public void execute(TransactionElement element, TransactionRequest3D request, Map featureSources,
57 | TransactionResponse response, ISOTransactionListener listener) throws WFSTransactionException {
58 | // nothing to do, we just ignore if possible
59 | }
60 |
61 | public Class getElementClass() {
62 | return Native.class;
63 | }
64 |
65 | /**
66 | * @return an empty array.
67 | * @see org.geoserver.wfs.ISOTransactionElementHandler#getTypeNames(TransactionElement)
68 | */
69 | public QName[] getTypeNames(TransactionElement element) throws WFSTransactionException {
70 | // we don't handle this
71 | return EMPTY_QNAMES;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/ISOTransactionElementHandler.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs;
7 |
8 | import java.util.Map;
9 |
10 | import javax.xml.namespace.QName;
11 |
12 | import net.opengis.wfs.TransactionResponseType;
13 | import net.opengis.wfs.TransactionType;
14 |
15 | import org.eclipse.emf.ecore.EObject;
16 | import org.geoserver.catalog.FeatureTypeInfo;
17 | import org.geoserver.wfs.request.TransactionElement;
18 | import org.geoserver.wfs.request.TransactionRequest;
19 | import org.geoserver.wfs.request.TransactionRequest3D;
20 | import org.geoserver.wfs.request.TransactionResponse;
21 | import org.geotools.data.FeatureStore;
22 |
23 |
24 | /**
25 | * Transaction elements are an open ended set, both thanks to the Native element
26 | * type, and to the XSD sustitution group concept (xsd inheritance). Element
27 | * handlers know how to process a certain element in a wfs transaction request.
28 | *
29 | * @author Andrea Aime - TOPP
30 | *
31 | */
32 | public interface ISOTransactionElementHandler {
33 | /**
34 | * Returns the element class this handler can proces
35 | */
36 | Class> getElementClass();
37 |
38 | /**
39 | * Returns the qualified names of feature types needed to handle this
40 | * element
41 | */
42 | QName[] getTypeNames(TransactionElement element) throws WFSTransactionException;
43 |
44 | /**
45 | * Checks the element content is valid, throws an exception otherwise
46 | *
47 | * @param element
48 | * the transaction element we're checking
49 | * @param featureTypeInfos
50 | * a map from {@link QName} to {@link FeatureTypeInfo}, where
51 | * the keys contain all the feature type names reported by
52 | * {@link #getTypeNames(EObject)}
53 | */
54 | void checkValidity(TransactionElement element, Map featureTypeInfos) throws WFSTransactionException;
55 |
56 | /**
57 | * Executes the element against the provided feature sources
58 | *
59 | * @param element
60 | * the tranaction element to be executed
61 | * @param request
62 | * the transaction request
63 | * @param featureStores
64 | * map from {@link QName} to {@link FeatureStore}, where the
65 | * keys do contain all the feature type names reported by
66 | * {@link #getTypeNames(EObject)}
67 | * @param response
68 | * the transaction response, that the element will update
69 | * according to the processing done
70 | * @param listener
71 | * a transaction listener that will be called before and after
72 | * each change performed against the data stores
73 | */
74 | @SuppressWarnings("rawtypes")
75 | void execute(TransactionElement element, TransactionRequest3D request, Map featureStores,
76 | TransactionResponse response, ISOTransactionListener listener) throws WFSTransactionException;
77 | }
78 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/ISOTransactionEvent.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs;
7 |
8 | import javax.xml.namespace.QName;
9 |
10 | import org.geoserver.wfs.request.TransactionRequest;
11 | import org.geoserver.wfs.request.TransactionRequest3D;
12 | import org.geotools.data.Transaction;
13 | import org.geotools.data.simple.SimpleFeatureCollection;
14 |
15 | import net.opengis.wfs.DeleteElementType;
16 | import net.opengis.wfs.InsertElementType;
17 | import net.opengis.wfs.TransactionType;
18 | import net.opengis.wfs.UpdateElementType;
19 |
20 |
21 | /**
22 | * Event carrying information about a change that happened/that is about to
23 | * occur.
24 | *
25 | * The feature collection may be an in-memory one, or may be based on a
26 | * real data store with a filter.
27 | *
28 | *
29 | * Note that care should be taken when relying on feature identifiers from a
30 | * {@link TransactionEventType#POST_INSERT} event. Depending on the type of store those identifiers
31 | * may be reliable. Essentially they can only be relied upon in the case of a spatial dbms (such
32 | * as PostGIS) is being used.
33 | *
34 | */
35 | public class ISOTransactionEvent {
36 | private TransactionEventType type;
37 | private SimpleFeatureCollection affectedFeatures;
38 | private QName layerName;
39 | private Object source;
40 | private final TransactionRequest3D request;
41 |
42 | public ISOTransactionEvent(TransactionEventType type, TransactionRequest3D request, QName layerName,
43 | SimpleFeatureCollection affectedFeatures) {
44 | this( type, request, layerName, affectedFeatures, null );
45 | }
46 |
47 | public ISOTransactionEvent(TransactionEventType type, TransactionRequest3D request, QName layerName,
48 | SimpleFeatureCollection affectedFeatures, Object source) {
49 | this.type = type;
50 | this.request = request;
51 | this.layerName = layerName;
52 | this.affectedFeatures = affectedFeatures;
53 | this.source = source;
54 | }
55 |
56 | /**
57 | * The type of change occurring
58 | */
59 | public TransactionEventType getType() {
60 | return type;
61 | }
62 |
63 | /**
64 | * A collection of the features that are being manipulated. Accessible and usable only
65 | * when the event is being thrown, if you store the event and try to access the collection later
66 | * there is no guarantee it will still be usable.
67 | */
68 | public SimpleFeatureCollection getAffectedFeatures() {
69 | return affectedFeatures;
70 | }
71 |
72 | /**
73 | * The name of the layer / feature type that this transaction effects.
74 | */
75 | public QName getLayerName() {
76 | return layerName;
77 | }
78 |
79 | /**
80 | * Sets the source of the transction.
81 | */
82 | public void setSource(Object source) {
83 | this.source = source;
84 | }
85 |
86 | /**
87 | * Returns the source of the transaction.
88 | *
89 | * One of:
90 | *
91 | *
{@link InsertElementType}
92 | *
{@link UpdateElementType}
93 | *
{@link DeleteElementType}
94 | *
95 | *
96 | */
97 | public Object getSource() {
98 | return source;
99 | }
100 |
101 | public TransactionType getRequest() {
102 | return TransactionRequest3D.WFS11.unadapt(request);
103 | }
104 |
105 | /**
106 | * Returns the current GeoTools Data {@link Transaction} associated with this event. May be {@code null}
107 | * for post-commit events.
108 | */
109 | public Transaction getTransaction() {
110 | return request.getTransaction();
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/ISOTransactionListener.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs;
7 |
8 |
9 | /**
10 | * Implemented by classes needing to listen to datastore change events during a
11 | * WFS Transaction
12 | */
13 | public interface ISOTransactionListener {
14 | /**
15 | * Check/alter feature collections and filters before a change hits the
16 | * datastores
17 | *
18 | * Note that caution should be exercised when relying on feature identifiers from a
19 | * {@link TransactionEventType#POST_INSERT} event. Depending on the type of store those identifiers
20 | * may be reliable. Essentially they can only be relied upon in the case of a spatial dbms (such
21 | * as PostGIS) is being used.
22 | *
23 | */
24 | void dataStoreChange(ISOTransactionEvent event) throws WFSException;
25 | }
26 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/WFSDescribeFeatureTypeOutputFormat_ISO.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs;
7 |
8 | import java.io.IOException;
9 | import java.io.OutputStream;
10 | import java.util.Set;
11 |
12 | import org.geoserver.catalog.FeatureTypeInfo;
13 | import org.geoserver.config.GeoServer;
14 | import org.geoserver.ows.SOAPAwareResponse;
15 | import org.geoserver.platform.Operation;
16 | import org.geoserver.platform.ServiceException;
17 | import org.geoserver.wfs.response.WFSResponse;
18 |
19 | import net.opengis.wfs.FeatureCollectionType;
20 |
21 |
22 | /**
23 | * Base class for a response to a WFS DescribeFeatureType operation.
24 | *
25 | * The result of a DescribeFeatureType operation is an array of
26 | * {@link FeatureTypeInfo}. Subclasses are responsible for serializing these
27 | * instances. See {@link #write(FeatureCollectionType, OutputStream, Operation)}.
28 | *
29 | *
30 | * Subclasses also need declare the mime-type in which the format is encoded.
31 | *
32 | * @author Justin Deoliveira, The Open Planning Project
33 | *
34 | */
35 | public abstract class WFSDescribeFeatureTypeOutputFormat_ISO extends WFSResponse implements SOAPAwareResponse {
36 | /**
37 | * Constructor which sets the outputFormat.
38 | *
39 | * @param outputFormat The well-known name of the format, not null
40 | */
41 | public WFSDescribeFeatureTypeOutputFormat_ISO(GeoServer gs, String outputFormat) {
42 | super(gs, FeatureTypeInfo[].class, outputFormat);
43 | }
44 |
45 | /**
46 | * Constructor which sets multiple outputFormats.
47 | *
48 | * @param outputFormat The well-known name of the format, not null
49 | */
50 | public WFSDescribeFeatureTypeOutputFormat_ISO(GeoServer gs, Set outputFormats) {
51 | super(gs, FeatureTypeInfo[].class, outputFormats);
52 | }
53 |
54 | /**
55 | * Ensures that the operation being executed is a DescribeFeatureType operation.
56 | *
57 | * This method may be extended to add additional checks, it should not be
58 | * overriden.
59 | *
60 | */
61 | public boolean canHandle(Operation operation) {
62 | if ("DescribeFeatureType".equalsIgnoreCase(operation.getId())) {
63 | return true;
64 | }
65 |
66 | return false;
67 | }
68 |
69 | public String getBodyType() {
70 | return "xsd:base64";
71 | }
72 |
73 | /**
74 | * Calls through to {@link #write(FeatureTypeInfo[], OutputStream, Operation)}.
75 | */
76 | public final void write(Object value, OutputStream output, Operation operation)
77 | throws IOException, ServiceException {
78 |
79 | write((FeatureTypeInfo[]) value, output, operation);
80 | }
81 |
82 | /**
83 | * Serializes the collection of feature type metadata objects in the format
84 | * declared.
85 | *
86 | * @param featureTypeInfos The feature type metadata objects to serialize
87 | * @param output The output stream to serialize to.
88 | * @param getFeature The DescribeFeatureType operation descriptor.
89 | */
90 | protected abstract void write(FeatureTypeInfo[] featureTypeInfos, OutputStream output,
91 | Operation describeFeatureType) throws IOException;
92 | }
93 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/WFSFactoryExtension_ISO.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs;
7 |
8 | import org.geoserver.config.ServiceFactoryExtension;
9 |
10 | public class WFSFactoryExtension_ISO extends ServiceFactoryExtension {
11 |
12 | protected WFSFactoryExtension_ISO() {
13 | super(WFSInfo.class);
14 | }
15 |
16 | public T create(Class clazz) {
17 | return (T) new WFSInfoImpl_ISO();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/WFSLoader_ISO.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs;
7 |
8 | import java.util.Map;
9 |
10 | import org.geoserver.config.GeoServer;
11 | import org.geoserver.config.util.LegacyServiceLoader;
12 | import org.geoserver.config.util.LegacyServicesReader;
13 | import org.geoserver.wfs.GMLInfo.SrsNameStyle;
14 | import org.geotools.util.Version;
15 |
16 | public class WFSLoader_ISO extends LegacyServiceLoader {
17 |
18 | public Class getServiceClass() {
19 | return WFSInfo.class;
20 | }
21 |
22 | public WFSInfo load(LegacyServicesReader reader, GeoServer geoServer)
23 | throws Exception {
24 |
25 | WFSInfoImpl_ISO wfs = new WFSInfoImpl_ISO();
26 | wfs.setId( "wfs-3d" );
27 |
28 | Map properties = reader.wfs();
29 | readCommon( wfs, properties, geoServer );
30 |
31 | //service level
32 | wfs.setServiceLevel( WFSInfo.ServiceLevel.get( (Integer) properties.get( "serviceLevel") ) );
33 |
34 | //max features
35 | Integer maxFeatures = (Integer) reader.global().get( "maxFeatures" );
36 | if ( maxFeatures == null ) {
37 | maxFeatures = Integer.MAX_VALUE;
38 | }
39 | wfs.setMaxFeatures( maxFeatures );
40 |
41 | Boolean featureBounding = (Boolean) properties.get( "featureBounding");
42 | if ( featureBounding != null ) {
43 | wfs.setFeatureBounding( featureBounding );
44 | }
45 |
46 | Boolean hitsIgnoreMaxFeatures = (Boolean) properties.get( "hitsIgnoreMaxFeatures");
47 | if (hitsIgnoreMaxFeatures != null) {
48 | wfs.setHitsIgnoreMaxFeatures( hitsIgnoreMaxFeatures );
49 | }
50 |
51 | //gml2
52 | GMLInfo gml = new GMLInfoImpl();
53 | gml.setOverrideGMLAttributes(true);
54 |
55 | Boolean srsXmlStyle = (Boolean) properties.get( "srsXmlStyle" );
56 | if( srsXmlStyle ) {
57 | gml.setSrsNameStyle( SrsNameStyle.XML );
58 | }
59 | else {
60 | gml.setSrsNameStyle( SrsNameStyle.NORMAL );
61 | }
62 | wfs.getGML().put( WFSInfo.Version.V_10 , gml );
63 |
64 | //gml3
65 | gml = new GMLInfoImpl();
66 | gml.setSrsNameStyle(SrsNameStyle.URN);
67 | gml.setOverrideGMLAttributes(false);
68 | wfs.getGML().put( WFSInfo.Version.V_11 , gml );
69 |
70 | //gml32
71 | gml = new GMLInfoImpl();
72 | gml.setSrsNameStyle(SrsNameStyle.URN2);
73 | gml.setOverrideGMLAttributes(false);
74 | wfs.getGML().put( WFSInfo.Version.V_20 , gml );
75 |
76 | wfs.getVersions().add( new Version( "1.0.0" ) );
77 | wfs.getVersions().add( new Version( "1.1.0" ) );
78 | wfs.getVersions().add( new Version( "2.0.0" ) );
79 |
80 | return wfs;
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/WFSReprojectionUtil_ISO.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs;
7 |
8 | import org.geotools.filter.ISOFilterFactoryImpl;
9 | import org.geotools.filter.spatial.DefaultCRSFilterVisitor;
10 | import org.geotools.filter.spatial.ISOReprojectingFilterVisitor;
11 | import org.geotools.filter.spatial.ReprojectingFilterVisitor;
12 | import org.geotools.gml2.iso.bindings.GML2EncodingUtils;
13 | import org.geotools.referencing.CRS;
14 | import org.opengis.feature.simple.SimpleFeatureType;
15 | import org.opengis.feature.type.FeatureType;
16 | import org.opengis.filter.Filter;
17 | import org.opengis.filter.FilterFactory2;
18 | import org.opengis.referencing.crs.CoordinateReferenceSystem;
19 |
20 | /**
21 | * Utility class used to handle common WFS reprojection issues
22 | *
23 | * @author Andrea Aime, TOPP
24 | *
25 | */
26 | class WFSReprojectionUtil_ISO {
27 |
28 | static FilterFactory2 ff = new ISOFilterFactoryImpl();
29 |
30 | /**
31 | * Returns the declared CRS given the native CRS and the request WFS version
32 | *
33 | * @param nativeCRS
34 | * @param wfsVersion
35 | *
36 | */
37 | public static CoordinateReferenceSystem getDeclaredCrs(CoordinateReferenceSystem nativeCRS,
38 | String wfsVersion) {
39 | try {
40 | if(nativeCRS == null)
41 | return null;
42 |
43 | if (wfsVersion.equals("1.0.0")) {
44 | return nativeCRS;
45 | } else {
46 | String code = GML2EncodingUtils.epsgCode(nativeCRS);
47 | //it's possible that we can't do the CRS -> code -> CRS conversion...so we'll just return what we have
48 | if (code == null) return nativeCRS;
49 | return CRS.decode("urn:x-ogc:def:crs:EPSG:6.11.2:" + code);
50 | }
51 | } catch (Exception e) {
52 | throw new WFSException("We have had issues trying to flip axis of " + nativeCRS, e);
53 | }
54 | }
55 |
56 | /**
57 | * Returns the declared CRS given a feature type and the request WFS version
58 | *
59 | * @param nativeCRS
60 | * @param wfsVersion
61 | *
62 | */
63 | public static CoordinateReferenceSystem getDeclaredCrs(FeatureType schema, String wfsVersion) {
64 | if (schema == null)
65 | return null;
66 |
67 | CoordinateReferenceSystem crs = (schema.getGeometryDescriptor() != null) ? schema
68 | .getGeometryDescriptor().getCoordinateReferenceSystem() : null;
69 |
70 | return getDeclaredCrs(crs, wfsVersion);
71 | }
72 |
73 | /**
74 | * Applies a default CRS to all geometric filter elements that do not
75 | * already have one
76 | *
77 | * @param nativeCRS
78 | * @param wfsVersion
79 | *
80 | */
81 | public static Filter applyDefaultCRS(Filter filter, CoordinateReferenceSystem defaultCRS) {
82 | DefaultCRSFilterVisitor defaultVisitor = new DefaultCRSFilterVisitor(ff, defaultCRS);
83 | return (Filter) filter.accept(defaultVisitor, null);
84 | }
85 |
86 | /**
87 | * Reprojects all geometric filter elements to the native CRS of the
88 | * provided schema
89 | *
90 | * @param filter
91 | * @param schema
92 | *
93 | */
94 | public static Filter reprojectFilter(Filter filter, FeatureType schema) {
95 | ISOReprojectingFilterVisitor visitor = new ISOReprojectingFilterVisitor(ff, schema);
96 | return (Filter) filter.accept(visitor, null);
97 | }
98 |
99 | /**
100 | * Convenience method, same as calling {@link #applyDefaultCRS} and then
101 | * {@link #reprojectFilter(Filter, SimpleFeatureType)} in a row
102 | *
103 | * @param filter
104 | * @param schema
105 | * @param defaultCRS
106 | *
107 | */
108 | public static Filter normalizeFilterCRS(Filter filter, FeatureType schema,
109 | CoordinateReferenceSystem defaultCRS) {
110 | Filter defaulted = applyDefaultCRS(filter, defaultCRS);
111 | return reprojectFilter(defaulted, schema);
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/WFSXStreamLoader_ISO.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs;
7 |
8 | import java.util.ArrayList;
9 | import java.util.HashMap;
10 |
11 | import org.geoserver.config.GeoServer;
12 | import org.geoserver.config.util.XStreamPersister;
13 | import org.geoserver.config.util.XStreamServiceLoader;
14 | import org.geoserver.platform.GeoServerResourceLoader;
15 | import org.geoserver.wfs.GMLInfo.SrsNameStyle;
16 |
17 | import com.thoughtworks.xstream.XStream;
18 |
19 | /**
20 | * Loads and persist the {@link WFSInfo} object to and from xstream
21 | * persistence.
22 | *
23 | * @author Justin Deoliveira, The Open Planning Project
24 | *
25 | */
26 | public class WFSXStreamLoader_ISO extends XStreamServiceLoader {
27 |
28 | public WFSXStreamLoader_ISO(GeoServerResourceLoader resourceLoader) {
29 | super(resourceLoader, "wfs3d");
30 | }
31 |
32 | @Override
33 | public void initXStreamPersister(XStreamPersister xp, GeoServer gs) {
34 | super.initXStreamPersister(xp, gs);
35 | initXStreamPersister(xp);
36 | }
37 |
38 | /**
39 | * Sets up aliases and allowed types for the xstream persister
40 | * @param xs
41 | */
42 | public static void initXStreamPersister(XStreamPersister xp) {
43 | XStream xs = xp.getXStream();
44 | xs.alias( "wfs3d", WFSInfo.class, WFSInfoImpl_ISO.class );
45 | xs.alias( "version", WFSInfo.Version.class);
46 | xs.alias( "gml", GMLInfo.class, GMLInfoImpl.class );
47 | // modify the WFSSettingsResource when
48 | xs.allowTypes(new Class[] { WFSInfo.Version.class, GMLInfo.class, GMLInfoImpl.class });
49 | }
50 |
51 | protected WFSInfo createServiceFromScratch(GeoServer gs) {
52 | WFSInfoImpl_ISO wfs = new WFSInfoImpl_ISO();
53 | wfs.setName("WFS");
54 | wfs.setMaxFeatures(1000000);
55 |
56 | //gml2
57 | addGml(wfs, WFSInfo.Version.V_10, GMLInfo.SrsNameStyle.XML, true);
58 |
59 | //gml3
60 | addGml(wfs, WFSInfo.Version.V_11, GMLInfo.SrsNameStyle.URN, false);
61 |
62 | //gml3.2
63 | addGml(wfs, WFSInfo.Version.V_20, SrsNameStyle.URN2, false);
64 | return wfs;
65 | }
66 |
67 | public Class getServiceClass() {
68 | return WFSInfo.class;
69 | }
70 |
71 | @Override
72 | protected WFSInfo initialize(WFSInfo service) {
73 | super.initialize(service);
74 | if ( service.getVersions().isEmpty() ) {
75 | service.getVersions().add(WFSInfo.Version.V_10.getVersion());
76 | service.getVersions().add(WFSInfo.Version.V_11.getVersion());
77 | }
78 |
79 | if (!service.getVersions().contains(WFSInfo.Version.V_20.getVersion())) {
80 | service.getVersions().add(WFSInfo.Version.V_20.getVersion());
81 | }
82 |
83 | //set the defaults for GMLInfo if they are not set
84 | if(service.getGML() == null) {
85 | ((WFSInfoImpl_ISO) service).setGML(new HashMap());
86 | }
87 | GMLInfo gml = service.getGML().get(WFSInfo.Version.V_10);
88 | if(gml == null) {
89 | addGml(service, WFSInfo.Version.V_10, SrsNameStyle.URL, false);
90 | } else if (gml.getOverrideGMLAttributes() == null) {
91 | gml.setOverrideGMLAttributes(true);
92 | }
93 | gml = service.getGML().get(WFSInfo.Version.V_11);
94 | if(gml == null) {
95 | addGml(service, WFSInfo.Version.V_11, SrsNameStyle.URN, false);
96 | } else if (gml.getOverrideGMLAttributes() == null) {
97 | gml.setOverrideGMLAttributes(false);
98 | }
99 | gml = service.getGML().get(WFSInfo.Version.V_20);
100 | if (gml == null) {
101 | addGml(service, WFSInfo.Version.V_20, SrsNameStyle.URN2, false);
102 | }
103 | if (service.getSRS() == null) {
104 | ((WFSInfoImpl_ISO) service).setSRS(new ArrayList());
105 | }
106 | return service;
107 | }
108 |
109 | void addGml(WFSInfo info, WFSInfo.Version ver, SrsNameStyle srs, boolean overrideGmlAtts) {
110 | GMLInfo gml = new GMLInfoImpl();
111 | gml.setSrsNameStyle(srs);
112 | gml.setOverrideGMLAttributes(overrideGmlAtts);
113 | info.getGML().put(ver, gml);
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/AcceptFormatsKvpParser.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import net.opengis.ows10.AcceptFormatsType;
9 | import net.opengis.ows10.Ows10Factory;
10 |
11 | import org.eclipse.emf.ecore.EObject;
12 | import org.geoserver.wfs.WFSInfo;
13 |
14 |
15 | /**
16 | * Parses a kvp of the form "acceptFormats=format1,format2,...,formatN" into
17 | * an instance of {@link net.opengis.ows.v1_0_0.AcceptFormatsType}.
18 | *
19 | * @author Justin Deoliveira, The Open Planning Project
20 | *
21 | */
22 | public class AcceptFormatsKvpParser extends org.geoserver.ows.kvp.AcceptFormatsKvpParser {
23 |
24 | public AcceptFormatsKvpParser() {
25 | super(AcceptFormatsType.class);
26 | setVersion(WFSInfo.Version.V_11.getVersion());
27 | }
28 |
29 | protected EObject createObject() {
30 | return Ows10Factory.eINSTANCE.createAcceptFormatsType();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/AcceptVersionsKvpParser.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import net.opengis.ows10.AcceptVersionsType;
9 | import net.opengis.ows10.Ows10Factory;
10 |
11 | import org.eclipse.emf.ecore.EObject;
12 | import org.geoserver.wfs.WFSInfo;
13 |
14 |
15 | /**
16 | * Parses a kvp of the form "acceptVersions=version1,version2,...,versionN" into
17 | * an instance of {@link net.opengis.ows.v1_0_0.AcceptVersionsType}.
18 | *
19 | * @author Justin Deoliveira, The Open Planning Project
20 | *
21 | */
22 | public class AcceptVersionsKvpParser extends org.geoserver.ows.kvp.AcceptVersionsKvpParser {
23 |
24 | public AcceptVersionsKvpParser() {
25 | super(AcceptVersionsType.class);
26 | setVersion(WFSInfo.Version.V_11.getVersion());
27 | }
28 |
29 | protected EObject createObject() {
30 | return Ows10Factory.eINSTANCE.createAcceptVersionsType();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/BBoxKvpParser.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import java.util.List;
9 |
10 | import org.geoserver.ows.KvpParser;
11 | import org.geoserver.ows.util.KvpUtils;
12 | import org.geoserver.platform.ServiceException;
13 | import org.geoserver.wfs.WFSException;
14 | import org.geotools.geometry.jts.ReferencedEnvelope;
15 | import org.geotools.geometry.jts.ReferencedEnvelope3D;
16 | import org.geotools.referencing.CRS;
17 | import org.opengis.referencing.crs.CoordinateReferenceSystem;
18 | import org.opengis.referencing.crs.SingleCRS;
19 |
20 | import com.vividsolutions.jts.geom.Envelope;
21 |
22 | /**
23 | *
24 | * @author Niels Charlier : added 3D BBOX support
25 | *
26 | */
27 | public class BBoxKvpParser extends KvpParser {
28 | public BBoxKvpParser() {
29 | super("bbox", Envelope.class);
30 | }
31 |
32 | public Object parse(String value) throws Exception {
33 | List unparsed = KvpUtils.readFlat(value, KvpUtils.INNER_DELIMETER);
34 |
35 | // check to make sure that the bounding box has 4 coordinates
36 | if (unparsed.size() < 4) {
37 | throw new IllegalArgumentException("Requested bounding box contains wrong"
38 | + "number of coordinates (should have " + "4): " + unparsed.size());
39 | }
40 |
41 | int countco = 4;
42 | if (unparsed.size() == 6 || unparsed.size() == 7) { // 3d-coordinates
43 | countco = 6;
44 | }
45 |
46 | //if it does, store them in an array of doubles
47 | double[] bbox = new double[countco];
48 |
49 | for (int i = 0; i < countco; i++) {
50 | try {
51 | bbox[i] = Double.parseDouble((String) unparsed.get(i));
52 | } catch (NumberFormatException e) {
53 | throw new IllegalArgumentException("Bounding box coordinate " + i
54 | + " is not parsable:" + unparsed.get(i));
55 | }
56 | }
57 |
58 | //ensure the values are sane
59 | double minx = bbox[0];
60 | double miny = bbox[1];
61 | double minz=0, maxx=0, maxy=0, maxz=0;
62 | if (countco == 6) {
63 | minz = bbox[2];
64 | maxx = bbox[3];
65 | maxy = bbox[4];
66 | maxz = bbox[5];
67 | } else {
68 | maxx = bbox[2];
69 | maxy = bbox[3];
70 | }
71 |
72 | if (minx > maxx) {
73 | throw new ServiceException("illegal bbox, minX: " + minx + " is "
74 | + "greater than maxX: " + maxx);
75 | }
76 |
77 | if (miny > maxy) {
78 | throw new ServiceException("illegal bbox, minY: " + miny + " is "
79 | + "greater than maxY: " + maxy);
80 | }
81 |
82 | if (minz > maxz) {
83 | throw new ServiceException("illegal bbox, minZ: " + minz + " is "
84 | + "greater than maxZ: " + maxz);
85 | }
86 |
87 | // check for srs
88 | String srs = null;
89 | if (unparsed.size() > countco) {
90 | // merge back the CRS definition, in case it is an AUTO one
91 | StringBuilder sb = new StringBuilder();
92 | for (int i = countco; i < unparsed.size(); i++) {
93 | sb.append(unparsed.get(i));
94 | if(i < (unparsed.size() - 1)) {
95 | sb.append(",");
96 | }
97 | }
98 | srs = sb.toString();
99 | }
100 |
101 | if (countco == 6) {
102 | CoordinateReferenceSystem crs = srs != null ? CRS.decode(srs) : null;
103 | return new ReferencedEnvelope3D(minx, maxx, miny, maxy, minz, maxz, crs);
104 | } else {
105 | CoordinateReferenceSystem crs = srs != null ? CRS.decode(srs) : null;
106 | if(crs == null || crs.getCoordinateSystem().getDimension() == 2) {
107 | return new SRSEnvelope(minx, maxx, miny, maxy, srs);
108 | } else if(crs.getCoordinateSystem().getDimension() == 3) {
109 | return new ReferencedEnvelope3D(minx, maxx, miny, maxy, -Double.MAX_VALUE, Double.MAX_VALUE, crs);
110 | } else {
111 | throw new WFSException("Unexpected BBOX, can only handle 2D or 3D ones", "bbox", "InvalidParameterValue");
112 | }
113 |
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/DescribeFeatureTypeKvpRequestReader.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 | import java.util.Map;
11 |
12 | import javax.xml.XMLConstants;
13 | import javax.xml.namespace.QName;
14 |
15 | import net.opengis.wfs.DescribeFeatureTypeType;
16 | import net.opengis.wfs.WfsFactory;
17 |
18 | import org.eclipse.emf.ecore.EFactory;
19 | import org.geoserver.catalog.Catalog;
20 | import org.geoserver.wfs.WFSInfo;
21 | import org.geoserver.wfs.request.DescribeFeatureTypeRequest;
22 | import org.xml.sax.helpers.NamespaceSupport;
23 |
24 |
25 | public class DescribeFeatureTypeKvpRequestReader extends WFSKvpRequestReader {
26 |
27 | private final Catalog catalog;
28 |
29 | public DescribeFeatureTypeKvpRequestReader(final Catalog catalog) {
30 | super(DescribeFeatureTypeType.class, WfsFactory.eINSTANCE);
31 | this.catalog = catalog;
32 | }
33 | public DescribeFeatureTypeKvpRequestReader(final Catalog catalog, Class requestBean, EFactory factory) {
34 | super(requestBean, factory);
35 | this.catalog = catalog;
36 | }
37 |
38 | @SuppressWarnings("unchecked")
39 | public Object read(Object request, Map kvp, Map rawKvp) throws Exception {
40 | //let super do its thing
41 | request = super.read(request, kvp, rawKvp);
42 |
43 | //do an additional check for outputFormat, because the default
44 | // in wfs 1.1 is not the default for wfs 1.0
45 | DescribeFeatureTypeRequest req = DescribeFeatureTypeRequest.adapt(request);
46 |
47 | if (!req.isSetOutputFormat()) {
48 | switch(WFSInfo.Version.negotiate(req.getVersion())) {
49 | case V_10:
50 | req.setOutputFormat("XMLSCHEMA"); break;
51 | case V_11:
52 | req.setOutputFormat("text/xml; subtype=gml/3.1.1"); break;
53 | case V_20:
54 | default:
55 | req.setOutputFormat("text/xml; subtype=gml/3.2");
56 | }
57 | }
58 |
59 | // did the user supply alternate namespace prefixes?
60 | NamespaceSupport namespaces = null;
61 | if (kvp.containsKey("NAMESPACE")) {
62 | if (kvp.get("NAMESPACE") instanceof NamespaceSupport) {
63 | namespaces = (NamespaceSupport) kvp.get("namespace");
64 | } else {
65 | LOGGER.warning("There's a namespace parameter but it seems it wasn't parsed to a "
66 | + NamespaceSupport.class.getName() + ": " + kvp.get("namespace"));
67 | }
68 | }
69 | if (namespaces != null) {
70 | List typeNames = req.getTypeNames();
71 | List newList = new ArrayList(typeNames.size());
72 | for(QName name : typeNames){
73 | String localPart = name.getLocalPart();
74 | String prefix = name.getPrefix();
75 | String namespaceURI = name.getNamespaceURI();
76 | if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
77 | //no prefix specified, did the request specify a default namespace?
78 | namespaceURI = namespaces.getURI(XMLConstants.DEFAULT_NS_PREFIX);
79 | } else if (XMLConstants.NULL_NS_URI.equals(namespaceURI)) {
80 | //prefix specified, does a namespace mapping were declared for it?
81 | if(namespaces.getURI(prefix) != null){
82 | namespaceURI = namespaces.getURI(prefix);
83 | }
84 | }
85 | if(catalog.getNamespaceByURI(namespaceURI) != null){
86 | prefix = catalog.getNamespaceByURI(namespaceURI).getPrefix();
87 | }
88 | newList.add(new QName(namespaceURI, localPart, prefix));
89 | }
90 | req.setTypeNames(newList);
91 | }
92 | return request;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/Filter_1_0_0_KvpParser.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import org.geoserver.config.GeoServer;
9 | import org.geotools.xml.Configuration;
10 |
11 | /**
12 | * Parses a {@code FILTER} parameter assuming the filters sent are encoded as
13 | * per the OGC Filter Encoding v1.0.0 specification.
14 | *
15 | * This kvp parser is meant to be configured in the spring context to parse
16 | * filters when a GetFeature request is sent conforming to the WFS 1.0 spec.
17 | *
18 | *
19 | * @author Gabriel Roldan
20 | */
21 | public class Filter_1_0_0_KvpParser extends FilterKvpParser {
22 |
23 | public Filter_1_0_0_KvpParser(GeoServer geoServer) {
24 | super(geoServer);
25 | }
26 |
27 | /**
28 | * Provides the 1.0 filter configuration for the superclass to perform the
29 | * parameter parsing.
30 | */
31 | @Override
32 | protected Configuration getParserConfiguration() {
33 | return new org.geotools.filter.v1_0.OGCConfiguration();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/Filter_1_1_0_KvpParser.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import org.geoserver.config.GeoServer;
9 | import org.geotools.xml.Configuration;
10 |
11 | /**
12 | * Parses a {@code FILTER} parameter assuming the filters sent are encoded as
13 | * per the OGC Filter Encoding v1.0.0 specification.
14 | *
15 | * This kvp parser is meant to be configured in the spring context to parse
16 | * filters when a GetFeature request is sent conforming to the WFS 1.1 spec.
17 | *
18 | *
19 | * @author Gabriel Roldan
20 | */
21 | public class Filter_1_1_0_KvpParser extends FilterKvpParser {
22 |
23 | public Filter_1_1_0_KvpParser(GeoServer geoServer) {
24 | super(geoServer);
25 | }
26 |
27 | @Override
28 | protected Configuration getParserConfiguration() {
29 | return new org.geotools.filter.v1_1.OGCConfiguration();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/Filter_2_0_0_KvpParser.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import org.geoserver.config.GeoServer;
9 | import org.geotools.xml.Configuration;
10 |
11 | /**
12 | * Parses a {@code FILTER} parameter assuming the filters sent are encoded as
13 | * per the OGC Filter Encoding v2.0.0 specification.
14 | *
15 | * This kvp parser is meant to be configured in the spring context to parse
16 | * filters when a GetFeature request is sent conforming to the WFS 2.0 spec.
17 | *
18 | *
19 | * @author Justin Deoliveira
20 | */
21 | public class Filter_2_0_0_KvpParser extends FilterKvpParser {
22 |
23 | public Filter_2_0_0_KvpParser(GeoServer geoServer) {
24 | super(geoServer);
25 | }
26 |
27 | @Override
28 | protected Configuration getParserConfiguration() {
29 | return new org.geotools.filter.v2_0.FESConfiguration();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/GetCapabilitiesKvpRequestReader.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import java.util.Map;
9 |
10 | import net.opengis.wfs.GetCapabilitiesType;
11 | import net.opengis.wfs.WfsFactory;
12 |
13 | import org.eclipse.emf.ecore.EFactory;
14 | import org.geoserver.wfs.request.GetCapabilitiesRequest3D;
15 |
16 | public class GetCapabilitiesKvpRequestReader extends WFSKvpRequestReader {
17 |
18 | public GetCapabilitiesKvpRequestReader() {
19 | this(GetCapabilitiesType.class, WfsFactory.eINSTANCE);
20 | }
21 |
22 | public GetCapabilitiesKvpRequestReader(Class requestBean, EFactory factory) {
23 | super(requestBean, factory);
24 | }
25 |
26 | @Override
27 | public Object read(Object request, Map kvp, Map rawKvp) throws Exception {
28 | request = super.read(request, kvp, rawKvp);
29 |
30 | //set the version attribute on the request
31 | if (kvp.containsKey("version")) {
32 | GetCapabilitiesRequest3D req = GetCapabilitiesRequest3D.adapt(request);
33 | //TODO: put this check in a cite hack
34 | if (req.getAcceptVersions() == null || req.getAcceptVersions().isEmpty()) {
35 | req.setAcceptVersions((String)kvp.get("version"));
36 | }
37 | }
38 |
39 | return request;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/QNameKvpParser.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import javax.xml.namespace.QName;
9 |
10 | import org.geoserver.catalog.Catalog;
11 | import org.geoserver.catalog.NamespaceInfo;
12 | import org.geoserver.ows.FlatKvpParser;
13 | import org.geoserver.wfs.WFSException;
14 |
15 |
16 | /**
17 | * Abstract kvp parser for parsing qualified names of the form "([prefix:]local)+".
18 | *
19 | * This parser will parse strings of the above format into a list of
20 | * {@link javax.xml.namespace.QName}
21 | *
22 | * @author Justin Deoliveira, The Open Planning Project
23 | *
24 | */
25 | public class QNameKvpParser extends FlatKvpParser {
26 | /**
27 | * catalog for namespace lookups.
28 | */
29 | protected Catalog catalog;
30 |
31 | private final boolean strict;
32 |
33 | public QNameKvpParser(String key, Catalog catalog) {
34 | this(key, catalog, true);
35 | }
36 |
37 | /**
38 | *
39 | * @param key
40 | * the key this kvp parser parses the value for
41 | * @param catalog
42 | * the catalog where to check if the namespace given by the qualified name prefix
43 | * exists
44 | * @param strict
45 | * if {@code true} and the qname being parsed contains a namespace prefix that does
46 | * not match a namespace from {@code catalog}, an exception will be thrown, otherwise a {@code QName}
47 | * with prefix and localName but without namespace will be returned.
48 | */
49 | protected QNameKvpParser(String key, Catalog catalog, boolean strict) {
50 | super(key, QName.class);
51 | this.catalog = catalog;
52 | this.strict = strict;
53 | }
54 |
55 | /**
56 | * Parses the token representing a type name, ( :, or )
57 | * into a {@link QName }.
58 | *
59 | * If the latter form is supplied the QName is given the default namespace
60 | * as specified in the catalog.
61 | *
62 | */
63 | protected Object parseToken(String token) throws Exception {
64 | int i = token.indexOf(':');
65 |
66 | if (i != -1) {
67 | String prefix = token.substring(0, i);
68 | String local = token.substring(i + 1);
69 |
70 | String uri = null;
71 | if(prefix != null && !"".equals(prefix)) {
72 | final NamespaceInfo namespace = catalog.getNamespaceByPrefix(prefix);
73 | if(strict && namespace == null){
74 | throw new WFSException("Unknown namespace [" + prefix + "]");
75 | }
76 | uri = namespace == null? null : namespace.getURI();
77 | }
78 |
79 | return new QName(uri, local, prefix);
80 | } else {
81 | /*
82 | String uri = catalog.getDefaultNamespace().getURI();
83 | String prefix = catalog.getDefaultNamespace().getPrefix();
84 | String local = token;
85 |
86 | return new QName(uri, local, prefix);
87 | */
88 | return new QName(token);
89 | }
90 | }
91 |
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/QNameNestedKvpParser.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import javax.xml.namespace.QName;
9 |
10 | import org.geoserver.catalog.Catalog;
11 | import org.geoserver.ows.NestedKvpParser;
12 |
13 | public class QNameNestedKvpParser extends NestedKvpParser {
14 |
15 | QNameKvpParser delegate;
16 |
17 | public QNameNestedKvpParser(String key, Catalog catalog) {
18 | super(key, QName.class);
19 | delegate = new QNameKvpParser(key, catalog);
20 | }
21 |
22 | @Override
23 | protected Object parseToken(String token) throws Exception {
24 | return delegate.parseToken(token);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/ReleaseLockKvpRequestReader.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import java.util.Map;
9 |
10 | import org.geoserver.ows.KvpRequestReader;
11 |
12 |
13 | public class ReleaseLockKvpRequestReader extends KvpRequestReader {
14 | public ReleaseLockKvpRequestReader() {
15 | super(String.class);
16 | }
17 |
18 | public Object createRequest() throws Exception {
19 | return new String();
20 | }
21 |
22 | public Object read(Object request, Map kvp, Map rawKvp) throws Exception {
23 | return kvp.get("lockId");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/gs-wfs-iso/src/main/java/org/geoserver/wfs/kvp/ResultTypeKvpParser.java:
--------------------------------------------------------------------------------
1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved
2 | * (c) 2001 - 2013 OpenPlans
3 | * This code is licensed under the GPL 2.0 license, available at the root
4 | * application directory.
5 | */
6 | package org.geoserver.wfs.kvp;
7 |
8 | import net.opengis.wfs.ResultTypeType;
9 |
10 | import org.geoserver.ows.KvpParser;
11 |
12 |
13 | /**
14 | * Parses a kvp of the form resultType=.
15 | *
16 | * Allowable values are "hits", and "results", which get parsed into
17 | * the following respectivley.
18 | *