/** Keys for overriding default layer properties */ public static class StyleProperty<T> { T get(Map<StyleProperty, Object> map, T def) { return map != null && map.containsKey(this) ? (T) map.get(this) : def; } public static StyleProperty<String> FORMAT = new StyleProperty<String>(); public static StyleProperty<Version> FORMAT_VERSION = new StyleProperty<Version>(); public static StyleProperty<LegendInfo> LEGEND_INFO = new StyleProperty<LegendInfo>(); }
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); testData.addStyle("relative", "se_relativepath.sld", ResourcePoolTest.class, getCatalog()); testData.addStyle( "relative_protocol", "se_relativepath_protocol.sld", ResourcePoolTest.class, getCatalog()); testData.addStyle(HUMANS, "humans.sld", ResourcePoolTest.class, getCatalog()); testData.addStyle(EXTERNAL_ENTITIES, "externalEntities.sld", TestData.class, getCatalog()); StyleInfo style = getCatalog().getStyleByName("relative"); style.setFormatVersion(new Version("1.1.0")); getCatalog().save(style); style = getCatalog().getStyleByName(HUMANS); style.setFormatVersion(new Version("1.1.0")); getCatalog().save(style); File images = new File(testData.getDataDirectoryRoot(), "styles/images"); assertTrue(images.mkdir()); File image = new File("./src/test/resources/org/geoserver/catalog/rockFillSymbol.png"); assertTrue(image.exists()); FileUtils.copyFileToDirectory(image, images); rockFillSymbolFile = new File(images, image.getName()).getCanonicalFile(); testData.addRasterLayer( TIMERANGES, "timeranges.zip", null, null, SystemTestData.class, getCatalog()); FileUtils.copyFileToDirectory( new File("./src/test/resources/geoserver-environment.properties"), testData.getDataDirectoryRoot()); }
style.setFormatVersion(new Version("1.1.0")); catalog.save(style); File images = new File(testData.getDataDirectoryRoot(), "styles/images");
Version version = Styles.handler(info.getFormat()).version(content); if (version != null) { info.setFormatVersion(version);
info.setFormatVersion(styleHandler.version(styleFile)); info.setWorkspace(task.getStore().getWorkspace());
} else { info.setFormat(handler.getFormat()); info.setFormatVersion(version); writeStyleRaw(info, new ByteArrayInputStream(rawData));
s.setFormatVersion(version); catalog.add(s); styleForm.info("Style saved");
style.setFormat(format); Version version = Styles.handler(format).version(rawStyle); style.setFormatVersion(version);
si.setFormatVersion(version); Style style = dd.parsedStyle(si); if (style != null) {
StyleInfo si = catalog.getFactory().createStyle(); si.setFormat("SLD"); si.setFormatVersion(new Version("1.0")); si.setName(layerInfo.getName()); si.setWorkspace(catalog.getWorkspaceByName(layerConfiguration.getWorkspace()));
/** * Constructs a new StyleInfo object, given a style name and format. * * <p>Note: It is up to the caller to add this style info to the catalog. * * @param workspaceName The workspace of the style, or null for a global style * @param name The name of the style * @param handler StyleHandler, containing format information of the style * @param mimeType Declared mime type of the style * @return A new StyleInfo object, constructed from the provided data * @throws RestException if a style of the given name and workspace already exists in the * catalog. */ private StyleInfo createStyleInfo( String workspaceName, String name, StyleHandler handler, String mimeType) throws RestException { // ensure that the style does not already exist if (catalog.getStyleByName(workspaceName, name) != null) { throw new RestException("Style " + name + " already exists.", HttpStatus.FORBIDDEN); } StyleInfo sinfo = catalog.getFactory().createStyle(); sinfo.setName(name); sinfo.setFilename(name + "." + handler.getFileExtension()); sinfo.setFormat(handler.getFormat()); sinfo.setFormatVersion(handler.versionForMimeType(mimeType)); if (workspaceName != null) { sinfo.setWorkspace(catalog.getWorkspaceByName(workspaceName)); } return sinfo; }