com.atlassian.jira.service.util.handler
Class CreateIssueHandler

java.lang.Object
  extended by com.atlassian.jira.service.util.handler.AbstractMessageHandler
      extended by com.atlassian.jira.service.util.handler.CreateIssueHandler
All Implemented Interfaces:
MessageHandler

public class CreateIssueHandler
extends AbstractMessageHandler

A message handler to create a new issue from an incoming message. Note: requires public noarg constructor as this class is instantiated by reflection


Field Summary
 boolean ccAssignee
           
 boolean ccWatcher
           
 String issueType
           
 String projectKey
           
 
Fields inherited from class com.atlassian.jira.service.util.handler.AbstractMessageHandler
applicationProperties, bulk, catchEmail, commentManager, CONTENT_TYPE_TEXT, createUsers, deleteEmail, HEADER_IN_REPLY_TO, HEADER_MESSAGE_ID, issueFactory, KEY_BULK, KEY_CATCHEMAIL, KEY_CREATEUSERS, KEY_FINGER_PRINT, KEY_NOTIFYUSERS, KEY_REPORTER, notifyUsers, params, reporteruserName
 
Constructor Summary
CreateIssueHandler()
           
 
Method Summary
 void addCcWatchersToIssue(javax.mail.Message message, org.ofbiz.core.entity.GenericValue issue, User reporter)
          Adds all valid users that are in the email to and cc fields as watchers of the issue.
protected  boolean attachHtmlParts(javax.mail.Part part)
          Html parts are not attached but rather potentially form the source of issue text.
protected  boolean attachPlainTextParts(javax.mail.Part part)
          Text parts are not attached but rather potentially form the source of issue text.
 Collection getAllUsersFromEmails(javax.mail.Address[] addresses)
           
static User getFirstValidAssignee(javax.mail.Address[] addresses, org.ofbiz.core.entity.GenericValue project)
          Given an array of addresses, this method returns the first valid assignee for the appropriate project.
protected  org.ofbiz.core.entity.GenericValue getProject(javax.mail.Message message)
           
protected  ProjectManager getProjectManager()
           
 boolean handleMessage(javax.mail.Message message)
          Perform the specific work of this handler for the given message.
protected  boolean hasValidIssueType()
           
 void init(Map params)
          Will be called before any messages are to be handled.
 
Methods inherited from class com.atlassian.jira.service.util.handler.AbstractMessageHandler
addError, addError, addErrorAndReturnFalse, addErrorAndReturnFalse, attachAttachmentsParts, attachInlineParts, attachMessagePart, attachRelatedPart, canHandleMessage, createAttachmentsForMessage, createAttachmentWithPart, createUserForReporter, findUserByEmail, findUserByUsername, getAssociatedIssue, getErrorHandler, getFileFromPart, getFilenameForAttachment, getI18nBean, getPrecedenceHeader, getReporter, isAutoSubmitted, isDeliveryStatus, recordMessageId, renameFileIfInvalid, setErrorHandler, 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

issueType

public String issueType

ccAssignee

public boolean ccAssignee

ccWatcher

public boolean ccWatcher
Constructor Detail

CreateIssueHandler

public CreateIssueHandler()
Method Detail

init

public void init(Map params)
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.

handleMessage

public boolean handleMessage(javax.mail.Message message)
                      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.
Returns:
true if the message is to be deleted from the source.
Throws:
javax.mail.MessagingException - if anything went wrong.

addCcWatchersToIssue

public void addCcWatchersToIssue(javax.mail.Message message,
                                 org.ofbiz.core.entity.GenericValue issue,
                                 User reporter)
                          throws javax.mail.MessagingException
Adds all valid users that are in the email to and cc fields as watchers of the issue.

Parameters:
message - message to extract the email addresses from
issue - issue to add the watchers to
reporter -
Throws:
javax.mail.MessagingException - message errors

getAllUsersFromEmails

public Collection getAllUsersFromEmails(javax.mail.Address[] addresses)

getProject

protected org.ofbiz.core.entity.GenericValue getProject(javax.mail.Message message)

hasValidIssueType

protected boolean hasValidIssueType()

getProjectManager

protected ProjectManager getProjectManager()

getFirstValidAssignee

public static User getFirstValidAssignee(javax.mail.Address[] addresses,
                                         org.ofbiz.core.entity.GenericValue project)
Given an array of addresses, this method returns the first valid assignee for the appropriate project. It returns null if addresses is null or empty array, or none of the users found by addresses is assignable.

Parameters:
addresses - array of addresses
project - project generic value
Returns:
first assignable user based on the array of addresses

attachPlainTextParts

protected boolean attachPlainTextParts(javax.mail.Part part)
                                throws javax.mail.MessagingException,
                                       IOException
Text parts are not attached but rather potentially form the source of issue text. However text part attachments are kept providing they aint empty.

Specified by:
attachPlainTextParts in class AbstractMessageHandler
Parameters:
part - The part which will have a content type of text/plain to be tested.
Returns:
Only returns true if the part is an attachment and not empty
Throws:
javax.mail.MessagingException
IOException

attachHtmlParts

protected boolean attachHtmlParts(javax.mail.Part part)
                           throws javax.mail.MessagingException,
                                  IOException
Html parts are not attached but rather potentially form the source of issue text. However html part attachments are kept providing they aint empty.

Specified by:
attachHtmlParts in class AbstractMessageHandler
Parameters:
part - The part which will have a content type of text/html to be tested.
Returns:
Only returns true if the part is an attachment and not empty
Throws:
javax.mail.MessagingException
IOException


Copyright © 2002-2009 Atlassian. All Rights Reserved.