@Override public ResourceBuilder<Theme> prepare() { try { RemoteWMSThemes cfg = (RemoteWMSThemes) unmarshall( "org.deegree.theme.persistence.remotewms.jaxb", provider.getSchema(), location.getAsStream(), workspace ); String id = cfg.getRemoteWMSId(); String lid = cfg.getLayerStoreId(); dependencies.add( new DefaultResourceIdentifier<LayerStore>( LayerStoreProvider.class, lid ) ); dependencies.add( new DefaultResourceIdentifier<RemoteOWS>( RemoteOWSProvider.class, id ) ); return new RemoteWmsThemeBuilder( this, workspace, cfg ); } catch ( Exception e ) { throw new ResourceInitException( "Could not parse remote WMS theme config.", e ); } }
@Override public Theme build() { try { String id = cfg.getRemoteWMSId(); String lid = cfg.getLayerStoreId(); LayerStore store = workspace.getResource( LayerStoreProvider.class, lid ); if ( store == null ) { throw new ResourceInitException( "The layer store with id " + lid + " was not available." ); } RemoteOWS ows = workspace.getResource( RemoteOWSProvider.class, id ); if ( !( ows instanceof RemoteWMS ) ) { throw new ResourceInitException( "The remote OWS store with id " + id + " was not of type WMS or was not available." ); } WMSClient client = ( (RemoteWMS) ows ).getClient(); Tree<LayerMetadata> tree = client.getLayerTree(); Theme theme = buildTheme( tree, store ); aggregateSpatialMetadata( theme ); return theme; } catch ( Exception e ) { throw new ResourceInitException( "Could not parse remote WMS theme config.", e ); } }