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 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" ) ) ); } }
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." );
List<OWS> wpvsControllers = wsConfig.getByOWSClass( WPVSController.class ); if ( wpvsControllers.isEmpty() ) { throw new ServiceInitException( "No active WPVS found in workspace." );