KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > imapserver > MailboxException


1 /***********************************************************************
2  * Copyright (c) 2000-2004 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.imapserver;
19
20 /**
21  * Thrown on an inappropriate attempt to reference a mailbox.
22  * Includes attempting to create a mailbox that already exists and attempting
23  * to open a mailbox that does not exist.
24  * If status is ALREADY_EXISTS_REMOTELY or IF_CREATED_REMOTE then field
25  * remoteServer should be set to the url of the remote server, formatted for
26  * Mailbox Referral.
27  *
28  * @version 0.1 on 14 Dec 2000
29  */

30 public class MailboxException extends Exception JavaDoc {
31
32     public final static String JavaDoc ALREADY_EXISTS_LOCALLY
33         = "Already exists locally";
34     public final static String JavaDoc ALREADY_EXISTS_REMOTELY
35         = "Already exists remotely";
36     public final static String JavaDoc IF_CREATED_LOCAL
37         = "If created, mailbox would be local";
38     public final static String JavaDoc IF_CREATED_REMOTE
39         = "If created, mailbox would be remote";
40     public final static String JavaDoc NOT_LOCAL
41         = "Does not exist locally, no further information available";
42     public final static String JavaDoc LOCAL_BUT_DELETED
43         = "Was local but has been deleted.";
44
45     protected String JavaDoc status = null;
46     protected String JavaDoc remoteServer = null;
47
48     /**
49      * Construct a new <code>MailboxException</code> instance.
50      *
51      * @param message The detail message for this exception (mandatory).
52      */

53     public MailboxException(String JavaDoc message) {
54         super(message);
55     }
56
57     /**
58      * Construct a new <code>MailBoxException</code> instance.
59      *
60      * @param message The detail message for this exception (mandatory).
61      * @param aStatus String constant indicating condition
62      */

63     public MailboxException(String JavaDoc message, String JavaDoc aStatus) {
64         super(message);
65         this.status = aStatus;
66     }
67
68     /**
69      * Construct a new <code>MailBoxException</code> instance.
70      *
71      * @param message The detail message for this exception (mandatory).
72      * @param aStatus String constant indicating condition
73      * @param sServer String indicating another server where Mailbox should be.
74      */

75     public MailboxException(String JavaDoc message, String JavaDoc aStatus, String JavaDoc aServer) {
76         super(message);
77         this.status = aStatus;
78         this.remoteServer = aServer;
79     }
80
81     public String JavaDoc getStatus() {
82         return status;
83     }
84
85     public String JavaDoc getRemoteServer() {
86         return remoteServer;
87     }
88
89     public boolean isRemote() {
90         return ( status.equals(ALREADY_EXISTS_REMOTELY)
91                  || status.equals(IF_CREATED_REMOTE) ) ;
92     }
93 }
94
Popular Tags