Search in sources :

Example 1 with GeoServerRESTManager

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;
}
Also used : URL(java.net.URL) GeoServerRESTManager(it.geosolutions.geoserver.rest.GeoServerRESTManager)

Example 2 with GeoServerRESTManager

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;
}
Also used : GeoServerRESTPublisher(it.geosolutions.geoserver.rest.GeoServerRESTPublisher) GeoServerRESTManager(it.geosolutions.geoserver.rest.GeoServerRESTManager)

Example 3 with GeoServerRESTManager

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;
}
Also used : GeoServerRESTReader(it.geosolutions.geoserver.rest.GeoServerRESTReader) GeoServerRESTManager(it.geosolutions.geoserver.rest.GeoServerRESTManager)

Example 4 with GeoServerRESTManager

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;
}
Also used : GeoServerRESTReader(it.geosolutions.geoserver.rest.GeoServerRESTReader) GeoServerRESTManager(it.geosolutions.geoserver.rest.GeoServerRESTManager)

Example 5 with GeoServerRESTManager

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;
}
Also used : GeoServerRESTPublisher(it.geosolutions.geoserver.rest.GeoServerRESTPublisher) GeoServerRESTManager(it.geosolutions.geoserver.rest.GeoServerRESTManager)

Aggregations

GeoServerRESTManager (it.geosolutions.geoserver.rest.GeoServerRESTManager)10 GeoServerRESTPublisher (it.geosolutions.geoserver.rest.GeoServerRESTPublisher)4 GeoServerRESTReader (it.geosolutions.geoserver.rest.GeoServerRESTReader)4 StyleWrapper (com.sldeditor.common.data.StyleWrapper)2 URL (java.net.URL)2 RESTLayerList (it.geosolutions.geoserver.rest.decoder.RESTLayerList)1 RESTStyleList (it.geosolutions.geoserver.rest.decoder.RESTStyleList)1 GSLayerEncoder (it.geosolutions.geoserver.rest.encoder.GSLayerEncoder)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1