001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.geoserver.wfsv;
006:
007: import net.opengis.wfs.FeatureCollectionType;
008: import net.opengis.wfs.GetCapabilitiesType;
009: import net.opengis.wfs.GetFeatureType;
010: import net.opengis.wfs.GetFeatureWithLockType;
011: import net.opengis.wfs.LockFeatureResponseType;
012: import net.opengis.wfs.LockFeatureType;
013: import net.opengis.wfs.TransactionResponseType;
014: import net.opengis.wfs.TransactionType;
015: import net.opengis.wfsv.DescribeVersionedFeatureTypeType;
016: import net.opengis.wfsv.GetDiffType;
017: import net.opengis.wfsv.GetLogType;
018: import net.opengis.wfsv.GetVersionedFeatureType;
019: import net.opengis.wfsv.VersionedFeatureCollectionType;
020:
021: import org.geoserver.wfs.DescribeFeatureType;
022: import org.geoserver.wfs.GetCapabilities;
023: import org.geoserver.wfs.GetFeature;
024: import org.geoserver.wfs.LockFeature;
025: import org.geoserver.wfs.WFS;
026: import org.geoserver.wfs.WFSException;
027: import org.geotools.data.postgis.FeatureDiffReader;
028: import org.geotools.xml.transform.TransformerBase;
029: import org.opengis.filter.FilterFactory;
030: import org.springframework.beans.BeansException;
031: import org.springframework.context.ApplicationContext;
032: import org.vfny.geoserver.global.Data;
033: import org.vfny.geoserver.global.FeatureTypeInfo;
034:
035: /**
036: * Default implementation of the versioned feature service
037: *
038: * @author aaime
039: */
040: public class DefaultVersioningWebFeatureService implements
041: VersionedWebFeatureService {
042:
043: /**
044: * WFS service configuration.
045: */
046: protected WFS wfs;
047:
048: /**
049: * The catalog
050: */
051: protected Data catalog;
052:
053: /**
054: * Filter factory
055: */
056: protected FilterFactory filterFactory;
057:
058: /**
059: * The spring application context, used to look up transaction listeners, plugins and
060: * element handlers
061: */
062: protected ApplicationContext context;
063:
064: public DefaultVersioningWebFeatureService(WFS wfs, Data catalog) {
065: this .wfs = wfs;
066: this .catalog = catalog;
067: }
068:
069: /**
070: * Sets the fitler factory.
071: */
072: public void setFilterFactory(FilterFactory filterFactory) {
073: this .filterFactory = filterFactory;
074: }
075:
076: /**
077: * WFS GetCapabilities operation.
078: *
079: * @param request The get capabilities request.
080: *
081: * @return A transformer instance capable of serializing a wfs capabilities
082: * document.
083: *
084: * @throws WFSException Any service exceptions.
085: */
086: public TransformerBase getCapabilities(GetCapabilitiesType request)
087: throws WFSException {
088: return new GetCapabilities(wfs, catalog).run(request);
089: }
090:
091: /**
092: * WFS GetFeature operation.
093: *
094: * @param request The get feature request.
095: *
096: * @return A feature collection type instance.
097: *
098: * @throws WFSException Any service exceptions.
099: */
100: public FeatureCollectionType getFeature(GetFeatureType request)
101: throws WFSException {
102: GetFeature getFeature = new GetFeature(wfs, catalog);
103: getFeature.setFilterFactory(filterFactory);
104:
105: return getFeature.run(request);
106: }
107:
108: /**
109: * WFS GetFeatureWithLock operation.
110: *
111: * @param request The get feature with lock request.
112: *
113: * @return A feature collection type instance.
114: *
115: * @throws WFSException Any service exceptions.
116: */
117: public FeatureCollectionType getFeatureWithLock(
118: GetFeatureWithLockType request) throws WFSException {
119: return getFeature(request);
120: }
121:
122: /**
123: * WFS LockFeatureType operation.
124: *
125: * @param request The lock feature request.
126: *
127: * @return A lock feture response type.
128: *
129: * @throws WFSException An service exceptions.
130: */
131: public LockFeatureResponseType lockFeature(LockFeatureType request)
132: throws WFSException {
133: LockFeature lockFeature = new LockFeature(wfs, catalog);
134: lockFeature.setFilterFactory(filterFactory);
135:
136: return lockFeature.lockFeature(request);
137: }
138:
139: //the following operations are not part of the spec
140: public void releaseLock(String lockId) throws WFSException {
141: new LockFeature(wfs, catalog).release(lockId);
142: }
143:
144: public void releaseAllLocks() throws WFSException {
145: new LockFeature(wfs, catalog).releaseAll();
146: }
147:
148: public void setApplicationContext(ApplicationContext context)
149: throws BeansException {
150: this .context = context;
151: }
152:
153: public TransactionResponseType transaction(TransactionType request)
154: throws WFSException {
155: VersioningTransaction transaction = new VersioningTransaction(
156: wfs, catalog, context);
157: transaction.setFilterFactory(filterFactory);
158:
159: return transaction.transaction(request);
160: }
161:
162: public FeatureCollectionType getLog(GetLogType request) {
163: GetLog log = new GetLog(wfs, catalog);
164:
165: return log.run(request);
166: }
167:
168: public FeatureDiffReader[] getDiff(GetDiffType request) {
169: GetDiff diff = new GetDiff(wfs, catalog);
170:
171: return diff.run(request);
172: }
173:
174: public VersionedFeatureCollectionType getVersionedFeature(
175: GetVersionedFeatureType request) {
176: VersionedGetFeature getFeature = new VersionedGetFeature(wfs,
177: catalog);
178: getFeature.setFilterFactory(filterFactory);
179:
180: return (VersionedFeatureCollectionType) getFeature.run(request);
181: }
182:
183: public FeatureTypeInfo[] describeFeatureType(
184: net.opengis.wfs.DescribeFeatureTypeType request) {
185: return new DescribeFeatureType(wfs, catalog).run(request);
186: }
187:
188: public VersionedDescribeResults describeVersionedFeatureType(
189: DescribeVersionedFeatureTypeType request) {
190: FeatureTypeInfo[] infos = new DescribeFeatureType(wfs, catalog)
191: .run(request);
192: return new VersionedDescribeResults(infos, request
193: .isVersioned());
194: }
195: }
|