Class CommunicationEngine
java.lang.Object
com.aquima.interactions.communication.impl.CommunicationEngine
- All Implemented Interfaces:
IDomainSchemaRegistry
,ICommunicationEngine
Internal ICommunicationEngine implementation that uses a datasource, metamodel and ruleengine for construction.
- Since:
- 9.0
- Author:
- Arjan Pragt, Jon van Leuven
-
Constructor Summary
ConstructorsConstructorDescriptionCommunicationEngine
(ICommunicationEngineDS datasource, IMetaModel metamodel, IRuleEngine ruleEngine) Construct a communication engine with a datasource. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addDataContract
(DomainSchemaDefinition definition) protected void
protected void
protected void
protected void
protected void
composeRestRequest
(IProfile profile, String serviceName, String operationName, String mimeType, ICommunicationEngineHandler handler) This method composes the rest message.composeRestRequest
(IProfile profile, String serviceName, String operationName, String mimeType, ICommunicationEngineHandler handler, Map<String, List<String>> headers) This method composes the rest message.composeRestResponse
(IProfile profile, String serviceName, String operationName, String mimeType, ICommunicationEngineHandler handler) This method composes a rest response message.composeSoapRequest
(IInternalPortalContext context, String serviceName, String operationName, ICommunicationEngineHandler handler) This methods composes a soap request message.composeSoapRequest
(IInternalPortalContext context, String serviceName, String operationName, ISoapMessageHandler[] handlers, ICommunicationEngineHandler handler) This methods composes a soap request message.composeSoapResponse
(IInternalPortalContext context, String serviceName, String operationName, ICommunicationEngineHandler handler) This method composes a soap response message.getDomainSchema
(String name) This method returns the definition of a domain schema for the specified name.getRestService
(String serviceName) This method returns the rest service.String[]
This method returns the available rest service name.getSchemaContract
(String name) Returns the schema contract of a specified name.String[]
Returns the names of the contracts.getSchemaSet
(String name) This method return the definition of a schema set for the specified name.String[]
This method returns the available schema set names.getSoapContract
(String name) Returns the soap contract of a specified name.String[]
Returns the names of the contracts.getSoapService
(String serviceName) This method return the definition of a service for the specified name.String[]
This method returns the available soap service name.matchOperation
(IRestRequestMessage request, String serviceName, ICommunicationEngineHandler handler) This method matches the urn of a request to an operation of the service.void
parseRestRequest
(IRestRequestMessage request, InferenceContext target, String serviceName, ICommunicationEngineHandler handler) This method parses a rest request message.void
parseRestResponse
(IRestMessage response, InferenceContext target, String serviceName, String operationName, ICommunicationEngineHandler handler) This method parses a rest response message.void
parseSoapRequest
(ISoapMessage message, InferenceContext target, String serviceName, String operationName) This method parses a soap request message.void
parseSoapResponse
(ISoapMessage message, InferenceContext target, String serviceName, String operationName) This method parses a soap response message.
-
Constructor Details
-
CommunicationEngine
public CommunicationEngine(ICommunicationEngineDS datasource, IMetaModel metamodel, IRuleEngine ruleEngine) throws InitializationException Construct a communication engine with a datasource.- Parameters:
datasource
- The datasource to initialize the definitions, may not be null.metamodel
- The metamodel containing definitions that are used by the communication engine, may not be null.ruleEngine
- The rule engine containing definitions that are used by the communication engine, may not be null.- Throws:
InitializationException
- Is thrown when the communication could not be constructed.
-
-
Method Details
-
getRestServiceNames
Description copied from interface:ICommunicationEngine
This method returns the available rest service name.- Specified by:
getRestServiceNames
in interfaceICommunicationEngine
- Returns:
- The names of the rest services that are available, never null, but may be an empty array.
-
getRestService
Description copied from interface:ICommunicationEngine
This method returns the rest service.- Specified by:
getRestService
in interfaceICommunicationEngine
- Parameters:
serviceName
- The name of the service, may not be null.- Returns:
- The definition of the service.
- Throws:
UnknownRestServiceException
- Is thrown when there is no definition for the provided name.
-
getSoapServiceNames
Description copied from interface:ICommunicationEngine
This method returns the available soap service name.- Specified by:
getSoapServiceNames
in interfaceICommunicationEngine
- Returns:
- The names of the soap services that are available, never null, but may be an empty array.
-
getSoapService
Description copied from interface:ICommunicationEngine
This method return the definition of a service for the specified name.- Specified by:
getSoapService
in interfaceICommunicationEngine
- Parameters:
serviceName
- The name of the service that is requested (case insensitive)- Returns:
- The service definition, never null
- Throws:
UnknownSoapServiceException
- Is thrown when there is no definition for the provided name.
-
getSchemaSetNames
Description copied from interface:ICommunicationEngine
This method returns the available schema set names.- Specified by:
getSchemaSetNames
in interfaceICommunicationEngine
- Returns:
- The names of the schema sets that are available, never null, but may be an empty array.
-
getSchemaSet
Description copied from interface:ICommunicationEngine
This method return the definition of a schema set for the specified name.- Specified by:
getSchemaSet
in interfaceICommunicationEngine
- Parameters:
name
- The name of the schema set that is requested (case insensitive)- Returns:
- The schema set definition, never null
- Throws:
UnknownSchemaSetException
- Is thrown when there is no definition for the provided name.
-
addSoapService
- Throws:
InitializationException
-
addRestService
- Throws:
InitializationException
-
addSchemaSet
- Throws:
InitializationException
-
composeRestRequest
public IRestRequestMessage composeRestRequest(IProfile profile, String serviceName, String operationName, String mimeType, ICommunicationEngineHandler handler) throws UnknownRestServiceException, UnknownOperationException, RestMessageComposeException Description copied from interface:ICommunicationEngine
This method composes the rest message.- Specified by:
composeRestRequest
in interfaceICommunicationEngine
- Parameters:
profile
- The used profile during the compose.serviceName
- The name of the rest service.operationName
- The name of the operation.mimeType
- the mime type of the requesthandler
- The handler for custom element composing.- Returns:
- The composed message.
- Throws:
UnknownRestServiceException
- when the rest service does not existUnknownOperationException
- when the operation does not exist for the rest serviceRestMessageComposeException
- when an error occurs when the rest message is composed
-
composeRestRequest
public IRestRequestMessage composeRestRequest(IProfile profile, String serviceName, String operationName, String mimeType, ICommunicationEngineHandler handler, Map<String, List<String>> headers) throws UnknownRestServiceException, UnknownOperationException, RestMessageComposeExceptionDescription copied from interface:ICommunicationEngine
This method composes the rest message.- Specified by:
composeRestRequest
in interfaceICommunicationEngine
- Parameters:
profile
- The used profile during the compose.serviceName
- The name of the rest service.operationName
- The name of the operation.mimeType
- the mime type of the requesthandler
- The handler for custom element composing.headers
- the http headers that will be put on the http request- Returns:
- The composed message.
- Throws:
UnknownRestServiceException
- when the rest service does not existUnknownOperationException
- when the operation does not exist for the rest serviceRestMessageComposeException
- when an error occurs when the rest message is composed
-
matchOperation
public IRestOperationDefinition matchOperation(IRestRequestMessage request, String serviceName, ICommunicationEngineHandler handler) throws UnknownRestServiceException, UnmatchableOperationException Description copied from interface:ICommunicationEngine
This method matches the urn of a request to an operation of the service.- Specified by:
matchOperation
in interfaceICommunicationEngine
- Parameters:
request
- The incoming rest request message.serviceName
- The name of the rest service, may not be null or empty.handler
- The handler for custom element composing.- Returns:
- The definition of the operation.
- Throws:
UnmatchableOperationException
- When no operation can be matched to the urnUnknownRestServiceException
-
parseRestRequest
public void parseRestRequest(IRestRequestMessage request, InferenceContext target, String serviceName, ICommunicationEngineHandler handler) throws UnknownRestServiceException, UnknownOperationException, RestMessageComposeException Description copied from interface:ICommunicationEngine
This method parses a rest request message.- Specified by:
parseRestRequest
in interfaceICommunicationEngine
- Parameters:
request
- The message to parse.target
- The target profile.serviceName
- The name of the rest service.handler
- The handler for custom element composing.- Throws:
UnknownRestServiceException
- when the rest service does not existUnknownOperationException
- when the operation does not exist for the rest serviceRestMessageComposeException
- when an error occurs when the rest message is composed
-
composeRestResponse
public IRestMessage composeRestResponse(IProfile profile, String serviceName, String operationName, String mimeType, ICommunicationEngineHandler handler) throws UnknownOperationException, RestMessageComposeException, UnknownRestServiceException Description copied from interface:ICommunicationEngine
This method composes a rest response message.- Specified by:
composeRestResponse
in interfaceICommunicationEngine
- Parameters:
profile
- The profile used to compose values.serviceName
- The name of the rest service.operationName
- The name of the operation.mimeType
- the mime type of the request.handler
- The handler for custom element composing.- Returns:
- The composed response message.
- Throws:
UnknownOperationException
- when the operation does not exist for the rest serviceRestMessageComposeException
- when an error occurs when the rest message is composedUnknownRestServiceException
- when the rest service does not exist
-
parseRestResponse
public void parseRestResponse(IRestMessage response, InferenceContext target, String serviceName, String operationName, ICommunicationEngineHandler handler) throws UnknownOperationException, RestMessageComposeException, UnknownRestServiceException Description copied from interface:ICommunicationEngine
This method parses a rest response message.- Specified by:
parseRestResponse
in interfaceICommunicationEngine
- Parameters:
response
- The response message to parse.target
- The target profile.serviceName
- The name of the rest service.operationName
- The name of the operation.handler
- The handler for custom element composing.- Throws:
UnknownOperationException
- when the operation does not exist for the rest serviceRestMessageComposeException
- when an error occurs when the rest message is composedUnknownRestServiceException
- when the rest service does not exist
-
composeSoapRequest
public ISoapMessage composeSoapRequest(IInternalPortalContext context, String serviceName, String operationName, ICommunicationEngineHandler handler) throws UnknownSoapServiceException, UnknownOperationException, SoapMessageComposeException Description copied from interface:ICommunicationEngine
This methods composes a soap request message.- Specified by:
composeSoapRequest
in interfaceICommunicationEngine
- Parameters:
context
- The context used to compose values.serviceName
- The name of the soap service.operationName
- The name of the operation.handler
- The handler used for custom element composing.- Returns:
- The composed soap message.
- Throws:
UnknownOperationException
- when the operation does not exist for the rest serviceUnknownSoapServiceException
SoapMessageComposeException
-
composeSoapRequest
public ISoapMessage composeSoapRequest(IInternalPortalContext context, String serviceName, String operationName, ISoapMessageHandler[] handlers, ICommunicationEngineHandler handler) Description copied from interface:ICommunicationEngine
This methods composes a soap request message.- Specified by:
composeSoapRequest
in interfaceICommunicationEngine
- Parameters:
context
- The context used to compose values.serviceName
- The name of the soap service.operationName
- The name of the operation.handlers
- an array of soap message handlers, must not be null.handler
- The handler used for custom element composing.- Returns:
- The composed soap message.
-
parseSoapRequest
public void parseSoapRequest(ISoapMessage message, InferenceContext target, String serviceName, String operationName) throws UnknownSoapServiceException, SoapMessageParseException Description copied from interface:ICommunicationEngine
This method parses a soap request message.- Specified by:
parseSoapRequest
in interfaceICommunicationEngine
- Parameters:
message
- The source message.target
- The target profile.serviceName
- The name of the soap service.operationName
- the name of the operation being called.- Throws:
UnknownSoapServiceException
- when the soap service does not existSoapMessageParseException
- when an error occurs on parsing the request message
-
composeSoapResponse
public ISoapMessage composeSoapResponse(IInternalPortalContext context, String serviceName, String operationName, ICommunicationEngineHandler handler) throws UnknownSoapServiceException, UnknownOperationException, SoapMessageComposeException Description copied from interface:ICommunicationEngine
This method composes a soap response message.- Specified by:
composeSoapResponse
in interfaceICommunicationEngine
- Parameters:
context
- The context used to compose values.serviceName
- The name of the soap service.operationName
- The name of the operation.handler
- The handler used for custom element composing.- Returns:
- The composed response message.
- Throws:
UnknownSoapServiceException
- when the soap service does not existUnknownOperationException
- when the oeration does not exist for the soap serviceSoapMessageComposeException
- when an error occurs when the soap message is composed
-
parseSoapResponse
public void parseSoapResponse(ISoapMessage message, InferenceContext target, String serviceName, String operationName) throws UnknownOperationException, UnknownSoapServiceException Description copied from interface:ICommunicationEngine
This method parses a soap response message.- Specified by:
parseSoapResponse
in interfaceICommunicationEngine
- Parameters:
message
- The source message.target
- The target profile.serviceName
- The name of the soap service.operationName
- The name of the operation.- Throws:
UnknownOperationException
- when the operation does not exist for the soap serviceUnknownSoapServiceException
-
getSchemaContractNames
Description copied from interface:ICommunicationEngine
Returns the names of the contracts.- Specified by:
getSchemaContractNames
in interfaceICommunicationEngine
- Returns:
- The contract names, not null.
-
getSoapContractNames
Description copied from interface:ICommunicationEngine
Returns the names of the contracts.- Specified by:
getSoapContractNames
in interfaceICommunicationEngine
- Returns:
- The contract names, not null.
-
getSchemaContract
Description copied from interface:ICommunicationEngine
Returns the schema contract of a specified name.- Specified by:
getSchemaContract
in interfaceICommunicationEngine
- Parameters:
name
- The name of the contract, not null.- Returns:
- The schema contract.
- Throws:
UnknownXmlContractException
- If the contact is unknown.
-
getDomainSchema
Description copied from interface:IDomainSchemaRegistry
This method returns the definition of a domain schema for the specified name.- Specified by:
getDomainSchema
in interfaceIDomainSchemaRegistry
- Parameters:
name
- The name of the domain schema requested (case insensitive), not null.- Returns:
- The Data contract definition, never null.
- Throws:
UnknownDomainSchemaException
- Is thrown when there is no definition for the provided name.
-
getSoapContract
Description copied from interface:ICommunicationEngine
Returns the soap contract of a specified name.- Specified by:
getSoapContract
in interfaceICommunicationEngine
- Parameters:
name
- The name of the contract, not null.- Returns:
- The soap contract.
- Throws:
UnknownSoapServiceContractException
- If the contract is unknown.
-
addSchemaContract
- Throws:
InitializationException
-
addDataContract
- Throws:
InitializationException
-
addSoapContract
- Throws:
InitializationException
-