cern.jira.emailhandler
Class AdvancedCreateIssueHandler

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

public class AdvancedCreateIssueHandler
extends com.atlassian.jira.service.util.handler.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.

Version:
2.3 (29-5-2007)
Author:
Daniele Raffo on the basis of the CreateIssueHandler class, copyright (c) 2002-2006 Atlassian

Field Summary
private static java.lang.String CC_ASSIGNEE
           
 boolean ccAssignee
           
 java.lang.String defaultIssueType
           
 java.lang.String defaultProjectKey
           
private  IssueDescriptor issueDescriptor
           
 java.lang.String issueType
           
private static java.lang.String KEY_ISSUETYPE
           
private static java.lang.String KEY_PROJECT
           
private static org.apache.log4j.Category log
           
private  java.util.Collection priorities
           
 java.lang.String projectKey
           
 
Fields inherited from class com.atlassian.jira.service.util.handler.AbstractMessageHandler
applicationProperties, bulk, catchEmail, commentManager, CONTENT_TYPE_PKCS7, CONTENT_TYPE_TEXT, createUsers, deleteEmail, issueFactory, KEY_BULK, KEY_CATCHEMAIL, KEY_CREATEUSERS, KEY_NOTIFYUSERS, KEY_REPORTER, notifyUsers, params, reporteruserName
 
Constructor Summary
AdvancedCreateIssueHandler()
           
 
Method Summary
private  java.lang.String getDefaultSystemPriority()
           
private  java.lang.String getDescription(com.opensymphony.user.User reporter, javax.mail.Message message)
          Extracts the description of the issue from the message.
static com.opensymphony.user.User getFirstValidAssignee(javax.mail.Address[] addresses, org.ofbiz.core.entity.GenericValue project)
          Given an array of addresses, returns the first valid assignee for the appropriate project.
private  java.lang.String getPriority()
          Get the issue's priority.
protected  org.ofbiz.core.entity.GenericValue getProject()
           
protected  com.atlassian.jira.project.ProjectManager getProjectManager()
           
static com.opensymphony.user.User getUserByName(java.lang.String userName)
          Returns an User given its userName.
 boolean handleMessage(javax.mail.Message message)
           
protected  boolean hasValidIssueType()
           
 void init(java.util.Map params)
           
private  boolean isEnterprise()
           
private static boolean isValidAssignee(org.ofbiz.core.entity.GenericValue project, com.opensymphony.user.User user)
          Tells if user is a valid assignee for project.
private  java.lang.String recordFromAddressForAnon(com.opensymphony.user.User reporter, javax.mail.Message message, java.lang.String description)
          Adds the senders' from addresses to the end of the issue's details (if they could be extracted), if the e-mail has been received from an unknown e-mail address and the mapping to an "anonymous" user has been enabled.
private  void setDefaultSecurityLevel(com.atlassian.jira.issue.MutableIssue issue)
           
(package private)  void setIssueDescriptor(IssueDescriptor issueDescriptor)
           
 
Methods inherited from class com.atlassian.jira.service.util.handler.AbstractMessageHandler
addError, addError, addErrorAndReturnFalse, addErrorAndReturnFalse, canHandleMessage, createAttachmentsForMessage, createAttachmentWithPart, createUserForReporter, getAssociatedIssue, getErrorHandler, getFileFromPart, getI18nBean, getPrecedenceHeader, getReporter, recordMessageId, setErrorHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.log4j.Category log

issueDescriptor

private IssueDescriptor issueDescriptor

priorities

private java.util.Collection priorities

projectKey

public java.lang.String projectKey

issueType

public java.lang.String issueType

defaultProjectKey

public java.lang.String defaultProjectKey

defaultIssueType

public java.lang.String defaultIssueType

ccAssignee

public boolean ccAssignee

KEY_PROJECT

private static final java.lang.String KEY_PROJECT
See Also:
Constant Field Values

KEY_ISSUETYPE

private static final java.lang.String KEY_ISSUETYPE
See Also:
Constant Field Values

CC_ASSIGNEE

private static final java.lang.String CC_ASSIGNEE
See Also:
Constant Field Values
Constructor Detail

AdvancedCreateIssueHandler

public AdvancedCreateIssueHandler()
Method Detail

init

public void init(java.util.Map params)
Specified by:
init in interface com.atlassian.jira.service.util.handler.MessageHandler
Overrides:
init in class com.atlassian.jira.service.util.handler.AbstractMessageHandler

handleMessage

public boolean handleMessage(javax.mail.Message message)
                      throws javax.mail.MessagingException
Specified by:
handleMessage in interface com.atlassian.jira.service.util.handler.MessageHandler
Specified by:
handleMessage in class com.atlassian.jira.service.util.handler.AbstractMessageHandler
Throws:
javax.mail.MessagingException

getProject

protected org.ofbiz.core.entity.GenericValue getProject()

hasValidIssueType

protected boolean hasValidIssueType()

getProjectManager

protected com.atlassian.jira.project.ProjectManager getProjectManager()

getDescription

private java.lang.String getDescription(com.opensymphony.user.User reporter,
                                        javax.mail.Message message)
                                 throws javax.mail.MessagingException
Extracts the description of the issue from the message.

Parameters:
reporter - the established reporter of the issue
message - the message from which the issue is created
Returns:
the description of the issue
Throws:
javax.mail.MessagingException

recordFromAddressForAnon

private java.lang.String recordFromAddressForAnon(com.opensymphony.user.User reporter,
                                                  javax.mail.Message message,
                                                  java.lang.String description)
                                           throws javax.mail.MessagingException
Adds the senders' from addresses to the end of the issue's details (if they could be extracted), if the e-mail has been received from an unknown e-mail address and the mapping to an "anonymous" user has been enabled.

Parameters:
reporter - the established reporter of the issue (after one has been established)
message - the message that is used to create issue
description - the issues extracted description
Returns:
the modified description if the e-mail is from anonymous user, unmodified description otherwise
Throws:
javax.mail.MessagingException

getPriority

private java.lang.String getPriority()
Get the issue's priority.


getDefaultSystemPriority

private java.lang.String getDefaultSystemPriority()

getFirstValidAssignee

public static com.opensymphony.user.User getFirstValidAssignee(javax.mail.Address[] addresses,
                                                               org.ofbiz.core.entity.GenericValue project)
Given an array of addresses, returns the first valid assignee for the appropriate project.

Parameters:
addresses - the addresses
project - the project
Returns:
the first valid assignee for project

isValidAssignee

private static boolean isValidAssignee(org.ofbiz.core.entity.GenericValue project,
                                       com.opensymphony.user.User user)
Tells if user is a valid assignee for project.

Parameters:
project - a project
user - an user
Returns:
whether user is a valid assignee for project

getUserByName

public static com.opensymphony.user.User getUserByName(java.lang.String userName)
Returns an User given its userName.

Parameters:
userName - the name of the user
Returns:
the user, or null if there was no user with name userName

setDefaultSecurityLevel

private void setDefaultSecurityLevel(com.atlassian.jira.issue.MutableIssue issue)
                              throws java.lang.Exception
Throws:
java.lang.Exception

isEnterprise

private boolean isEnterprise()

setIssueDescriptor

final void setIssueDescriptor(IssueDescriptor issueDescriptor)