}
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());
if (m.hasNext()) {
typeNames.append(",");
}
}
params.put("typeName", typeNames.toString());
//set the schema location if the user provides it, otherwise give a default one
if (userSchemaLocation != null) {
encoder.setSchemaLocation(namespaceURI, userSchemaLocation);
} else {
String schemaLocation = buildURL(gft.getBaseUrl(), "wfs", params, URLType.SERVICE);
LOGGER.finer("Unable to find user-defined schema location for: " + namespaceURI
+ ". Using a built schema location by default: " + schemaLocation);
encoder.setSchemaLocation(namespaceURI, schemaLocation);
}
}
encoder.encode(results, org.geoserver.wfs.xml.v1_1_0.WFS.FEATURECOLLECTION, output);
}