org.deegree.services.controller
Class AbstractOGCServiceController

java.lang.Object
  extended by org.deegree.services.controller.AbstractOGCServiceController
All Implemented Interfaces:
OWS
Direct Known Subclasses:
CSWController, SOSController, WCSController, WFSController, WMSController, WPService, WPVSController

public abstract class AbstractOGCServiceController
extends java.lang.Object
implements OWS

Each concrete extension of this class is responsible for handling requests to a specific OGC web service (WPS, WMS, WFS, CSW,...).

Version:
$Revision:$, $Date:$
Author:
Markus Schneider , Rutger Bezema , last edited by: $Author:$
See Also:
OGCFrontController, ImplementationMetadata

Field Summary
protected  DeegreeServiceControllerType mainControllerConf
           
protected  DeegreeServicesMetadataType mainMetadataConf
          Common configuration (metadata) of parent OGCFrontController.
protected  java.util.SortedSet<org.deegree.commons.tom.ows.Version> offeredVersions
          Versions offered by the AbstractOGCServiceController instance (depends on configuration).
 
Constructor Summary
AbstractOGCServiceController()
           
 
Method Summary
protected  void beginSOAPResponse(HttpResponseBuffer response)
          Convenience method that may be used by controller implementations to produce OGC-SOAP responses.
protected  void checkConfigVersion(java.lang.String confFileURL, java.lang.String configVersionString)
           
 void checkOrCreateDCPGetURL(javax.servlet.http.HttpServletRequest requestWrapper)
          Check if the main controller configuration defines a dcp 'GET' url if not, set it with the values gotten from the request.
 void checkOrCreateDCPPostURL(javax.servlet.http.HttpServletRequest requestWrapper)
          Check if the main controller configuration defines a dcp 'POST' url if not, set it with the values gotten from the request.
protected  org.deegree.commons.tom.ows.Version checkVersion(org.deegree.commons.tom.ows.Version requestedVersion)
          Checks if a request version can be handled by this controller (i.e. if is supported by the implementation *and* offered by the current configuration).
 void doSOAP(org.apache.axiom.soap.SOAPEnvelope soapDoc, javax.servlet.http.HttpServletRequest request, HttpResponseBuffer response, java.util.List<org.apache.commons.fileupload.FileItem> multiParts, org.apache.axiom.soap.SOAPFactory factory)
          Called by the OGCFrontController to allow this AbstractOGCServiceController to handle a SOAP request.
protected  void endSOAPResponse(HttpResponseBuffer response)
          Finishes an OGC-SOAP response that has been initiated by beginSOAPResponse(HttpResponseBuffer).
 org.deegree.commons.utils.Pair<XMLExceptionSerializer<OWSException>,java.lang.String> getExceptionSerializer(org.deegree.commons.tom.ows.Version requestVersion)
          Returns the ExceptionSerializer and mime-type suitable for the given request version.
 java.util.Set<java.lang.String> getHandledNamespaces()
          Returns all namespaces that are handled by this controller.
 java.util.Set<java.lang.String> getHandledRequests()
          Returns the names of all requests that are handled by this controller.
 java.util.List<java.lang.String> getOfferedVersions()
          Returns the offered protocol versions.
 java.lang.String getOfferedVersionsString()
          Returns the offered protocol versions.
protected  void init(DeegreeServicesMetadataType mainMetadataConf, DeegreeServiceControllerType mainControllerConf, ImplementationMetadata<? extends java.lang.Enum<?>> serviceInformation, org.deegree.commons.xml.XMLAdapter controllerConfig)
          Initializes the AbstractOGCServiceController instance.
protected  org.deegree.commons.tom.ows.Version negotiateVersion(org.deegree.protocol.ows.capabilities.GetCapabilities request)
          Generic version negotiation algorithm for GetCapabilities requests according to OWS Common Specification 1.1.0 (OGC 06-121r3), section 7.3.2 and D.11.
static
<T extends ControllerException>
void
sendException(java.lang.String contentType, java.lang.String encoding, java.util.Map<java.lang.String,java.lang.String> additionalHeaders, int httpStatusCode, ExceptionSerializer<T> serializer, T exception, javax.servlet.http.HttpServletResponse response)
          Sends an exception to the client.
 void sendSOAPException(org.apache.axiom.soap.SOAPHeader header, org.apache.axiom.soap.SOAPFactory factory, HttpResponseBuffer response, OWSException exception, XMLExceptionSerializer<OWSException> serializer, java.lang.String SOAPFaultCode, java.lang.String SOAPMessage, java.lang.String SOAPaction, java.lang.String characterEncoding)
          Encapsulates the given OWSException into a SOAP environment for which the given factory will be used.
protected  ServiceIdentificationType synchronizeServiceIdentificationWithMainController(ServiceIdentificationType serviceIdentification)
           
protected  ServiceProviderType synchronizeServiceProviderWithMainControllerConf(ServiceProviderType configuredServiceProvider)
           
protected  java.lang.Object unmarshallConfig(java.lang.String jaxbPackage, java.lang.String schemaLocation, org.apache.axiom.om.OMElement element)
           
