org.apache.james.management.impl
Class SpoolManagement

java.lang.Object
  extended by org.apache.james.management.impl.SpoolManagement
All Implemented Interfaces:
org.apache.avalon.framework.service.Serviceable, SpoolManagementMBean, SpoolManagementService

public class SpoolManagement
extends java.lang.Object
implements org.apache.avalon.framework.service.Serviceable, SpoolManagementService, SpoolManagementMBean

high-level management of spool contents like list, remove, resend


Field Summary
 
Fields inherited from interface org.apache.james.management.SpoolManagementService
ROLE
 
Constructor Summary
SpoolManagement()
           
 
Method Summary
protected  boolean filterMatches(org.apache.mailet.Mail mail, SpoolFilter filter)
          Return true if the given Mail match the given SpoolFilter
 java.util.List getSpoolItems(java.lang.String spoolRepositoryURL, SpoolFilter filter)
          Return a List which contains all mails which can accessed by given spoolRepositoryUrl and matched the given SpoolFilter
 java.lang.String[] listSpoolItems(java.lang.String spoolRepositoryURL, SpoolFilter filter)
          Lists all mails from the given repository matching the given filter criteria
 java.lang.String[] listSpoolItems(java.lang.String spoolRepositoryURL, java.lang.String state, java.lang.String header, java.lang.String headerValueRegex)
          Lists all mails from the given repository matching the given filter criteria
 int moveSpoolItems(java.lang.String srcSpoolRepositoryURL, java.lang.String dstSpoolRepositoryURL, java.lang.String dstState, SpoolFilter filter)
          Move all mails from the given repository to another repository matching the given filter criteria
 int moveSpoolItems(java.lang.String srcSpoolRepositoryURL, java.lang.String srcState, java.lang.String dstSpoolRepositoryURL, java.lang.String dstState, java.lang.String header, java.lang.String headerValueRegex)
          Move all mails from the given repository to another repository matching the given filter criteria
 int removeSpoolItems(java.lang.String spoolRepositoryURL, java.lang.String key, java.util.List lockingFailures, SpoolFilter filter)
          Removes all mails from the given repository matching the filter
 int removeSpoolItems(java.lang.String spoolRepositoryURL, java.lang.String key, SpoolFilter filter)
          Removes all mails from the given repository matching the filter
 int removeSpoolItems(java.lang.String spoolRepositoryURL, java.lang.String key, java.lang.String state, java.lang.String header, java.lang.String headerValueRegex)
          Removes one specific or all mails from the given spool repository matching the given criteria
 int resendSpoolItems(java.lang.String spoolRepositoryURL, java.lang.String key, java.util.List lockingFailures, SpoolFilter filter)
          Tries to resend all mails from the given repository matching the given filter criteria
 int resendSpoolItems(java.lang.String spoolRepositoryURL, java.lang.String key, SpoolFilter filter)
          Tries to resend all mails from the given repository matching the given filter criteria
 int resendSpoolItems(java.lang.String spoolRepositoryURL, java.lang.String key, java.lang.String state, java.lang.String header, java.lang.String headerValueRegex)
          Tries to resend all mails from the given repository matching the given filter criteria
 void service(org.apache.avalon.framework.service.ServiceManager serviceManager)
           
 void setStore(org.apache.avalon.cornerstone.services.store.Store mailStore)
          Set the Store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpoolManagement

public SpoolManagement()
Method Detail

setStore

public void setStore(org.apache.avalon.cornerstone.services.store.Store mailStore)
Set the Store

Parameters:
mailStore - the store

service

public void service(org.apache.avalon.framework.service.ServiceManager serviceManager)
             throws org.apache.avalon.framework.service.ServiceException
Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
Throws:
org.apache.avalon.framework.service.ServiceException
See Also:
Serviceable.service(ServiceManager)

moveSpoolItems

public int moveSpoolItems(java.lang.String srcSpoolRepositoryURL,
                          java.lang.String srcState,
                          java.lang.String dstSpoolRepositoryURL,
                          java.lang.String dstState,
                          java.lang.String header,
                          java.lang.String headerValueRegex)
                   throws SpoolManagementException
