@Override public ResourceBuilder<ConnectionProvider> prepare() { try { final Object cfg = unmarshall( JAXB_PACKAGE, SCHEMA_URL, location.getAsStream(), workspace ); return new DataSourceConnectionProviderBuilder( (DataSourceConnectionProvider) cfg, this, workspace ); } catch ( Exception e ) { LOG.error( e.getLocalizedMessage(), e ); throw new ResourceInitException( e.getLocalizedMessage(), e ); } }
private List<File> buildDatasets( List<String> files, ICRS crs ) { List<File> datasets = new ArrayList<File>( files.size() ); for ( String path : files ) { try { File file = metadata.getLocation().resolveToFile( path ).getCanonicalFile(); gdalSettings.getDatasetPool().addDataset( file, crs ); datasets.add( file ); } catch ( IOException e ) { throw new IllegalArgumentException( e.getMessage(), e ); } } return datasets; }
private URI resolveURI( String fileName ) { URI resolve = null; try { URL url = metadata.getLocation().resolveToUrl( fileName ); resolve = url.toURI(); } catch ( URISyntaxException e ) { LOG.warn( "Error while resolving url for file: " + fileName + "." ); } return resolve; }
@Override public <T extends Resource> void deactivate( ResourceLocation<T> location ) { location.deactivate(); states.setState( location.getIdentifier(), Deactivated ); }
@Override public <T extends Resource> void activate( ResourceLocation<T> location ) { location.activate(); states.setState( location.getIdentifier(), Scanned ); }
protected void read( List<ResourceLocation<T>> list ) { for ( ResourceLocation<T> loc : list ) { try { ResourceProvider<T> prov = nsToProvider.get( loc.getNamespace() ); if ( prov != null ) { LOG.info( "Scanning resource {} with provider {}.", loc, prov.getClass().getSimpleName() ); ResourceMetadata<T> md = prov.read( workspace, loc ); metadataMap.put( md.getIdentifier(), md ); } else { LOG.warn( "Not scanning resource {}, no provider found for namespace {}.", loc, loc.getNamespace() ); } } catch ( Exception e ) { LOG.error( "Unable to scan resource {}: {}.", loc.getIdentifier(), e.getLocalizedMessage() ); LOG.trace( "Stack trace:", e ); } } }
@Override public ResourceBuilder<RemoteOWS> prepare() { try { RemoteWMTSConfig cfg = unmarshall( location.getAsStream() ); return new RemoteWmtsBuilder( cfg, this ); } catch ( Exception e ) { String msg = "Remote WMTS store config '" + location.getIdentifier() + "' could not be parsed: " + e.getLocalizedMessage(); throw new ResourceInitException( msg, e ); } }
return null; URL styleFile = location.resolveToUrl( unresolved ); InputStream styleStream = null; Style style; String cd = rasterCache.getValue(); if ( cd != null ) { cacheDir = location.resolveToFile( cd );
@Override public ResourceIdentifier<T> getIdentifier() { return location.getIdentifier(); }
@Override public <T extends Resource> ResourceLocation<T> persist( ResourceLocation<T> location ) { ResourceManager<?> mgr = managers.get( location.getIdentifier().getProvider() ); File file = new File( directory, mgr.getMetadata().getWorkspacePath() ); file = new File( file, location.getIdentifier().getId() + ".xml" ); file.getParentFile().mkdirs(); try { // copy to avoid persisting from same file File tmp = File.createTempFile( "config", ".xml" ); FileUtils.copyInputStreamToFile( location.getAsStream(), tmp ); tmp.renameTo( file ); return new DefaultResourceLocation<T>( file, location.getIdentifier() ); } catch ( Exception e ) { throw new ResourceException( "Could not persist resource location: " + e.getLocalizedMessage(), e ); } }
static FeatureInfoManager buildFeatureInfoManager( FeatureInfoFormatsType conf, ResourceLocation<?> location, Workspace workspace ) throws ResourceInitException { FeatureInfoManager featureInfoManager = new FeatureInfoManager( true ); try { if ( conf != null ) { for ( GetFeatureInfoFormat t : conf.getGetFeatureInfoFormat() ) { if ( t.getFile() != null ) { featureInfoManager.addOrReplaceFormat( t.getFormat(), location.resolveToFile( t.getFile() ).toString() ); } else { XSLTFile xsltFile = t.getXSLTFile(); GMLVersion version = GMLVersion.valueOf( xsltFile.getGmlVersion().toString() ); featureInfoManager.addOrReplaceXsltFormat( t.getFormat(), location.resolveToUrl( xsltFile.getValue() ), version, workspace ); } } } } catch ( Exception e ) { throw new ResourceInitException( "GetFeatureInfo format handler could not be initialized: " + e.getLocalizedMessage(), e ); } return featureInfoManager; }
@Override public int hashCode() { return location.getIdentifier().hashCode(); }
private RemoteWMTSTileStoreJAXB unmarshallConfig() throws JAXBException { return (RemoteWMTSTileStoreJAXB) unmarshall( JAXB_PACKAGE, provider.getSchema(), location.getAsStream(), workspace ); }
@Override public ResourceBuilder<RemoteOWS> prepare() { try { org.deegree.remoteows.wms_new.jaxb.RemoteWMS cfg; cfg = (org.deegree.remoteows.wms_new.jaxb.RemoteWMS) unmarshall( CONFIG_JAXB_PACKAGE, provider.getSchema(), location.getAsStream(), workspace ); return new RemoteWmsBuilder( cfg, this ); } catch ( Exception e ) { throw new ResourceInitException( "Unable to prepare " + location.getIdentifier() + ": " + e.getLocalizedMessage(), e ); } }
@Override public MetadataStore<? extends MetadataRecord> build() { List<File> recordDirectories = new ArrayList<File>(); File insertDirectory = null; try { List<String> isoRecordDirectories = config.getISORecordDirectory(); for ( String isoRecordDirectory : isoRecordDirectories ) { recordDirectories.add( metadata.getLocation().resolveToFile( isoRecordDirectory ) ); } if ( config.getInsertDirectory() != null ) { insertDirectory = metadata.getLocation().resolveToFile( config.getInsertDirectory() ); } else { insertDirectory = recordDirectories.get( 0 ); } return new ISOMemoryMetadataStore( recordDirectories, insertDirectory, metadata ); } catch ( Exception e ) { String msg = "Error setting up iso memory meatadata store from configuration: " + e.getMessage(); throw new ResourceInitException( msg, e ); } }
if ( t.getFile() != null ) { featureInfoManager.addOrReplaceFormat( t.getFormat(), metadata.getLocation().resolveToFile( t.getFile() ).toString() ); } else if ( t.getXSLTFile() != null ) { XSLTFile xsltFile = t.getXSLTFile(); GMLVersion version = GMLVersion.valueOf( xsltFile.getGmlVersion().toString() ); featureInfoManager.addOrReplaceXsltFormat( t.getFormat(), metadata.getLocation().resolveToUrl( xsltFile.getValue() ), version, workspace ); } else if ( t.getSerializer() != null ) {
private URI resolveURI( String fileName ) { URI resolve = null; try { URL url = metadata.getLocation().resolveToUrl( fileName ); resolve = url.toURI(); } catch ( URISyntaxException e ) { LOG.warn( "Error while resolving url for file: " + fileName + "." ); } return resolve; }
@Override public String toString() { return location.getIdentifier().toString(); }
@Override public ProcessProvider build() { try { XMLStreamReader xmlStream = XMLInputFactory.newInstance().createXMLStreamReader( metadata.getLocation().getAsStream() ); while ( xmlStream.getEventType() != XMLStreamConstants.END_DOCUMENT ) { if ( xmlStream.isStartElement() && "Process".equals( xmlStream.getLocalName() ) ) { return new StyleProcessProvider( xmlStream.getAttributeValue( null, "id" ), metadata ); } else { xmlStream.next(); } } } catch ( Exception e ) { throw new ResourceInitException( "Error parsing style process provider configuration '" + metadata.getIdentifier() + "': " + e.getMessage(), e ); } throw new ResourceInitException( "Could not parse style process configuration." ); }
@Override public ResourceBuilder<TileStore> prepare() { try { RemoteWMSTileStoreJAXB config = (RemoteWMSTileStoreJAXB) unmarshall( JAXB_PACKAGE, provider.getSchema(), location.getAsStream(), workspace ); String wmsId = config.getRemoteWMSId(); dependencies.add( new DefaultResourceIdentifier<RemoteOWS>( RemoteOWSProvider.class, wmsId ) ); return new RemoteWmsTileStoreBuilder( config, this, workspace ); } catch ( Exception e ) { throw new ResourceInitException( "Unable to prepare " + location.getIdentifier() + ": " + e.getLocalizedMessage(), e ); } }