protected  java.lang.Object unmarshallConfig(java.lang.String jaxbPackage, java.lang.String schemaLocation, org.deegree.commons.xml.XMLAdapter xmlAdapter)
           
protected  void validateAndSetOfferedVersions(java.util.Collection<java.lang.String> requestedVersions)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.deegree.services.OWS
destroy, doKVP, doXML, init
 

Field Detail

mainMetadataConf

protected DeegreeServicesMetadataType mainMetadataConf
Common configuration (metadata) of parent OGCFrontController.


mainControllerConf

protected DeegreeServiceControllerType mainControllerConf

offeredVersions

protected java.util.SortedSet<org.deegree.commons.tom.ows.Version> offeredVersions
Versions offered by the AbstractOGCServiceController instance (depends on configuration).

Versions are sorted from lowest to highest in order to support the (old-style) version negotiation algorithm.

Constructor Detail

AbstractOGCServiceController

public AbstractOGCServiceController()
Method Detail

init

protected void init(DeegreeServicesMetadataType mainMetadataConf,
                    DeegreeServiceControllerType mainControllerConf,
                    ImplementationMetadata<? extends java.lang.Enum<?>> serviceInformation,
                    org.deegree.commons.xml.XMLAdapter controllerConfig)
             throws ControllerInitException
Initializes the AbstractOGCServiceController instance.

Parameters:
mainMetadataConf -
serviceInformation -
controllerConfig - controller configuration, must not be null
Throws:
ControllerInitException - if the config version does not match one of the supported versions

getHandledRequests

public final java.util.Set<java.lang.String> getHandledRequests()
Returns the names of all requests that are handled by this controller.

Returns:
names of handled requests

getHandledNamespaces

public final java.util.Set<java.lang.String> getHandledNamespaces()
Returns all namespaces that are handled by this controller.

Returns:
handled namespaces

validateAndSetOfferedVersions

protected final void validateAndSetOfferedVersions(java.util.Collection<java.lang.String> requestedVersions)
                                            throws ControllerInitException
Parameters:
requestedVersions -
Throws:
ControllerInitException

doSOAP

public void doSOAP(org.apache.axiom.soap.SOAPEnvelope soapDoc,
                   javax.servlet.http.HttpServletRequest request,
                   HttpResponseBuffer response,
                   java.util.List<org.apache.commons.fileupload.FileItem> multiParts,
                   org.apache.axiom.soap.SOAPFactory factory)
            throws javax.servlet.ServletException,
                   java.io.IOException,
                   SecurityException
Called by the OGCFrontController to allow this AbstractOGCServiceController to handle a SOAP request.

Specified by:
doSOAP in interface OWS
Parameters:
soapDoc - XMLAdapter for parsing the SOAP request document
request - provides access to all information of the original HTTP request (NOTE: may be GET or POST)
response - response that is sent to the client
multiParts - A list of multiparts contained in the request. If the request was not a multipart request the list will be null. If multiparts were found, the requestDoc will be the first (xml-lized) FileItem in the list.
factory - initialized to the soap version of the request.
Throws:
javax.servlet.ServletException
java.io.IOException - if an IOException occurred
SecurityException

beginSOAPResponse

protected void beginSOAPResponse(HttpResponseBuffer response)
                          throws javax.xml.stream.XMLStreamException,
                                 java.io.IOException
Convenience method that may be used by controller implementations to produce OGC-SOAP responses.

Performs the following actions using the given HttpResponseBuffer:

After calling this method, the controller may simply write the normal OGC-XML response using the HttpResponseBuffer.getXMLWriter() object and call endSOAPResponse(HttpResponseBuffer) afterwards.

Parameters:
response -
Throws:
javax.xml.stream.XMLStreamException
java.io.IOException
See Also:
endSOAPResponse(HttpResponseBuffer)

endSOAPResponse

protected void endSOAPResponse(HttpResponseBuffer response)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
Finishes an OGC-SOAP response that has been initiated by beginSOAPResponse(HttpResponseBuffer).

Parameters:
response -
Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
See Also:
beginSOAPResponse(HttpResponseBuffer)

checkVersion

protected org.deegree.commons.tom.ows.Version checkVersion(org.deegree.commons.tom.ows.Version requestedVersion)
                                                    throws OWSException
Checks if a request version can be handled by this controller (i.e. if is supported by the implementation *and* offered by the current configuration).

NOTE: This method does use exception code OWSException.INVALID_PARAMETER_VALUE, not OWSException.VERSION_NEGOTIATION_FAILED -- the latter should only be used for failed GetCapabilities requests.

Parameters:
requestedVersion - version to be checked, may be null (causes exception)
Returns:
requestedVersion (if it is not null), or highest version supported
Throws:
OWSException - if the requested version is not available

getOfferedVersionsString

public java.lang.String getOfferedVersionsString()
Returns the offered protocol versions.

Returns:
the offered protocol versions

getOfferedVersions

public java.util.List<java.lang.String> getOfferedVersions()
Returns the offered protocol versions.

