org.apache.james.transport.mailets
Class StripAttachment

java.lang.Object
  extended by org.apache.mailet.base.GenericMailet
      extended by org.apache.james.transport.mailets.StripAttachment
All Implemented Interfaces:
Mailet, MailetConfig

public class StripAttachment
extends GenericMailet

Remove attachments from a Message. Supports simple removal, storing to file, or storing to mail attributes.

Configuration:

   <mailet match="All" class="StripAttachment" >
     <pattern >.*\.xls </pattern>  <!-- The regular expression that must be matched -- >
     <!-- notpattern >.*\.xls </notpattern-->  <!-- The regular expression that must be matched -- >
     <directory >c:\temp\james_attach </directory>   <!-- The directory to save to -- >
     <remove >all </remove>   <!-- either "no", "matched", "all" -- >
     <!-- attribute>my.attribute.name</attribute -->
   </mailet >
 


Field Summary
static java.lang.String ATTRIBUTE_PARAMETER_NAME
           
static java.lang.String DECODE_FILENAME_PARAMETER_NAME
           
static java.lang.String DIRECTORY_PARAMETER_NAME
           
static java.lang.String NOTPATTERN_PARAMETER_NAME
           
static java.lang.String PATTERN_PARAMETER_NAME
           
static java.lang.String REMOVE_ALL
           
static java.lang.String REMOVE_ATTACHMENT_PARAMETER_NAME
           
static java.lang.String REMOVE_MATCHED
           
static java.lang.String REMOVE_NONE
           
static java.lang.String REMOVED_ATTACHMENTS_ATTRIBUTE_KEY
           
static java.lang.String REPLACE_FILENAME_PATTERN_PARAMETER_NAME
           
static java.lang.String SAVED_ATTACHMENTS_ATTRIBUTE_KEY
           
 
Constructor Summary
StripAttachment()
           
 
Method Summary
 java.lang.String getMailetInfo()
          returns a String describing this mailet.
 void init()
          Checks if the mandatory parameters are present, creates the directory to save the files ni (if not present).
 void service(Mail mail)
          Service the mail: scan it for attchemnts matching the pattern, store the content of a matchin attachment in the given directory.
 
Methods inherited from class org.apache.mailet.base.GenericMailet
arrayToString, checkInitParameters, destroy, getInitParameter, getInitParameter, getInitParameter, getInitParameterNames, getMailetConfig, getMailetContext, getMailetName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATTERN_PARAMETER_NAME

public static final java.lang.String PATTERN_PARAMETER_NAME
See Also:
Constant Field Values

NOTPATTERN_PARAMETER_NAME

public static final java.lang.String NOTPATTERN_PARAMETER_NAME
See Also:
Constant Field Values

ATTRIBUTE_PARAMETER_NAME

public static final java.lang.String ATTRIBUTE_PARAMETER_NAME
See Also:
Constant Field Values

DIRECTORY_PARAMETER_NAME

public static final java.lang.String DIRECTORY_PARAMETER_NAME
See Also:
Constant Field Values

REMOVE_ATTACHMENT_PARAMETER_NAME

public static final java.lang.String REMOVE_ATTACHMENT_PARAMETER_NAME
See Also:
Constant Field Values

DECODE_FILENAME_PARAMETER_NAME

public static final java.lang.String DECODE_FILENAME_PARAMETER_NAME
See Also:
Constant Field Values

REPLACE_FILENAME_PATTERN_PARAMETER_NAME

public static final java.lang.String REPLACE_FILENAME_PATTERN_PARAMETER_NAME
See Also:
Constant Field Values

REMOVE_NONE

public static final java.lang.String REMOVE_NONE
See Also:
Constant Field Values

REMOVE_ALL

public static final java.lang.String REMOVE_ALL
See Also:
Constant Field Values

REMOVE_MATCHED

public static final java.lang.String REMOVE_MATCHED
See Also:
Constant Field Values

REMOVED_ATTACHMENTS_ATTRIBUTE_KEY

public static final java.lang.String REMOVED_ATTACHMENTS_ATTRIBUTE_KEY
See Also:
Constant Field Values

SAVED_ATTACHMENTS_ATTRIBUTE_KEY

public static final java.lang.String SAVED_ATTACHMENTS_ATTRIBUTE_KEY
See Also:
Constant Field Values
Constructor Detail

StripAttachment

public StripAttachment()
Method Detail

init

public void init()
          throws MailetException
Checks if the mandatory parameters are present, creates the directory to save the files ni (if not present).

Overrides:
init in class GenericMailet
Throws:
MailetException

service

public void service(Mail mail)
             throws MailetException
Service the mail: scan it for attchemnts matching the pattern, store the content of a matchin attachment in the given directory.

Specified by:
service in interface Mailet
Specified by:
service in class GenericMailet
Parameters:
mail - The mail to service
Throws:
MailetException - Thrown when an error situation is encountered.

getMailetInfo

public java.lang.String getMailetInfo()
returns a String describing this mailet.

Specified by:
getMailetInfo in interface Mailet
Overrides:
getMailetInfo in class GenericMailet
Returns:
A desciption of this mailet


Copyright © 2008-2009 The Apache Software Foundation. All Rights Reserved.