org.apache.james.transport.matchers
Class AttachmentFileNameIs

java.lang.Object
  extended by org.apache.mailet.GenericMatcher
      extended by org.apache.james.transport.matchers.AttachmentFileNameIs
All Implemented Interfaces:
Matcher, MatcherConfig

public class AttachmentFileNameIs
extends GenericMatcher

Checks if at least one attachment has a file name which matches any element of a comma-separated or space-separated list of file name masks.

Syntax: match="AttachmentFileNameIs=[-d] [-z] masks"

The match is case insensitive.

File name masks may start with a wildcard '*'.

Multiple file name masks can be specified, e.g.: '*.scr,*.bat'.

If '-d' is coded, some debug info will be logged.

If '-z' is coded, the check will be non-recursively applied to the contents of any attached '*.zip' file.

Since:
2.2.0
Version:
CVS $Revision: 365582 $ $Date: 2006-01-03 08:51:21 +0000 (mar, 03 gen 2006) $

Field Summary
protected static java.lang.String DEBUG_REQUEST_PARAMETER
          Debug request parameter.
protected  boolean isDebug
          Controls certain log messages.
protected static java.lang.String UNZIP_REQUEST_PARAMETER
          Unzip request parameter.
protected  boolean unzipIsRequested
          True if unzip is requested.
protected static java.lang.String ZIP_SUFFIX
          Match string for zip files.
 
Constructor Summary
AttachmentFileNameIs()
           
 
Method Summary
protected  java.lang.String cleanFileName(java.lang.String fileName)
          Transforms fileName in a trimmed lowercase string usable for matching agains the masks.
 void init()
          A convenience method which can be overridden so that there's no need to call super.init(config).
 java.util.Collection match(Mail mail)
          Either every recipient is matching or neither of them.
protected  boolean matchFound(javax.mail.Part part)
          Checks if part matches with at least one of the masks.
protected  boolean matchFound(java.lang.String fileName)
          Checks if fileName matches with at least one of the masks.
protected  boolean matchFoundInZip(javax.mail.Part part)
          Checks if part is a zip containing a file that matches with at least one of the masks.
 
Methods inherited from class org.apache.mailet.GenericMatcher
destroy, getCondition, getMailetContext, getMatcherConfig, getMatcherInfo, getMatcherName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNZIP_REQUEST_PARAMETER

protected static final java.lang.String UNZIP_REQUEST_PARAMETER
Unzip request parameter.

See Also:
Constant Field Values

DEBUG_REQUEST_PARAMETER

protected static final java.lang.String DEBUG_REQUEST_PARAMETER
Debug request parameter.

See Also:
Constant Field Values

ZIP_SUFFIX

protected static final java.lang.String ZIP_SUFFIX
Match string for zip files.

See Also:
Constant Field Values

isDebug

protected boolean isDebug
Controls certain log messages.


unzipIsRequested

protected boolean unzipIsRequested
True if unzip is requested.

Constructor Detail

AttachmentFileNameIs

public AttachmentFileNameIs()
Method Detail

init

public void init()
          throws javax.mail.MessagingException
Description copied from class: GenericMatcher

A convenience method which can be overridden so that there's no need to call super.init(config).

Instead of overriding init(MatcherConfig), simply override this method and it will be called by GenericMatcher.init(MatcherConfig config). The MatcherConfig object can still be retrieved via getMatcherConfig().

Overrides:
init in class GenericMatcher
Throws:
javax.mail.MessagingException

match

public java.util.Collection match(Mail mail)
                           throws javax.mail.MessagingException
Either every recipient is matching or neither of them.

Specified by:
match in interface Matcher
Specified by:
match in class GenericMatcher
Parameters:
mail - - the Mail object that contains the MimeMessage and routing information
Returns:
java.util.Collection - the recipients that the mailet container should have the mailet affect.
Throws:
javax.mail.MessagingException - if no matching attachment is found and at least one exception was thrown

matchFound

protected boolean matchFound(javax.mail.Part part)
                      throws java.lang.Exception
Checks if part matches with at least one of the masks.

Throws:
java.lang.Exception

matchFound

protected boolean matchFound(java.lang.String fileName)
Checks if fileName matches with at least one of the masks.


matchFoundInZip

protected boolean matchFoundInZip(javax.mail.Part part)
                           throws javax.mail.MessagingException,
                                  java.io.IOException
Checks if part is a zip containing a file that matches with at least one of the masks.

Throws:
javax.mail.MessagingException
java.io.IOException

cleanFileName

protected java.lang.String cleanFileName(java.lang.String fileName)
Transforms fileName in a trimmed lowercase string usable for matching agains the masks.



Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.