org.apache.james.mailet.standard.mailets
Class StripAttachment

java.lang.Object
  extended by org.apache.mailet.base.GenericMailet
      extended by org.apache.james.mailet.standard.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 String ATTRIBUTE_PARAMETER_NAME
           
static String DECODE_FILENAME_PARAMETER_NAME
           
static String DIRECTORY_PARAMETER_NAME
           
static String NOTPATTERN_PARAMETER_NAME
           
static String PATTERN_PARAMETER_NAME
           
static String REMOVE_ALL
           
static String REMOVE_ATTACHMENT_PARAMETER_NAME
           
static String REMOVE_MATCHED
           
static String REMOVE_NONE
           
static String REMOVED_ATTACHMENTS_ATTRIBUTE_KEY
           
static String REPLACE_FILENAME_PATTERN_PARAMETER_NAME
           
static String SAVED_ATTACHMENTS_ATTRIBUTE_KEY
           
 
Constructor Summary
StripAttachment()
           
 
Method Summary
 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 String PATTERN_PARAMETER_NAME
See Also:
Constant Field Values

NOTPATTERN_PARAMETER_NAME

public static final String NOTPATTERN_PARAMETER_NAME
See Also:
Constant Field Values

ATTRIBUTE_PARAMETER_NAME

public static final String ATTRIBUTE_PARAMETER_NAME
See Also:
Constant Field Values

DIRECTORY_PARAMETER_NAME

public static final String DIRECTORY_PARAMETER_NAME
See Also:
Constant Field Values

REMOVE_ATTACHMENT_PARAMETER_NAME

public static final String REMOVE_ATTACHMENT_PARAMETER_NAME
See Also:
Constant Field Values

DECODE_FILENAME_PARAMETER_NAME

public static final String DECODE_FILENAME_PARAMETER_NAME
See Also:
Constant Field Values

REPLACE_FILENAME_PATTERN_PARAMETER_NAME

public static final String REPLACE_FILENAME_PATTERN_PARAMETER_NAME
See Also:
Constant Field Values

REMOVE_NONE

public static final String REMOVE_NONE
See Also:
Constant Field Values

REMOVE_ALL

public static final String REMOVE_ALL
See Also:
Constant Field Values

REMOVE_MATCHED

public static final String REMOVE_MATCHED
See Also:
Constant Field Values

REMOVED_ATTACHMENTS_ATTRIBUTE_KEY

public static final String REMOVED_ATTACHMENTS_ATTRIBUTE_KEY
See Also:
Constant Field Values

SAVED_ATTACHMENTS_ATTRIBUTE_KEY

public static final 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 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-2012 The Apache Software Foundation. All Rights Reserved.