Returns:
the offered protocol versions

checkConfigVersion

protected void checkConfigVersion(java.lang.String confFileURL,
                                  java.lang.String configVersionString)
                           throws ControllerInitException
Parameters:
confFileURL -
configVersionString -
Throws:
ControllerInitException

unmarshallConfig

protected java.lang.Object unmarshallConfig(java.lang.String jaxbPackage,
                                            java.lang.String schemaLocation,
                                            org.apache.axiom.om.OMElement element)
                                     throws ControllerInitException
Throws:
ControllerInitException

unmarshallConfig

protected java.lang.Object unmarshallConfig(java.lang.String jaxbPackage,
                                            java.lang.String schemaLocation,
                                            org.deegree.commons.xml.XMLAdapter xmlAdapter)
                                     throws ControllerInitException
Throws:
ControllerInitException

negotiateVersion

protected org.deegree.commons.tom.ows.Version negotiateVersion(org.deegree.protocol.ows.capabilities.GetCapabilities request)
                                                        throws OWSException
Generic version negotiation algorithm for GetCapabilities requests according to OWS Common Specification 1.1.0 (OGC 06-121r3), section 7.3.2 and D.11.

Parameters:
request - GetCapabilities request
Returns:
agreed version (used for response)
Throws:
OWSException - if new-style version negotiation is used and no common version exists

sendException

public static <T extends ControllerException> void sendException(java.lang.String contentType,
                                                                 java.lang.String encoding,
                                                                 java.util.Map<java.lang.String,java.lang.String> additionalHeaders,
                                                                 int httpStatusCode,
                                                                 ExceptionSerializer<T> serializer,
                                                                 T exception,
                                                                 javax.servlet.http.HttpServletResponse response)
                          throws javax.servlet.ServletException
Sends an exception to the client.

Type Parameters:
T - the type of the Exception, which should be subtype of controller exception
Parameters:
contentType - of the exception response
encoding - of the exception response
additionalHeaders - to add to the response.
httpStatusCode - of the exception response
serializer - responsible for creating the appropriate response format of the exception.
exception - the cause, holding relevant information.
response - to write to.
Throws:
javax.servlet.ServletException - if the exception could not be sent.

sendSOAPException

public void sendSOAPException(org.apache.axiom.soap.SOAPHeader header,
                              org.apache.axiom.soap.SOAPFactory factory,
                              HttpResponseBuffer response,
                              OWSException exception,
                              XMLExceptionSerializer<OWSException> serializer,
                              java.lang.String SOAPFaultCode,
                              java.lang.String SOAPMessage,
                              java.lang.String SOAPaction,
                              java.lang.String characterEncoding)
                       throws javax.servlet.ServletException
Encapsulates the given OWSException into a SOAP environment for which the given factory will be used.

Parameters:
header - SOAPheaders to be set in the envelope, if missing no headers will be set.
factory - to create the soap elements.
response - to write to.
exception - to write in the 'fault/detail' section
serializer - to use for writing the OWSException.
SOAPFaultCode - optional (see SOAPException for valid once. If missing SOAPException.SENDER will be used.
SOAPMessage - optional message to explicitly set. If missing the owsException message will be used.
SOAPaction - to set, optional.
characterEncoding - of the response.
Throws:
javax.servlet.ServletException

synchronizeServiceProviderWithMainControllerConf

protected ServiceProviderType synchronizeServiceProviderWithMainControllerConf(ServiceProviderType configuredServiceProvider)
Parameters:
configuredServiceProvider - to be synchronized with the main configuration
Returns:
the configured service provider, with missing values filled from the main configuration.

synchronizeServiceIdentificationWithMainController

protected ServiceIdentificationType synchronizeServiceIdentificationWithMainController(ServiceIdentificationType serviceIdentification)
Parameters:
serviceIdentification - to be synchronized with the configuration of the main controller.
Returns:
the service identification with all missing values filled in from the main controller service identification.

checkOrCreateDCPPostURL

public void checkOrCreateDCPPostURL(javax.servlet.http.HttpServletRequest requestWrapper)
Check if the main controller configuration defines a dcp 'POST' url if not, set it with the values gotten from the request.

Parameters:
requestWrapper -

checkOrCreateDCPGetURL

public void checkOrCreateDCPGetURL(javax.servlet.http.HttpServletRequest requestWrapper)
Check if the main controller configuration defines a dcp 'GET' url if not, set it with the values gotten from the request.

Parameters:
requestWrapper - to get the requested url from.

getExceptionSerializer

public org.deegree.commons.utils.Pair<XMLExceptionSerializer<OWSException>,java.lang.String> getExceptionSerializer(org.deegree.commons.tom.ows.Version requestVersion)
Returns the ExceptionSerializer and mime-type suitable for the given request version.

Parameters:
requestVersion - version of the request for which the exception has to be produced, may be null (implies that the serializer and mime type for the highest supported version shall be returned)
Returns:
an OWSCommon 1.1.0 XML adapter by default, never null


Copyright © 2011. All Rights Reserved.