james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ber...@apache.org
Subject svn commit: r422908 - in /james/server/trunk/src/java/org/apache/james: management/SpoolFilter.java management/SpoolManagement.java services/SpoolManagementService.java
Date Mon, 17 Jul 2006 22:57:47 GMT
Author: berndf
Date: Mon Jul 17 15:57:46 2006
New Revision: 422908

URL: http://svn.apache.org/viewvc?rev=422908&view=rev
Log:
- javadoc for SpoolManagement
- fixed re-use of SpoolFilter compiled patterns

Modified:
    james/server/trunk/src/java/org/apache/james/management/SpoolFilter.java
    james/server/trunk/src/java/org/apache/james/management/SpoolManagement.java
    james/server/trunk/src/java/org/apache/james/services/SpoolManagementService.java

Modified: james/server/trunk/src/java/org/apache/james/management/SpoolFilter.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/management/SpoolFilter.java?rev=422908&r1=422907&r2=422908&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/management/SpoolFilter.java (original)
+++ james/server/trunk/src/java/org/apache/james/management/SpoolFilter.java Mon Jul 17 15:57:46
2006
@@ -27,10 +27,10 @@
 import java.util.Map;
 
 /**
- * immutual collection of filers used to specify which mail should be processed by SpoolManagement
+ * immutual collection of filters used to specify which mail should be processed by SpoolManagement
  * criterias are:
  * exact state match
- * all headers match all related headerValue regular expressions
+ * headerValue regular expressions match all related headers 
  */
 public class SpoolFilter {
 
@@ -105,7 +105,9 @@
         String headerValueRegex = getHeaderValueRegex(header);
         if (headerValueRegex == null) return null;
         try {
-            return compiler.compile(headerValueRegex, Perl5Compiler.READ_ONLY_MASK);
+            Pattern pattern = compiler.compile(headerValueRegex, Perl5Compiler.READ_ONLY_MASK);
+            headerFiltersCompiled.put(header, pattern); // cache
+            return pattern;
         } catch (MalformedPatternException e) {
             throw new SpoolManagementException("failed to compile regular expression", e);
         }

Modified: james/server/trunk/src/java/org/apache/james/management/SpoolManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/management/SpoolManagement.java?rev=422908&r1=422907&r2=422908&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/management/SpoolManagement.java (original)
+++ james/server/trunk/src/java/org/apache/james/management/SpoolManagement.java Mon Jul 17
15:57:46 2006
@@ -55,11 +55,27 @@
         setStore(mailStore);
     }
 
+    /**
+     * Lists all mails from the given repository matching the given filter criteria 
+     * @param spoolRepositoryURL the spool whose item are listed
+     * @param state if not NULL, only mails with matching state are returned
+     * @param header if not NULL, only mails with at least one header with a value matching
headerValueRegex are returned
+     * @param headerValueRegex the regular expression the header must match
+     * @return String array, each line describing one matching mail from the spool 
+     * @throws SpoolManagementException
+     */
     public String[] listSpoolItems(String spoolRepositoryURL, String state, String header,
String headerValueRegex) 
             throws SpoolManagementException {
         return listSpoolItems(spoolRepositoryURL, new SpoolFilter(state, header, headerValueRegex));
     }
 
+    /**
+     * Lists all mails from the given repository matching the given filter criteria 
+     * @param spoolRepositoryURL the spool whose item are listed
+     * @param filter the criteria against which all mails are matched
+     * @return String array, each line describing one matching mail from the spool 
+     * @throws SpoolManagementException
+     */
     public String[] listSpoolItems(String spoolRepositoryURL, SpoolFilter filter) throws
