if (filter == null) {
filter = Filter.INCLUDE;
}
FeatureTypeInfo meta;
FeatureSource<? extends FeatureType, ? extends Feature> source;
FeatureCollection<? extends FeatureType, ? extends Feature> features;
try {
meta = catalog.getFeatureTypeByName(typeName.getNamespaceURI(), typeName.getLocalPart());
if (meta == null) {
throw new WFSException("Unknown feature type " + typeName.getPrefix() + ":"
+ typeName.getLocalPart());
}
source = meta.getFeatureSource(null,null);
// make sure all geometric elements in the filter have a crs, and that the filter
// is reprojected to store's native crs as well
CoordinateReferenceSystem declaredCRS = WFSReprojectionUtil.getDeclaredCrs(
source.getSchema(), request.getVersion());
filter = WFSReprojectionUtil.normalizeFilterCRS(filter, source.getSchema(), declaredCRS);
// now gather the features
features = source.getFeatures(filter);
if (source instanceof FeatureLocking) {
((FeatureLocking<SimpleFeatureType, SimpleFeature>) source).setFeatureLock(fLock);
}
} catch (IOException e) {
throw new WFSException(e);
}
Iterator reader = null;
int numberLocked = -1;
try {
for (reader = features.iterator(); reader.hasNext();) {
SimpleFeature feature = (SimpleFeature) reader.next();
FeatureId fid = fid(feature.getID());
Id fidFilter = fidFilter(fid);
if (!(source instanceof FeatureLocking)) {
LOGGER.fine("Lock " + fid + " not supported by data store (authID:"
+ fLock.getAuthorization() + ")");
response.getFeaturesNotLocked().getFeatureId().add(fid);
// lockFailedFids.add(fid);
} else {
// DEFQuery is just some indirection, should be in
// the locking interface.
// int numberLocked =
// ((DEFQueryFeatureLocking)source).lockFeature(feature);
// HACK: Query.NO_NAMES isn't working in postgis
// right now,
// so we'll just use all.
Query query = new DefaultQuery(meta.getName(), (Filter) fidFilter,
Query.DEFAULT_MAX, Query.ALL_NAMES, lock.getHandle());
numberLocked = ((FeatureLocking<SimpleFeatureType, SimpleFeature>) source)
.lockFeatures(query);