final FeatureTypeConstraint[] featureConstraints = ul.getLayerFeatureConstraints();
if (featureConstraints == null || featureConstraints.length == 0)
throw new WmsException(
"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 WmsException("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 WmsException("Could not find layer feature type '" + name
+ "' on remote WFS '" + service.getOnlineResource());
}
// grab the filter
Filter filter = featureConstraints[i].getFilter();
if (filter == null)
filter = Filter.INCLUDE;
// connect the layer
FeatureSource<SimpleFeatureType, SimpleFeature> fs = remoteWFS.getFeatureSource(name);
// this is messy, why the spec allows for multiple constraints and multiple
// styles is beyond me... we'll style each remote layer with all possible
// styles, feauture type style matching will do the rest during rendering
for (int j = 0; j < layerStyles.length; j++) {