Java Code Examples for it.geosolutions.geoserver.rest.GeoServerRESTReader#getWorkspaceNames()

The following examples show how to use it.geosolutions.geoserver.rest.GeoServerRESTReader#getWorkspaceNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoServerClient.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: WorkspaceCommands.java    From geoserver-shell with MIT License 5 votes vote down vote up
@CliCommand(value = "workspace list", help = "List workspaces.")
public String list() throws Exception {
    GeoServerRESTReader reader = new GeoServerRESTReader(geoserver.getUrl(), geoserver.getUser(), geoserver.getPassword());
    List<String> names = reader.getWorkspaceNames();
    Collections.sort(names);
    StringBuilder builder = new StringBuilder();
    for (String name : names) {
        builder.append(name + OsUtils.LINE_SEPARATOR);
    }
    return builder.toString();
}