1 /************************************************************************ 2 * Copyright (c) 1999-2006 The Apache Software Foundation. * 3 * All rights reserved. * 4 * ------------------------------------------------------------------- * 5 * Licensed under the Apache License, Version 2.0 (the "License"); you * 6 * may not use this file except in compliance with the License. You * 7 * may obtain a copy of the License at: * 8 * * 9 * http://www.apache.org/licenses/LICENSE-2.0 * 10 * * 11 * Unless required by applicable law or agreed to in writing, software * 12 * distributed under the License is distributed on an "AS IS" BASIS, * 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * 14 * implied. See the License for the specific language governing * 15 * permissions and limitations under the License. * 16 ***********************************************************************/ 17 18 package org.apache.james.services; 19 20 import org.apache.mailet.Mail; 21 22 import javax.mail.MessagingException; 23 24 import java.util.Collection; 25 import java.util.Iterator; 26 27 /*** 28 * Interface for a Repository to store Mails. 29 * @version 1.0.0, 24/04/1999 30 */ 31 public interface MailRepository { 32 33 /*** 34 * The component role used by components implementing this service 35 */ 36 String ROLE = "org.apache.james.services.MailRepository"; 37 38 /*** 39 * Define a MAIL repository. MAILS are stored in the specified 40 * destination. 41 */ 42 String MAIL = "MAIL"; 43 44 45 /*** 46 * Stores a message in this repository. Shouldn't this return the key 47 * under which it is stored? 48 * 49 * @param mc the mail message to store 50 */ 51 void store(Mail mc) throws MessagingException; 52 53 /*** 54 * List string keys of messages in repository. 55 * 56 * @return an <code>Iterator</code> over the list of keys in the repository 57 * 58 */ 59 Iterator list() throws MessagingException; 60 61 /*** 62 * Retrieves a message given a key. At the moment, keys can be obtained 63 * from list() in superinterface Store.Repository 64 * 65 * @param key the key of the message to retrieve 66 * @return the mail corresponding to this key, null if none exists 67 */ 68 Mail retrieve(String key) throws MessagingException; 69 70 /*** 71 * Removes a specified message 72 * 73 * @param mail the message to be removed from the repository 74 */ 75 void remove(Mail mail) throws MessagingException; 76 77 /*** 78 * Remove an Collection of mails from the repository 79 * 80 * @param mails The Collection of <code>MailImpl</code>'s to delete 81 * @since 2.2.0 82 */ 83 void remove(Collection mails) throws MessagingException; 84 85 /*** 86 * Removes a message identified by key. 87 * 88 * @param key the key of the message to be removed from the repository 89 */ 90 void remove(String key) throws MessagingException; 91 92 /*** 93 * Obtains a lock on a message identified by key 94 * 95 * @param key the key of the message to be locked 96 * 97 * @return true if successfully obtained the lock, false otherwise 98 */ 99 boolean lock(String key) throws MessagingException; 100 101 /*** 102 * Releases a lock on a message identified the key 103 * 104 * @param key the key of the message to be unlocked 105 * 106 * @return true if successfully released the lock, false otherwise 107 */ 108 boolean unlock(String key) throws MessagingException; 109 }