String layer = values.get("layer");
if (layer == null) {
throw new OWSException(400, "MissingParameterValue", "LAYER", "Missing LAYER parameter");
}
TileLayer tileLayer = null;
try {
tileLayer = tld.getTileLayer(layer);
} catch (GeoWebCacheException e) {
throw new OWSException(400, "InvalidParameterValue", "LAYER", "LAYER " + layer
+ " is not known.");
}
Map<String, String> fullParameters;
try {
// WMTS uses the "STYLE" instead of "STYLES"
@SuppressWarnings("unchecked")
Map<String, Object> rawParameters = new HashMap<>(request.getParameterMap());
for(Entry<String, Object> e:rawParameters.entrySet()){
if(e.getKey().equalsIgnoreCase("STYLE")) {
rawParameters.put("STYLES", e.getValue());
break;
}
}
fullParameters = tileLayer.getModifiableParameters(rawParameters, encoding);
} catch (GeoWebCacheException e) {
throw new OWSException(500, "NoApplicableCode", "", e.getMessage()
+ " while fetching modifiable parameters for LAYER " + layer);
}
MimeType mimeType = null;
if (reqType == RequestType.TILE) {
String format = values.get("format");
if (format == null) {
throw new OWSException(400, "MissingParameterValue", "FORMAT",
"Unable to determine requested FORMAT, " + format);
}
try {
mimeType = MimeType.createFromFormat(format);
} catch (MimeException me) {
throw new OWSException(400, "InvalidParameterValue", "FORMAT",
"Unable to determine requested FORMAT, " + format);
}
} else {
String infoFormat = ServletUtils.stringFromMap(request.getParameterMap(),
request.getCharacterEncoding(), "infoformat");
if (infoFormat == null) {
throw new OWSException(400, "MissingParameterValue", "INFOFORMAT",
"Parameter INFOFORMAT was not provided");
}
try {
mimeType = MimeType.createFromFormat(infoFormat);
} catch (MimeException me) {
throw new OWSException(400, "InvalidParameterValue", "INFOFORMAT",
"Unable to determine requested INFOFORMAT, " + infoFormat);
}
}
final String tilematrixset = values.get("tilematrixset");
if (tilematrixset == null) {
throw new OWSException(400, "MissingParameterValue", "TILEMATRIXSET",
"No TILEMATRIXSET specified");
}
GridSubset gridSubset = tileLayer.getGridSubset(tilematrixset);
if (gridSubset == null) {
throw new OWSException(400, "InvalidParameterValue", "TILEMATRIXSET",
"Unable to match requested TILEMATRIXSET " + tilematrixset
+ " to those supported by layer");
}