throw new ServiceException("SLD document contains no layers");
}
final List<MapLayerInfo> layers = new ArrayList<MapLayerInfo>();
final List<Style> styles = new ArrayList<Style>();
MapLayerInfo currLayer;
StyledLayer sl = null;
for (int i = 0; i < slCount; i++) {
sl = styledLayers[i];
String layerName = sl.getName();
if (null == layerName) {
throw new ServiceException("A UserLayer without layer name was passed");
}
// TODO: add support for remote WFS here
// handle the InLineFeature stuff
boolean isBaseMap = false;
if ((sl instanceof UserLayer)
&& ((((UserLayer) sl)).getInlineFeatureDatastore() != null)) {
// SPECIAL CASE - we make the temporary version
UserLayer ul = ((UserLayer) sl);
CoordinateReferenceSystem crs = (getMapRequest.getCrs() == null) ? DefaultGeographicCRS.WGS84
: getMapRequest.getCrs();
currLayer = initializeInlineFeatureLayer(ul, crs);
addStyles(wms, getMapRequest, currLayer, styledLayers[i], layers, styles);
} else {
LayerGroupInfo layerGroup = getWMS().getLayerGroupByName(layerName);
if (layerGroup != null) {
List<LayerInfo> layerGroupLayers = layerGroup.layers();
List<StyleInfo> layerGroupStyles = layerGroup.getStyles();
for (int j = 0; j < layerGroupStyles.size(); j++) {
StyleInfo si = layerGroupStyles.get(j);
LayerInfo layer = layerGroupLayers.get(j);
currLayer = new MapLayerInfo(layer);
if (si != null){
currLayer.setStyle(si.getStyle());
}
addStyles(wms, getMapRequest, currLayer, styledLayers[i], layers, styles);
}
} else {
LayerInfo layerInfo = getWMS().getLayerByName(layerName);
if (layerInfo == null) {
throw new ServiceException("Layer not found: " + layerName);
}
currLayer = new MapLayerInfo(layerInfo);
addStyles(wms, getMapRequest, currLayer, styledLayers[i], layers, styles);
}
}
}