/** * 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; }
/** * 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; }
@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(); }
List<String> names = styles.getNames(); Iterator<String> iterator = names.iterator();