public String getURL() { return delegate.getURL(); }
final String urlString = expandedStore.getURL(); Object readObject = getObjectToRead(urlString);
@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); }
expect(cs.getURL()).andReturn(URLs.fileToUrl(covFile).toString()).anyTimes(); expect(cs.getType()) .andAnswer(
expect(csi.getURL()).andReturn(rasterSource).anyTimes(); expect(csi.getFormat()).andReturn(format).anyTimes(); expect(csi.getId()).andReturn("ThisIsMe").anyTimes();
replay(format); CoverageStoreInfo storeInfo = createNiceMock("storeInfo", CoverageStoreInfo.class); expect(storeInfo.getURL()).andReturn(url).anyTimes(); expect(storeInfo.getFormat()).andReturn(format).anyTimes(); replay(storeInfo);
catalog.save(savedStore); } catch (RuntimeException e) { LOGGER.log(Level.INFO, "Adding the store for " + info.getURL(), e); throw new IllegalArgumentException( "The coverage store could not be saved. Failure message: " + e.getMessage()); layerChooserPage = new NewLayerPage(savedStore.getId()); } catch (RuntimeException e) { LOGGER.log(Level.INFO, "Getting list of coverages for saved store " + info.getURL(), e);
protected void onSuccessfulSave( final CoverageStoreInfo info, final Catalog catalog, CoverageStoreInfo savedStore) { // the StoreInfo save succeeded... try to present the list of coverages (well, _the_ // coverage while the getotools coverage api does not allow for more than one NewLayerPage layerChooserPage; CoverageStoreInfo expandedStore; try { expandedStore = catalog.getResourcePool().clone(savedStore, true); // The ID is assigned by the catalog and therefore cannot be cloned layerChooserPage = new NewLayerPage(savedStore.getId()); } catch (RuntimeException e) { LOGGER.log(Level.INFO, "Getting list of coverages for saved store " + info.getURL(), e); // doh, can't present the list of coverages, means saving the StoreInfo is meaningless. try { // be extra cautious catalog.remove(savedStore); } catch (RuntimeErrorException shouldNotHappen) { LOGGER.log(Level.WARNING, "Can't remove CoverageStoreInfo after adding it!", e); } // tell the caller why we failed... throw new IllegalArgumentException(e.getMessage(), e); } setResponsePage(layerChooserPage); } }
URLs.urlToFile(new URL(coverage.getURL())).getPath(), catalog.getResourceLoader().get(""));
LOGGER.log(Level.WARNING, "Saving the store for " + info.getURL(), e); throw new IllegalArgumentException("Unable to save the store: " + e.getMessage());
URLs.urlToFile(new URL(coverage.getURL())).getPath(), catalog.getResourceLoader().get(""));
@Override protected void onSave(final CoverageStoreInfo info, AjaxRequestTarget target) throws IllegalArgumentException { final Catalog catalog = getCatalog(); /* * Try saving a copy of it so if the process fails somehow the original "info" does not end * up with an id set */ CoverageStoreInfo expandedStore = getCatalog().getResourcePool().clone(info, true); CoverageStoreInfo savedStore = catalog.getFactory().createCoverageStore(); // GR: this shouldn't fail, the Catalog.save(StoreInfo) API does not declare any action in // case // of a failure!... strange, why a save can't fail? // Still, be cautious and wrap it in a try/catch block so the page does not blow up try { // GeoServer Env substitution; validate first catalog.validate(expandedStore, false).throwIfInvalid(); // GeoServer Env substitution; force to *AVOID* resolving env placeholders... savedStore = catalog.getResourcePool().clone(info, false); // ... and save catalog.save(savedStore); } catch (RuntimeException e) { LOGGER.log(Level.INFO, "Adding the store for " + info.getURL(), e); throw new IllegalArgumentException( "The coverage store could not be saved. Failure message: " + e.getMessage()); } onSuccessfulSave(info, catalog, savedStore); }
LOGGER.log(Level.WARNING, "Saving the store for " + info.getURL(), e); throw new IllegalArgumentException("Unable to save the store: " + e.getMessage());
@Override public void visit(CoverageStoreInfo coverageStore) { CoverageStoreInfo otherCoverageStore = otherCatalog.getCoverageStore(coverageStore.getId()); if (!(Objects.equals(coverageStore, otherCoverageStore) && Objects.equals(coverageStore.getType(), otherCoverageStore.getType()) && Objects.equals(coverageStore.getFormat(), otherCoverageStore.getFormat()) && Objects.equals(coverageStore.getURL(), otherCoverageStore.getURL()) && checkEquals(coverageStore.getMetadata(), otherCoverageStore.getMetadata()) && checkEquals( coverageStore.getConnectionParameters(), otherCoverageStore.getConnectionParameters()))) { differences.add(new InfoDiff(coverageStore, otherCoverageStore)); } }
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()); }
@Test public void testSuccessAndCleanup() throws SchedulerException { dataUtil.setConfigurationAttribute(config, ATT_FILE_SERVICE, FILE_SERVICE); dataUtil.setConfigurationAttribute(config, ATT_FILE, FILE_LOCATION); dataUtil.setConfigurationAttribute(config, ATT_LAYER, LAYER_NAME); config = dao.save(config); Trigger trigger = TriggerBuilder.newTrigger().forJob(batch.getId().toString()).startNow().build(); scheduler.scheduleJob(trigger); while (scheduler.getTriggerState(trigger.getKey()) != TriggerState.NONE) {} assertNotNull(catalog.getLayerByName(LAYER_NAME)); CoverageStoreInfo csi = catalog.getStoreByName(WORKSPACE, COVERAGE_NAME, CoverageStoreInfo.class); assertNotNull(csi); assertEquals(fileServices.get(FILE_SERVICE).getURI(FILE_LOCATION).toString(), csi.getURL()); assertNotNull(catalog.getResourceByName(LAYER_NAME, CoverageInfo.class)); taskUtil.cleanup(config); assertNull(catalog.getLayerByName(LAYER_NAME)); assertNull(catalog.getStoreByName(WORKSPACE, COVERAGE_NAME, CoverageStoreInfo.class)); assertNull(catalog.getResourceByName(LAYER_NAME, CoverageInfo.class)); }
int originalCount = gs.getCount(Query.ALL); String mosaicLocation = store.getURL(); File mosaicFolder = URLs.urlToFile(new URL(mosaicLocation));
@Test public void testImportGeoTIFFFromDataDir() throws Exception { File dataDir = getCatalog().getResourceLoader().getBaseDirectory(); File dir = unpack("geotiff/EmissiveCampania.tif.bz2", dataDir); ImportContext context = importer.createContext(new SpatialFile(new File(dir, "EmissiveCampania.tif"))); assertEquals(1, context.getTasks().size()); ImportTask task = context.getTasks().get(0); assertEquals(ImportTask.State.READY, task.getState()); assertEquals("EmissiveCampania", task.getLayer().getResource().getName()); importer.run(context); Catalog cat = getCatalog(); assertNotNull(cat.getLayerByName("EmissiveCampania")); assertEquals(ImportTask.State.COMPLETE, task.getState()); assertEquals( "file:EmissiveCampania.tif", ((CoverageStoreInfo) task.getLayer().getResource().getStore()).getURL()); runChecks("EmissiveCampania"); }