}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public GetCapabilitiesRequest read(Object req, Map kvp, Map rawKvp) throws Exception {
GetCapabilitiesRequest request = (GetCapabilitiesRequest) super.read(req, kvp, rawKvp);
request.setRawKvp(rawKvp);
String version = request.getVersion();
if (null == version || version.length() == 0) {
version = (String) rawKvp.get("WMTVER");
}
//kind of a silly check but the cite tests put some rules about using WMTVER vs VERSION
// depending on which one shows up as a kvp parameter first in order, which actualy
// violates http get, but we do a check here to throw out one if it does not match
// an available wms version
if (rawKvp.containsKey("VERSION") && rawKvp.containsKey("WMTVER")) {
String ver = (String) rawKvp.get("VERSION");
String wmtver = (String) rawKvp.get("WMTVER");
if (WMS.version(ver, true) != null && WMS.version(wmtver, true) == null) {
version = ver;
}
else if (WMS.version(ver, true) == null && WMS.version(wmtver, true) != null) {
version = wmtver;
}
}
// version negotation
Version requestedVersion = WMS.version(version);
Version negotiatedVersion = wms.negotiateVersion(requestedVersion);
request.setVersion(negotiatedVersion.toString());
return request;
}