com.atlassian.jira.plugins.mail.handlers
Class CreateOrCommentHandler

java.lang.Object
  extended by com.atlassian.jira.plugins.mail.handlers.AbstractMessageHandler
      extended by com.atlassian.jira.plugins.mail.handlers.CreateOrCommentHandler
All Implemented Interfaces:
MessageHandler
Direct Known Subclasses:
StudioEmailHandler

public class CreateOrCommentHandler
extends AbstractMessageHandler

A message handler to create a new issue, or add a comment to an existing issue, from an incoming message. If the subject contains a project key the message is added as a comment to that issue. If no project key is found, a new issue is created in the default project.


Field Summary
 String issueType
          Default type for new issues.
static String KEY_ISSUETYPE
           
static String KEY_PROJECT
           
static String KEY_QUOTES
           
 String projectKey
          Default project where new issues are created.
 String stripquotes
          If set (to anything except "false"), quoted text is removed from comments.
 
Fields inherited from class com.atlassian.jira.plugins.mail.handlers.AbstractMessageHandler
applicationProperties, bulk, catchEmail, CONTENT_TYPE_TEXT, createUsers, deleteEmail, HEADER_IN_REPLY_TO, HEADER_MESSAGE_ID, KEY_BULK, KEY_CATCHEMAIL, KEY_CREATEUSERS, KEY_FINGER_PRINT, KEY_NOTIFYUSERS, KEY_REPORTER, log, messageUserProcessor, notifyUsers, params, reporteruserName, userManager, VALUE_BULK_DELETE, VALUE_BULK_FORWARD, VALUE_BULK_IGNORE, VALUE_FINGER_PRINT_ACCEPT, VALUE_FINGER_PRINT_FORWARD, VALUE_FINGER_PRINT_IGNORE
 
Constructor Summary
CreateOrCommentHandler()
           
 
Method Summary
protected  boolean attachHtmlParts(javax.mail.Part part)
          Comments never wish to keep html parts that are not attachments as they extract the plain text part and use that as the content.
protected  boolean attachPlainTextParts(javax.mail.Part part)
          Plain text parts must be kept if they are not empty.
 boolean handleMessage(javax.mail.Message message, MessageHandlerContext context)
          Perform the specific work of this handler for the given message.
 void init(Map<String,String> params, MessageHandlerErrorCollector errorCollector)
          Will be called before any messages are to be handled.
 
Methods inherited from class com.atlassian.jira.plugins.mail.handlers.AbstractMessageHandler
attachAttachmentsParts, attachInlineParts, attachMessagePart, attachRelatedPart, canHandleMessage, createAttachmentsForMessage, createAttachmentWithPart, createUserForReporter, getAssociatedIssue, getFileFromPart, getFilenameForAttachment, getI18nBean, getMessageUserProcessor, getPrecedenceHeader, getReporter, isAutoSubmitted, isDeliveryStatus, recordMessageId, renameFileIfInvalid, shouldAttach
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

projectKey

public String projectKey
Default project where new issues are created.


issueType

public String issueType
Default type for new issues.


stripquotes

public String stripquotes
If set (to anything except "false"), quoted text is removed from comments.


KEY_PROJECT

public static final String KEY_PROJECT
See Also:
Constant Field Values

KEY_ISSUETYPE

public static final String KEY_ISSUETYPE
See Also:
Constant Field Values

KEY_QUOTES

public static final String KEY_QUOTES
See Also:
Constant Field Values
Constructor Detail

CreateOrCommentHandler

public CreateOrCommentHandler()
Method Detail

handleMessage

public boolean handleMessage(javax.mail.Message message,
                             MessageHandlerContext context)
                      throws javax.mail.MessagingException
Description copied from class: AbstractMessageHandler
Perform the specific work of this handler for the given message.

Specified by:
handleMessage in interface MessageHandler
Specified by:
handleMessage in class AbstractMessageHandler
Parameters:
message - the message to check for handling.
context - user-friendly message handler should utilize this interface to create issue, comments, users and provide feedback information about messages being processed and problems being encountered. While MessageHandler-s are run from UI (in TEST / dry-run mode) such invocations are not mutative (they do not create any JIRA entities) and information provided by the handler is displayed back to the user as a summary of the dry-run.
Returns:
true if the message is to be deleted from the source.
Throws:
javax.mail.MessagingException - if anything went wrong.

init

public void init(Map<String,String> params,
                 MessageHandlerErrorCollector errorCollector)
Description copied from interface: MessageHandler
Will be called before any messages are to be handled.

Specified by:
init in interface MessageHandler
Overrides:
init in class AbstractMessageHandler
Parameters:
params - configuration.
errorCollector - potential problems encountered during initialization of the handler should be reported here. Depending on the run mode it may be e.g. displayed back to the user (when handler is tested from UI) or logged to the file .

attachPlainTextParts

protected boolean attachPlainTextParts(javax.mail.Part part)
                                throws javax.mail.MessagingException,
                                       IOException
Plain text parts must be kept if they are not empty.

Specified by:
attachPlainTextParts in class AbstractMessageHandler
Parameters:
part - The plain text part being tested.
Returns:
Returns true to attach false otherwise.
Throws:
javax.mail.MessagingException - if javamail complains
IOException - if javamail complains

attachHtmlParts

protected boolean attachHtmlParts(javax.mail.Part part)
                           throws javax.mail.MessagingException,
                                  IOException
Comments never wish to keep html parts that are not attachments as they extract the plain text part and use that as the content. This method therefore is hard wired to always return false.

Specified by:
attachHtmlParts in class AbstractMessageHandler
Parameters:
part - The html part being processed
Returns:
Always return false.
Throws:
javax.mail.MessagingException
IOException


Copyright © 2002-2012 Atlassian. All Rights Reserved.