Package com.luciad.ogc.common
Class TLcdOGCCommandDispatcher
java.lang.Object
com.luciad.ogc.common.ALcdOGCCommandDispatcher
com.luciad.ogc.common.TLcdOGCCommandDispatcher
- All Implemented Interfaces:
ILcdDisposable
,AutoCloseable
- Direct Known Subclasses:
TLcdWCSCommandDispatcher
,TLcdWFSCommandDispatcher
A basic implementation of
ALcdOGCCommandDispatcher
. Most
applications will want to extend this class rather than rewriting it
entirely.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ILcdRequestHandler
getRequestHandler
(String aService, String aRequest) Finds the registered handler for the given service and request, if any.void
handleRequest
(ILcdRequest aRequest, ILcdResponse aResponse) Handles a request.protected void
handleServiceException
(ILcdResponse aResponse, TLcdOGCServiceException aException, ILcdRequest aRequest) Handles a service exception.protected void
handleUnknownRequest
(String aRequest) Called if no request handler can be found for the given request.void
registerRequestHandler
(String aService, String aRequest, ILcdRequestHandler aHandler) Registers a new request handler.protected String
validateService
(String aService, String aRequestType, ILcdRequest aRequest) This method allows implementations to validate the "service" parameter of a request.Methods inherited from class com.luciad.ogc.common.ALcdOGCCommandDispatcher
dispose
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.util.ILcdDisposable
close
-
Field Details
-
REQUEST
- See Also:
-
SERVICE
- See Also:
-
-
Constructor Details
-
TLcdOGCCommandDispatcher
public TLcdOGCCommandDispatcher()
-
-
Method Details
-
handleRequest
Description copied from class:ALcdOGCCommandDispatcher
Handles a request.- Specified by:
handleRequest
in classALcdOGCCommandDispatcher
- Parameters:
aRequest
- the request which may be a KVP request or a XML request or ...aResponse
- the response to encode the result into.- Throws:
IOException
- if the request handling fails.
-
validateService
protected String validateService(String aService, String aRequestType, ILcdRequest aRequest) throws TLcdOGCServiceException This method allows implementations to validate the "service" parameter of a request. If the parameter is incorrect, and there is no applicable default value, an exception describing the problem should be thrown. Specific implementations can choose when an exception is to be thrown and when a default value is returned. The default implementation is optimized for WFS compliancy, which results in exceptions in some cases and default values in other cases. Parameters that influence the result are the version and operation name, if they can be derived from the request. This method can be implemented by specific services to improve exception reporting.- Parameters:
aService
- the service parameter to validate, e.g. WFSaRequestType
- the name of the request type, e.g. GetCapabilitiesaRequest
- the original request from which the service parameter has been extracted- Returns:
- The name of the service, which is either
aService
or a default value that should be used ifaService
is not correct. - Throws:
TLcdOGCServiceException
- in case the parameter is invalid.
-
handleServiceException
protected void handleServiceException(ILcdResponse aResponse, TLcdOGCServiceException aException, ILcdRequest aRequest) Handles a service exception.- Parameters:
aResponse
- The response to which the service exception can be encodedaException
- The service exception to handleaRequest
- The original request that triggered the service exception
-
handleUnknownRequest
Called if no request handler can be found for the given request. By default, an exception is thrown of typeTLcdOGCServiceException.UNKNOWN_REQUEST
; this triggers a call tohandleServiceException(com.luciad.ogc.common.ILcdResponse, com.luciad.ogc.common.TLcdOGCServiceException, com.luciad.ogc.common.ILcdRequest)
, which by default results in the encoding of an XML service exception report that is sent to the client.- Parameters:
aRequest
- The value of the request parameterREQUEST
- Throws:
TLcdOGCServiceException
- if a service exception report should be generated and sent to the client
-
getRequestHandler
Finds the registered handler for the given service and request, if any. If no handler is found,null
is returned.- Parameters:
aService
- The value of the request parameterSERVICE
aRequest
- The value of the request parameterREQUEST
- Returns:
- the registered handler for the given service and request, or
null
if no handler is found
-
registerRequestHandler
Registers a new request handler.- Specified by:
registerRequestHandler
in classALcdOGCCommandDispatcher
- Parameters:
aService
- The name of the service for which this request handler is valid, e.g. "WCS".aRequest
- The name of the request for which the handler is to be used, e.g. "GetCapabilities".aHandler
- AnILcdRequestHandler
.
-