ns2metas.put(featureTypeName.getNamespaceURI(), metas);
}
metas.add(meta);
}
} else {
FeatureType featureType = ((FeatureCollection) featureCollections.get(fcIndex)).getSchema();
//load the metadata for the feature type
String namespaceURI = featureType.getName().getNamespaceURI();
FeatureTypeInfo meta = catalog.getFeatureTypeByName(featureType.getName());
if(meta == null)
throw new WFSException("Could not find feature type " + featureType.getName() + " in the GeoServer catalog");
//add it to the map
Set metas = (Set) ns2metas.get(namespaceURI);
if (metas == null) {
metas = new HashSet();
ns2metas.put(namespaceURI, metas);
}
metas.add(meta);
}
}
//set feature bounding parameter
//JD: this is quite bad as its not at all thread-safe, once we remove the configuration
// as being a singleton on trunk/2.0.x this should not be an issue
if ( wfs.isFeatureBounding() ) {
configuration.getProperties().remove( GMLConfiguration.NO_FEATURE_BOUNDS );
}
else {
configuration.getProperties().add( GMLConfiguration.NO_FEATURE_BOUNDS);
}
Encoder encoder = new Encoder(configuration, configuration.schema());
encoder.setEncoding(Charset.forName( global.getCharset() ));
//declare wfs schema location
BaseRequestType gft = (BaseRequestType)getFeature.getParameters()[0];
if (wfs.isCanonicalSchemaLocation()) {
encoder.setSchemaLocation(org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE,
WFS.CANONICAL_SCHEMA_LOCATION);
} else {
encoder.setSchemaLocation(org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE,
buildSchemaURL(gft.getBaseUrl(), "wfs/1.1.0/wfs.xsd"));
}
//declare application schema namespaces
Map<String, String> params = params("service", "WFS", "version", "1.1.0", "request", "DescribeFeatureType");
for (Iterator i = ns2metas.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
String namespaceURI = (String) entry.getKey();
Set metas = (Set) entry.getValue();
StringBuffer typeNames = new StringBuffer();
String userSchemaLocation = null;
for (Iterator m = metas.iterator(); m.hasNext();) {
FeatureTypeInfo meta = (FeatureTypeInfo) m.next();
if (userSchemaLocation == null) {
FeatureType featureType = meta.getFeatureType();
Object schemaUri = featureType.getUserData().get("schemaURI");
if (schemaUri != null) {
userSchemaLocation = schemaUri.toString();
}
}
typeNames.append(meta.getPrefixedName());