/** * @param connId */ public PostgreSQLWriter( String connId, String schema, Workspace workspace ) { connProvider = workspace.getResource( ConnectionProviderProvider.class, connId ); this.schema = schema; }
@Override public void init( Workspace workspace ) { exceptionSerializers.clear(); Iterator<SerializerProvider> serializers = ServiceLoader.load( SerializerProvider.class, workspace.getModuleClassLoader() ).iterator(); while ( serializers.hasNext() ) { SerializerProvider p = serializers.next(); p.init( workspace ); exceptionSerializers.add( p ); } }
private String analyseWmsConfigurations( HashMap<String, List<FeatureLayer>> map ) throws XMLStreamException { String crs = null; OwsManager mgr = workspace.getResourceManager( OwsManager.class ); XMLInputFactory infac = XMLInputFactory.newInstance(); List<OWS> wmss = mgr.getByOWSClass( WMSController.class ); for ( OWS ows : wmss ) { StreamSource streamSource = new StreamSource( ows.getMetadata().getLocation().getAsStream() ); XMLStreamReader reader = infac.createXMLStreamReader( streamSource ); reader.next(); while ( reader.hasNext() ) { if ( crs == null && reader.isStartElement() && reader.getLocalName().equals( "CRS" ) ) { crs = reader.getElementText(); } if ( reader.isStartElement() && ( reader.getLocalName().equals( "RequestableLayer" ) || reader.getLocalName().equals( "LogicalLayer" ) ) ) { extractLayer( reader, map ); } reader.next(); } } return crs; }
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 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 ); }
@Override public void init() { connProvider = workspace.getResource( ConnectionProviderProvider.class, getConnId() ); LOG.debug( "init" ); try { ConnectionProvider conn = this.workspace.getResource( ConnectionProviderProvider.class, "LOCK_DB" ); lockManager = new DefaultLockManager( this, conn ); } catch ( Throwable e ) { FeatureStoreManager fsMgr = this.workspace.getResourceManager( FeatureStoreManager.class ); if ( fsMgr != null ) { this.bboxCache = fsMgr.getBBoxCache(); try { @SuppressWarnings("unchecked") Class<FeatureInspector> inspectorClass = (Class<FeatureInspector>) workspace.getModuleClassLoader().loadClass( className ); inspectors.add( inspectorClass.newInstance() ); } catch ( Exception e ) {
file.mkdir(); Workspace workspace = new DefaultWorkspace( file ); workspace.getLocationHandler().addExtraResource( ConnectionProviderUtils.getSyntheticProvider( "style", url, user, pass ) ); workspace.initAll(); connProvider = workspace.getResource( ConnectionProviderProvider.class, "style" ); workspace.destroy(); } catch ( ParseException exp ) { System.err.println( Messages.getMessage( "TOOL_COMMANDLINE_ERROR", exp.getMessage() ) );
ResourceLocation<ConnectionProvider> loc = ConnectionProviderUtils.getSyntheticProvider( db_id, con, user, pass ); workspace.getLocationHandler().addExtraResource( loc ); workspace.initAll(); connProvider = workspace.getResource( ConnectionProviderProvider.class, db_id ); } else { db_id = null;
ws.initAll(); FeatureStore fs = ws.getResource( FeatureStoreProvider.class, fsConfigId );
String tmsId = cfg.getTileMatrixSetId(); File file = location.resolveToFile( filename ); TileMatrixSet tms = workspace.getResource( TileMatrixSetProvider.class, tmsId ); GdalSettings gdalSettings = workspace.getInitializable( GdalSettings.class ); gdalSettings.getDatasetPool().addDataset( file, tms.getSpatialMetadata().getCoordinateSystems().get( 0 ) ); List<TileDataLevel> levels = new ArrayList<TileDataLevel>();
ResourceLocation<ConnectionProvider> loc = ConnectionProviderUtils.getSyntheticProvider( id, dbURL, user, pass ); workspace.getLocationHandler().addExtraResource( loc ); workspace.initAll(); } catch ( ResourceInitException e ) { LOG.error( "Initialization failed: {}", e.getLocalizedMessage() ); if ( workspace.getResourceManager( OwsManager.class ) == null ) { throw new FileNotFoundException( "No web service configurations were found in the workspace." ); if ( workspace.getResourceManager( OwsManager.class ).getByOWSClass( WPVSController.class ) == null ) { throw new FileNotFoundException( "No WPVS configuration was found in the workspace." );
ResourceLocation<ConnectionProvider> loc = ConnectionProviderUtils.getSyntheticProvider( "style", url, user, pass ); workspace.startup(); workspace.getLocationHandler().addExtraResource( loc ); workspace.initAll(); style.getName() ); workspace.destroy(); } catch ( ParseException exp ) { System.err.println( Messages.getMessage( "TOOL_COMMANDLINE_ERROR", exp.getMessage() ) );
/** * Simple importer for SE files, with hardcoded 'configtool' on localhost. * * @param args * @throws XMLStreamException * @throws FactoryConfigurationError * @throws IOException */ public static void main( String[] args ) throws XMLStreamException, FactoryConfigurationError, IOException { Style style = new SymbologyParser( true ).parse( XMLInputFactory.newInstance().createXMLStreamReader( new FileInputStream( args[0] ) ) ); Workspace workspace = new DefaultWorkspace( new File( "nonexistant" ) ); ResourceLocation<ConnectionProvider> loc = ConnectionProviderUtils.getSyntheticProvider( "configtool", "jdbc:postgresql://localhost/configtool", "postgres", "postgres" ); workspace.getLocationHandler().addExtraResource( loc ); workspace.initAll(); if ( style.isSimple() ) { new PostgreSQLWriter( "configtool", "schematest", workspace ).write( style, null ); } else { new PostgreSQLWriter( "configtool", "schematest", workspace ).write( new FileInputStream( args[0] ), style.getName() ); } workspace.destroy(); }
ws.initAll(); DefaultResourceIdentifier<FeatureStore> identifier = new DefaultResourceIdentifier<FeatureStore>( FeatureStoreProvider.class, "unknown" ); ws.add( new DefaultResourceLocation<FeatureStore>( new File( storeFile ), identifier ) ); ws.prepare( identifier ); FeatureStore store = ws.init( identifier, null );
serviceConfiguration = workspace.getNewWorkspace().getResourceManager( OwsManager.class ); OwsGlobalConfigLoader loader = workspace.getNewWorkspace().getInitializable( OwsGlobalConfigLoader.class ); mainConfig = loader.getMainConfig(); if ( mainConfig != null ) {
/** * Destroys and initializes all resources connected to the resource with the given id. * * @param workspace * may not be <code>null</code> * @param id * may not be <code>null</code> */ public static void reinitializeChain( Workspace workspace, ResourceIdentifier<? extends Resource> id ) { ResourceNode<? extends Resource> node = workspace.getDependencyGraph().getNode( id ); List<ResourceMetadata<? extends Resource>> list = new ArrayList<ResourceMetadata<? extends Resource>>(); ResourceMetadata<? extends Resource> meta = workspace.getResourceMetadata( id.getProvider(), id.getId() ); if ( meta == null ) { return; } list.add( meta ); collectDependencies( list, node ); collectDependents( list, node ); ResourceGraph g = new ResourceGraph( list ); list = g.toSortedList(); workspace.destroy( list.get( 0 ).getIdentifier() ); for ( ResourceMetadata<? extends Resource> md : list ) { workspace.add( md.getLocation() ); workspace.init( md.getIdentifier(), null ); } }
workspace.initAll(); } catch ( ResourceInitException e1 ) { LOG.error( "Initialization of secure proxy failed: {}", e1.getLocalizedMessage() ); OwsGlobalConfigLoader loader = workspace.getInitializable( OwsGlobalConfigLoader.class ); requestLogger = loader.getRequestLogger();
@Override public void destroy() { workspace.destroy(); }
/** * Returns the service controller instance based on the class of the service controller. * * @param c * class of the requested service controller, e.g. <code>WPSController.getClass()</code> * @return the instance of the requested service used by OGCFrontController, or null if no such service controller * is active */ public List<OWS> getByOWSClass( Class<?> c ) { List<ResourceIdentifier<OWS>> list = workspace.getResourcesOfType( OWSProvider.class ); List<OWS> services = new ArrayList<OWS>(); for ( ResourceIdentifier<OWS> id : list ) { OWS ows = workspace.getResource( OWSProvider.class, id.getId() ); if ( ows != null ) { if ( c == ows.getClass() ) { services.add( ows ); } } } return services; }