public void setURL(String url) { delegate.setURL(url); }
void importFormats(CatalogFactory factory, List formats) { for (Iterator f = formats.iterator(); f.hasNext(); ) { Map map = (Map) f.next(); CoverageStoreInfo coverageStore = factory.createCoverageStore(); coverageStore.setName((String) map.get("id")); coverageStore.setType((String) map.get("type")); coverageStore.setURL((String) map.get("url")); coverageStore.setDescription((String) map.get("description")); String namespacePrefix = (String) map.get("namespace"); // coverageStore.setNamespace( catalog.getNamespaceByPrefix( namespacePrefix )); coverageStore.setWorkspace(catalog.getWorkspaceByName(namespacePrefix)); coverageStore.setEnabled((Boolean) map.get("enabled")); catalog.add(coverageStore); LOGGER.info( "Processed coverage store '" + coverageStore.getName() + "', " + (coverageStore.isEnabled() ? "enabled" : "disabled")); } }
/** 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>(); }
@Test public void testMosaicParameters() throws Exception { // build a mosaic with 1025 files (the standard ulimit is 1024) File mosaic = new File("./target/smallMosaic"); try { createTimeMosaic(mosaic, 4); // now configure a new store based on it Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); CoverageStoreInfo store = cb.buildCoverageStore("smallMosaic"); store.setURL(mosaic.getAbsolutePath()); store.setType("ImageMosaic"); cat.add(store); // and configure also the coverage cb.setStore(store); CoverageInfo ci = cb.buildCoverage(); cat.add(ci); // check the parameters have the default values assertEquals( String.valueOf(-1), ci.getParameters() .get(ImageMosaicFormat.MAX_ALLOWED_TILES.getName().toString())); assertEquals("", ci.getParameters().get(ImageMosaicFormat.FILTER.getName().toString())); cat.getResourcePool().dispose(); } finally { if (mosaic.exists() && mosaic.isDirectory()) { FileUtils.deleteDirectory(mosaic); } } }
@Test public void testLargeNDMosaic() throws Exception { // build a mosaic with 1025 files (the standard ulimit is 1024) File mosaic = new File("./target/largeMosaic"); try { createTimeMosaic(mosaic, 1025); // now configure a new store based on it Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); CoverageStoreInfo store = cb.buildCoverageStore("largeMosaic"); store.setURL(mosaic.getAbsolutePath()); store.setType("ImageMosaic"); cat.add(store); // and configure also the coverage cb.setStore(store); CoverageInfo ci = cb.buildCoverage(); cat.add(ci); cat.getResourcePool().dispose(); } finally { if (mosaic.exists() && mosaic.isDirectory()) { FileUtils.deleteDirectory(mosaic); } } }
@Test public void testModifyCoverageStore() throws Exception { testAddCoverageStore(); CoverageStoreInfo cs = catalog.getCoverageStoreByName("acme", "foostore"); assertNull(cs.getURL()); cs.setURL("file:data/foo.tiff"); catalog.save(cs); File f = new File( testData.getDataDirectoryRoot(), "workspaces/acme/foostore/coveragestore.xml"); Document dom = dom(f); assertXpathEvaluatesTo("file:data/foo.tiff", "/coverageStore/url/text()", dom); }
@Test public void testAddFilePathWithSpaces() throws Exception { // Other tests mess with or reset the resourcePool, so lets make it is initialised properly GeoServerExtensions.extensions(ResourcePoolInitializer.class) .get(0) .initialize(getGeoServer()); ResourcePool rp = getCatalog().getResourcePool(); CoverageStoreInfo info = getCatalog().getFactory().createCoverageStore(); info.setName("spaces"); info.setType("ImagePyramid"); info.setEnabled(true); info.setURL( "file://./src/test/resources/data_dir/nested_layer_groups/data/pyramid with space"); try { rp.getGridCoverageReader(info, null); } catch (Exception e) { e.printStackTrace(); fail("Unable to add an imagepyramid with a space in it's name"); } rp.dispose(); }
@Test public void testDropCoverageStore() throws Exception { // build the store Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); CoverageStoreInfo store = cb.buildCoverageStore("dem"); store.setURL(MockData.class.getResource("tazdem.tiff").toExternalForm()); store.setType("GeoTIFF"); cat.add(store); // build the coverage cb.setStore(store); CoverageInfo ci = cb.buildCoverage(); cat.add(ci); // build the layer LayerInfo layer = cb.buildLayer(ci); cat.add(layer); // grab a reader just to inizialize the code ci.getGridCoverage(null, null); ci.getGridCoverageReader(null, GeoTools.getDefaultHints()); // now drop the store CascadeDeleteVisitor visitor = new CascadeDeleteVisitor(cat); visitor.visit(store); // and reload (GEOS-4782 -> BOOM!) getGeoServer().reload(); }
cs.setName("csName"); cs.setType("fakeCoverageType"); cs.setURL("file://fake");
@Override public CoverageStoreInfo createStore(ImportData data, WorkspaceInfo workspace, Catalog catalog) throws IOException { MosaicIndex index = new MosaicIndex((Mosaic) data); index.write(); CoverageStoreInfo store = super.createStore(data, workspace, catalog); store.setURL(URLs.fileToUrl(index.getFile()).toString()); return store; }
@Override public CoverageStoreInfo createStore(ImportData data, WorkspaceInfo workspace, Catalog catalog) throws IOException { MosaicIndex index = new MosaicIndex((Mosaic) data); index.write(); CoverageStoreInfo store = super.createStore(data, workspace, catalog); store.setURL(DataUtilities.fileToURL(index.getFile()).toString()); return store; }
public void validate(final Form form) { CoverageStoreInfo storeInfo = (CoverageStoreInfo) form.getModelObject(); String coverageUrl = urlFormComponent.getValue(); if (enabled.getModelObject()) { coverageUrl = advancedConfigPanel.buildURL() + coverageUrl; } storeInfo.setURL(coverageUrl); } });
@Override public CoverageStoreInfo createStore(ImportData data, WorkspaceInfo workspace, Catalog catalog) throws IOException { File f = file(data); if (f == null) { return null; } CatalogBuilder cb = new CatalogBuilder(catalog); cb.setWorkspace(workspace); CoverageStoreInfo store = cb.buildCoverageStore(data.getName()); store.setURL(f.toURI().toURL().toString()); store.setType(gridFormat().getName()); return store; }
@Override public CoverageStoreInfo createStore(ImportData data, WorkspaceInfo workspace, Catalog catalog) throws IOException { File f = file(data); if (f == null) { return null; } CatalogBuilder cb = new CatalogBuilder(catalog); cb.setWorkspace(workspace); CoverageStoreInfo store = cb.buildCoverageStore(data.getName()); store.setURL(relativeDataFileURL(f.toURI().toURL().toString(), catalog)); store.setType(gridFormat().getName()); return store; }
/** * @param coverageFactoryName the {@link Format#getName() name} of the format to create a new * raster coverage for */ public CoverageStoreNewPage(final String coverageFactoryName) { Catalog catalog = getCatalog(); final WorkspaceInfo workspace = catalog.getDefaultWorkspace(); CoverageStoreInfo store = catalog.getFactory().createCoverageStore(); store.setWorkspace(workspace); store.setType(coverageFactoryName); store.setEnabled(true); store.setURL("file:data/example.extension"); initUI(store); }
protected void clone(final CoverageStoreInfo source, CoverageStoreInfo target) { target.setDescription(source.getDescription()); target.setEnabled(source.isEnabled()); target.setName(source.getName()); target.setType(source.getType()); target.setURL(source.getURL()); target.setWorkspace(source.getWorkspace()); }
public void testSkipMisconfigured() throws Exception { // enable skipping of misconfigured layers GeoServerInfo global = getGeoServer().getGlobal(); global.setResourceErrorHandling(ResourceErrorHandling.SKIP_MISCONFIGURED_LAYERS); getGeoServer().save(global); // manually misconfigure one layer CoverageStoreInfo cvInfo = getCatalog().getCoverageStoreByName(MockData.TASMANIA_DEM.getLocalPart()); cvInfo.setURL("file:///I/AM/NOT/THERE"); getCatalog().save(cvInfo); // check we got everything but that specific layer, and that the output is still schema compliant Document dom = getAsDOM(BASEPATH + "?request=GetCapabilities&service=WCS&version=1.0.0"); checkValidationErrors(dom, WCS10_DESCRIBECOVERAGE_SCHEMA); int count = getCatalog().getCoverages().size(); assertEquals(count - 1, dom.getElementsByTagName("wcs:CoverageOfferingBrief").getLength()); }
public void testSkipMisconfigured() throws Exception { // enable skipping of misconfigured layers GeoServerInfo global = getGeoServer().getGlobal(); global.setResourceErrorHandling(ResourceErrorHandling.SKIP_MISCONFIGURED_LAYERS); getGeoServer().save(global); // manually misconfigure one layer CoverageStoreInfo cvInfo = getCatalog().getCoverageStoreByName(MockData.TASMANIA_DEM.getLocalPart()); cvInfo.setURL("file:///I/AM/NOT/THERE"); getCatalog().save(cvInfo); Document dom = getAsDOM(BASEPATH + "?request=DescribeCoverage&service=WCS&version=1.0.0"); checkValidationErrors(dom, WCS10_DESCRIBECOVERAGE_SCHEMA); int count = getCatalog().getCoverages().size(); assertEquals(count - 1, dom.getElementsByTagName("wcs:CoverageOffering").getLength()); }
/** Helper method that creates a static raster store and adds it to the catalog. */ private StoreInfo createStaticRasterStore(WorkspaceInfo workspace) { Catalog catalog = getCatalog(); CoverageStoreInfo store = catalog.getFactory().createCoverageStore(); store.setWorkspace(workspace); store.setType("StaticRaster"); store.setEnabled(true); store.setName("StaticRaster"); // some fictive URL store.setURL("http://127.0.0.1:geoserver"); // add the store to the catalog catalog.add(store); return store; }