request.setHttpServletRequest(httpRequest);
String version = super.getRequestVersion();
if (!GetLegendGraphicRequest.SLD_VERSION.equals(version)) {
throw new WmsException("Invalid SLD version number \"" + version
+ "\"");
}
String layer = getValue("LAYER");
FeatureTypeInfo fti;
FeatureType ft;
try {
WMS wms = request.getWMS();
Data catalog = wms.getData();
fti = catalog.getFeatureTypeInfo(layer);
ft = fti.getFeatureType();
} catch (NoSuchElementException e) {
throw new WmsException(layer + " layer does not exists.",
"LayerNotDefined");
} catch (IOException e) {
throw new WmsException(
"Can't obtain the schema for the required layer.");
}
request.setLayer(ft);
String format = getValue("FORMAT");
if (!org.vfny.geoserver.wms.responses.GetLegendGraphicResponse
.supportsFormat(format)) {
throw new WmsException("Invalid graphic format: " + format,
"InvalidFormat");
}
request.setFormat(format);