KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > dods > access > AccessException


1 /**
2  * Title: WebDocWf AccessException<p>
3  * Description: AccessException is thrown if a User does not have the right to execute a certain DODS access or an error accurs during evaluation of rights<p>
4  * Copyright: Copyright (c) Together Teamlösungen EDV-Dienstleistungen GmbH. under LGPL<p>
5  * Company: Together Teamlösungen EDV-Dienstleistungen GmbH.<p>
6  * @author Alfred Madl (a.madl@together.at)
7  * @version 1.0
8  */

9 package org.webdocwf.dods.access;
10
11 import java.io.PrintStream JavaDoc;
12 import java.io.PrintWriter JavaDoc;
13 import org.enhydra.dods.exceptions.DodsBaseException;
14
15 public abstract class AccessException extends DodsBaseException {
16     public User usr = null;
17     public String JavaDoc operation = null;
18     public SecureDO obj = null;
19     public String JavaDoc className = null;
20     public String JavaDoc attrName = null;
21     public String JavaDoc value = null;
22     public String JavaDoc oldValue = null;
23     public String JavaDoc datatype = null;
24     public String JavaDoc cmp_op = null;
25
26     /**
27      * Construct an exception with a message and detail data.
28      *
29      * @param msg The message associated with the exception.
30      * @param inUsr The user for the access right check
31      * @param inOperation The desired operation
32      * @param inObj The accessed object
33      * @param inClassName The accessed class
34      * @param inAttrName The accessed attribute
35      * @param inValue The accessed value
36      * @param inOldValue The new value in set-operations
37      * @param inDatatype The datatype of the value
38      * @param inCmp_op The comparison operator for queries
39      */

40     public AccessException(String JavaDoc msg, User inUsr, String JavaDoc inOperation, SecureDO inObj, String JavaDoc inClassName, String JavaDoc inAttrName, String JavaDoc inValue, String JavaDoc inOldValue, String JavaDoc inDatatype, String JavaDoc inCmp_op) {
41         super(msg);
42         usr = inUsr;
43         operation = inOperation;
44         obj = inObj;
45         className = inClassName;
46         attrName = inAttrName;
47         value = inValue;
48         oldValue = inOldValue;
49         datatype = inDatatype;
50         cmp_op = inCmp_op;
51     }
52
53     /**
54      * Construct an exception with a message and detail data.
55      *
56      * @param msg The message associated with the exception.
57      * @param cause The error or exception that cause this
58      * exception.
59      * @param inUsr The user for the access right check
60      * @param inOperation The desired operation
61      * @param inObj The accessed object
62      * @param inClassName The accessed class
63      * @param inAttrName The accessed attribute
64      * @param inValue The accessed value
65      * @param inOldValue The new value in set-operations
66      * @param inDatatype The datatype of the value
67      * @param inCmp_op The comparison operator for queries
68      */

69     public AccessException(String JavaDoc msg, Throwable JavaDoc cause, User inUsr, String JavaDoc inOperation, SecureDO inObj, String JavaDoc inClassName, String JavaDoc inAttrName, String JavaDoc inValue, String JavaDoc inOldValue, String JavaDoc inDatatype, String JavaDoc inCmp_op) {
70         super(msg, cause);
71         usr = inUsr;
72         operation = inOperation;
73         obj = inObj;
74         className = inClassName;
75         attrName = inAttrName;
76         value = inValue;
77         oldValue = inOldValue;
78         datatype = inDatatype;
79         cmp_op = inCmp_op;
80     }
81
82     /**
83      * Construct an exception with a message
84      *
85      * @param msg The message associated with the exception.
86      */

87     public AccessException(String JavaDoc msg) {
88         super(msg);
89     }
90
91     /**
92      * Construct an exception with a message
93      *
94      * @param msg The message associated with the exception.
95      * @param cause The error or exception that cause this
96      * exception.
97      */

98     public AccessException(String JavaDoc msg, Throwable JavaDoc cause) {
99         super(msg, cause);
100     }
101
102     /**
103      * Prints the details
104      */

105     private void printDetails(PrintWriter JavaDoc out) {
106         if (usr != null) {
107             out.println("User : " + usr.getName());
108         }
109         if (operation != null) {
110             out.println("Operation : " + operation);
111         }
112         if (obj != null) {
113             out.println("Object OID: " + obj.get_OId());
114         }
115         if (obj != null) {
116             out.println("Object class: " + obj.getClass().getName());
117         }
118         if (className != null) {
119             out.println("Class name : " + className);
120         }
121         if (attrName != null) {
122             out.println("Attribute name : " + attrName);
123         }
124         if (value != null) {
125             out.println("Value : " + value);
126         }
127         if (oldValue != null) {
128             out.println("Old value : " + oldValue);
129         }
130         if (datatype != null) {
131             out.println("Datatype : " + datatype);
132         }
133         if (cmp_op != null) {
134             out.println("Comparison operator : " + cmp_op);
135         }
136     }
137
138     /**
139      * Prints this Exception and its data to the standard error stream.
140      */

141     public void printStackTrace() {
142         super.printStackTrace();
143         printTrace();
144     }
145
146     /**
147      * Prints this Exception and its data to the e specified print stream.
148      */

149     public void printStackTrace(PrintStream JavaDoc s) {
150         super.printStackTrace(s);
151         printTrace(s);
152     }
153
154     /**
155      * Prints this Exception and its data to the e specified print writer.
156      */

157     public void printStackTrace(PrintWriter JavaDoc s) {
158         super.printStackTrace(s);
159         printTrace(s);
160     }
161
162     /**
163      * Prints stacktrace
164      */

165     protected void printTrace() {
166         PrintWriter JavaDoc pw = new PrintWriter JavaDoc(System.err);
167
168         printDetails(pw);
169         pw.flush();
170     }
171
172     /**
173      * Prints stacktrace
174      */

175     protected void printTrace(PrintStream JavaDoc s) {
176         PrintWriter JavaDoc pw = new PrintWriter JavaDoc(s);
177
178         printDetails(pw);
179         pw.flush();
180     }
181
182     /**
183      * Prints stacktrace
184      */

185     public void printTrace(PrintWriter JavaDoc out) {
186         printDetails(out);
187         out.flush();
188     }
189 }
190
Popular Tags