use of it.geosolutions.geoserver.rest.GeoServerRESTManager in project sldeditor by robward-scisys.
the class GeoServerClient method updateLayerStyles.
/**
* Update layer styles.
*
* @param layer the original layer
* @return true, if successful
*/
@Override
public boolean updateLayerStyles(GeoServerLayer layer) {
if (layer == null) {
return false;
}
StyleWrapper updatedStyle = layer.getStyle();
boolean ok = false;
GeoServerRESTManager manager = GeoServerRESTManagerFactory.getManager(connection);
GeoServerRESTPublisher publisher = manager.getPublisher();
if (publisher != null) {
GSLayerEncoder layerEncoder = new GSLayerEncoder();
String defaultStyle;
if (isDefaultWorkspace(updatedStyle.getWorkspace())) {
defaultStyle = updatedStyle.getStyle();
} else {
defaultStyle = updatedStyle.getWorkspace() + ":" + updatedStyle.getStyle();
}
layerEncoder.setDefaultStyle(defaultStyle);
ok = publisher.configureLayer(layer.getLayerWorkspace(), layer.getLayerName(), layerEncoder);
}
return ok;
}
use of it.geosolutions.geoserver.rest.GeoServerRESTManager in project sldeditor by robward-scisys.
the class GeoServerClient method retrieveData.
/**
* Retrieve data from GeoServer.
*/
@Override
public void retrieveData() {
GeoServerRESTManager manager = GeoServerRESTManagerFactory.getManager(connection);
if (manager != null) {
GeoServerRESTReader reader = manager.getReader();
if (reader != null) {
if (parentObj != null) {
parentObj.startPopulating(connection);
}
List<String> workspaceList = getWorkspaceList();
parseStyleList(reader, workspaceList);
parseLayerList(reader, workspaceList, null);
}
}
}
use of it.geosolutions.geoserver.rest.GeoServerRESTManager in project sldeditor by robward-scisys.
the class GeoServerClient method uploadSLD.
/**
* Upload sld.
*
* @param styleWrapper the style wrapper
* @param sldBody the sld body
* @return true, if successful
*/
@Override
public boolean uploadSLD(StyleWrapper styleWrapper, String sldBody) {
String workspaceName = styleWrapper.getWorkspace();
String styleName = styleWrapper.getStyle();
if (!workspaceValid(workspaceName)) {
return false;
}
boolean result = false;
GeoServerRESTManager manager = GeoServerRESTManagerFactory.getManager(connection);
GeoServerRESTPublisher publisher = manager.getPublisher();
if (publisher != null) {
if (styleExists(workspaceName, styleName)) {
if (isDefaultWorkspace(workspaceName)) {
result = publisher.updateStyle(sldBody, styleName, true);
} else {
result = publisher.updateStyleInWorkspace(workspaceName, sldBody, styleName);
}
} else {
if (isDefaultWorkspace(workspaceName)) {
result = publisher.publishStyle(sldBody, styleName, true);
} else {
GeoServerRESTReader reader = manager.getReader();
if (reader != null) {
if (!reader.existsWorkspace(workspaceName)) {
if (!publisher.createWorkspace(workspaceName)) {
ConsoleManager.getInstance().error(this, Localisation.getField(GeoServerClient.class, "GeoServerClient.failedToCreateWorkspace") + workspaceName);
return false;
}
}
} else {
return false;
}
result = publisher.publishStyleInWorkspace(workspaceName, sldBody, styleName);
}
}
}
if (result) {
ConsoleManager.getInstance().information(this, String.format("%s : %s %s/%s", Localisation.getString(GeoServerClient.class, "GeoServerClient.styleUploaded"), connection.getConnectionName(), workspaceName, styleName));
}
return result;
}
use of it.geosolutions.geoserver.rest.GeoServerRESTManager in project sldeditor by robward-scisys.
the class GeoServerClient method refreshWorkspace.
/**
* Refresh workspace.
*
* @param workspaceName the workspace name
*/
@Override
public void refreshWorkspace(String workspaceName) {
GeoServerRESTManager manager = GeoServerRESTManagerFactory.getManager(connection);
if (manager != null) {
GeoServerRESTReader reader = manager.getReader();
if (reader != null) {
Map<String, List<StyleWrapper>> styleMap = new LinkedHashMap<String, List<StyleWrapper>>();
int count = 1;
List<StyleWrapper> styleList = new ArrayList<StyleWrapper>();
if (workspaceName.compareTo(DEFAULT_WORKSPACE_NAME) == 0) {
count = parseStyleInDefaultWorkspace(reader, count, styleList);
styleMap.put(DEFAULT_WORKSPACE_NAME, styleList);
} else {
// Read styles from workspace
count = parseStyleInWorkspace(reader, styleMap, count, workspaceName);
}
if (parentObj != null) {
parentObj.readStylesComplete(connection, styleMap, true);
}
}
}
}
Aggregations