001 /*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License"). You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2006-2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.types;
028 import org.opends.messages.Message;
029
030
031
032
033
034 import java.util.List;
035
036
037
038 /**
039 * This class defines an exception that may be thrown if a problem
040 * occurs in the Directory Server.
041 */
042 @org.opends.server.types.PublicAPI(
043 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
044 mayInstantiate=true,
045 mayExtend=false,
046 mayInvoke=true)
047 public final class DirectoryException
048 extends IdentifiedException
049 {
050 /**
051 * The serial version identifier required to satisfy the compiler
052 * because this class extends <CODE>java.lang.Exception</CODE>,
053 * which implements the <CODE>java.io.Serializable</CODE> interface.
054 * This value was generated using the <CODE>serialver</CODE>
055 * command-line utility included with the Java SDK.
056 */
057 private static final long serialVersionUID = 2615453139798417203L;
058
059
060
061 // The matched DN for this directory exception.
062 private final DN matchedDN;
063
064 // The set of referral URLs for this directory exception.
065 private final List<String> referralURLs;
066
067 // The result code for this directory exception.
068 private final ResultCode resultCode;
069
070
071
072 /**
073 * Creates a new directory exception with the provided information.
074 *
075 * @param resultCode The result code for this directory
076 * exception.
077 * @param errorMessage The error message for this directory
078 * exception.
079 */
080 public DirectoryException(ResultCode resultCode,
081 Message errorMessage)
082 {
083 super(errorMessage);
084
085
086 this.resultCode = resultCode;
087 this.matchedDN = null;
088 this.referralURLs = null;
089 }
090
091
092
093 /**
094 * Creates a new directory exception with the provided information.
095 *
096 * @param resultCode The result code for this directory
097 * exception.
098 * @param errorMessage The error message for this directory
099 * exception.
100 * @param cause The exception that was caught to trigger
101 * this directory exception.
102 */
103 public DirectoryException(ResultCode resultCode,
104 Message errorMessage,
105 Throwable cause)
106 {
107 super(errorMessage, cause);
108
109
110 this.resultCode = resultCode;
111 this.matchedDN = null;
112 this.referralURLs = null;
113 }
114
115
116 /**
117 * Creates a new directory exception with the provided information.
118 *
119 * @param resultCode The result code for this directory
120 * exception.
121 * @param cause The exception that was caught to trigger
122 * this directory exception. The message of
123 * this exception will be set to that of this
124 * parameter.
125 */
126 public DirectoryException(ResultCode resultCode,
127 OpenDsException cause)
128 {
129 super(cause.getMessageObject(), cause);
130
131
132 this.resultCode = resultCode;
133 this.matchedDN = null;
134 this.referralURLs = null;
135 }
136
137
138 /**
139 * Creates a new directory exception with the provided information.
140 *
141 * @param resultCode The result code for this directory
142 * exception.
143 * @param errorMessage The error message for this directory
144 * exception.
145 * @param matchedDN The matched DN for this directory
146 * exception.
147 * @param cause The exception that was caught to trigger
148 * this directory exception.
149 */
150 public DirectoryException(ResultCode resultCode,
151 Message errorMessage,
152 DN matchedDN, Throwable cause)
153 {
154 super(errorMessage, cause);
155
156
157 this.resultCode = resultCode;
158 this.matchedDN = matchedDN;
159 this.referralURLs = null;
160 }
161
162
163
164 /**
165 * Creates a new directory exception with the provided information.
166 *
167 * @param resultCode The result code for this directory
168 * exception.
169 * @param errorMessage The error message for this directory
170 * @param matchedDN The matched DN for this directory
171 * exception.
172 * @param referralURLs The set of referral URLs for this
173 * directory exception.
174 * @param cause The exception that was caught to trigger
175 * this directory exception.
176 */
177 public DirectoryException(ResultCode resultCode,
178 Message errorMessage,
179 DN matchedDN, List<String> referralURLs,
180 Throwable cause)
181 {
182 super(errorMessage, cause);
183
184
185 this.resultCode = resultCode;
186 this.matchedDN = matchedDN;
187 this.referralURLs = referralURLs;
188 }
189
190
191
192 /**
193 * Retrieves the result code for this directory exception.
194 *
195 * @return The result code for this directory exception.
196 */
197 public ResultCode getResultCode()
198 {
199 return resultCode;
200 }
201
202
203
204 /**
205 * Retrieves the matched DN for this directory exception.
206 *
207 * @return The matched DN for this directory exception, or
208 * <CODE>null</CODE> if there is none.
209 */
210 public DN getMatchedDN()
211 {
212 return matchedDN;
213 }
214
215
216
217 /**
218 * Retrieves the set of referral URLs for this directory exception.
219 *
220 * @return The set of referral URLs for this directory exception,
221 * or <CODE>null</CODE> if there are none.
222 */
223 public List<String> getReferralURLs()
224 {
225 return referralURLs;
226 }
227 }
228