Interface IJEMHVelocityContextUtils


  • public interface IJEMHVelocityContextUtils
    Velocity Context helper interface, accessed vie email templates, used to inhibit mail sending, for now.. published url: http://ppl-docs.s3-website-us-east-1.amazonaws.com/JEMH/3.0.0/com/javahollic/jira/emh/api/IJEMHVelocityContextUtils.html
    Author:
    andy
    • Method Detail

      • getCalData

        String getCalData()
        Get the content of the text/calendar message part
        Returns:
        the content as a String.
      • isAttachmentPresent

        boolean isAttachmentPresent​(javax.mail.Message message,
                                    String filename,
                                    boolean isRegex)
        Parameters:
        message - the email message to look for attachments in (typically the 'message' script context variable)
        filename - limits search to attachments with a matching filename, leave null to search for any attachment
        isRegex - whether the given filename String is to be considered a Regular Expression or not
        Returns:
        true if the message contains an attachment (matching given filename if provided), false otherwise
      • isAttachmentPresent

        @Deprecated
        boolean isAttachmentPresent​(javax.mail.Message message,
                                    String filename)
        Deprecated.
        since 3.3.14 and will be removed, use isAttachmentPresent(Message, String, boolean) instead
        Parameters:
        message - the email message to look for attachments in (typically the 'message' script context variable)
        filename - limits search to attachments with a matching filename, leave null to search for any attachment
        Returns:
        true if the message contains an attachment (matching given filename if provided), false otherwise
      • hasWorkflowPermission

        boolean hasWorkflowPermission​(String permission,
                                      com.atlassian.jira.issue.Issue issue,
                                      com.atlassian.jira.user.ApplicationUser user)
        Checks both the permission scheme and the issue's workflow properties to determine if the specified user has a particular project permission.
        Parameters:
        permission - the short name of a corresponding project permission
        issue - the target issue
        user - the user to check permissions for
        Returns:
        true if the given permission name is valid and the user has that permission, false otherwise
        See Also:
        Checking project permissions
      • hasPermission

        boolean hasPermission​(String permission,
                              com.atlassian.jira.issue.Issue issue,
                              com.atlassian.jira.user.ApplicationUser user)
        Checks the permission scheme only to determine if the specified user has a particular project permission.
        Parameters:
        permission - the short name of a corresponding project permission
        issue - the target issue
        user - the user to check permissions for
        Returns:
        true if the given permission name is valid and the user has that permission, false otherwise
        See Also:
        Checking project permissions
      • getTimeZone

        TimeZone getTimeZone​(String location)
        Parameters:
        location - for which the timeZone is needed
        Returns:
        TimeZone of the passed in location
      • getCatchEmailAddress

        javax.mail.internet.InternetAddress getCatchEmailAddress()
        Returns:
        catch email address that matched for profile
      • filterText

        String filterText​(String text)
        Parameters:
        text - to Filters the input text through some Mime decoding
        Returns:
        filtered input
      • setInhibitSending

        void setInhibitSending​(boolean val)
        Used during sending messages to inhibit sending, specifically needed due to split phase issue creation/update to enable ignoring ISSUE_CREATED events when JEMH has not yet added attachments to the issue, that are potentially required later.
        Parameters:
        val - , true to inhibit
      • isInhibitSending

        boolean isInhibitSending()
        determine if the outcome of the script is to inhibit sending of 'this' notification
        Returns:
        true if is to inhibit
      • setInhibitSendingReason

        void setInhibitSendingReason​(String reason)
        Sets a reason, retained in the audit entry to indicate why this message was inhibited for sending
        Parameters:
        reason - as text
      • getInhibitSendingReason

        String getInhibitSendingReason()
        Gets the reason that was possibly set by the processing script why this message was inhibited for sending
        Returns:
        reason
      • isPrivateJSDComment

        boolean isPrivateJSDComment​(com.atlassian.jira.user.ApplicationUser contextUser,
                                    com.atlassian.jira.issue.comments.Comment c)
        Helper method to determine if a comment is JSD private
        Parameters:
        contextUser - , the context for the question
        c - , related comment
        Returns:
        true if JSD is installed, and comment is private
      • isPrivateJSDComment

        boolean isPrivateJSDComment​(com.atlassian.jira.mail.TemplateUser contextTemplateUser,
                                    com.atlassian.jira.issue.comments.Comment c)
        Helper method to determine if a comment is JSD private, which is required during actual mail sending
        Parameters:
        contextTemplateUser - , the contextTemplateUser for the question
        c - , related comment
        Returns:
        true if JSD is installed, and comment is private
      • getCommentProperties

        Properties getCommentProperties​(com.atlassian.jira.issue.comments.Comment comment)
        Get comment properties
        Parameters:
        comment - to get properties of
        Returns:
        java.util.Properties object
      • addMailHeader

        void addMailHeader​(String key,
                           String value)
        Adds a mail header to the outgoing mail. Any additional processed to make the header valid is the responsibility of the caller.
        Parameters:
        key - text, all spaces in the value are removed, the result is prefixed by X-JEMH-ADHOC-
        value - text, should be relatively short. We don't wrap or encode the data supplied
      • addRawMailHeader

        void addRawMailHeader​(String key,
                              String value)
        Adds a mail header that is not prefixed. It is the callers responsilbity to ensure it is valid. Caller should NOT use recipient headers (to/cc/bcc)!
        Parameters:
        key - , usually of format X-something-else
        value - , text, should be relatively short. We don't wrap or encode the data supplied
      • addRecipientsFromRole

        void addRecipientsFromRole​(String recipientType,
                                   String issueKey,
                                   com.atlassian.jira.project.Project project,
                                   String roleName)
        Add recipients based on Role membership
        Parameters:
        issueKey - eg ABC-123
        project - from the issue
        roleName - eg "Customers"
        recipientType - eg "to" or "cc" (only)
      • addRecipientAddress

        void addRecipientAddress​(String recipientType,
                                 String addressCsv)
        Adds recipients through CSV SMTP address
        Parameters:
        recipientType - , valid values are to and cc
        addressCsv - , valid values are of format user@domain.com, NO Name parts are supported.
      • addRecipientGroup

        void addRecipientGroup​(String recipientType,
                               String groupName)
        Adds recipients from a given Jira group
        Parameters:
        recipientType - , valid values are to and cc
        groupName - of Jira group
      • getParams

        Map<String,​List<String>> getParams()
        Accessor for Map of value keys to list of values
        Returns:
        params, parms aggregate mail headers, but mail in future have other uses
      • getAdditionalAddressRecipients

        Set<javax.mail.internet.InternetAddress> getAdditionalAddressRecipients()
        Accessor for Set of additional Internet Addresses related to an email only user to be added to the recipient list
        Returns:
        set of email only user Addresses
      • getAdditionalUserRecipients

        Set<javax.mail.internet.InternetAddress> getAdditionalUserRecipients()
        Accessor for Set of additional Internet Addresses related to a Jira user entity to be added to the recipient list
        Returns:
        set of user Addresses
      • getAdditionalRecipientGroups

        Set<String> getAdditionalRecipientGroups()
        Accessor for Set of additional Internet Addresses related to a Jira user entity in a named Group to be added to the recipient list
        Returns:
        set of user Addresses
      • getReferencedMessageIds

        Set<String> getReferencedMessageIds()
        Getter referenced Message ID's from the message object
        Returns:
        Set of Reference IDs as string
      • getUserByEmail

        com.atlassian.jira.user.ApplicationUser getUserByEmail​(javax.mail.internet.InternetAddress address)
        Helper method to get a User
        Parameters:
        address - of the user as an InternetAddress object
        Returns:
        the user or null
      • getUserByEmail

        com.atlassian.jira.user.ApplicationUser getUserByEmail​(String emailStr)
        Helper method to bet a User
        Parameters:
        emailStr - of the user as text in format user@domain.com, no Name part is supported.
        Returns:
        the user or null
      • dropMessage

        void dropMessage​(String reason)
        During Script Field Processor handling of a message, allows a given message to be dropped immediately with no further processing
        Parameters:
        reason - , a non empty value used in auditing
      • dropAndExitGroupMessage

        void dropAndExitGroupMessage​(String reason)
        During Script Field Processor handling of a message, allows a given message to be dropped immediately with no further processing and exits processing if within a profile group
        Parameters:
        reason - , a non empty value used in auditing
      • forwardMessage

        void forwardMessage​(String reason)
        During Script Field Processor handling of a message, allows a given message to not be processed but forwarded to the Profile defined 'Forward' user
        Parameters:
        reason - , a non empty value used in auditing
      • filterMessage

        void filterMessage​(String reason)
        During Script Field Processor handling of a message, allows a given message to not be processed but filtered (like drop), here for completeness and differentation to drop
        Parameters:
        reason - , a non empty value used in auditing
      • rejectMessage

        void rejectMessage​(String reason)
        During Script Field Processor handling of a message, allows a given message to be rejected to the initator, with the given reason
        Parameters:
        reason - , a non empty value used in auditing
      • getProcessOutcome

        com.javahollic.jira.emh.api.ao.IJEMHFPAuditEventEntiyDef.ProcessingOutcome getProcessOutcome()
        Accessor method to get script driven outcome of message processing that would override future processing/outcome.
        Returns:
        outcome object, .name() of which returns: canHandle, filtered, forward, reject, drop, delete, hold
      • getRejectReason

        String getRejectReason()
        Get the message that may be set to describe why a message was rejected, ends up in audit record.
        Returns:
        text
      • getLocaleI18nBean

        com.atlassian.jira.util.I18nHelper getLocaleI18nBean​(String localeIn)
        Get a specific locale i18n helper
        Parameters:
        localeIn - the locale
        Returns:
        instance of I18nHelper
      • addStaticResourceAttachment

        String addStaticResourceAttachment​(Integer id)
        Add a global (unscoped) static resource by its Id.
        Parameters:
        id - , numeric ID of the Static Resource
        Returns:
        html message (not i18n), a non empty value indicates a failure, eg, a resource was referred that is not scoped to the project the event is processing
      • addStaticResourceAttachment

        String addStaticResourceAttachment​(com.atlassian.jira.project.Project project,
                                           Integer id)
        Add a static resource (scoped to project) by its Id
        Parameters:
        project - , the project in which the Static Resource has been scoped
        id - , numeric ID of the Static Resource
        Returns:
        html message (not i18n), a non empty value indicates a failure, eg, a resource was referred that is not scoped to the project the event is processing
      • renderStaticResourceImage

        String renderStaticResourceImage​(Integer id)
        Render a given static resource image (unscoped) inline.
        Parameters:
        id - , numeric ID of the Static Resource
        Returns:
        html to inline the related image, can also contain (non i18n) error messages if the inline failed
      • renderStaticResourceImage

        String renderStaticResourceImage​(com.atlassian.jira.project.Project project,
                                         Integer id)
        Render a given static resource image (scoped to the given project) inline.
        Parameters:
        project - , the project in which the Static Resource image is scoped
        id - , numeric ID of the Static Resource
        Returns:
        html to inline the related image, can also contain (non i18n) error messages if the inline failed, eg if not in scope
      • renderStaticResourceImage

        String renderStaticResourceImage​(com.atlassian.jira.project.Project project,
                                         Integer id,
                                         String type)
        Render a given static resource image (scoped to the given project) inline.
        Parameters:
        project - , the project in which the Static Resource image is scoped
        id - , numeric ID of the Static Resource
        type - , "cid" is the new default, "base64" (inline encoded data) is also valid
        Returns:
        html to inline the related image, can also contain (non i18n) error messages if the inline failed, eg if not in scope
      • getImageCidMap

        Map<String,​Integer> getImageCidMap()
        Internal use
        Returns:
        map of a generated CID to a given Static Resource
      • isCustomFieldChanged

        boolean isCustomFieldChanged​(com.atlassian.jira.event.issue.IssueEvent issueEvent,
                                     String cfId)
        Used to determine during outbound processing, whether the given custom field id was in a ChildChangeItem of the event
        Parameters:
        issueEvent - involved
        cfId - , custom field id, of format, customfield_12345
        Returns:
        true if changed
      • urlencode

        String urlencode​(String incoming)
        Helper method to urlencode(UTF-8) a string in Java context:
        Parameters:
        incoming - value
        Returns:
        encoded value
      • request

        com.atlassian.jira.util.json.JSONObject request​(Map<String,​Object> options)
        Perform a custom HTTP request
        Parameters:
        options - a Map containing the configuration options for this HTTP request
        • url - String - the absolute (full) request URL
        • method - String - the request method to use. GET is default.
        • type - an alias for "method"
        • username - String - username of the user to perform the request as
        • timeout - String or Integer - connection timeout in milliseconds
        • data - String - JSON data for request body. Appended to URL for GET requests. In JavaScript
          JSON.stringify(data)
          can be used to convert JSON/Object to String
        Returns:
        JSONObject containing the response
      • invokeLocalRest

        com.atlassian.jira.util.json.JSONObject invokeLocalRest​(String path)
        Make a HTTP request relative to the local Jira path
        Parameters:
        path - of local rest call, relative to Jira's base URL
        Returns:
        JSONObject containing the response body (if present)
      • invokeLocalAnonRest

        com.atlassian.jira.util.json.JSONObject invokeLocalAnonRest​(String path)
                                                             throws com.atlassian.jira.util.json.JSONException
        Make an anonymous HTTP request relative to the local Jira path
        Parameters:
        path - of local rest call, relative to Jira's base URL
        Returns:
        JSONObject containing the response body (if present)
        Throws:
        com.atlassian.jira.util.json.JSONException - if it breaks
      • createResultSet

        Map<String,​Object> createResultSet()
        Enable scripts to create multiple issue,by creating an additional (possibly many) new result sets containing key/value paris as usual
        Returns:
        map of values to initialize an issue, e.g. project="ABC", issueType="bug" etc.
      • getResultSets

        Collection<Map<String,​Object>> getResultSets()
        Accessor method to expose any additional ResultSets created by the script
        Returns:
        collection of result sets
      • addAdditionalResultSet

        void addAdditionalResultSet​(Map<String,​Object> resultSet)
        Method to add additional ResultSets created by the script
        Parameters:
        resultSet - New result set to be added to additional resultSets
      • log

        void log​(String level,
                 String msg)
        Output a message to the JEMH log file
        Parameters:
        level - the log level for the output: DEBUG, INFO, WARN, ERROR
        msg - the message to log
      • log

        void log​(String msg)
        Log an INFO message to the JEMH log file
        Parameters:
        msg - the message to log
      • getMessage

        javax.mail.Message getMessage()
      • getMessageSubParts

        List<javax.mail.Message> getMessageSubParts​(javax.mail.internet.MimeMessage parentMessage)
        Get the child attachment Parts that are message/rfc822
        Parameters:
        parentMessage - the Mime message
        Returns:
        child parts loaded as Message objects to allow further processing
      • getMessagePartText

        String getMessagePartText​(String contentType)
      • getMessageBody

        String getMessageBody​(javax.mail.Message message)
        Get the body (according to htmL to wiki conversion configuration in the Profile)
        Parameters:
        message - source
        Returns:
        wiki markup extracted
      • getLdap

        IJEMHLdapVelocityContextUtil getLdap()
        Create an Ldap helper that enables querying through LDAP configurations selected in the Profile
        Returns:
        ldap util support class
      • getUserAvatarURL

        URI getUserAvatarURL​(com.atlassian.jira.user.ApplicationUser user,
                             int size)
        Enable the URI of a user avatar to be retrieved for inlining
        Parameters:
        user - user to get avatar for
        size - size of avatar to get
        Returns:
        URI object
      • getProjectContext

        com.atlassian.jira.issue.context.ProjectContext getProjectContext​(Long projectId)
      • getIssueContext

        com.atlassian.jira.issue.context.IssueContext getIssueContext​(Long projectId,
                                                                      String issueTypeId)
      • addIndividualRecipientAddress

        void addIndividualRecipientAddress​(String addressCsv)
        * Adds an individual address to recipients list to a Non Jira User Template set in Non Jira user notification Project Mapping found in Notifications
        Parameters:
        addressCsv - valid values are of format user@domain.com, NO Name parts are supported.
      • addIndividualRecipientUser

        void addIndividualRecipientUser​(String username)
        Adds an individual user to recipients list to a Non Jira User Template found in the Non Jira user notification Project Mapping found in Notifications
        Parameters:
        username - user to entity to be notified in a Jira User Issue Event Template Set.
      • addIndividualRecipientGroup

        void addIndividualRecipientGroup​(String groupName)
        Adds users in a Group to the recipients list to a Jira User Issue Event Template set in the Jira user notification Project Mapping found in Notifications 1
        Parameters:
        groupName - user Group to entity to be notified in a Jira User Issue Event Template Set.
      • getOriginalAddressees

        List<javax.mail.internet.InternetAddress> getOriginalAddressees​(PreProcHeaderBean headerBean)
        Returns list of the Internet Addresses from specific header
        Parameters:
        headerBean - the value of the desired header
        Returns:
        list of InternetAddress
      • createInternetAddress

        javax.mail.internet.InternetAddress createInternetAddress​(String personal,
                                                                  String address)
        Creates a new Internet address
        Parameters:
        personal - , personal name
        address - , email address
        Returns:
        InternetAddress
      • updatePreProcHeader

        PreProcHeaderBean updatePreProcHeader​(List<javax.mail.internet.InternetAddress> addresses,
                                              PreProcHeaderBean headerBean)
        Updates specific header with the list of Internet addresses
        Parameters:
        addresses - , list of the internet addresses
        headerBean - , specific header
        Returns:
        PreProcHeaderBean
      • updatePreProcHeader

        void updatePreProcHeader​(String newValue,
                                 PreProcHeaderBean headerBean)
        Updates specific header with the provided value
        Parameters:
        newValue - , value
        headerBean - , specific header
      • getRequestType

        RequestTypeBean getRequestType​(String requestTypeKey)
        Returns a RequestTypeBean which holds properties of the Customer request type such as Name and Description
        Parameters:
        requestTypeKey - , the value of the desired request type
        Returns:
        RequestTypeBean or null
      • loadComponent

        <T> T loadComponent​(String interfaceOrClassName)
        As the previous context $jirautils was removed for security reasons the loadComponent functionality may still be required. However this is with a restricted internally with a list of Allowed Classes If you find that loadComponent does not load the class or component you require then please raise a support ticket and mentioning internal ticket JEMH-7702
        Type Parameters:
        T - the type of the component
        Parameters:
        interfaceOrClassName - , the class name or interface name of the component desired for example class name = [com.atlassian.jira.mention.MentionFinderImpl] interface name = [MentionFinder]
        Returns:
        if valid the typed resulting object instance or null if the object does not exist or if class/interface is not present or forbidden.
      • createResultSetForAdditionalMailboxAddresses

        List<Map<String,​Object>> createResultSetForAdditionalMailboxAddresses()
        Creates a List of Result Maps for every matching Catch Email Address in the email (except the initial Catch Email address). Each Result Map will be added as an additional result set, creating a new issue.
        Returns:
        a List of Result Maps
      • createJSONFromSource

        com.atlassian.jira.util.json.JSONObject createJSONFromSource​(String jsonSource)
                                                              throws com.atlassian.jira.util.json.JSONException
        Genreates a https://docs.atlassian.com/software/jira/docs/api/9.11.0/com/atlassian/jira/util/json/JSONObject.html from source JSON.
        Parameters:
        jsonSource - correctly formed JSON as TEXT
        Returns:
        parseable JSON Object
        Throws:
        com.atlassian.jira.util.json.JSONException