org.cert.cc.jira.email.handler
Class JIRAMediatorImpl

java.lang.Object
  extended by org.cert.cc.jira.email.handler.JIRAMediatorImpl
All Implemented Interfaces:
JIRAMediator
Direct Known Subclasses:
MockJIRAMediatorImpl

public class JIRAMediatorImpl
extends Object
implements JIRAMediator

JIRAMediatorImpl is the go between for most JIRA operations.

© 2009 Carnegie Mellon University

Author:
Steve Scholnick

Field Summary
protected static String PARAMETER_ADD_CC_WATCHERS
          add CC users configuration key
protected static String PARAMETER_DEFAULT_ASSIGNEE
          default assignee key
protected static String PARAMETER_DEFAULT_PRIORITY
          priority configuration key
protected static String PARAMETER_ISSUE_TYPE
          issue type configuration key
protected static String PARAMETER_PROJECT
          project configuration key
protected static String PARAMETER_REPORTER_IS_ASSIGNEE
          reporter always as assignee configuration key
protected static String PARAMETER_REPORTER_OVERRIDE
          reporter override
protected static String PARAMETER_REPORTER_USER
          report user key
protected static String PARAMETER_SCAN_RECIPIENTS_FOR_ASSIGNEE
          scan recipinet list for assigniee configuration key
protected static String PARAMETER_SUPPRESS_CREATED
          suppress the created by configuration key
 
Constructor Summary
JIRAMediatorImpl(Map<String,String> parameters)
          Constructs a new JIRAMediatorImpl
 
Method Summary
 IssueType calculateIssueType(Message message)
          Calculates and returns the JIRA IssueType
 Priority calculatePriority(Message message)
          Calculates and returns the JIRA issue Priority
 User determineAssignee(Message message, Project project, User reporter)
          Calculates and returns the issue assignee.
 Priority getDefaultSystemPriority()
          Returns the default system Priority
 String getDescription(Message message)
          Returns the description
 IssueType getIssueType(String issueTypeId)
          Returns the IssueType based on its ID
 String getParameterValue(Message message, String key, String xHeaderName)
          Returns a parameter value or an X-Header value.
 String getParameterValue(String key)
          Returns a parameter value based on the key
 List<Priority> getPossiblePriorties()
          Returns all of the possible Priority values
 Priority getPriority(int id)
          Returns the Priority based on its id value
 Comparator<Priority> getPriorityComparator()
          Returns a Comparator for Prioritys
 Project getProject(String projectKey)
          Returns the Project based on the key.
 GenericValue getProjectByName(String projectName)
          Returns the Project based on the key.
 User getUser(String identifier)
          Returns the JIRA User based on: If the identifier has an @, check to see the email address corresponds to a user. If the identifier does not have a @, check for username only.
 User getUserByEmail(String address)
          Returns the JIRA User based on their email address
 User getUserByUsername(String username)
          Returns the JIRA User based on their username
 boolean isValidUser(String emailAddress)
          Returns if the emailAddress is a valid JIRA user
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAMETER_PROJECT

protected static final String PARAMETER_PROJECT
project configuration key

See Also:
Constant Field Values

PARAMETER_DEFAULT_PRIORITY

protected static final String PARAMETER_DEFAULT_PRIORITY
priority configuration key

See Also:
Constant Field Values

PARAMETER_ADD_CC_WATCHERS

protected static final String PARAMETER_ADD_CC_WATCHERS
add CC users configuration key

See Also:
Constant Field Values

PARAMETER_ISSUE_TYPE

protected static final String PARAMETER_ISSUE_TYPE
issue type configuration key

See Also:
Constant Field Values

PARAMETER_REPORTER_OVERRIDE

protected static final String PARAMETER_REPORTER_OVERRIDE
reporter override

See Also:
Constant Field Values

PARAMETER_REPORTER_IS_ASSIGNEE

protected static final String PARAMETER_REPORTER_IS_ASSIGNEE
reporter always as assignee configuration key

See Also:
Constant Field Values

PARAMETER_DEFAULT_ASSIGNEE

protected static final String PARAMETER_DEFAULT_ASSIGNEE
default assignee key

See Also:
Constant Field Values

PARAMETER_REPORTER_USER

protected static final String PARAMETER_REPORTER_USER
report user key

See Also:
Constant Field Values

PARAMETER_SCAN_RECIPIENTS_FOR_ASSIGNEE

protected static final String PARAMETER_SCAN_RECIPIENTS_FOR_ASSIGNEE
scan recipinet list for assigniee configuration key

See Also:
Constant Field Values

PARAMETER_SUPPRESS_CREATED

protected static final String PARAMETER_SUPPRESS_CREATED
suppress the created by configuration key

See Also:
Constant Field Values
Constructor Detail

JIRAMediatorImpl

public JIRAMediatorImpl(Map<String,String> parameters)
Constructs a new JIRAMediatorImpl

Parameters:
parameters - Handler parameters
Method Detail

determineAssignee

public final User determineAssignee(Message message,
                                    Project project,
                                    User reporter)
                             throws MessagingException
