public boolean isSingleServiceConfigured() { return getSingleConfiguredService() != null; }
/** * Sends an {@link OWSException} to the client. * * @param contentType * @param encoding * @param additionalHeaders * @param httpStatusCode * @param serializer * @param exception */ public void sendException( String contentType, Map<String, String> additionalHeaders, int httpStatusCode, ExceptionSerializer serializer, OWSException exception ) { rollback(); } }
public String getMetadataURLTemplate() { // TODO handle this properly in init(), needs service level dependency management if ( metadataURLTemplate == null ) { OwsManager mgr = workspace.getResourceManager( OwsManager.class ); Map<String, List<OWS>> ctrls = mgr.getAll(); for ( List<OWS> lists : ctrls.values() ) { for ( OWS o : lists ) { ImplementationMetadata<?> md = ( (OWSProvider) o.getMetadata().getProvider() ).getImplementationMetadata(); for ( String s : md.getImplementedServiceName() ) { if ( s.equalsIgnoreCase( "csw" ) && md.getImplementedVersions().contains( new Version( 2, 0, 2 ) ) ) { this.metadataURLTemplate = ""; // special case to use requested address } } } } } return metadataURLTemplate; }
/** * Returns the {@link OWS} instance that is responsible for handling requests to a certain service type, e.g. WMS, * WFS. * * @param serviceType * service type code, e.g. "WMS" or "WFS" * @return responsible <code>OWS</code> or null, if no responsible service was found */ public List<OWS> getByServiceType( String serviceType ) { List<ResourceIdentifier<OWS>> list = workspace.getResourcesOfType( OWSProvider.class ); List<OWS> services = new ArrayList<OWS>(); for ( ResourceIdentifier<OWS> id : list ) { OWS ows = workspace.getResource( OWSProvider.class, id.getId() ); if ( ows == null ) { continue; } for ( String name : ( (OWSProvider) ows.getMetadata().getProvider() ).getImplementationMetadata().getImplementedServiceName() ) { if ( name.equalsIgnoreCase( serviceType ) ) { services.add( ows ); } } } return services; }
private WFSRequestType getRequestTypeByName( String requestName ) throws OWSException { ImplementationMetadata<?> md = ( (OWSProvider) getMetadata().getProvider() ).getImplementationMetadata(); WFSRequestType requestType = (WFSRequestType) md.getRequestTypeByName( requestName ); if ( requestType == null ) { String msg = "Request type '" + requestName + "' is not supported."; throw new OWSException( msg, OWSException.OPERATION_NOT_SUPPORTED, "request" ); } return requestType; }
/** * Method for mapping the request operation to the implemented operations located in {@link CSWConstants} * * @param requestName * @return CSWRequestType * @throws OWSException */ private CSWRequestType getRequestType( String requestName ) throws OWSException { CSWRequestType requestType = null; try { requestType = (CSWRequestType) ( (ImplementationMetadata) ( (OWSProvider) getMetadata().getProvider() ).getImplementationMetadata() ).getRequestTypeByName( requestName ); } catch ( IllegalArgumentException e ) { throw new OWSException( e.getMessage(), OWSException.OPERATION_NOT_SUPPORTED ); } return requestType; }
private WPSRequestType getRequestTypeByName( String requestName ) throws OWSException { WPSRequestType requestType = null; try { requestType = (WPSRequestType) ( (ImplementationMetadata) ( (OWSProvider) metadata.getProvider() ).getImplementationMetadata() ).getRequestTypeByName( requestName ); } catch ( IllegalArgumentException e ) { throw new OWSException( e.getMessage(), OPERATION_NOT_SUPPORTED ); } return requestType; }
private void initOfferedVersions( SupportedVersions supportedVersions ) { List<String> versions = null; if ( supportedVersions != null ) { versions = supportedVersions.getVersion(); } if ( versions == null || versions.isEmpty() ) { LOG.info( "No protocol versions specified. Activating all implemented versions." ); ImplementationMetadata<?> md = ( (OWSProvider) getMetadata().getProvider() ).getImplementationMetadata(); versions = new ArrayList<String>( md.getImplementedVersions().size() ); for ( Version version : md.getImplementedVersions() ) { versions.add( version.toString() ); } } validateAndSetOfferedVersions( versions ); }
private void initOfferedVersions( SupportedVersions supportedVersions ) { List<String> versions = null; if ( supportedVersions != null ) { versions = supportedVersions.getVersion(); } if ( versions == null || versions.isEmpty() ) { LOG.info( "No protocol versions specified. Activating all implemented versions." ); ImplementationMetadata<?> md = ( (OWSProvider) getMetadata().getProvider() ).getImplementationMetadata(); versions = new ArrayList<String>( md.getImplementedVersions().size() ); for ( Version version : md.getImplementedVersions() ) { versions.add( version.toString() ); } } validateAndSetOfferedVersions( versions ); }
/** * Returns the {@link OWS} instance that is responsible for handling requests with a certain name, e.g. GetMap, * GetFeature. * * @param requestName * request name, e.g. "GetMap" or "GetFeature" * @return responsible <code>OWS</code> or null, if no responsible service was found */ public List<OWS> getByRequestName( String requestName ) { List<ResourceIdentifier<OWS>> list = workspace.getResourcesOfType( OWSProvider.class ); List<OWS> services = new ArrayList<OWS>(); for ( ResourceIdentifier<OWS> id : list ) { OWS ows = workspace.getResource( OWSProvider.class, id.getId() ); if ( ows == null ) { continue; } for ( String name : ( (OWSProvider) ows.getMetadata().getProvider() ).getImplementationMetadata().getHandledRequests() ) { if ( name.equalsIgnoreCase( "GetCapabilities" ) ) { continue; } if ( name.equalsIgnoreCase( requestName ) ) { services.add( ows ); } } } return services; }
/** * Determines the {@link OWS} instance that is responsible for handling XML requests in the given namespace. * * @param ns * XML namespace * @return responsible <code>OWS</code> or null, if no responsible service was found */ public List<OWS> getByRequestNS( String ns ) { List<ResourceIdentifier<OWS>> list = workspace.getResourcesOfType( OWSProvider.class ); List<OWS> services = new ArrayList<OWS>(); for ( ResourceIdentifier<OWS> id : list ) { OWS ows = workspace.getResource( OWSProvider.class, id.getId() ); if ( ows == null ) { continue; } for ( String name : ( (OWSProvider) ows.getMetadata().getProvider() ).getImplementationMetadata().getHandledNamespaces() ) { if ( name.equalsIgnoreCase( ns ) ) { services.add( ows ); } } } return services; }
/** * @param requestedVersions * @throws ResourceInitException */ protected final void validateAndSetOfferedVersions( Collection<String> requestedVersions ) throws ResourceInitException { for ( String requestedVersion : requestedVersions ) { Version version = Version.parseVersion( requestedVersion ); if ( !( ( (OWSProvider) metadata.getProvider() ).getImplementationMetadata().getImplementedVersions().contains( Version.parseVersion( requestedVersion ) ) ) ) { String msg = "Version '" + requestedVersion + "' is not supported by the service implementation."; throw new ResourceInitException( msg ); } offeredVersions.add( version ); } }
/** * @param confFileURL * @param configVersionString * @throws ResourceInitException */ protected void checkConfigVersion( String confFileURL, String configVersionString ) throws ResourceInitException { Version configVersion = Version.parseVersion( configVersionString ); if ( !( (OWSProvider) metadata.getProvider() ).getImplementationMetadata().getSupportedConfigVersions().contains( configVersion ) ) { LOG.error( "" ); LOG.error( "*** Configuration version mismatch ***", confFileURL ); LOG.error( "" ); StringBuilder msg = new StringBuilder( "File uses config version " ).append( configVersion ); msg.append( ", but this deegree build only supports version(s): " ); boolean separatorNeeded = false; for ( Version supportedVersion : ( (OWSProvider) metadata.getProvider() ).getImplementationMetadata().getSupportedConfigVersions() ) { msg.append( supportedVersion ); if ( separatorNeeded ) { msg.append( "," ); } separatorNeeded = true; } msg.append( " for this file type. Information on resolving this issue can be found at 'http://wiki.deegree.org/deegreeWiki/deegree3/ConfigurationVersions'. " ); throw new ResourceInitException( msg.toString() ); } }
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; }
private void watchTimeout( final OWS ows, final String requestName ) { if ( requestWatchdog != null ) { final String serviceId = ows.getMetadata().getIdentifier().getId(); requestWatchdog.watchCurrentThread( serviceId, requestName ); } }
private OWS determineOWSByPath( HttpServletRequest request ) throws OWSException { OWS ows = null; String pathInfo = request.getPathInfo(); if ( pathInfo != null ) { // remove start "/" String serviceId = pathInfo.substring( 1 ); ows = workspace.getNewWorkspace().getResource( OWSProvider.class, serviceId ); if ( ows == null && serviceConfiguration.isSingleServiceConfigured() ) { ows = serviceConfiguration.getSingleConfiguredService(); } if ( ows == null ) { String msg = "No service with identifier '" + serviceId + "' available."; throw new OWSException( msg, NOT_FOUND ); } } return ows; }
/** * @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 ); } }
/** * Return all active {@link OWS}. * * @return the instance of the requested service used by OGCFrontController, or null if the service is not * registered. */ public Map<String, List<OWS>> getAll() { List<ResourceIdentifier<OWS>> list = workspace.getResourcesOfType( OWSProvider.class ); Map<String, List<OWS>> services = new HashMap<String, List<OWS>>(); for ( ResourceIdentifier<OWS> id : list ) { OWS ows = workspace.getResource( OWSProvider.class, id.getId() ); if ( ows == null ) { continue; } String[] names = ( (OWSProvider) ows.getMetadata().getProvider() ).getImplementationMetadata().getImplementedServiceName(); for ( String name : names ) { List<OWS> owss = services.get( name ); if ( owss == null ) { owss = new ArrayList<OWS>(); services.put( name, owss ); } owss.add( ows ); } } return services; }
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" ) ) ); } }
private OWS determineOWSByPathQuirk( HttpServletRequest request ) throws OWSException { OWS ows = null; String pathInfo = request.getPathInfo(); if ( pathInfo != null ) { // remove start "/" String serviceId; // nice hack to work around the most stupid WFS 1.1.0 CITE tests // I'm sure there are a bazillion clients around that send out broken URLs, then validate the exception // responses, see the error of their ways and then send a proper request... if ( pathInfo.indexOf( "#" ) != -1 ) { serviceId = pathInfo.substring( 1, pathInfo.indexOf( "#" ) ); } else if ( pathInfo.indexOf( "=" ) != -1 ) { serviceId = pathInfo.substring( 1, pathInfo.indexOf( "=" ) ); } else { serviceId = pathInfo.substring( 1 ); } ows = workspace.getNewWorkspace().getResource( OWSProvider.class, serviceId ); if ( ows == null && serviceConfiguration.isSingleServiceConfigured() ) { ows = serviceConfiguration.getSingleConfiguredService(); } if ( ows == null ) { String msg = "No service with identifier '" + serviceId + "' available."; throw new OWSException( msg, NOT_FOUND ); } } return ows; }