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
  • Constructor Details

    • AbstractFluentService

      public AbstractFluentService()
  • Method Details

    • invoke

      public Object invoke(Map<String,Object> parameters)
      Invoke the Fluent Service using the given parameters.
      Specified by:
      invoke in interface IFluentService
      Parameters:
      parameters - the service script parameters (required)
      Returns:
      a new invocation result
      See Also:
    • 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 interface IUnitTestableService
      Returns:
      an Exception if the test case failed, or null if the test case succeeded or no 'Unit Test Script' defined.
      See Also:
    • getTestLogOutput

      public String getTestLogOutput()
      Return the service Unit Test Script logger output.
      Specified by:
      getTestLogOutput in interface IUnitTestableService
      Returns:
      the service Unit Test Script logger output
      Since:
      17.10.0
      See Also:
    • 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 interface IServiceDefinitionAware
      Returns:
      the service definition.
    • setServiceDefinition

      public void setServiceDefinition(ServiceDefinition serviceDefinition)
      Set the service definition.
      Specified by:
      setServiceDefinition in interface IServiceDefinitionAware
      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 interface IFluentService
      Parameters:
      logger - the service logger
      Since:
      17.10.0
      See Also:
    • 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 error
      startCpuTimes - 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 error
      context - the error context information
      userMsg - the user message
      solution - the solution
      submission - the submission object
      form - the form
      functionTrigger - 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(jakarta.servlet.http.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