Source:
private void handleLayers() { start("Layer"); Filter filter; { Filter enabled = equal("enabled", Boolean.TRUE); Filter advertised = equal("advertised", Boolean.TRUE); filter = and(enabled, advertised); } if (request.getNamespace() != null) { final String nsPrefix = request.getNamespace(); final String nsProp = "resource.namespace.prefix"; Filter equals = equal(nsProp, nsPrefix); filter = and(filter, equals); } final Catalog catalog = wmsConfig.getCatalog(); WMSInfo serviceInfo = wmsConfig.getServiceInfo(); element("Title", serviceInfo.getTitle()); element("Abstract", serviceInfo.getAbstract()); List<String> srsList = serviceInfo.getSRS(); Set<String> srs = new LinkedHashSet<String>(); if (srsList != null) { srs.addAll(srsList); } for (ExtendedCapabilitiesProvider provider : extCapsProviders) { provider.customizeRootCrsList(srs); } handleRootCrsList(srs); final Filter lgFilter = Predicates.acceptAll(); CloseableIterator<LayerInfo> layers = catalog.list(LayerInfo.class, filter); CloseableIterator<LayerGroupInfo> layerGroups = catalog.list(LayerGroupInfo.class, lgFilter); try{ handleRootBbox(layers, layerGroups); }finally{ layers.close(); } handleAuthorityURL(serviceInfo.getAuthorityURLs()); handleLayerIdentifiers(serviceInfo.getIdentifiers()); Set<LayerInfo> layersAlreadyProcessed = new HashSet<LayerInfo>(); { SortBy layerGroupOrder = asc("name"); layerGroups = catalog.list(LayerGroupInfo.class, lgFilter, null, null, layerGroupOrder); } try { layersAlreadyProcessed = handleLayerGroups(layerGroups); } catch (Exception e) { throw new RuntimeException("Can't obtain Envelope of Layer-Groups: " + e.getMessage(), e); } finally { layerGroups.close(); } SortBy layerOrder = asc("name"); layers = catalog.list(LayerInfo.class, filter, null, null, layerOrder); try { handleLayerTree(layers, layersAlreadyProcessed); } finally { layers.close(); } end("Layer"); }

Target:
private void handleLayers() { start("Layer"); Filter filter; { Filter enabled = equal("enabled", Boolean.TRUE); Filter advertised = equal("advertised", Boolean.TRUE); filter = and(enabled, advertised); } filter = addNameSpaceFilterIfNeed(filter, "resource.namespace.prefix"); final Catalog catalog = wmsConfig.getCatalog(); WMSInfo serviceInfo = wmsConfig.getServiceInfo(); element("Title", serviceInfo.getTitle()); element("Abstract", serviceInfo.getAbstract()); List<String> srsList = serviceInfo.getSRS(); Set<String> srs = new LinkedHashSet<String>(); if (srsList != null) { srs.addAll(srsList); } for (ExtendedCapabilitiesProvider provider : extCapsProviders) { provider.customizeRootCrsList(srs); } handleRootCrsList(srs); Filter lgFilter = Predicates.acceptAll(); lgFilter = addNameSpaceFilterIfNeed(lgFilter, "workspace.name"); CloseableIterator<LayerInfo> layers = catalog.list(LayerInfo.class, filter); CloseableIterator<LayerGroupInfo> layerGroups = catalog.list(LayerGroupInfo.class, lgFilter); try{ handleRootBbox(layers, layerGroups); }finally{ layers.close(); } handleAuthorityURL(serviceInfo.getAuthorityURLs()); handleLayerIdentifiers(serviceInfo.getIdentifiers()); Set<LayerInfo> layersAlreadyProcessed = new HashSet<LayerInfo>(); { SortBy layerGroupOrder = asc("name"); layerGroups = catalog.list(LayerGroupInfo.class, lgFilter, null, null, layerGroupOrder); } try { layersAlreadyProcessed = handleLayerGroups(layerGroups); } catch (Exception e) { throw new RuntimeException("Can't obtain Envelope of Layer-Groups: " + e.getMessage(), e); } finally { layerGroups.close(); } SortBy layerOrder = asc("name"); layers = catalog.list(LayerInfo.class, filter, null, null, layerOrder); try { handleLayerTree(layers, layersAlreadyProcessed); } finally { layers.close(); } end("Layer"); }