public DefaultCoverageBuilder( Object config, ResourceMetadata<Coverage> metadata ) { this.config = config; this.metadata = metadata; this.location = metadata.getLocation(); }
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; }
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 boolean equals( Object obj ) { if ( !( obj instanceof ResourceMetadata ) ) { return false; } return location.getIdentifier().equals( ( (ResourceMetadata) obj ).getLocation().getIdentifier() ); }
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; }
@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." ); }
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; }
@Override public StyleStore build() { InputStream in = null; XMLStreamReader reader = null; try { in = metadata.getLocation().getAsStream(); XMLInputFactory fac = XMLInputFactory.newInstance(); reader = fac.createXMLStreamReader( in ); SymbologyParser parser = new SymbologyParser( metadata.getLocation() ); Style style = parser.parse( reader ); return new SEStyleStore( style, metadata ); } catch ( Exception e ) { throw new ResourceInitException( "Could not read SE style file.", e ); } finally { try { if ( reader != null ) { reader.close(); } } catch ( XMLStreamException e ) { // eat it } closeQuietly( in ); } }
@Override public TileStore build() { try { GdalTileDataSetMapBuilder builder = new GdalTileDataSetMapBuilder( workspace, metadata.getLocation(), cfg ); Map<String, TileDataSet> map = builder.buildTileDataSetMap(); return new GenericTileStore( map, metadata ); } catch ( Exception e ) { e.printStackTrace(); throw new ResourceInitException( "Unable to build GDALTileStore: " + e.getLocalizedMessage(), e ); } }
public void transform() throws TransformerException, XMLStreamException { OwsManager mgr = workspace.getResourceManager( OwsManager.class ); List<OWS> wmss = mgr.getByOWSClass( WMSController.class ); for ( OWS ows : wmss ) { ResourceMetadata<? extends Resource> md = ows.getMetadata(); ResourceIdentifier<? extends Resource> id = md.getIdentifier(); File loc = md.getLocation().resolveToFile( id.getId() + ".xml" ); ByteArrayOutputStream bos = new ByteArrayOutputStream(); transformer.transform( new StreamSource( loc ), new StreamResult( bos ) ); ThemeXmlStreamEncoder.writeOut( bos ); WorkspaceUtils.activateSynthetic( workspace, ThemeProvider.class, id.getId(), new String( bos.toByteArray(), Charset.forName( "UTF-8" ) ) ); } }
@Override public TileStore build() { try { GeoTiffTileDataSetMapBuilder builder = new GeoTiffTileDataSetMapBuilder( workspace, metadata.getLocation(), cfg ); Map<String, TileDataSet> map = builder.buildTileDataSetMap(); return new GenericTileStore( map, metadata ); } catch ( Exception e ) { throw new ResourceInitException( "Unable to build GeoTiff tile store: " + 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 ); } }
@Override public BatchedMTStore build() { BatchedMTStore bs = null; try { CRSManager.getCRSRef( config.getCrs() ); URL dir = metadata.getLocation().resolveToUrl( config.getDirectory() ); int maxDirectMem = config.getMaxDirectMemory().intValue(); bs = new BatchedMTFileStore( dir, maxDirectMem, metadata ); } catch ( Exception e ) { throw new ResourceInitException( "Unable to build batched MT store: " + e.getLocalizedMessage(), e ); } return bs; }
/** * @return the parsed ServiceConfiguration * @throws XMLProcessingException */ public static ServiceConfiguration parse( Workspace workspace, ResourceMetadata<OWS> metadata ) throws XMLProcessingException { try { DeegreeWCS wcsConf = (DeegreeWCS) unmarshall( "org.deegree.services.jaxb.wcs", ( (OWSProvider) metadata.getProvider() ).getSchema(), metadata.getLocation().getAsStream(), workspace ); return wcsConf.getServiceConfiguration(); } catch ( JAXBException e ) { throw new XMLProcessingException( e.getMessage(), e ); } }
private WMTSClient createClient() throws OWSExceptionReport, XMLStreamException, IOException { URL capas = metadata.getLocation().resolveToUrl( config.getCapabilitiesDocumentLocation().getLocation() ); OwsHttpClient httpClient = createOwsHttpClient( config ); return new WMTSClient( capas, httpClient ); }
@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 ); } }
@Override public void init( DeegreeServicesMetadataType serviceMetadata, DeegreeServiceControllerType mainConfig, Object controllerConf ) { WmtsBuilder builder = new WmtsBuilder( workspace, (DeegreeWMTS) controllerConf ); this.metadataUrlTemplate = builder.getMetadataUrlTemplate(); dispatcher = new WmtsRequestDispatcher( (DeegreeWMTS) controllerConf, serviceMetadata, workspace, builder, getMetadata().getIdentifier().getId(), getMetadata().getLocation() ); }
@Override public void init( DeegreeServicesMetadataType serviceMetadata, DeegreeServiceControllerType mainConf, Object controllerConf ) { LOG.info( "Checking for JOGL." ); JOGLChecker.check(); LOG.info( "JOGL status check successful." ); identification = serviceMetadata.getServiceIdentification(); provider = serviceMetadata.getServiceProvider(); DeegreeWPVS cfg = (DeegreeWPVS) controllerConf; NamespaceBindings nsContext = new NamespaceBindings(); nsContext.addNamespace( "wpvs", "http://www.deegree.org/services/wpvs" ); try { publishedInformation = cfg.getPublishedInformation(); parsePublishedInformation( nsContext, publishedInformation ); ServiceConfiguration sc = cfg.getServiceConfiguration(); service = new PerspectiveViewService( metadata.getLocation(), sc, workspace ); } catch ( ServiceInitException e ) { throw new ResourceInitException( e.getMessage(), e ); } }
private void addSupportedCapabilitiesFormats( DeegreeWMS conf ) throws InstantiationException, IllegalAccessException { if ( conf.getGetCapabilitiesFormats() != null ) { for ( GetCapabilitiesFormat getCapabilitiesFormat : conf.getGetCapabilitiesFormats().getGetCapabilitiesFormat() ) { if ( getCapabilitiesFormat.getXSLTFile() != null ) { String format = getCapabilitiesFormat.getFormat(); String xsltFile = getCapabilitiesFormat.getXSLTFile(); URL xsltUrl = metadata.getLocation().resolveToUrl( xsltFile ); capabilitiesManager.addOrReplaceXsltFormat( format, xsltUrl, workspace ); } } } }
private void addSupportedExceptionFormats( DeegreeWMS conf ) throws InstantiationException, IllegalAccessException { if ( conf.getExceptionFormats() != null ) { for ( ExceptionFormat exceptionFormat : conf.getExceptionFormats().getExceptionFormat() ) { if ( exceptionFormat.getXSLTFile() != null ) { String format = exceptionFormat.getFormat(); String xsltFile = exceptionFormat.getXSLTFile(); URL xsltUrl = metadata.getLocation().resolveToUrl( xsltFile ); exceptionsManager.addOrReplaceXsltFormat( format, xsltUrl, workspace ); } } } }