Calculates and returns the issue assignee. The algorithm is:
  1. If reporterassignee is set to 1, the assignee is the reporter
  2. If recipientassignee is set to 1, the To: followed by the CC: recipients is scanned looking for a valid JIRA user. The first one, that is found, becomes the assignee.
  3. The default assignee --usually the project lead, becomes the assignee.
  4. No assignee is set
  5. Specified by:
    determineAssignee in interface JIRAMediator
    Parameters:
    message - Email Message
    project - JIRA Project
    reporter - Who is reporting this issue
    Returns:
    Assignee or null
    Throws:
    MessagingException - If unable to interrogate the Message

calculateIssueType

public final IssueType calculateIssueType(Message message)
                                   throws MessagingException
Calculates and returns the JIRA IssueType

Specified by:
calculateIssueType in interface JIRAMediator
Parameters:
message - Email Message
Returns:
IssueType
Throws:
MessagingException - If unable to interrogate the Message

calculatePriority

public final Priority calculatePriority(Message message)
                                 throws MessagingException
Calculates and returns the JIRA issue Priority

Specified by:
calculatePriority in interface JIRAMediator
Parameters:
message - Email Message
Returns:
Priority
Throws:
MessagingException - If unable to interrogate the Message

getPriority

public Priority getPriority(int id)
Returns the Priority based on its id value

Specified by:
getPriority in interface JIRAMediator
Parameters:
id - Integer value for the Priority
Returns:
Priority

getIssueType

public IssueType getIssueType(String issueTypeId)
Returns the IssueType based on its ID

Specified by:
getIssueType in interface JIRAMediator
Parameters:
issueTypeId - IssueType ID
Returns:
IssueType

getPossiblePriorties

public List<Priority> getPossiblePriorties()
Returns all of the possible Priority values

Specified by:
getPossiblePriorties in interface JIRAMediator

getProject

public Project getProject(String projectKey)
Returns the Project based on the key. If no Project is found, null will be returned.

Specified by:
getProject in interface JIRAMediator
Parameters:
projectKey - Project key
Returns:
Project

getProjectByName

public GenericValue getProjectByName(String projectName)
                              throws DataAccessException
Returns the Project based on the key.

Specified by:
getProjectByName in interface JIRAMediator
Parameters:
projectName - Project name
Returns:
Project
Throws:
DataAccessException - If unable to find the project

getDefaultSystemPriority

public Priority getDefaultSystemPriority()
Returns the default system Priority

Specified by:
getDefaultSystemPriority in interface JIRAMediator

getUser

public final User getUser(String identifier)
                   throws EntityNotFoundException
Returns the JIRA User based on:
  1. If the identifier has an @, check to see the email address corresponds to a user.
  2. If the identifier does not have a @, check for username only.
  3. If the identifier has an @ and the email address is invalid, check the username part only of the email address.

Specified by:
getUser in interface JIRAMediator
Parameters:
identifier - Identifier (username or email address)
Returns:
JIRA User
Throws:
EntityNotFoundException - If no matching User is found

getUserByEmail

public User getUserByEmail(String address)
                    throws EntityNotFoundException
Returns the JIRA User based on their email address

Specified by:
getUserByEmail in interface JIRAMediator
Parameters:
address - Email address
Returns:
JIRA User
Throws:
EntityNotFoundException - If no User matches the email address

getUserByUsername

public User getUserByUsername(String username)
                       throws EntityNotFoundException
Returns the JIRA User based on their username

Specified by:
getUserByUsername in interface JIRAMediator
Parameters:
username - JIRA username
Returns:
JIRA User
Throws:
EntityNotFoundException - If no User matches the username

isValidUser

public boolean isValidUser(String emailAddress)
Returns if the emailAddress is a valid JIRA user

Specified by:
isValidUser in interface JIRAMediator
Parameters:
emailAddress - Email address
Returns:
If the emailAddress is a valid JIRA user

getDescription

public String getDescription(Message message)
                      throws MessagingException
Returns the description

Specified by:
getDescription in interface JIRAMediator
Parameters:
message - Email Message
Returns:
Description
Throws:
MessagingException - If unable to interrogate the Message

getParameterValue

public final String getParameterValue(String key)
Returns a parameter value based on the key

Specified by:
getParameterValue in interface JIRAMediator

getParameterValue

public final String getParameterValue(Message message,
                                      String key,
                                      String xHeaderName)
                               throws MessagingException
Returns a parameter value or an X-Header value. If the X-Header value is not null, it will be returned. Otherwise the value of the parameter will be returned.

Specified by:
getParameterValue in interface JIRAMediator
Parameters:
message - Email Message
key - Parameter key
xHeaderName - X-Header name
Returns:
Configuration value
Throws:
MessagingException - If unable to interrogate the Message

getPriorityComparator

public Comparator<Priority> getPriorityComparator()
Returns a Comparator for Prioritys

Specified by:
getPriorityComparator in interface JIRAMediator


Copyright © 2012 Carnegie Mellon University