@Override public ResourceIdentifier<T> getIdentifier() { return location.getIdentifier(); }
@Override public int hashCode() { return location.getIdentifier().hashCode(); }
@Override public String toString() { return location.getIdentifier().toString(); }
@Override public boolean equals( Object obj ) { if ( !( obj instanceof ResourceMetadata ) ) { return false; } return location.getIdentifier().equals( ( (ResourceMetadata) obj ).getLocation().getIdentifier() ); }
@Override public ResourceMetadata<OWSMetadataProvider> add( ResourceLocation<OWSMetadataProvider> location ) { // else new locations will be filtered out super.read( Collections.singletonList( location ) ); return metadataMap.get( location.getIdentifier() ); }
@Override public void addExtraResource( ResourceLocation<? extends Resource> location ) { List<ResourceLocation<? extends Resource>> list = extraResources.get( location.getIdentifier().getProvider() ); if ( list == null ) { list = new ArrayList<ResourceLocation<? extends Resource>>(); extraResources.put( location.getIdentifier().getProvider(), list ); } list.add( location ); }
@Override public ResourceMetadata<T> add( ResourceLocation<T> location ) { read( Collections.singletonList( location ) ); return metadataMap.get( location.getIdentifier() ); }
@Override public <T extends Resource> void add( ResourceLocation<T> location ) { LOG.info( "Scanning {}", location.getIdentifier() ); ResourceManager<T> mgr = (ResourceManager) resourceManagers.get( location.getIdentifier().getProvider() ); ResourceMetadata<T> md = mgr.add( location ); resourceMetadata.put( md.getIdentifier(), md ); }
@Override protected void read( List<ResourceLocation<OWSMetadataProvider>> list ) { list = new ArrayList<ResourceLocation<OWSMetadataProvider>>( list ); ListIterator<ResourceLocation<OWSMetadataProvider>> iter = list.listIterator(); while ( iter.hasNext() ) { ResourceLocation<OWSMetadataProvider> loc = iter.next(); if ( !loc.getIdentifier().getId().endsWith( "_metadata" ) ) { iter.remove(); } } super.read( list ); }
@Override protected void read( List<ResourceLocation<OWS>> list ) { ListIterator<ResourceLocation<OWS>> iter = list.listIterator(); while ( iter.hasNext() ) { ResourceLocation<OWS> loc = iter.next(); if ( loc.getIdentifier().getId().endsWith( "_metadata" ) ) { iter.remove(); } if ( loc.getIdentifier().getId().equals( "metadata" ) | loc.getIdentifier().getId().equals( "main" ) ) { iter.remove(); } } super.read( list ); }
@Override protected void read( List<ResourceLocation<TileStore>> list ) { ListIterator<ResourceLocation<TileStore>> iter = list.listIterator(); while ( iter.hasNext() ) { ResourceLocation<TileStore> loc = iter.next(); if ( loc.getIdentifier().getId().startsWith( "tilematrixset" ) ) { iter.remove(); } } super.read( list ); }
@Override public <T extends Resource> void activate( ResourceLocation<T> location ) { location.activate(); states.setState( location.getIdentifier(), Scanned ); }
@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 ); } }
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 <T extends Resource> void deactivate( ResourceLocation<T> location ) { location.deactivate(); states.setState( location.getIdentifier(), Deactivated ); }
@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 ); } }
@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 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 ); } }
@Override public ResourceBuilder<MetadataStore<? extends MetadataRecord>> prepare() { EbrimEOMDStoreConfig storeConfig; try { storeConfig = (EbrimEOMDStoreConfig) JAXBUtils.unmarshall( CONFIG_JAXB_PACKAGE, provider.getSchema(), location.getAsStream(), workspace ); dependencies.add( new DefaultResourceIdentifier<ConnectionProvider>( ConnectionProviderProvider.class, storeConfig.getJDBCConnId() ) ); return new EbrimEOMDStoreBuilder( this, workspace, storeConfig ); } catch ( Exception e ) { String msg = Messages.getMessage( "ERROR_IN_CONFIG_FILE", location.getIdentifier(), e.getMessage() ); throw new ResourceInitException( msg, e ); } }
@Override public ResourceBuilder<MetadataStore<? extends MetadataRecord>> prepare() { try { ISOMetadataStoreConfig cfg = (ISOMetadataStoreConfig) JAXBUtils.unmarshall( "org.deegree.metadata.persistence.iso19115.jaxb", provider.getSchema(), location.getAsStream(), workspace ); dependencies.add( new DefaultResourceIdentifier<ConnectionProvider>( ConnectionProviderProvider.class, cfg.getJDBCConnId() ) ); return new IsoMetadataStoreBuilder( cfg, this, workspace ); } catch ( Exception e ) { String msg = Messages.getMessage( "ERROR_IN_CONFIG_FILE", location.getIdentifier(), e.getMessage() ); throw new ResourceInitException( msg, e ); } }