View Javadoc

1   /****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  
21  
22  
23  package org.apache.james.management;
24  
25  import javax.mail.MessagingException;
26  import java.util.List;
27  
28  public interface SpoolManagementService {
29      String ROLE = "org.apache.james.management.SpoolManagementService";
30  
31      /**
32       * Move all mails from the given repository to another repository matching the given filter criteria
33       *
34       * @param srcSpoolRepositoryURL the spool whose item are listed
35       * @param dstSpoolRepositoryURL the destination spool
36       * @param dstState if not NULL, the state will be changed before storing the message to the new repository.
37       * @param filter the filter to select messages from the source repository
38       * @return a counter of moved mails
39       * @throws MessagingException 
40       * @throws SpoolManagementException
41       */
42      public int moveSpoolItems(String srcSpoolRepositoryURL, String dstSpoolRepositoryURL, String dstState, SpoolFilter filter)
43              throws MessagingException, SpoolManagementException;
44  
45      /**
46       * Removes all mails from the given repository matching the filter
47       *  
48       * @param spoolRepositoryURL the spool whose item are listed
49       * @param key ID of the mail to be removed. if not NULL, all other filters are ignored
50       * @param lockingFailures is populated with a list of mails which could not be processed because
51       * a lock could not be obtained
52       * @param filter the criteria against which all mails are matched. only applied if key is NULL.
53       * @return number of removed mails
54       * @throws MessagingException 
55       * @throws SpoolManagementException
56       */
57      public int removeSpoolItems(String spoolRepositoryURL, String key, List lockingFailures, SpoolFilter filter) 
58              throws MessagingException, SpoolManagementException;
59      
60      /**
61       * Tries to resend all mails from the given repository matching the given filter criteria 
62       * 
63       * @param spoolRepositoryURL the spool whose item are about to be resend
64       * @param key ID of the mail to be resend. if not NULL, all other filters are ignored
65       * @param lockingFailures is populated with a list of mails which could not be processed because
66       *                        a lock could not be obtained
67       * @param filter the criteria against which all mails are matched. only applied if key is NULL.
68       * @return int number of resent mails 
69       * @throws MessagingException
70       * @throws SpoolManagementException
71       */
72      public int resendSpoolItems(String spoolRepositoryURL, String key, List lockingFailures, SpoolFilter filter) 
73              throws MessagingException, SpoolManagementException;
74  
75      /**
76       * Return a List which contains all mails which can accessed by given spoolRepositoryUrl and matched
77       * the given SpoolFilter
78       * 
79       * @param spoolRepositoryURL the url under which a spool can be accessed
80       * @param filter the SpoolFilter to use
81       * @return List<Mail> all matching mails from the given spool
82       * @throws MessagingException
83       * @throws SpoolManagementException
84       */
85      public List getSpoolItems(String spoolRepositoryURL, SpoolFilter filter) 
86              throws MessagingException, SpoolManagementException;
87  }