Class GroovyEmailService

All Implemented Interfaces:
IEmailService, IGroovyDebugLogService, IServiceDefinitionAware, IUnitTestableService

Provides a Groovy Email service.
Since:
4.3.2
  • Constructor Details

    • GroovyEmailService

      public GroovyEmailService()
  • Method Details

    • sendEmailMessage

      public void sendEmailMessage(String subject, String message, String fromAddress, String replyToAddress, String toAddress, String ccAddress, String bccAddress, Map<String,byte[]> attachmentMap, Submission submission)
      Send an email message.
      Specified by:
      sendEmailMessage in interface IEmailService
      Parameters:
      subject - email subject
      message - email message body
      fromAddress - the from address
      replyToAddress - the reply-to address
      toAddress - email to address
      ccAddress - email address to cc
      bccAddress - email address to bcc
      attachmentMap - attachments map
      submission - the submission the email relates to (optional)
      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.
    • getGroovyDebugLogging

      public Boolean getGroovyDebugLogging()
      Return true if GroovyLogger DEBUG level message recording is enabled.
      Specified by:
      getGroovyDebugLogging in interface IGroovyDebugLogService
      Returns:
      true if GroovyLogger DEBUG level message recording is enabled.
      Since:
      20.11.7
    • setGroovyDebugLogging

      public void setGroovyDebugLogging(Boolean debugEnabled)
      Set whether GroovyLogger DEBUG level message recording is enabled.
      Specified by:
      setGroovyDebugLogging in interface IGroovyDebugLogService
      Parameters:
      debugEnabled - the groovyDebugLoggingEnabled to set
      Since:
      4.3.4
    • isGroovyLoggingEnabled

      public boolean isGroovyLoggingEnabled()
      Return true if the Groovy Service logging is enabled.
      Returns:
      true if the Groovy Service logging is enabled.
    • setGroovyLoggingEnabled

      public void setGroovyLoggingEnabled(Boolean loggingEnabled)
      Specify whether the Groovy Service logging is enabled.
      Parameters:
      loggingEnabled - specify whether 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
    • 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
    • isGroovyTypeChecked

      public boolean isGroovyTypeChecked()
      Return true if the Groovy runtime should perform static type checking.
      Returns:
      true if the Groovy runtime should perform static type checking
    • setGroovyTypeChecked

      public void setGroovyTypeChecked(boolean typeChecked)
      Specify whether the Groovy runtime should perform static type checking.
      Parameters:
      typeChecked - specify whether the Groovy runtime should perform static type checking
    • 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
      Overrides:
      getServiceDefinition in class AbstractEmailService
      Returns:
      the service definition.
      See Also:
    • setServiceDefinition

      public void setServiceDefinition(ServiceDefinition serviceDefinition)
      Set the service definition.
      Specified by:
      setServiceDefinition in interface IServiceDefinitionAware
      Overrides:
      setServiceDefinition in class AbstractEmailService
      Parameters:
      serviceDefinition - the service definition to set
      See Also:
    • executeGroovyScript

      protected Object executeGroovyScript(Map<String,Object> parameters, Client client)
      Execute the service Groovy Script using the given parameters and security context client.
      Parameters:
      parameters - the script parameters (required)
      client - the calling client (optional)
      Returns:
      a new GroovyScript runtime for the given client
    • createExceptionAndLog

      protected ApplicationException createExceptionAndLog(Date startTime, com.jezhumble.javasysmon.CpuTimes startCpuTimes, Long startFreeMemory, Throwable cause, String context, String userMsg, String solution, Submission submission, Form form, Client client)
      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
      client - the client
      Returns:
      a new application exception
    • getServiceName

      protected String getServiceName()
      Deprecated.
      this no longer uniquely identifies the service - use getNameAndVersion() where possible
      Returns:
      the service definition service name
    • getServiceNameAndVersion

      protected String getServiceNameAndVersion()
      Returns:
      the service definition name and version number
    • getServiceTimeout

      protected Integer getServiceTimeout()
      Returns:
      the service timeout
    • getCause

      protected Throwable getCause(Throwable e)
      Return the root cause of the exception
      Parameters:
      e - the error
      Returns:
      the root cause of the exception
      Since:
      4.3.1