//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
DescribeFeatureTypeRequest req = DescribeFeatureTypeRequest.adapt(request);
if (!req.isSetOutputFormat()) {
switch(WFSInfo.Version.negotiate(req.getVersion())) {
case V_10:
req.setOutputFormat("XMLSCHEMA"); break;
case V_11:
req.setOutputFormat("text/xml; subtype=gml/3.1.1"); break;
case V_20:
default:
req.setOutputFormat("text/xml; subtype=gml/3.2");
}
}
// 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 = req.getTypeNames();
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));
}
req.setTypeNames(newList);
}
return request;
}