Package com.avoka.fc.core.service.fluent
Class AbstractFluentService
- java.lang.Object
-
- com.avoka.fc.core.service.fluent.AbstractFluentService
-
- All Implemented Interfaces:
IFluentService
,IServiceDefinitionAware
,IUnitTestableService
- Direct Known Subclasses:
FluentDeliveryProcessService
,FluentDynamicDataService
,FluentFormPrefillService
,FluentFormSavedProcessor
,FluentFormSecurityFilterService
,FluentFormVersionSelectorService
,FluentFunctionService
,FluentGroovyService
,FluentJobActionService
,FluentMediaTypeScanService
,FluentReceiptNumberService
,FluentRenderReceiptService
,FluentScheduledService
,FluentSubmissionCompletedProcessor
,FluentSubmissionDataValidator
,FluentTaskExpiryService
,FluentTrackingNumberService
,FluentTransactionHistoryPublisher
,FluentVirusScanService
public abstract class AbstractFluentService extends Object implements IFluentService
Provides an abstract Fluent Groovy service.- Since:
- 5.0.0
-
-
Field Summary
-
Fields inherited from interface com.avoka.fc.core.service.fluent.IFluentService
PARAM_ACTION_PROPERTIES, PARAMS_FILEDATA, PARAMS_FILENAME, PARAMS_FORM, PARAMS_FORM_XML, PARAMS_FUNC_PARAM, PARAMS_JOB, PARAMS_JOB_ACTION, PARAMS_PARAMS, PARAMS_REQUEST, PARAMS_ROWS, PARAMS_SVC_DEF, PARAMS_TEST_PARAMS, PARAMS_TXN, PARAMS_USER
-
-
Constructor Summary
Constructors Constructor Description AbstractFluentService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ApplicationException
createExceptionAndLog(Date startTime, com.jezhumble.javasysmon.CpuTimes startCpuTimes, Long startFreeMemory, Throwable cause, String context, String userMsg, String solution, JobAction jobAction, Submission submission, Form form, String functionTrigger)
Create application exception and optionally log ErrorLog and GroovyServiceLog records if Groovy Logging enabled.protected Throwable
getCause(Throwable e)
Return the root cause of the exceptionprotected Client
getClient()
Boolean
getCommitChanges()
Return the commit changes flag.Integer
getExecutionTimeout()
Return the GroovyScript execution timeout in milliseconds.protected String
getFunctionTrigger()
Return the function trigger.String
getGroovyScript()
GroovyServiceLog
getGroovyServiceLog()
Return the GroovyServiceLog record created after executing the script.Logger
getLogger()
Return the service logger.protected User
getRequestUser(HttpServletRequest request)
Return the authenticated user value object for the request session, or null if none available.ServiceDefinition
getServiceDefinition()
Return the service definitionprotected String
getServiceNameAndVersion()
protected Integer
getServiceTimeout()
protected org.slf4j.Logger
getSlf4jLogger()
String
getTestLogOutput()
Return the service Unit Test Script logger output.Object
invoke(Map<String,Object> parameters)
Invoke the Fluent Service using the given parameters.boolean
isExceptionDebugLoggingEnabled()
Return true if the Exception DEBUG level message recording is enabled.Boolean
isGroovyDebugLogging()
Return true if GroovyLogger DEBUG level message recording is enabled.boolean
isGroovyLoggingEnabled()
Return true if the Groovy Service logging is enabled.Throwable
runUnitTest()
Run the service's Unit Test Script if defined for the service, returning null if succeeded or an error if it failed.void
setCommitChanges(Boolean commitChanges)
Set the commit changes flag.void
setExceptionDebugLoggingEnabled(Boolean debugEnabled)
Specify whether the Exception DEBUG level message recording is enabled.void
setExecutionTimeout(Integer timeout)
Return the GroovyScript execution timeout in milliseconds.void
setGroovyDebugLogging(Boolean debugEnabled)
Set whether GroovyLogger DEBUG level message recording is enabled.void
setGroovyLoggingEnabled(Boolean loggingEnabled)
Specify whether the Groovy Service logging is enabled.void
setGroovyScript(String script)
void
setLogger(Logger logger)
Set the service logger.void
setServiceDefinition(ServiceDefinition serviceDefinition)
Set the service definition.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.avoka.fc.core.service.fluent.IFluentService
getErrorType
-
-
-
-
Method Detail
-
invoke
public Object invoke(Map<String,Object> parameters)
Invoke the Fluent Service using the given parameters.- Specified by:
invoke
in interfaceIFluentService
- Parameters:
parameters
- the service script parameters (required)- Returns:
- a new invocation result
- See Also:
IFluentService.invoke(Map)
-
runUnitTest
public Throwable runUnitTest()
Run the service's Unit Test Script if defined for the service, returning null if succeeded or an error if it failed. If there is no 'Unit Test Script' defined, this method will return null.- Specified by:
runUnitTest
in interfaceIUnitTestableService
- Returns:
- an Exception if the test case failed, or null if the test case succeeded or no 'Unit Test Script' defined.
- See Also:
IUnitTestableService.runUnitTest()
-
getTestLogOutput
public String getTestLogOutput()
Return the service Unit Test Script logger output.- Specified by:
getTestLogOutput
in interfaceIUnitTestableService
- Returns:
- the service Unit Test Script logger output
- Since:
- 17.10.0
- See Also:
IUnitTestableService.getTestLogOutput()
-
getGroovyServiceLog
public GroovyServiceLog getGroovyServiceLog()
Return the GroovyServiceLog record created after executing the script.- Returns:
- the GroovyServiceLog record created after executing the script.
-
isGroovyDebugLogging
public Boolean isGroovyDebugLogging()
Return true if GroovyLogger DEBUG level message recording is enabled.- Returns:
- true if GroovyLogger DEBUG level message recording is enabled.
-
setGroovyDebugLogging
public void setGroovyDebugLogging(Boolean debugEnabled)
Set whether GroovyLogger DEBUG level message recording is enabled.- Parameters:
debugEnabled
- the groovyDebugLoggingEnabled to set
-
isGroovyLoggingEnabled
public boolean isGroovyLoggingEnabled()
Return true if the Groovy Service logging is enabled.- Returns:
- true if the Groovy Service logging is enabled.
-
setExceptionDebugLoggingEnabled
public void setExceptionDebugLoggingEnabled(Boolean debugEnabled)
Specify whether the Exception DEBUG level message recording is enabled.- Parameters:
debugEnabled
- specify the Exception DEBUG level message recording is enabled- Since:
- 19.5.3
-
isExceptionDebugLoggingEnabled
public boolean isExceptionDebugLoggingEnabled()
Return true if the Exception DEBUG level message recording is enabled.- Returns:
- true if the Exception DEBUG level message recording is enabled.
- Since:
- 19.5.3
-
setGroovyLoggingEnabled
public void setGroovyLoggingEnabled(Boolean loggingEnabled)
Specify whether the Groovy Service logging is enabled.- Parameters:
loggingEnabled
- specify whether the Groovy Service logging is enabled
-
getGroovyScript
public String getGroovyScript()
- Returns:
- the Groovy Script content to execute
-
setGroovyScript
public void setGroovyScript(String script)
- Parameters:
script
- the Groovy Script content to execute
-
getExecutionTimeout
public Integer getExecutionTimeout()
Return the GroovyScript execution timeout in milliseconds.- Returns:
- the GroovyScript execution timeout in milliseconds
-
setExecutionTimeout
public void setExecutionTimeout(Integer timeout)
Return the GroovyScript execution timeout in milliseconds.- Parameters:
timeout
- the GroovyScript execution timeout in milliseconds
-
getServiceDefinition
public ServiceDefinition getServiceDefinition()
Return the service definition- Specified by:
getServiceDefinition
in interfaceIServiceDefinitionAware
- Returns:
- the service definition.
-
setServiceDefinition
public void setServiceDefinition(ServiceDefinition serviceDefinition)
Set the service definition.- Specified by:
setServiceDefinition
in interfaceIServiceDefinitionAware
- Parameters:
serviceDefinition
- the service definition to set
-
getCommitChanges
public Boolean getCommitChanges()
Return the commit changes flag.- Returns:
- the commit changes flag.
-
setCommitChanges
public void setCommitChanges(Boolean commitChanges)
Set the commit changes flag.- Parameters:
commitChanges
- the commit changes flag
-
setLogger
public void setLogger(Logger logger)
Set the service logger.- Specified by:
setLogger
in interfaceIFluentService
- Parameters:
logger
- the service logger- Since:
- 17.10.0
- See Also:
IFluentService.setLogger(Logger)
-
getLogger
public Logger getLogger()
Return the service logger.- Returns:
- the service logger
- Since:
- 17.10.0
-
getSlf4jLogger
protected org.slf4j.Logger getSlf4jLogger()
- Returns:
- the class logger
-
createExceptionAndLog
protected ApplicationException createExceptionAndLog(Date startTime, com.jezhumble.javasysmon.CpuTimes startCpuTimes, Long startFreeMemory, Throwable cause, String context, String userMsg, String solution, JobAction jobAction, Submission submission, Form form, String functionTrigger)
Create application exception and optionally log ErrorLog and GroovyServiceLog records if Groovy Logging enabled.- Parameters:
startTime
- the time the service was invoked prior to the errorstartCpuTimes
- the CPU times when the service was invoked (required)startFreeMemory
- the free memory in bytes when the service was invoked (required)cause
- the root cause of the errorcontext
- the error context informationuserMsg
- the user messagesolution
- the solutionsubmission
- the submission objectform
- the formfunctionTrigger
- the function trigger- Returns:
- a new application exception
-
getServiceNameAndVersion
protected String getServiceNameAndVersion()
- Returns:
- the service definition name and version number
-
getServiceTimeout
protected Integer getServiceTimeout()
- Returns:
- the service timeout
-
getClient
protected Client getClient()
- Returns:
- the client security execution context
-
getCause
protected Throwable getCause(Throwable e)
Return the root cause of the exception- Parameters:
e
- the error- Returns:
- the root cause of the exception
-
getRequestUser
protected User getRequestUser(HttpServletRequest request)
Return the authenticated user value object for the request session, or null if none available.- Parameters:
request
- the servlet request (required)- Returns:
- user value object
-
getFunctionTrigger
protected String getFunctionTrigger()
Return the function trigger.- Returns:
- the function trigger
- Since:
- 17.10.0
-
-