String outputFormat = request.getOutputFormat();
try {
delegate = GetNearestResponse.getDelegate(outputFormat);
} catch (NoSuchElementException ex) {
throw new WfsException("output format: " + outputFormat + " not "
+ "supported by geoserver", ex);
}
GetNearestResults results = new GetNearestResults(request);
//
// Optimization Idea
//
// We should be able to reduce this to a two pass opperations.
//
// Pass #1 execute
// - Attempt to Locks Fids during the first pass
// - Also collect Bounds information during the first pass
//
// Pass #2 writeTo
// - Using the Bounds to describe our FeatureCollections
// - Iterate through FeatureResults producing GML
//
// And allways remember to release locks if we are failing:
// - if we fail to aquire all the locks we will need to fail and
// itterate through the the FeatureSources to release the locks
//
WFS wfs = request.getWFS();
GeoServer config = wfs.getGeoServer();
Data catalog = wfs.getData();
FeatureTypeInfo meta = null;
NameSpaceInfo namespace;
Query query;
FeatureSource source;
Feature feature;
String fid;
FilterFactory filterFactory = FilterFactoryFinder.createFilterFactory();
FidFilter fidFilter;
try {
for (Iterator it = request.getQueries().iterator(); it.hasNext();) {
query = (Query) it.next();
// the feature type name used in the content disposition response will match
// the first feature type
if (featureTypeName == null) {
featureTypeName = query.getTypeName();
}
meta = catalog.getFeatureTypeInfo(query.getTypeName());
namespace = meta.getDataStoreInfo().getNameSpace();
source = meta.getFeatureSource();
List attrs = meta.getAttributes();
List propNames = query.getPropertyNames(); // REAL LIST: be careful here :)
List attributeNames = meta.getAttributeNames();
for (Iterator iter = propNames.iterator(); iter.hasNext();) {
String propName = (String) iter.next();
if (!attributeNames.contains(propName)) {
String mesg = "Requested property: " + propName + " is "
+ "not available for " + query.getTypeName() + ". "
+ "The possible propertyName values are: " + attributeNames;
throw new WfsException(mesg);
}
}