use of it.geosolutions.geoserver.rest.decoder.RESTLayer in project sldeditor by robward-scisys.
the class GeoServerClient method parseLayerList.
/**
* Parses the layer list.
*
* @param reader the reader
* @param existingWorkspaceList the existing workspace list
* @param workspaceName the workspace name
*/
private void parseLayerList(GeoServerRESTReader reader, List<String> existingWorkspaceList, String workspaceName) {
Thread t1 = new Thread(new Runnable() {
public void run() {
List<String> workspaceList = null;
if (workspaceName == null) {
workspaceList = existingWorkspaceList;
// Add the default workspace last
workspaceList.add(null);
}
Map<String, List<GeoServerLayer>> layerMap = new LinkedHashMap<String, List<GeoServerLayer>>();
RESTLayerList layers = reader.getLayers();
int count = 1;
int total = layers.size();
for (NameLinkElem featureTypeName : layers) {
@SuppressWarnings("deprecation") RESTLayer layer = reader.getLayer(featureTypeName.getName());
if (layer != null) {
String layerName = layer.getName();
String workspace = null;
for (String workspaceNameToTest : workspaceList) {
if (reader.existsLayer(workspaceNameToTest, layerName, true)) {
if (workspaceNameToTest == null) {
workspace = DEFAULT_WORKSPACE_NAME;
} else {
workspace = workspaceNameToTest;
}
break;
}
}
GeoServerLayer geoServerlayer = new GeoServerLayer();
geoServerlayer.setLayerWorkspace(workspace);
geoServerlayer.setLayerName(layerName);
geoServerlayer.setConnection(connection);
StyleWrapper styleWrapper = new StyleWrapper();
styleWrapper.setStyle(layer.getDefaultStyle());
String styleWorkspace = layer.getDefaultStyleWorkspace();
styleWrapper.setWorkspace((styleWorkspace == null) ? DEFAULT_WORKSPACE_NAME : styleWorkspace);
geoServerlayer.setStyle(styleWrapper);
List<GeoServerLayer> layerList = layerMap.get(workspace);
if (layerList == null) {
layerList = new ArrayList<GeoServerLayer>();
layerMap.put(workspace, layerList);
}
layerList.add(geoServerlayer);
if (parentObj != null) {
parentObj.readLayersProgress(connection, count, total);
}
}
count++;
}
if (parentObj != null) {
parentObj.readLayersComplete(connection, layerMap);
}
}
});
t1.start();
}
Aggregations