org.sakaiproject.james
Class SakaiMailet

java.lang.Object
  extended by org.apache.mailet.GenericMailet
      extended by org.sakaiproject.james.SakaiMailet
All Implemented Interfaces:
org.apache.mailet.Mailet, org.apache.mailet.MailetConfig

public class SakaiMailet
extends org.apache.mailet.GenericMailet

SakaiMailet watches incoming mail (via James) and sends mail to the appropriate mail archive channel in Sakai.


Field Summary
static String POSTMASTER
          The user name of the postmaster user - the one who posts incoming mail.
 
Constructor Summary
SakaiMailet()
           
 
Method Summary
protected  org.sakaiproject.entity.api.Reference createAttachment(String siteId, List attachments, String type, String fileName, byte[] body, String id)
          Create an attachment, adding it to the list of attachments.
 void destroy()
          Called when leaving.
protected  boolean fromValidUser(String fromAddr, MailArchiveChannel channel)
          Check if the fromAddr email address is recognized as belonging to a user who has permission to add to the channel.
 void init()
          Called when created.
protected  Integer parseParts(String siteId, javax.mail.Part p, String id, StringBuilder[] bodyBuf, StringBuilder bodyContentType, List attachments, Integer embedCount)
          Breaks email messages into parts which can be saved as files (saves as attachments) or viewed as plain text (added to body of message).
protected  byte[] readBody(int approxSize, InputStream stream)
          Read in a stream from the mime body into a byte array
 void service(org.apache.mailet.Mail mail)
          Process incoming mail.
 
Methods inherited from class org.apache.mailet.GenericMailet
getInitParameter, getInitParameter, getInitParameterNames, getMailetConfig, getMailetContext, getMailetInfo, getMailetName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSTMASTER

public static final String POSTMASTER
The user name of the postmaster user - the one who posts incoming mail.

See Also:
Constant Field Values
Constructor Detail

SakaiMailet

public SakaiMailet()
Method Detail

init

public void init()
          throws javax.mail.MessagingException
Called when created.

Overrides:
init in class org.apache.mailet.GenericMailet
Throws:
javax.mail.MessagingException

destroy

public void destroy()
Called when leaving.

Specified by:
destroy in interface org.apache.mailet.Mailet
Overrides:
destroy in class org.apache.mailet.GenericMailet

service

public void service(org.apache.mailet.Mail mail)
             throws javax.mail.MessagingException
Process incoming mail.

Specified by:
service in interface org.apache.mailet.Mailet
Specified by:
service in class org.apache.mailet.GenericMailet
Parameters:
mail - ...
Throws:
javax.mail.MessagingException

fromValidUser

protected boolean fromValidUser(String fromAddr,
                                MailArchiveChannel channel)
Check if the fromAddr email address is recognized as belonging to a user who has permission to add to the channel.

Parameters:
fromAddr - The email address to check.
channel - The mail archive channel.
Returns:
True if the email address is from a user who is authorized to add mail, false if not.

createAttachment

protected org.sakaiproject.entity.api.Reference createAttachment(String siteId,
                                                                 List attachments,
                                                                 String type,
                                                                 String fileName,
                                                                 byte[] body,
                                                                 String id)
Create an attachment, adding it to the list of attachments.


readBody

protected byte[] readBody(int approxSize,
                          InputStream stream)
Read in a stream from the mime body into a byte array


parseParts

protected Integer parseParts(String siteId,
                             javax.mail.Part p,
                             String id,
                             StringBuilder[] bodyBuf,
                             StringBuilder bodyContentType,
                             List attachments,
                             Integer embedCount)
                      throws javax.mail.MessagingException,
                             IOException
Breaks email messages into parts which can be saved as files (saves as attachments) or viewed as plain text (added to body of message).

Parameters:
siteId - Site associated with attachments, if any
p - The message-part embedded in a message..
id - The string containing the message's id.
bodyBuf - The string-buffers in which the plain/text and/or html/text message body is being built.
bodyContentType - The value of the Content-Type header for the mesage body.
attachments - The ReferenceVector in which references to attachments are collected.
embedCount - An Integer that counts embedded messages (outer message is zero).
Returns:
Value of embedCount (updated if this call processed any embedded messages).
Throws:
javax.mail.MessagingException
IOException


Copyright © 2003-2012 Sakai Foundation. All Rights Reserved.