1 | /* |
2 | * $Id: CacheException.java,v 1.12 2007-08-30 21:11:05 abaranov Exp $ |
3 | */ |
4 | |
5 | package diskCacheV111.util ; |
6 | |
7 | |
8 | /* |
9 | * @Immutable |
10 | */ |
11 | public class CacheException extends Exception { |
12 | |
13 | private final int _rc; |
14 | private final String _message; |
15 | |
16 | /** |
17 | * Disk I/O error. |
18 | */ |
19 | public final static int ERROR_IO_DISK = 204 ; |
20 | |
21 | /** |
22 | * Usually followed by component shutdown. |
23 | */ |
24 | public final static int PANIC = 10000 ; |
25 | |
26 | /** |
27 | * file not know/register in pnfs. Non existing path or pnfsid |
28 | */ |
29 | public final static int FILE_NOT_FOUND = 10001 ; |
30 | |
31 | /** |
32 | * file is precious - not flush to HSM yet |
33 | */ |
34 | public final static int FILE_PRECIOUS = 10002 ; |
35 | public final static int FILESIZE_UNKNOWN = 10003 ; |
36 | |
37 | /** |
38 | * file size in pnfs/stoageInfo do not match to data file size |
39 | * or |
40 | * restored from tape/receved by p2p file do not match expected size |
41 | */ |
42 | public final static int FILESIZE_MISMATCH = 10004 ; |
43 | public final static int FILE_NOT_STORED = 10005 ; |
44 | |
45 | /** |
46 | * indicated a timeout in cell communication |
47 | */ |
48 | public final static int TIMEOUT = 10006 ; |
49 | |
50 | /** |
51 | * returned by pool in case of a request for IO on a file, which is not in the pool repository |
52 | */ |
53 | public final static int FILE_NOT_IN_REPOSITORY = 10007; |
54 | |
55 | /** |
56 | * returned by PnfsManager on create of existing file or directory |
57 | */ |
58 | public final static int FILE_EXISTS = 10008; |
59 | |
60 | /** |
61 | * returned in case of directory specific request ( like list ) on non existing path or pnfsid |
62 | */ |
63 | public final static int DIR_NOT_EXISTS = 10009; |
64 | |
65 | /** |
66 | * returned in case of directory specific request ( like list ) on existing not a directory |
67 | * path or pnfsid, |
68 | */ |
69 | public final static int NOT_DIR = 10010; |
70 | |
71 | /** |
72 | * all kind of unexpected exceptions |
73 | */ |
74 | public final static int UNEXPECTED_SYSTEM_EXCEPTION = 10011; |
75 | public final static int ATTRIBUTE_FORMAT_ERROR = 10012; |
76 | |
77 | /** |
78 | * indicates, that HSM request to suspend current restore request |
79 | */ |
80 | public final static int HSM_DELAY_ERROR = 10013; |
81 | |
82 | /** |
83 | * returned in case of file specific request ( like read ) on existing not a file |
84 | * path or pnfsid, |
85 | */ |
86 | public final static int NOT_FILE = 10014; |
87 | |
88 | |
89 | /** |
90 | * indicates that request contains invalid value |
91 | */ |
92 | public final static int INVALID_ARGS = 10015; |
93 | |
94 | /** |
95 | * Pnfsid is not in trash directory |
96 | */ |
97 | public final static int NOT_IN_TRASH = 10016; |
98 | |
99 | /** |
100 | * There are no sufficient resources to process current request. |
101 | * Typically returned if some limits excided. |
102 | */ |
103 | public final static int RESOURCE = 10017; |
104 | |
105 | /** |
106 | * The user is not authorized to perform the action requested. |
107 | */ |
108 | public final static int PERMISSION_DENIED = 10018; |
109 | |
110 | /** |
111 | * file not online and user has no permission to perform STAGING |
112 | */ |
113 | public final static int FILE_NOT_ONLINE = 10019 ; |
114 | |
115 | /** |
116 | * Target object is locked or busy and the operation was denied. |
117 | */ |
118 | public final static int LOCKED = 10020; |
119 | |
120 | /** |
121 | * default error code. |
122 | * <b>It's recommended to use more specific error codes</b> |
123 | */ |
124 | public final static int DEFAULT_ERROR_CODE = 666; // I don't like this number.... |
125 | |
126 | |
127 | private static final long serialVersionUID = 3219663683702355240L; |
128 | |
129 | private static String setMessage( String message ){ |
130 | |
131 | if( message == null ) return ""; |
132 | |
133 | StringBuilder sb = new StringBuilder() ; |
134 | |
135 | for( int i = 0 ; i < message.length() ; i++ ){ |
136 | |
137 | char c = message.charAt(i) ; |
138 | if( c == '\n' ){ |
139 | if( i != ( message.length() -1 ) )sb.append(';') ; |
140 | }else{ |
141 | sb.append(c) ; |
142 | } |
143 | } |
144 | return sb.toString() ; |
145 | |
146 | } |
147 | |
148 | /** |
149 | * Create a new CacheException with default error code and given error message |
150 | * @param msg error message |
151 | */ |
152 | public CacheException( String msg ){ |
153 | this(DEFAULT_ERROR_CODE, msg); |
154 | } |
155 | |
156 | /** |
157 | * Create a new CacheException with given error code and message |
158 | * @param rc error code |
159 | * @param msg error message |
160 | */ |
161 | public CacheException( int rc , String msg ){ |
162 | _message = setMessage(msg) ; |
163 | _rc = rc ; |
164 | } |
165 | |
166 | @Override |
167 | public String getMessage(){ return _message ; } |
168 | public int getRc(){ return _rc ; } |
169 | @Override |
170 | public String toString(){ |
171 | return "CacheException(rc="+_rc+ |
172 | ";msg="+getMessage()+")" ; |
173 | } |
174 | } |
175 | |