throw new ServiceException("SLD document contains no layers");
}
final List<MapLayerInfo> layers = new ArrayList<MapLayerInfo>();
final List<Style> styles = new ArrayList<Style>();
MapLayerInfo currLayer = null;
Style currStyle = null;
String layerName;
UserLayer ul;
for (StyledLayer sl : styledLayers) {
layerName = sl.getName();
if (null == layerName) {
throw new ServiceException("A UserLayer without layer name was passed");
}
if (sl instanceof UserLayer && ((((UserLayer) sl)).getRemoteOWS() != null)) {
// this beast can define multiple feature sources and multiple styles, we'll
// have to mix and match them (ugh)
ul = ((UserLayer) sl);
try {
addRemoteLayersFromUserLayer(request, ul, layers, styles);
} catch (IOException e) {
throw new ServiceException("Error accessing remote layers", e,
"RemoteAccessFailed");
}
} else {
// simpler case, one layer, eventually multiple styles
currLayer = null;
// handle the InLineFeature stuff
if ((sl instanceof UserLayer)
&& ((((UserLayer) sl)).getInlineFeatureDatastore() != null)) {
// SPECIAL CASE - we make the temporary version
ul = ((UserLayer) sl);
try {
currLayer = initializeInlineFeatureLayer(request, ul);
} catch (Exception e) {
throw new ServiceException(e);
}
} else {
if (wms.getLayerGroupByName(layerName) != null) {
LayerGroupInfo group = wms.getLayerGroupByName(layerName);
for (int i = 0; i < group.getLayers().size(); i++) {
LayerInfo layer = group.getLayers().get(i);
layers.add(new MapLayerInfo(layer));
StyleInfo style = group.getStyles().get(i);
if (style != null) {
styles.add(style.getStyle());
} else {
styles.add(layer.getDefaultStyle().getStyle());
}
}
// move to the next named layer
continue;
} else {
LayerInfo layerInfo = wms.getLayerByName(layerName);
if (layerInfo == null)
throw new ServiceException("Unknown layer: " + layerName);
currLayer = new MapLayerInfo(layerInfo);
if (sl instanceof NamedLayer) {
NamedLayer namedLayer = ((NamedLayer) sl);
currLayer.setLayerFeatureConstraints(namedLayer
.getLayerFeatureConstraints());
}
}
}
if (currLayer.getType() == MapLayerInfo.TYPE_RASTER) {
try {
addStyles(wms, request, currLayer, sl, layers, styles);
} catch (ServiceException wm) {
// hmm, well, the style they specified in the wms
// request