Move all mails from the given repository to another repository matching the given filter criteria

Specified by:
moveSpoolItems in interface SpoolManagementMBean
Parameters:
srcSpoolRepositoryURL - the spool whose item are listed
srcState - if not NULL, only mails with matching state are returned
dstSpoolRepositoryURL - the destination spool
dstState - if not NULL, the state will be changed before storing the message to the new repository.
header - if not NULL, only mails with at least one header with a value matching headerValueRegex are returned
headerValueRegex - the regular expression the header must match
Returns:
a counter of moved mails
Throws:
SpoolManagementException

moveSpoolItems

public int moveSpoolItems(java.lang.String srcSpoolRepositoryURL,
                          java.lang.String dstSpoolRepositoryURL,
                          java.lang.String dstState,
                          SpoolFilter filter)
                   throws javax.mail.MessagingException,
                          SpoolManagementException
Move all mails from the given repository to another repository matching the given filter criteria

Specified by:
moveSpoolItems in interface SpoolManagementService
Parameters:
srcSpoolRepositoryURL - the spool whose item are listed
dstSpoolRepositoryURL - the destination spool
dstState - if not NULL, the state will be changed before storing the message to the new repository.
filter - the filter to select messages from the source repository
Returns:
a counter of moved mails
Throws:
org.apache.avalon.framework.service.ServiceException
javax.mail.MessagingException
SpoolManagementException

listSpoolItems

public java.lang.String[] listSpoolItems(java.lang.String spoolRepositoryURL,
                                         java.lang.String state,
                                         java.lang.String header,
                                         java.lang.String headerValueRegex)
                                  throws SpoolManagementException
Lists all mails from the given repository matching the given filter criteria

Specified by:
listSpoolItems in interface SpoolManagementMBean
Parameters:
spoolRepositoryURL - the spool whose item are listed
state - if not NULL, only mails with matching state are returned
header - if not NULL, only mails with at least one header with a value matching headerValueRegex are returned
headerValueRegex - the regular expression the header must match
Returns:
String array, each line describing one matching mail from the spool
Throws:
SpoolManagementException

listSpoolItems

public java.lang.String[] listSpoolItems(java.lang.String spoolRepositoryURL,
                                         SpoolFilter filter)
                                  throws SpoolManagementException
Lists all mails from the given repository matching the given filter criteria

Parameters:
spoolRepositoryURL - the spool whose item are listed
filter - the criteria against which all mails are matched
Returns:
String array, each line describing one matching mail from the spool
Throws:
SpoolManagementException

filterMatches

protected boolean filterMatches(org.apache.mailet.Mail mail,
                                SpoolFilter filter)
                         throws SpoolManagementException
Return true if the given Mail match the given SpoolFilter

Parameters:
mail - the Mail which should be checked
filter - the SpoolFilter which should be used
Returns:
TRUE, if given mail matches all given filter criteria
Throws:
SpoolManagementException

getSpoolItems

public java.util.List getSpoolItems(java.lang.String spoolRepositoryURL,
                                    SpoolFilter filter)
                             throws javax.mail.MessagingException,
                                    SpoolManagementException
Description copied from interface: SpoolManagementService
Return a List which contains all mails which can accessed by given spoolRepositoryUrl and matched the given SpoolFilter

Specified by:
getSpoolItems in interface SpoolManagementService
Parameters:
spoolRepositoryURL - the url under which a spool can be accessed
filter - the SpoolFilter to use
Returns:
List all matching mails from the given spool
Throws:
javax.mail.MessagingException
SpoolManagementException
See Also:
SpoolManagementService.getSpoolItems(String, SpoolFilter)

removeSpoolItems

public int removeSpoolItems(java.lang.String spoolRepositoryURL,
                            java.lang.String key,
                            java.lang.String state,
                            java.lang.String header,
                            java.lang.String headerValueRegex)
                     throws SpoolManagementException
Description copied from interface: SpoolManagementMBean
Removes one specific or all mails from the given spool repository matching the given criteria

