use of it.geosolutions.geoserver.rest.GeoServerRESTManager in project sldeditor by robward-scisys.
the class GeoServerRESTManagerFactory method internal_getManager.
/**
* Internal_get manager.
*
* @param connection the connection
* @return the geo server rest manager
*/
private GeoServerRESTManager internal_getManager(GeoServerConnection connection) {
if (connection == null) {
return null;
}
GeoServerRESTManager manager = map.get(connection);
if (manager == null) {
URL geoserverURL = connection.getUrl();
if (geoserverURL != null) {
try {
if (connection.getUserName() != null) {
manager = new GeoServerRESTManager(geoserverURL, connection.getUserName(), connection.getPassword());
map.put(connection, manager);
}
} catch (IllegalArgumentException e) {
ConsoleManager.getInstance().exception(this, e);
}
}
}
return manager;
}
use of it.geosolutions.geoserver.rest.GeoServerRESTManager in project sldeditor by robward-scisys.
the class GeoServerClient method deleteStyle.
/**
* Delete style.
*
* @param styleToDelete the style to delete
* @return true, if successful
*/
@Override
public boolean deleteStyle(StyleWrapper styleToDelete) {
if (styleToDelete == null) {
return false;
}
boolean result = false;
GeoServerRESTManager manager = GeoServerRESTManagerFactory.getManager(connection);
GeoServerRESTPublisher publisher = manager.getPublisher();
if (publisher != null) {
if (isDefaultWorkspace(styleToDelete.getWorkspace())) {
result = publisher.removeStyle(styleToDelete.getStyle());
} else {
result = publisher.removeStyleInWorkspace(styleToDelete.getWorkspace(), styleToDelete.getStyle());
}
}
return result;
}
use of it.geosolutions.geoserver.rest.GeoServerRESTManager in project sldeditor by robward-scisys.
the class GeoServerClient method getWorkspaceList.
/**
* Gets the workspace list.
*
* @return the workspace list
*/
@Override
public List<String> getWorkspaceList() {
List<String> workspaceList = null;
GeoServerRESTManager manager = GeoServerRESTManagerFactory.getManager(connection);
if (manager != null) {
GeoServerRESTReader reader = manager.getReader();
if (reader != null) {
workspaceList = reader.getWorkspaceNames();
}
}
if (workspaceList == null) {
workspaceList = new ArrayList<>();
}
return workspaceList;
}
use of it.geosolutions.geoserver.rest.GeoServerRESTManager in project sldeditor by robward-scisys.
the class GeoServerClient method styleExists.
/**
* Check to see if style exists.
*
* @param workspaceName the workspace name
* @param styleName the style name
* @return true, if successful
*/
private boolean styleExists(String workspaceName, String styleName) {
GeoServerRESTManager manager = GeoServerRESTManagerFactory.getManager(connection);
GeoServerRESTReader reader = manager.getReader();
if (reader != null) {
if (isDefaultWorkspace(workspaceName)) {
return reader.existsStyle(styleName, true);
} else {
// Check workspace exists first
if (reader.existsWorkspace(workspaceName)) {
return reader.existsStyle(workspaceName, styleName);
}
}
}
return false;
}
use of it.geosolutions.geoserver.rest.GeoServerRESTManager in project sldeditor by robward-scisys.
the class GeoServerClient method deleteWorkspace.
/**
* Delete workspace.
*
* @param workspaceName the workspace name
* @return true, if successful
*/
@Override
public boolean deleteWorkspace(String workspaceName) {
if (workspaceName == null) {
return false;
}
boolean result = false;
GeoServerRESTManager manager = GeoServerRESTManagerFactory.getManager(connection);
GeoServerRESTPublisher publisher = manager.getPublisher();
if (publisher != null) {
if (isDefaultWorkspace(workspaceName)) {
ConsoleManager.getInstance().error(this, Localisation.getString(GeoServerClient.class, "GeoServerClient.cannotDeleteDefaultWorkspace"));
} else {
result = publisher.removeWorkspace(workspaceName, false);
}
}
return result;
}
Aggregations