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.wfs;
006:
007: import net.opengis.wfs.DescribeFeatureTypeType;
008: import net.opengis.wfs.FeatureCollectionType;
009: import net.opengis.wfs.GetCapabilitiesType;
010: import net.opengis.wfs.GetFeatureType;
011: import net.opengis.wfs.GetFeatureWithLockType;
012: import net.opengis.wfs.LockFeatureResponseType;
013: import net.opengis.wfs.LockFeatureType;
014: import net.opengis.wfs.TransactionResponseType;
015: import net.opengis.wfs.TransactionType;
016: import org.geotools.xml.transform.TransformerBase;
017: import org.opengis.filter.FilterFactory;
018: import org.springframework.beans.BeansException;
019: import org.springframework.context.ApplicationContext;
020: import org.springframework.context.ApplicationContextAware;
021: import org.vfny.geoserver.global.Data;
022: import org.vfny.geoserver.global.FeatureTypeInfo;
023:
024: /**
025: * Web Feature Service implementation.
026: *
027: * @author Justin Deoliveira, The Open Planning Project
028: *
029: */
030: public class DefaultWebFeatureService implements WebFeatureService,
031: ApplicationContextAware {
032: /**
033: * WFS service configuration.
034: */
035: protected WFS wfs;
036:
037: /**
038: * The catalog
039: */
040: protected Data catalog;
041:
042: /**
043: * Filter factory
044: */
045: protected FilterFactory filterFactory;
046:
047: /**
048: * The spring application context, used to look up transaction listeners, plugins and
049: * element handlers
050: */
051: protected ApplicationContext context;
052:
053: public DefaultWebFeatureService(WFS wfs, Data catalog) {
054: this .wfs = wfs;
055: this .catalog = catalog;
056: }
057:
058: /**
059: * Sets the fitler factory.
060: */
061: public void setFilterFactory(FilterFactory filterFactory) {
062: this .filterFactory = filterFactory;
063: }
064:
065: /**
066: * WFS GetCapabilities operation.
067: *
068: * @param request The get capabilities request.
069: *
070: * @return A transformer instance capable of serializing a wfs capabilities
071: * document.
072: *
073: * @throws WFSException Any service exceptions.
074: */
075: public TransformerBase getCapabilities(GetCapabilitiesType request)
076: throws WFSException {
077: return new GetCapabilities(wfs, catalog).run(request);
078: }
079:
080: /**
081: * WFS DescribeFeatureType operation.
082: *
083: * @param request The describe feature type request.
084: *
085: * @return A set of feature type metadata objects.
086: *
087: * @throws WFSException Any service exceptions.
088: */
089: public FeatureTypeInfo[] describeFeatureType(
090: DescribeFeatureTypeType request) throws WFSException {
091: return new DescribeFeatureType(wfs, catalog).run(request);
092: }
093:
094: /**
095: * WFS GetFeature operation.
096: *
097: * @param request The get feature request.
098: *
099: * @return A feature collection type instance.
100: *
101: * @throws WFSException Any service exceptions.
102: */
103: public FeatureCollectionType getFeature(GetFeatureType request)
104: throws WFSException {
105: GetFeature getFeature = new GetFeature(wfs, catalog);
106: getFeature.setFilterFactory(filterFactory);
107:
108: return getFeature.run(request);
109: }
110:
111: /**
112: * WFS GetFeatureWithLock operation.
113: *
114: * @param request The get feature with lock request.
115: *
116: * @return A feature collection type instance.
117: *
118: * @throws WFSException Any service exceptions.
119: */
120: public FeatureCollectionType getFeatureWithLock(
121: GetFeatureWithLockType request) throws WFSException {
122: return getFeature(request);
123: }
124:
125: /**
126: * WFS LockFeatureType operation.
127: *
128: * @param request The lock feature request.
129: *
130: * @return A lock feture response type.
131: *
132: * @throws WFSException An service exceptions.
133: */
134: public LockFeatureResponseType lockFeature(LockFeatureType request)
135: throws WFSException {
136: LockFeature lockFeature = new LockFeature(wfs, catalog);
137: lockFeature.setFilterFactory(filterFactory);
138:
139: return lockFeature.lockFeature(request);
140: }
141:
142: /**
143: * WFS transaction operation.
144: *
145: * @param request The transaction request.
146: *
147: * @return A transaction response instance.
148: *
149: * @throws WFSException Any service exceptions.
150: */
151: public TransactionResponseType transaction(TransactionType request)
152: throws WFSException {
153: Transaction transaction = new Transaction(wfs, catalog, context);
154: transaction.setFilterFactory(filterFactory);
155:
156: return transaction.transaction(request);
157: }
158:
159: //the following operations are not part of the spec
160: public void releaseLock(String lockId) throws WFSException {
161: new LockFeature(wfs, catalog).release(lockId);
162: }
163:
164: public void releaseAllLocks() throws WFSException {
165: new LockFeature(wfs, catalog).releaseAll();
166: }
167:
168: public void setApplicationContext(ApplicationContext context)
169: throws BeansException {
170: this.context = context;
171: }
172: }
|