/** * @param connId */ public PostgreSQLWriter( String connId, String schema, Workspace workspace ) { connProvider = workspace.getResource( ConnectionProviderProvider.class, connId ); this.schema = schema; }
public OWS getSingleConfiguredService() { List<ResourceIdentifier<OWS>> owss = workspace.getResourcesOfType( OWSProvider.class ); if ( owss.size() == 1 ) { return workspace.getResource( OWSProvider.class, owss.get( 0 ).getId() ); } return null; }
private RemoteWMTS getRemoteWmts( String remoteWmtsId ) throws ResourceInitException { RemoteOWS wmts = workspace.getResource( RemoteOWSProvider.class, remoteWmtsId ); if ( !( wmts instanceof RemoteWMTS ) ) { String msg = "The remote WMTS id " + remoteWmtsId + " must correspond to a WMTS instance (was " + wmts.getClass().getSimpleName() + ")"; throw new ResourceInitException( msg ); } return (RemoteWMTS) wmts; }
/** * Returns the process with the specified identifier. * * @param id * identifier of the process, must not be <code>null</code> * @return process with the specified identifier or <code>null</code> if no such process exists */ public WPSProcess getProcess( CodeType id ) { WPSProcess process = null; for ( ResourceIdentifier<ProcessProvider> rid : workspace.getResourcesOfType( ProcessProviderProvider.class ) ) { ProcessProvider prov = workspace.getResource( rid.getProvider(), rid.getId() ); process = prov.getProcess( id ); if ( process != null ) { break; } } return process; }
private TileMatrixSet getLocalTileMatrixSet( String requestTileMatrixSetId, String workspaceTileMatrixSetId ) throws ResourceInitException { String tileMatrixSetId = workspaceTileMatrixSetId; if ( tileMatrixSetId == null ) { tileMatrixSetId = requestTileMatrixSetId; } TileMatrixSet tileMatrixSet = workspace.getResource( TileMatrixSetProvider.class, tileMatrixSetId ); if ( tileMatrixSet == null ) { String msg = "No local TileMatrixSet definition with identifier '" + tileMatrixSetId + "' available."; throw new ResourceInitException( msg ); } return tileMatrixSet; }
/** * @return a connection to the database * @throws SQLException */ public Connection getConnection() throws SQLException { ConnectionProvider prov = workspace.getResource( ConnectionProviderProvider.class, connectionID ); Connection connection = prov.getConnection(); connection.setAutoCommit( true ); return connection; }
@Override public TileStore build() throws ResourceInitException { List<TileStore> tileStores = new ArrayList<TileStore>(); TileMatrixSet tileMatrix = workspace.getResource( TileMatrixSetProvider.class, cfg.getTileMatrixSetId() ); for ( String tileStoreId : cfg.getTileStoreId() ) { TileStore tileStore = workspace.getResource( TileStoreProvider.class, tileStoreId ); if ( tileStore == null ) { throw new ResourceInitException( "Cannot build MergingTileStore: No tile store with id '" + tileStoreId + "' in workspace." ); } tileStores.add( tileStore ); } return new MergingTileStore( metadata, tileMatrix, tileStores ); } }
private static ModelBackend<?> getModelBackend( CommandLine line ) throws UnsupportedOperationException, DatasourceException { String id = "1"; if ( workspace.getResource( ConnectionProviderProvider.class, id ) == null ) { ResourceLocation<ConnectionProvider> loc = getSyntheticProvider( id, line.getOptionValue( DB_HOST ), line.getOptionValue( OPT_DB_USER ), line.getOptionValue( OPT_DB_PASS ) ); workspace.getLocationHandler().addExtraResource( loc ); } return ModelBackend.getInstance( id, null ); }
private static ModelBackend<?> getModelBackend( CommandLine line ) throws UnsupportedOperationException, DatasourceException { String id = "1"; if ( workspace.getResource( ConnectionProviderProvider.class, id ) == null ) { ResourceLocation<ConnectionProvider> loc = getSyntheticProvider( id, line.getOptionValue( DB_HOST ), line.getOptionValue( OPT_DB_USER ), line.getOptionValue( OPT_DB_PASS ) ); workspace.getLocationHandler().addExtraResource( loc ); } return ModelBackend.getInstance( id, null ); }
WmtsBuilder( Workspace workspace, DeegreeWMTS conf ) { this.metadataUrlTemplate = conf.getMetadataURLTemplate(); themes = new ArrayList<Theme>(); List<String> ids = conf.getServiceConfiguration().getThemeId(); for ( String id : ids ) { Theme t = workspace.getResource( ThemeProvider.class, id ); if ( t == null ) { LOG.warn( "Theme with id {} was not available.", id ); continue; } themes.add( t ); } featureInfoConf = conf.getFeatureInfoFormats(); }
private void checkBase( long x, long y, File file ) { if ( baseStoreId != null && !file.exists() ) { file.getParentFile().mkdirs(); TileStore store = workspace.getResource( TileStoreProvider.class, baseStoreId ); TileDataSet set = store.getTileDataSet( baseDataSetId ); TileDataLevel lev = set.getTileDataLevel( metadata.getIdentifier() ); Tile tile = lev.getTile( x, y ); TileStoreTransaction ta = workspace.getResource( TileStoreProvider.class, tsMetadata.getIdentifier().getId() ).acquireTransaction( myId ); ta.put( metadata.getIdentifier(), tile, x, y ); } }
private OWS determineOWSByPath( HttpServletRequest request ) throws OWSException { OWS ows = null; String pathInfo = request.getPathInfo(); if ( pathInfo != null ) { // remove start "/" String serviceId = pathInfo.substring( 1 ); ows = workspace.getNewWorkspace().getResource( OWSProvider.class, serviceId ); if ( ows == null && serviceConfiguration.isSingleServiceConfigured() ) { ows = serviceConfiguration.getSingleConfiguredService(); } if ( ows == null ) { String msg = "No service with identifier '" + serviceId + "' available."; throw new OWSException( msg, NOT_FOUND ); } } return ows; }
@Override public MetadataStore<? extends MetadataRecord> build() { try { ConnectionProvider prov = workspace.getResource( ConnectionProviderProvider.class, cfg.getJDBCConnId() ); SQLDialect dialect = prov.getDialect(); return new ISOMetadataStore( cfg, dialect, metadata, workspace ); } catch ( Exception e ) { String msg = Messages.getMessage( "ERROR_IN_CONFIG_FILE", metadata.getIdentifier(), e.getMessage() ); throw new ResourceInitException( msg, e ); } }
@Override public FeatureStore build() { ConnectionProvider conn = workspace.getResource( ConnectionProviderProvider.class, config.getJDBCConnId().getValue() ); checkConnection( conn ); File file = metadata.getLocation().resolveToFile( metadata.getIdentifier().getId() + ".xml" ); SQLFeatureStore fs = null; try { // TODO rewrite needed to properly resolve files using resource location fs = new SQLFeatureStore( config, file.toURI().toURL(), conn.getDialect(), metadata, workspace ); } catch ( MalformedURLException e ) { LOG.trace( "Stack trace:", e ); } return fs; }
@Override public TileStore build() { try { String cache = cfg.getCacheConfiguration(); File f = new File( cache ); if ( !f.isAbsolute() ) { f = metadata.getLocation().resolveToFile( cache ); } CacheManager cmgr = new CacheManager( f.toURI().toURL() ); TileStore tileStore = workspace.getResource( TileStoreProvider.class, cfg.getTileStoreId() ); return new CachingTileStore( tileStore, cmgr, cfg.getCacheName(), metadata ); } catch ( CacheException e ) { // case needed, as NPE's inside exception can occur otherwise throw new ResourceInitException( "Unable to create tile store: " + e.getMessage() ); } catch ( Exception e ) { throw new ResourceInitException( "Unable to create tile store", e ); } }
Map<String, TileDataSet> extractTileDataSets() throws ResourceInitException { Map<String, TileDataSet> map = new HashMap<String, TileDataSet>(); for ( RemoteWMSTileStoreJAXB.TileDataSet cfg : config.getTileDataSet() ) { String id = cfg.getIdentifier(); String tmsId = cfg.getTileMatrixSetId(); TileMatrixSet tms = workspace.getResource( TileMatrixSetProvider.class, tmsId ); if ( tms == null ) { throw new ResourceInitException( "The tile matrix set with id " + tmsId + " was not available." ); } RequestParams params = cfg.getRequestParams(); map.put( id, buildTileDataSet( params, tms, wms.getClient(), cfg.getOutputFormat() ) ); } return map; }
@Override public LayerStore build() { String id = cfg.getRemoteWMSId(); RemoteOWS store = workspace.getResource( RemoteOWSProvider.class, id ); if ( !( store instanceof RemoteWMS ) ) { throw new ResourceInitException( "The remote WMS store with id " + id + " is not available or not of type WMS." ); } RemoteWmsLayerBuilder builder = new RemoteWmsLayerBuilder( ( (RemoteWMS) store ).getClient(), cfg ); Map<String, Layer> map = builder.buildLayerMap(); return new MultipleLayerStore( map, metadata ); }
CapabilitiesHandler( DeegreeServicesMetadataType mainMetadataConf, Workspace workspace, String metadataUrlTemplate, String wmtsId, List<Theme> themes, FeatureInfoManager mgr ) { this.themes = themes; this.mgr = mgr; identification = convertFromJAXB( mainMetadataConf.getServiceIdentification() ); provider = convertFromJAXB( mainMetadataConf.getServiceProvider() ); OWSMetadataProvider metadata = workspace.getResource( OWSMetadataProviderProvider.class, wmtsId + "_metadata" ); if ( metadata != null ) { identification = metadata.getServiceIdentification(); provider = metadata.getServiceProvider(); } this.metadataUrlTemplate = metadataUrlTemplate; }
LayerStore buildManual( CoverageLayers cfg ) { Map<String, Layer> map = new HashMap<String, Layer>(); Coverage cov = workspace.getResource( CoverageProvider.class, cfg.getCoverageStoreId() ); for ( CoverageLayerType lay : cfg.getCoverageLayer() ) { LayerMetadata md = buildLayerMetadata( lay, cov ); Pair<Map<String, Style>, Map<String, Style>> p = parseStyles( workspace, lay.getName(), lay.getStyleRef() ); md.setStyles( p.first ); md.setLegendStyles( p.second ); Layer l = new CoverageLayer( md, cov instanceof AbstractRaster ? (AbstractRaster) cov : null, cov instanceof MultiResolutionRaster ? (MultiResolutionRaster) cov : null ); map.put( lay.getName(), l ); } return new MultipleLayerStore( map, metadata ); }
@Override public FeatureStore build() { String connId = config.getConnectionPoolId(); if ( connId == null ) { connId = config.getJDBCConnId(); } String srs = config.getStorageCRS(); String stmt = config.getSQLStatement(); String name = config.getFeatureTypeName(); String ns = config.getFeatureTypeNamespace(); String prefix = config.getFeatureTypePrefix(); String bbox = config.getBBoxStatement(); LinkedList<Pair<Integer, String>> lods = map( config.getLODStatement(), lodMapper ); ConnectionProvider prov = workspace.getResource( ConnectionProviderProvider.class, connId ); return new SimpleSQLFeatureStore( prov, srs, stmt, name, ns, prefix, bbox, lods, metadata ); }