KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ldap > server > interceptor > InterceptorException


1 /*
2  * Copyright 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package org.apache.ldap.server.interceptor;
18
19
20 import org.apache.ldap.common.exception.LdapException;
21 import org.apache.ldap.common.exception.LdapNamingException;
22 import org.apache.ldap.common.message.ResultCodeEnum;
23 import org.apache.ldap.server.invocation.Invocation;
24
25
26 /**
27  * A {@link LdapNamingException} that wraps uncaught runtime exceptions thrown from {@link Interceptor}s.
28  *
29  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
30  * @version $Rev: 169198 $, $Date: 2005-05-08 20:05:59 -0400 (Sun, 08 May 2005) $
31  */

32 public class InterceptorException extends LdapNamingException
33 {
34     private static final long serialVersionUID = 3258690996517746233L;
35
36     /**
37      * The Invocation the Interceptor failed on
38      */

39     private final Invocation invocation;
40
41     /**
42      * The Interceptor causing the failure
43      */

44     private final Interceptor interceptor;
45
46
47     /**
48      * Creates an InterceptorException without a message.
49      *
50      * @param interceptor the Interceptor causing the failure
51      * @param invocation the Invocation the Interceptor failed on
52      */

53     public InterceptorException( Interceptor interceptor, Invocation invocation )
54     {
55         super( ResultCodeEnum.OTHER );
56
57         this.invocation = invocation;
58
59         this.interceptor = interceptor;
60     }
61
62
63     /**
64      * Creates an InterceptorException with a custom message.
65      *
66      * @param interceptor the Interceptor causing the failure
67      * @param invocation the Invocation the Interceptor failed on
68      * @param explanation String explanation of why the Interceptor failed
69      */

70     public InterceptorException( Interceptor interceptor, Invocation invocation, String JavaDoc explanation )
71     {
72         super( explanation, ResultCodeEnum.OTHER );
73
74         this.invocation = invocation;
75
76         this.interceptor = interceptor;
77     }
78
79
80     /**
81      * Creates an InterceptorException without a message.
82      *
83      * @param interceptor the Interceptor causing the failure
84      * @param invocation the Invocation the Interceptor failed on
85      * @param rootCause the root cause of this exception
86      */

87     public InterceptorException( Interceptor interceptor, Invocation invocation, Throwable JavaDoc rootCause )
88     {
89         this( interceptor, invocation );
90
91         super.setRootCause( rootCause );
92     }
93
94
95     /**
96      * Creates an InterceptorException without a message.
97      *
98      * @param interceptor the Interceptor causing the failure
99      * @param invocation the Invocation the Interceptor failed on
100      * @param explanation String explanation of why the Interceptor failed
101      * @param rootCause the root cause of this exception
102      */

103     public InterceptorException( Interceptor interceptor, Invocation invocation, String JavaDoc explanation,
104                                  Throwable JavaDoc rootCause )
105     {
106         this( interceptor, invocation, explanation );
107
108         super.setRootCause( rootCause );
109     }
110
111
112     /**
113      * Gets the invovation object this exception is associated with.
114      *
115      * @return the invovation object this exception is associated with
116      */

117     public Invocation getInvocation()
118     {
119         return invocation;
120     }
121
122
123     /**
124      * Gets the interceptor this exception is associated with.
125      *
126      * @return the interceptor this exception is associated with
127      */

128     public Interceptor getInterceptor()
129     {
130         return interceptor;
131     }
132
133
134     /**
135      * Will return the resultCode of the root cause if the root cause implements LdapException.
136      *
137      * @see org.apache.ldap.common.exception.LdapException#getResultCode()
138      */

139     public ResultCodeEnum getResultCode()
140     {
141         if ( getRootCause() != null && ( getRootCause() instanceof LdapException ) )
142         {
143             return ( ( LdapException ) getRootCause() ).getResultCode();
144         }
145
146         return super.getResultCode();
147     }
148 }
149
Popular Tags