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

java.lang.Object
  extended bycom.atlassian.jira.service.util.handler.AbstractMessageHandler
All Implemented Interfaces:
MessageHandler
Direct Known Subclasses:
AbstractCommentHandler, CreateIssueHandler, CreateOrCommentHandler, CVSLogHandler, EmailHandler

public abstract class AbstractMessageHandler
extends Object
implements MessageHandler

An AbstractMessageHandler that stores the parameter map.


Field Summary
 String catchEmail
          New issues without this receipient are ignored.
 boolean createUsers
          Whether to create users if they do not exist
protected static String KEY_CATCHEMAIL
           
protected static String KEY_CREATEUSERS
           
protected static String KEY_NOTIFYUSERS
           
protected static String KEY_REPORTER
           
 boolean notifyUsers
           
protected  Map params
           
 String reporteruserName
          Username of default reporter, if sender not recognized.
 
Constructor Summary
AbstractMessageHandler()
           
 
Method Summary
 void addError(String error)
           
 void addError(String error, Exception e)
           
 boolean addErrorAndReturnFalse(String error)
           
 boolean addErrorAndReturnFalse(String error, Exception e)
           
protected  void createAttachmentsForMessage(javax.mail.Message message, org.ofbiz.core.entity.GenericValue issue)
          Loops through all the Parts, and for each one of type Part.ATTACHMENT, call createAttachmentWithPart(BodyPart, Message, GenericValue).
protected  void createAttachmentWithPart(javax.mail.BodyPart part, javax.mail.Message message, org.ofbiz.core.entity.GenericValue issue)
          Create an attachment for a particular mime-part.
protected  org.ofbiz.core.entity.GenericValue getAssociatedIssue(javax.mail.Message message)
           
protected  MessageErrorHandler getErrorHandler()
           
protected  File getFileFromPart(javax.mail.BodyPart part, org.ofbiz.core.entity.GenericValue issue)
           
protected  I18nBean getI18nBean()
           
protected  User getReporter(javax.mail.Message message)
          Get the reporter from the email address who sent the message, or else create a new user if creating users is set to true, or use the default reporter if one is specified.
abstract  boolean handleMessage(javax.mail.Message message)
          To be implemented in sub-classes
 void init(Map params)
           
protected  void recordMessageId(String type, javax.mail.Message message, Long issueId)
           
 void setErrorHandler(MessageErrorHandler errorHandler)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_REPORTER

protected static final String KEY_REPORTER
See Also:
Constant Field Values

KEY_CATCHEMAIL

protected static final String KEY_CATCHEMAIL
See Also:
Constant Field Values

KEY_CREATEUSERS

protected static final String KEY_CREATEUSERS
See Also:
Constant Field Values

KEY_NOTIFYUSERS

protected static final String KEY_NOTIFYUSERS
See Also:
Constant Field Values

params

protected Map params

reporteruserName

public String reporteruserName
Username of default reporter, if sender not recognized.


catchEmail

public String catchEmail
New issues without this receipient are ignored.


createUsers

public boolean createUsers
Whether to create users if they do not exist


notifyUsers

public boolean notifyUsers
Constructor Detail

AbstractMessageHandler

public AbstractMessageHandler()
Method Detail

init

public void init(Map params)
Specified by:
init in interface MessageHandler

handleMessage

public abstract boolean handleMessage(javax.mail.Message message)
                               throws javax.mail.MessagingException
To be implemented in sub-classes

Specified by:
handleMessage in interface MessageHandler
Throws:
javax.mail.MessagingException

createAttachmentsForMessage

protected void createAttachmentsForMessage(javax.mail.Message message,
                                           org.ofbiz.core.entity.GenericValue issue)
                                    throws IOException,
                                           javax.mail.MessagingException
Loops through all the Parts, and for each one of type Part.ATTACHMENT, call createAttachmentWithPart(BodyPart, Message, GenericValue).

Parameters:
message - The multipart message to search for attachments in
issue - The issue to create attachments in
Throws:
IOException - If there is a problem creating the attachment
javax.mail.MessagingException - If there is a problem reading the message

createAttachmentWithPart

protected void createAttachmentWithPart(javax.mail.BodyPart part,
                                        javax.mail.Message message,
                                        org.ofbiz.core.entity.GenericValue issue)
                                 throws IOException
Create an attachment for a particular mime-part. The BodyPart must be of type Part.ATTACHMENT.

Parameters:
part - The part of disposition Part.ATTACHMENT to create the attachment from
issue - The issue to create attachments in
Throws:
IOException - If there is a problem creating the attachment in the filesystem

getFileFromPart

protected File getFileFromPart(javax.mail.BodyPart part,
                               org.ofbiz.core.entity.GenericValue issue)
                        throws IOException,
                               javax.mail.MessagingException,
                               org.ofbiz.core.entity.GenericEntityException
Throws:
IOException
javax.mail.MessagingException
org.ofbiz.core.entity.GenericEntityException

getReporter

protected User getReporter(javax.mail.Message message)
                    throws javax.mail.MessagingException
Get the reporter from the email address who sent the message, or else create a new user if creating users is set to true, or use the default reporter if one is specified.

If neither of these are found, return null.

Parameters:
message - The email message to search through.
Returns:
The user who sent the email, or the default reporter, or null.
Throws:
javax.mail.MessagingException - If there is a problem getting the user who created the message.

recordMessageId

protected void recordMessageId(String type,
                               javax.mail.Message message,
                               Long issueId)
                        throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

getAssociatedIssue

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

setErrorHandler

public void setErrorHandler(MessageErrorHandler errorHandler)
Specified by:
setErrorHandler in interface MessageHandler

addError

public void addError(String error)

addError

public void addError(String error,
                     Exception e)

addErrorAndReturnFalse

public boolean addErrorAndReturnFalse(String error)

addErrorAndReturnFalse

public boolean addErrorAndReturnFalse(String error,
                                      Exception e)

getErrorHandler

protected MessageErrorHandler getErrorHandler()

getI18nBean

protected I18nBean getI18nBean()


Copyright © 2002-2006 Atlassian. All Rights Reserved.