request.setStyles(styles);
}
private static void addRemoteLayersFromUserLayer(GetMapRequest request, UserLayer ul,
List layers, List styles) throws ServiceException, IOException {
RemoteOWS service = ul.getRemoteOWS();
if (!service.getService().equalsIgnoreCase("WFS"))
throw new ServiceException("GeoServer only supports WFS as remoteOWS service");
if (service.getOnlineResource() == null)
throw new ServiceException("OnlineResource for remote WFS not specified in SLD");
final FeatureTypeConstraint[] featureConstraints = ul.getLayerFeatureConstraints();
if (featureConstraints == null || featureConstraints.length == 0)
throw new ServiceException(
"No FeatureTypeConstraint specified, no layer can be loaded for this UserStyle");
DataStore remoteWFS = null;
List remoteTypeNames = null;
try {
URL url = new URL(service.getOnlineResource());
remoteWFS = connectRemoteWFS(url);
remoteTypeNames = new ArrayList(Arrays.asList(remoteWFS.getTypeNames()));
Collections.sort(remoteTypeNames);
} catch (MalformedURLException e) {
throw new ServiceException("Invalid online resource url: '"
+ service.getOnlineResource() + "'");
}
Style[] layerStyles = ul.getUserStyles();
if (request.getFilter() == null)
request.setFilter(new ArrayList());
for (int i = 0; i < featureConstraints.length; i++) {
// make sure the layer is there
String name = featureConstraints[i].getFeatureTypeName();
if (Collections.binarySearch(remoteTypeNames, name) < 0) {
throw new ServiceException("Could not find layer feature type '" + name
+ "' on remote WFS '" + service.getOnlineResource());
}
// grab the filter
Filter filter = featureConstraints[i].getFilter();
if (filter == null)