it.geosolutions.geoserver.rest.decoder.RESTStyleList Java Examples

The following examples show how to use it.geosolutions.geoserver.rest.decoder.RESTStyleList. 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
/**
 * Parses the style in default workspace.
 *
 * @param reader the reader
 * @param count the count
 * @param styleList the style list
 * @return the int
 */
private int parseStyleInDefaultWorkspace(
        GeoServerRESTReader reader, int count, List<StyleWrapper> styleList) {
    // Read styles not in a workspace
    RESTStyleList geoServerStyleList = reader.getStyles();

    for (String style : geoServerStyleList.getNames()) {
        StyleWrapper newStyleWrapper = new StyleWrapper(DEFAULT_WORKSPACE_NAME, style);
        styleList.add(newStyleWrapper);

        if (parentObj != null) {
            parentObj.readStylesProgress(connection, count, count);
        }
        count++;
    }
    return count;
}
 
Example #2
Source File: GeoServerClient.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Parses the style in workspace.
 *
 * @param reader the reader
 * @param styleMap the style map
 * @param count the count
 * @param workspaceName the workspace name
 * @return the int
 */
private int parseStyleInWorkspace(
        GeoServerRESTReader reader,
        Map<String, List<StyleWrapper>> styleMap,
        int count,
        String workspaceName) {
    List<StyleWrapper> styleList;
    if (workspaceName != null) {
        RESTStyleList geoServerWorkspaceStyleList = reader.getStyles(workspaceName);

        styleList = new ArrayList<>();

        for (String style : geoServerWorkspaceStyleList.getNames()) {
            StyleWrapper newStyleWrapper = new StyleWrapper(workspaceName, style);
            styleList.add(newStyleWrapper);

            if (parentObj != null) {
                parentObj.readStylesProgress(connection, count, count);
            }
            count++;
        }

        styleMap.put(workspaceName, styleList);
    }
    return count;
}
 
Example #3
Source File: StyleCommands.java    From geoserver-shell with MIT License 5 votes vote down vote up
@CliCommand(value = "style list", help = "List style.")
public String list(
        @CliOption(key = "workspace", mandatory = false, help = "The workspace") String workspace
) throws Exception {
    GeoServerRESTReader reader = new GeoServerRESTReader(geoserver.getUrl(), geoserver.getUser(), geoserver.getPassword());
    RESTStyleList styleList = workspace != null ? this.getStyles(workspace) : reader.getStyles();
    List<String> names = styleList.getNames();
    Collections.sort(names);
    StringBuilder builder = new StringBuilder();
    for (String name : names) {
        builder.append(name + OsUtils.LINE_SEPARATOR);
    }
    return builder.toString();
}
 
Example #4
Source File: StyleCommands.java    From geoserver-shell with MIT License 4 votes vote down vote up
private RESTStyleList getStyles(String workspace) throws Exception {
    String url = "/rest/workspaces/" + URLUtil.encode(workspace) + "/styles.xml";
    return RESTStyleList.build(HTTPUtils.get(geoserver.getUrl() + url, geoserver.getUser(), geoserver.getPassword()));
}