Specified by:
removeSpoolItems in interface SpoolManagementMBean
Parameters:
spoolRepositoryURL - specifies the spool
key - identifies the item to be removed. if NULL, all items are removed
state - only mails in the given state are processed, or ALL if NULL
header - the header whose value should be checked
headerValueRegex - regular expression matched against header value. only matching mails are processed
Returns:
number of removed items
Throws:
SpoolManagementException
See Also:
SpoolManagementMBean.removeSpoolItems(String, String, String, String, String)

removeSpoolItems

public int removeSpoolItems(java.lang.String spoolRepositoryURL,
                            java.lang.String key,
                            SpoolFilter filter)
                     throws SpoolManagementException
Removes all mails from the given repository matching the filter

Parameters:
spoolRepositoryURL - the spool whose item are listed
key - ID of the mail to be removed. if not NULL, all other filters are ignored
filter - the criteria against which all mails are matched. only applied if key is NULL.
Returns:
number of removed mails
Throws:
SpoolManagementException

removeSpoolItems

public int removeSpoolItems(java.lang.String spoolRepositoryURL,
                            java.lang.String key,
                            java.util.List lockingFailures,
                            SpoolFilter filter)
                     throws SpoolManagementException,
                            javax.mail.MessagingException,
                            SpoolManagementException
Description copied from interface: SpoolManagementService
Removes all mails from the given repository matching the filter

Specified by:
removeSpoolItems in interface SpoolManagementService
Parameters:
spoolRepositoryURL - the spool whose item are listed
key - ID of the mail to be removed. if not NULL, all other filters are ignored
lockingFailures - is populated with a list of mails which could not be processed because a lock could not be obtained
filter - the criteria against which all mails are matched. only applied if key is NULL.
Returns:
number of removed mails
Throws:
SpoolManagementException
javax.mail.MessagingException
See Also:
SpoolManagementService.removeSpoolItems(String, String, List, SpoolFilter)

resendSpoolItems

public int resendSpoolItems(java.lang.String spoolRepositoryURL,
                            java.lang.String key,
                            SpoolFilter filter)
                     throws SpoolManagementException
Tries to resend all mails from the given repository matching the given filter criteria

Parameters:
spoolRepositoryURL - the spool whose item are about to be resend
key - ID of the mail to be resend. if not NULL, all other filters are ignored
filter - the SpoolFilter to use
Returns:
int the number of resent mails
Throws:
SpoolManagementException

resendSpoolItems

public int resendSpoolItems(java.lang.String spoolRepositoryURL,
                            java.lang.String key,
                            java.lang.String state,
                            java.lang.String header,
                            java.lang.String headerValueRegex)
                     throws SpoolManagementException
Tries to resend all mails from the given repository matching the given filter criteria

Specified by:
resendSpoolItems in interface SpoolManagementMBean
Parameters:
spoolRepositoryURL - the spool whose item are about to be resend
key - ID of the mail to be resend. if not NULL, all other filters are ignored
state - if not NULL, only mails with matching state are resend
header - if not NULL, only mails with at least one header with a value matching headerValueRegex are resend
headerValueRegex - the regular expression the header must match
Returns:
int number of resent mails
Throws:
SpoolManagementException

resendSpoolItems

public int resendSpoolItems(java.lang.String spoolRepositoryURL,
                            java.lang.String key,
                            java.util.List lockingFailures,
                            SpoolFilter filter)
                     throws javax.mail.MessagingException,
                            SpoolManagementException
Description copied from interface: SpoolManagementService
Tries to resend all mails from the given repository matching the given filter criteria

Specified by:
resendSpoolItems in interface SpoolManagementService
Parameters:
spoolRepositoryURL - the spool whose item are about to be resend
key - ID of the mail to be resend. if not NULL, all other filters are ignored
lockingFailures - is populated with a list of mails which could not be processed because a lock could not be obtained
filter - the criteria against which all mails are matched. only applied if key is NULL.
Returns:
int number of resent mails
Throws:
javax.mail.MessagingException
SpoolManagementException
See Also:
SpoolManagementService.resendSpoolItems(String, String, List, SpoolFilter)


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.