/** * Serializes a style to configuration. * * @param info The configuration for the style. * @param style The style object. */ public void writeStyle(StyleInfo info, Style style) throws IOException { writeStyle(info, style, false); }
/** * Returns a coverage reader, caching the result. * * @param info The coverage metadata. * @param hints Hints to use when loading the coverage, may be <code>null</code>. * @throws IOException Any errors that occur loading the reader. */ @SuppressWarnings("deprecation") public GridCoverageReader getGridCoverageReader(CoverageStoreInfo info, Hints hints) throws IOException { return getGridCoverageReader(info, (String) null, hints); }
/** * Writes a raw style to configuration. * * @param style The configuration for the style. * @param in input stream representing the raw a style. */ public void writeStyle(StyleInfo style, InputStream in) throws IOException { synchronized (styleCache) { Resource styleFile = dataDir().style(style); writeStyle(in, styleFile); clear(style); } }
/** * Loads a grid coverage. * * <p> * * @param info The grid coverage metadata. * @param envelope The section of the coverage to load. * @param hints Hints to use while loading the coverage. * @throws IOException Any errors that occur loading the coverage. */ @SuppressWarnings("deprecation") public GridCoverage getGridCoverage( CoverageInfo info, String coverageName, ReferencedEnvelope env, Hints hints) throws IOException { final GridCoverageReader reader = getGridCoverageReader(info, coverageName, hints); if (reader == null) { return null; } return getGridCoverage(info, reader, env, hints); }
FeatureType getFeatureType(FeatureTypeInfo info, boolean handleProjectionPolicy) throws IOException { try { return tryGetFeatureType(info, handleProjectionPolicy); } catch (Exception ex) { LOGGER.log( Level.WARNING, "Error while getting feature type, flushing cache and retrying: {0}", ex.getMessage()); LOGGER.log(Level.FINE, "", ex); this.clear(info); this.flushDataStore(info); return tryGetFeatureType(info, handleProjectionPolicy); } }
@Test public void testEntityExpansionOnValidation() throws Exception { URL url = getClass().getResource("../data/test/externalEntities.sld"); try { Styles.handler("SLD") .validate(url, null, getCatalog().getResourcePool().getEntityResolver()); fail("Should have failed due to the entity resolution attempt"); } catch (Exception e) { String message = e.getMessage(); assertThat(message, containsString("Entity resolution disallowed")); assertThat(message, containsString("/this/file/does/not/exist")); } } }
throws IOException { DataStoreInfo expandedStore = clone(info, true); ResourcePool.getParams( connectionParameters, catalog.getResourceLoader()); factory = getDataStoreFactory(info); } catch (IOException e) { throw new IOException( EntityResolver resolver = getEntityResolver(); if (resolver != null && params != null) { for (Param p : params) {
@Override public void visit(StyleInfo style) { clear(style); } }
public Object getPropertyValue(StoreInfo item) { String type = item.getType(); if(type != null) { return type; } try { ResourcePool resourcePool = getCatalog().getResourcePool(); if(item instanceof DataStoreInfo) { DataStoreInfo dsInfo = (DataStoreInfo) item; DataAccessFactory factory = resourcePool.getDataStoreFactory(dsInfo); if(factory != null) { return factory.getDisplayName(); } } else if(item instanceof CoverageStoreInfo) { Format format = resourcePool.getGridCoverageFormat((CoverageStoreInfo) item); if(format != null) { return format.getName(); } } } catch(Exception e) { // fine, we tried } return "?"; } };
StyleInfo backupStyle(StyleInfo s) throws IOException { StyleInfo backup = catalog.getFactory().createStyle(); new CatalogBuilder(catalog).updateStyle(backup, s); backup.setWorkspace(s.getWorkspace()); // find a unique name for the style String name = findUniqueStyleName( s.getWorkspace() == null ? null : s.getWorkspace().getName(), s.getName() + "_BACKUP"); backup.setName(name); // update it's file name backup.setFilename(name + "." + FilenameUtils.getExtension(s.getFilename())); // copy over the style contents try (BufferedReader reader = catalog.getResourcePool().readStyle(s)) { catalog.getResourcePool() .writeStyle(backup, new ByteArrayInputStream(IOUtils.toByteArray(reader))); } return backup; }
WMSStoreInfo expandedStore = clone(info, true); EntityResolver entityResolver = getEntityResolver(); wms = wmsCache.get(id); if (wms == null) { HTTPClient client = getHTTPClient(expandedStore); String capabilitiesURL = expandedStore.getCapabilitiesURL(); URL serverURL = new URL(capabilitiesURL);
resourcePool.clear(info); dataStore = catalog.getResourcePool().getDataStore(info); LOGGER.finer("connection parameters verified for store " + info.getName() + ". Got a " + dataStore.getClass().getName());
DataAccess<? extends FeatureType, ? extends Feature> dataStore = pool.getDataStore(info); assertNotNull(dataStore); assertFalse(disposeCalled); pool.clear(info); assertTrue(disposeCalled); dataStore = pool.getDataStore(info); assertNotNull(dataStore); disposeCalled = false; pool.dispose(); assertTrue(disposeCalled);
dataStore = getDataStore(ds); } catch (IOException e) { LOGGER.log( return; final int dsFtCount = countFeatureTypesOf(ds); if (dsFtCount == 0) { "Feature Type {0} cleared: Disposing DataStore {1} - {2}", new String[] {ft.getName(), ds.getName(), "Last Feature Type Disposed"}); clear(ds); } else { if (dataStore instanceof ContentDataStore) { flushState(contentDataStore, nativeName); LOGGER.log( Level.FINE,
getCatalog() .getResourcePool() .writeStyle(stylePath, new ByteArrayInputStream(rawStyle.getBytes())); } catch (IOException e) { throw new WicketRuntimeException(e); getCatalog().getResourcePool().getStyle(stylePath);
FeatureTypeInfo info, Hints hints) throws IOException { DataAccess<? extends FeatureType, ? extends Feature> dataAccess = getDataStore(info.getStore()); FeatureTypeCallback initializer = getFeatureTypeInitializer(info, dataAccess); if (initializer != null) { initializer.initialize(info, dataAccess, null); final SimpleFeatureType nativeFeatureType = dataStore.getSchema(typeName); final SimpleFeatureType renamedFeatureType = (SimpleFeatureType) getFeatureType(info, false); if (!typeName.equals(alias) || DataUtilities.compare(nativeFeatureType, renamedFeatureType) != 0) { resultCRS = nativeCRS; } else { resultCRS = getCRS(info.getSRS()); SimpleFeatureType schema = (SimpleFeatureType) getFeatureType(info); try { if (!CRS.equalsIgnoreMetadata(resultCRS, schema.getCoordinateReferenceSystem())) resultCRS, info.getProjectionPolicy().getCode(), getTolerance(info), info.getMetadata());
factory = getCatalog().getResourcePool().getDataStoreFactory((DataStoreInfo) info); } catch (IOException e) { LOGGER.log(
@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(); }
/** * Serializes a style to configuration optionally formatting the style when writing it. * * @param info The configuration for the style. * @param style The style object. * @param format Whether to format the style */ public void writeSLD(StyleInfo info, StyledLayerDescriptor style, boolean format) throws IOException { synchronized (sldCache) { Resource styleFile = dataDir().style(info); BufferedOutputStream out = new BufferedOutputStream(styleFile.out()); try { Styles.handler(info.getFormat()) .encode(style, info.getFormatVersion(), format, out); clear(info); } finally { out.close(); } } }