//let super do its thing
request = super.read(request, kvp, rawKvp);
//do an additional check for outputFormat, because the default
// in wfs 1.1 is not the default for wfs 1.0
DescribeFeatureTypeType describeFeatureType = (DescribeFeatureTypeType) request;
if (!describeFeatureType.isSetOutputFormat()) {
if (describeFeatureType.getVersion().startsWith("1.1")) {
//set 1.1 default
describeFeatureType.setOutputFormat("text/xml; subtype=gml/3.1.1");
} else {
//set 1.0 default
describeFeatureType.setOutputFormat("XMLSCHEMA");
}
}
// did the user supply alternate namespace prefixes?
NamespaceSupport namespaces = null;
if (kvp.containsKey("NAMESPACE")) {
if (kvp.get("NAMESPACE") instanceof NamespaceSupport) {
namespaces = (NamespaceSupport) kvp.get("namespace");
} else {
LOGGER.warning("There's a namespace parameter but it seems it wasn't parsed to a "
+ NamespaceSupport.class.getName() + ": " + kvp.get("namespace"));
}
}
if (namespaces != null) {
List<QName> typeNames = describeFeatureType.getTypeName();
List<QName> newList = new ArrayList<QName>(typeNames.size());
for(QName name : typeNames){
String localPart = name.getLocalPart();
String prefix = name.getPrefix();
String namespaceURI = name.getNamespaceURI();
if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
//no prefix specified, did the request specify a default namespace?
namespaceURI = namespaces.getURI(XMLConstants.DEFAULT_NS_PREFIX);
} else if (XMLConstants.NULL_NS_URI.equals(namespaceURI)) {
//prefix specified, does a namespace mapping were declared for it?
if(namespaces.getURI(prefix) != null){
namespaceURI = namespaces.getURI(prefix);
}
}
if(catalog.getNamespaceByURI(namespaceURI) != null){
prefix = catalog.getNamespaceByURI(namespaceURI).getPrefix();
}
newList.add(new QName(namespaceURI, localPart, prefix));
}
describeFeatureType.getTypeName().clear();
describeFeatureType.getTypeName().addAll(newList);
}
return request;
}