SpoolManagementException {
         List spoolItems;
         try {
@@ -70,7 +86,12 @@
         return (String[]) spoolItems.toArray(new String[]{});
     }
 
-
+    /**
+     * @param mail
+     * @param filter
+     * @return TRUE, if given mail matches all given filter criteria
+     * @throws SpoolManagementException
+     */
     protected boolean filterMatches(Mail mail, SpoolFilter filter) throws SpoolManagementException
{
         if (filter == null || !filter.doFilter()) return true;
 
@@ -89,6 +110,7 @@
                 try {
                     headerValues = mail.getMessage().getHeader(header);
                     if (headerValues == null) {
+                        // some headers need special retrieval
                         if (header.equalsIgnoreCase("to")) {
                             headerValues = addressesToStrings(mail.getMessage().getRecipients(MimeMessage.RecipientType.TO));
                         }
@@ -135,6 +157,12 @@
         return addressStrings;
     }
 
+    /**
+     * @param spoolRepositoryURL
+     * @param filter
+     * @return List<Mail> all matching mails from the given spool
+     * @throws SpoolManagementException
+     */
     public List getSpoolItems(String spoolRepositoryURL, SpoolFilter filter)
             throws ServiceException, MessagingException, SpoolManagementException {
         SpoolRepository spoolRepository = getSpoolRepository(spoolRepositoryURL);
@@ -167,6 +195,14 @@
         return removeSpoolItems(spoolRepositoryURL, key, new SpoolFilter(state, header, headerValueRegex));
     }
 
+    /**
+     * Removes all mails from the given repository matching the filter 
+     * @param spoolRepositoryURL the spool whose item are listed
+     * @param key ID of the mail to be removed. if not NULL, all other filters are ignored
+     * @param filter the criteria against which all mails are matched. only applied if key
is NULL.
+     * @return number of removed mails
+     * @throws SpoolManagementException
+     */
     public int removeSpoolItems(String spoolRepositoryURL, String key, SpoolFilter filter)
throws SpoolManagementException {
         try {
             return removeSpoolItems(spoolRepositoryURL, key, null, filter);
@@ -175,12 +211,21 @@
         }
     }
 
+    /**
+     * Removes all mails from the given repository matching the filter 
+     * @param spoolRepositoryURL the spool whose item are listed
+     * @param key ID of the mail to be removed. if not NULL, all other filters are ignored
+     * @param lockingFailures is populated with a list of mails which could not be processed
because
+     * a lock could not be obtained
+     * @param filter the criteria against which all mails are matched. only applied if key
is NULL.
+     * @return number of removed mails
+     */
     public int removeSpoolItems(String spoolRepositoryURL, String key, List lockingFailures,
SpoolFilter filter) throws ServiceException, MessagingException {
         int count = 0;
         SpoolRepository spoolRepository = getSpoolRepository(spoolRepositoryURL);
 
         if (key != null) {
-            count = removeMail(spoolRepository, key, count, lockingFailures, filter);
+            count = removeMail(spoolRepository, key, count, lockingFailures, null);
         } else {
             Iterator spoolR = spoolRepository.list();
 
@@ -211,10 +256,30 @@
         }
     }
 
+    /**
+     * Tries to resend all mails from the given repository matching the given filter criteria

+     * @param spoolRepositoryURL the spool whose item are about to be resend
+     * @param key ID of the mail to be resend. if not NULL, all other filters are ignored
+     * @param state if not NULL, only mails with matching state are resend
+     * @param header if not NULL, only mails with at least one header with a value matching
headerValueRegex are resend
+     * @param headerValueRegex the regular expression the header must match
+     * @return int number of resent mails 
+     * @throws SpoolManagementException
+     */
     public int resendSpoolItems(String spoolRepositoryURL, String key, String state, String
header, String headerValueRegex) throws SpoolManagementException {
         return resendSpoolItems(spoolRepositoryURL, key, new SpoolFilter(state, header, headerValueRegex));
     }
 
+    /**
+     * Tries to resend all mails from the given repository matching the given filter criteria

+     * @param spoolRepositoryURL the spool whose item are about to be resend
+     * @param key ID of the mail to be resend. if not NULL, all other filters are ignored
+     * @param lockingFailures is populated with a list of mails which could not be processed
because
+     * a lock could not be obtained
+     * @param filter the criteria against which all mails are matched. only applied if key
is NULL.
+     * @return int number of resent mails 
+     * @throws SpoolManagementException
+     */
     public int resendSpoolItems(String spoolRepositoryURL, String key, List lockingFailures,
SpoolFilter filter)
             throws ServiceException, MessagingException, SpoolManagementException {
         int count = 0;

Modified: james/server/trunk/src/java/org/apache/james/services/SpoolManagementService.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/services/SpoolManagementService.java?rev=422908&r1=422907&r2=422908&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/services/SpoolManagementService.java (original)
+++ james/server/trunk/src/java/org/apache/james/services/SpoolManagementService.java Mon
Jul 17 15:57:46 2006
@@ -28,9 +28,12 @@
 public interface SpoolManagementService {
     String ROLE = "org.apache.james.services.SpoolManagementService";
 
-    public int removeSpoolItems(String spoolRepositoryURL, String key, List lockingFailures,
SpoolFilter filter) throws ServiceException, MessagingException;
+    public int removeSpoolItems(String spoolRepositoryURL, String key, List lockingFailures,
SpoolFilter filter) 
+            throws ServiceException, MessagingException;
     
-    public int resendSpoolItems(String spoolRepositoryURL, String key, List lockingFailures,
SpoolFilter filter) throws ServiceException, MessagingException, SpoolManagementException;
+    public int resendSpoolItems(String spoolRepositoryURL, String key, List lockingFailures,
SpoolFilter filter) 
+            throws ServiceException, MessagingException, SpoolManagementException;
 
-    public List getSpoolItems(String spoolRepositoryURL, SpoolFilter filter) throws ServiceException,
MessagingException, SpoolManagementException;
+    public List getSpoolItems(String spoolRepositoryURL, SpoolFilter filter) 
+            throws ServiceException, MessagingException, SpoolManagementException;
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message