001 /*
002 * file WvcmException.java
003 *
004 * Licensed Materials - Property of IBM
005 * Restricted Materials of IBM
006 *
007 * (c) Copyright IBM Corporation 2004, 2008. All Rights Reserved.
008 * Note to U.S. Government Users Restricted Rights: Use, duplication or
009 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
010 */
011 package javax.wvcm;
012
013 import java.util.HashMap;
014
015 /**
016 * An exception that indicates that a failure of some sort has occurred in the WVCM provider.
017 *
018 * A WvcmException contains information such as a code describing the reason for the failure
019 * and optionally an array of nested exceptions to further explain the cause of the error.
020 *
021 * @since 1.0
022 */
023 public class WvcmException extends Exception {
024
025 /** The reason code for a WvcmException. */
026 public static enum ReasonCode
027 {
028
029 /**
030 * The provider suffered an I/O failure, the operation may be retried.
031 * <p>
032 * This ReasonCode can be thrown by any method that reads information
033 * from the server or a persistent store.
034 */
035 READ_FAILED("read-failed"), //$NON-NLS-1$
036 //
037
038 /**
039 * The provider suffered an I/O failure, the operation may be retried.
040 * <p>
041 * This ReasonCode can be thrown by any method that writes information
042 * to the server or a persistent store.
043 */
044 WRITE_FAILED("write-failed"), //$NON-NLS-1$
045
046 /**
047 * Even though the specification says the property is valid for the
048 * targeted resource, the server does not support it.
049 * <p>
050 * This ReasonCode can be thrown by any method defined to return a
051 * property value from a proxy, i.e., any method of the form getXyz().
052 */
053 PROPERTY_NOT_SUPPORTED_BY_SERVER("property-not-supported-by-server"), //$NON-NLS-1$
054
055 /**
056 * The property value is unavailable because it was not in the property
057 * name list when the proxy was created.
058 * <p>
059 * This ReasonCode can be thrown by any method defined to return a
060 * property value from a proxy, i.e., any method of the form getXyz().
061 */
062 PROPERTY_NOT_REQUESTED("property-not-requested"), //$NON-NLS-1$
063
064 /**
065 * The property is not valid for this resource.
066 * <p>
067 * This ReasonCode can be thrown by any method defined to return a
068 * property value from a proxy, i.e., any method of the form getXyz().
069 */
070 PROPERTY_NOT_DEFINED_FOR_RESOURCE("property-not-defined-for-resource"), //$NON-NLS-1$
071
072 /** The property value update would overwrite an earlier change. */
073 PROPERTY_OVERWRITE_FORBIDDEN("property-overwrite-forbidden"), //$NON-NLS-1$
074
075 /**
076 * The user is not authorized to execute the attempted operation.
077 * <p>
078 * This ReasonCode can be thrown by any method.
079 */
080 UNAUTHORIZED("unauthorized"), //$NON-NLS-1$
081
082 /**
083 * The provider understood the request, but is refusing to fulfill it.
084 * Authorization will not help and the request SHOULD NOT be repeated.
085 * If the provider wishes to make public why the operation has not been
086 * successful, it SHOULD describe the reason for the refusal in the
087 * message. If the provider does not wish to make this information
088 * available to the client, the reason code {@link #NOT_FOUND} can be
089 * used instead.
090 * <p>
091 * This ReasonCode can be thrown by any method that contacts the server,
092 * i.e. any doXyz() method.
093 */
094 FORBIDDEN("forbidden"), //$NON-NLS-1$
095
096 /**
097 * The corresponding remote resource no longer exists or was never
098 * created.
099 */
100 /**
101 * The provider has not found anything matching the location of the
102 * proxy. No indication is given whether the condition is temporary or
103 * permanent. This reason code is commonly used when the server does not
104 * wish to reveal exactly why the operation has been refused, or when no
105 * other response is applicable.
106 * <p>
107 * This ReasonCode can be thrown by any method that contacts the server,
108 * i.e. any doXyz() method.
109 */
110 NOT_FOUND("not-found"), //$NON-NLS-1$
111
112 /**
113 * The operation could not be completed because of a conflict with the
114 * current state of the resource. This code is only allowed in
115 * situations where it is expected that the user might be able to
116 * resolve the conflict and attempt the operation again. The exception
117 * message and data SHOULD include enough information for the user to
118 * recognize the source of the conflict. Ideally, the exception would
119 * include enough information for the user or user agent to fix the
120 * problem; however, that might not be possible and is not required.
121 * Conflicts are most likely to occur in response to an update
122 * operation. For example, if versioning were being used and the entity
123 * being updated included changes to a resource that conflict with those
124 * made by an earlier (third-party) operation, the provider might use
125 * the CONFLICT reason code to indicate that it can't complete the
126 * request. In this case, the exception would likely contain a list of
127 * the differences between the two versions in a format defined by the
128 * exception subclass documentation.
129 * <p>
130 * This ReasonCode can be thrown by any method that contacts the server,
131 * i.e. any doXyz() method.
132 */
133 CONFLICT("conflict"), //$NON-NLS-1$
134
135 /**
136 * The type of the persistent resource identified by this argument was
137 * not compatible with the specified argument type.
138 */
139 BAD_ARGUMENT_TYPE("bad-argument-type"), //$NON-NLS-1$
140
141 /** This folder already has a configuration. */
142 CONTROLLED_CONFIGURATION_ALREADY_EXISTS(
143 "controlled-configuration-already-exists"), //$NON-NLS-1$
144
145 /**
146 * A baseline controlled folder already exists in this workspace for
147 * this baseline history.
148 */
149 CANNOT_HAVE_MULTIPLE_BASELINE_CONTROLLED_FOLDERS(
150 "cannot-have-multiple-baseline-controlled-folders"), //$NON-NLS-1$
151
152 /** Cannot create this resource at the specified location. */
153 CANNOT_CREATE_AT_THIS_LOCATION("cannot-create-at-this-location"), //$NON-NLS-1$
154
155 /**
156 * Failed to perform the merge because the target could not be
157 * checked-out.
158 */
159 CANNOT_MERGE_CHECKOUT_NOT_ALLOWED("checkout-not-allowed"), //$NON-NLS-1$
160
161 /**
162 * Failed to checkout resource because multiple checkout is discouraged
163 * and the caller did not specify fork-ok.
164 */
165 CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_DISCOURAGED(
166 "checkout-of-checked-out-version-is-discouraged"), //$NON-NLS-1$
167
168 /**
169 * A potentially recoverable condition prevented the server from
170 * retrieving the property. This ReasonCode can be thrown by any method
171 * defined to return a property value from a proxy, i.e., any method of
172 * the form getXyz().
173 */
174 PROPERTY_NOT_CURRENTLY_AVAILABLE("property-not-currently-available"), //$NON-NLS-1$
175
176 /** Checkout of an already checked-out resource is forbidden. */
177 CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_FORBIDDEN(
178 "cannot-checkout-multi-checkout-is-forbidden"), //$NON-NLS-1$
179
180 /**
181 * Cannot remove the specified label because it does not used by this
182 * resource.
183 */
184 CANNOT_REMOVE_LABEL_DOES_NOT_EXIST("cannot-remove-label-does-not-exist"), //$NON-NLS-1$
185
186 /**
187 * Cannot checkin since it would cause a fork and forking is
188 * discouraged.
189 */
190 CANNOT_CHECKIN_FORK_DISCOURAGED("checkin-fork-discouraged"), //$NON-NLS-1$
191
192 /** A fork in the version tree is not allowed. */
193 CANNOT_FORK("checkin-fork-forbidden"), //$NON-NLS-1$
194
195 /**
196 * Failed to modify content/properties because the resource specified
197 * was a version.
198 */
199 CANNOT_MODIFY_VERSION("cannot-modify-version"), //$NON-NLS-1$
200
201 /**
202 * Method failed on some of the specified resources.
203 */
204 MULTI_STATUS("multi-status"), //$NON-NLS-1$
205
206 /**
207 * Creating a resource failed because a resource already exists at the
208 * specified location.
209 */
210 RESOURCE_ALREADY_EXISTS_AT_LOCATION(
211 "resource-already-exists-at-location"), //$NON-NLS-1$
212
213 /**
214 * Failed to checkout because descendant already exists and forking is
215 * discouraged.
216 */
217 CANNOT_CHECKOUT_FORKING_IS_DISCOURAGED(
218 "checkout-of-version-with-descendant-is-discouraged"), //$NON-NLS-1$
219
220 /**
221 * Failed to checkout because descendant already exists and forking is
222 * forbidden.
223 */
224 CANNOT_CHECKOUT_FORKING_IS_FORBIDDEN(
225 "cannot-checkout-forking-is-forbidden"), //$NON-NLS-1$
226
227 /**
228 * Cannot checkin because the resources predecessors are not descendants
229 * of the root of the version history.
230 */
231 VERSION_HISTORY_MUST_BE_A_TREE("version-history-must-be-a-tree"), //$NON-NLS-1$
232
233 /**
234 * baseline control failed because the folder already has controlled
235 * resources.
236 */
237 CANNOT_HAVE_CONTROLLED_MEMBERS("cannot-have-controlled-members"), //$NON-NLS-1$
238
239 /**
240 * The operation failed because it would result in more than one
241 * controlled resource for this version history in a workspace.
242 */
243 ONE_CONTROLLED_RESOURCE_PER_HISTORY_PER_WORKSPACE(
244 "one-controlled-resource-per-history-per-workspace"), //$NON-NLS-1$
245
246 /**
247 * Failed because more than one version of this resource is referenced
248 * in the specified activity.
249 */
250 ONE_CHECKOUT_PER_ACTIVITY_PER_HISTORY(
251 "one-checkout-per-activity-per-history"), //$NON-NLS-1$
252
253 /**
254 * Failed because there is a reserved checkout of a version in this
255 * version history.
256 */
257 CANNOT_CHECKIN_TO_RESERVED_ACTIVITY(
258 "cannot-checkin-to-reserved-activity"), //$NON-NLS-1$
259
260 /**
261 * The operation failed because the resource must be in the checked-in
262 * state.
263 */
264 MUST_BE_CHECKED_IN("must-be-checked-in"), //$NON-NLS-1$
265
266 /**
267 * The operation failed because the resource must be in the checked-out
268 * state.
269 */
270 MUST_BE_CHECKED_OUT("must-be-checked-out"), //$NON-NLS-1$
271
272 /**
273 * Each version in an activity for a given version history must be on
274 * the same line of descent.
275 */
276 CANNOT_CREATE_BRANCH_IN_ACTIVITY("linear-activity"), //$NON-NLS-1$
277
278 /**
279 * Each version in a stream for a given version history must be on the
280 * same line of descent.
281 */
282 CANNOT_CREATE_BRANCH_IN_STREAM("linear-stream"), //$NON-NLS-1$
283
284 /** The label is already in use by this resource. */
285 ADD_MUST_BE_NEW_LABEL("add-must-be-new-label"), //$NON-NLS-1$
286
287 /**
288 * Failed to checkin the configuration because some of it's members are
289 * still checked-out.
290 */
291 NO_CHECKED_OUT_BASELINE_CONTROLLED_FOLDER_MEMBERS(
292 "no-checked-out-baseline-controlled-folder-members"), //$NON-NLS-1$
293
294 /** Operation failed because it attempted to set a protected property. */
295 CANNOT_MODIFY_PROTECTED_PROPERTY("cannot-modify-protected-property"), //$NON-NLS-1$
296
297 /**
298 * Report failed since the resource does not support the specified
299 * report.
300 */
301 METHOD_NOT_SUPPORTED("method-not-supported"), //$NON-NLS-1$
302
303 /** Illegal syntax for location string value. */
304 ILLEGAL_LOCATION_SYNTAX("illegal-location-syntax"), //$NON-NLS-1$
305
306 /** Cannot create cross-server binding. */
307 NO_CROSS_SERVER_BINDING("no-cross-server-binding"), //$NON-NLS-1$
308
309 /** Cannot overwrite existing binding. */
310 CANNOT_OVERWRITE("cannot-overwrite"), //$NON-NLS-1$
311
312 /** Cannot create location cycle. */
313 CYCLE_NOT_ALLOWED("cycle-not-allowed"), //$NON-NLS-1$
314
315 /** Method execution was aborted via notification to the Feedback object. */
316 ABORTED("aborted"), //$NON-NLS-1$
317
318 /**
319 * The provider understood the request, but is refusing to fulfill it
320 * due to suspected version incompatibility with the client.
321 * Authorization will not help and the request SHOULD NOT be repeated.
322 * <p>
323 * This ReasonCode can be thrown by any method that contacts the server,
324 * i.e. any doXyz() method.
325 */
326 VERSION_NOT_SUPPORTED("version-not-supported"); //$NON-NLS-1$
327
328
329 /**
330 * Map of RFC 3253 pre & post condition names to
331 * WvcmException.ReasonCode.
332 */
333 private static final HashMap<String, ReasonCode> _rfc3253ToWvcmMap
334 = new HashMap<String, ReasonCode>();
335
336 static
337 {
338 // VERSION-CONTROL
339 _rfc3253ToWvcmMap.put("put-under-version-control", FORBIDDEN ); //$NON-NLS-1$
340 _rfc3253ToWvcmMap.put("must-not-change-existing-checked-in-out", FORBIDDEN); //$NON-NLS-1$
341 // REPORT
342 _rfc3253ToWvcmMap.put("supported-report", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
343 _rfc3253ToWvcmMap.put("acceptable-depth", FORBIDDEN); //$NON-NLS-1$
344 _rfc3253ToWvcmMap.put("no-modification", FORBIDDEN); //$NON-NLS-1$
345 // PUT
346 _rfc3253ToWvcmMap.put("cannot-modify-version-controlled-content", FORBIDDEN); //$NON-NLS-1$
347 _rfc3253ToWvcmMap.put("cannot-modify-version", CANNOT_MODIFY_VERSION); //$NON-NLS-1$
348 _rfc3253ToWvcmMap.put("auto-checkout", FORBIDDEN); //$NON-NLS-1$
349 _rfc3253ToWvcmMap.put("auto-checkout-checkin", FORBIDDEN); //$NON-NLS-1$
350 // PROPFIND
351 _rfc3253ToWvcmMap.put("supported-live-property", PROPERTY_NOT_CURRENTLY_AVAILABLE); //$NON-NLS-1$
352 // PROPPATCH
353 _rfc3253ToWvcmMap.put("cannot-modify-version-controlled-property", FORBIDDEN); //$NON-NLS-1$
354 _rfc3253ToWvcmMap.put("cannot-modify-version", CANNOT_MODIFY_VERSION); //$NON-NLS-1$
355 _rfc3253ToWvcmMap.put("cannot-modify-protected-property", CANNOT_MODIFY_PROTECTED_PROPERTY); //$NON-NLS-1$
356 _rfc3253ToWvcmMap.put("supported-live-property", PROPERTY_NOT_CURRENTLY_AVAILABLE); //$NON-NLS-1$
357 _rfc3253ToWvcmMap.put("auto-checkout", FORBIDDEN); //$NON-NLS-1$
358 _rfc3253ToWvcmMap.put("auto-checkout-checkin", FORBIDDEN); //$NON-NLS-1$
359 // DELETE
360 _rfc3253ToWvcmMap.put("no-version-delete", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
361 _rfc3253ToWvcmMap.put("update-predecessor-set", FORBIDDEN); //$NON-NLS-1$
362 // COPY
363 _rfc3253ToWvcmMap.put("must-not-copy-versioning-property", FORBIDDEN); //$NON-NLS-1$
364 _rfc3253ToWvcmMap.put("auto-checkout", FORBIDDEN); //$NON-NLS-1$
365 _rfc3253ToWvcmMap.put("auto-checkout-checkin", FORBIDDEN); //$NON-NLS-1$
366 _rfc3253ToWvcmMap.put("copy-creates-new-resource", FORBIDDEN); //$NON-NLS-1$
367 // MOVE
368 _rfc3253ToWvcmMap.put("cannot-rename-version", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
369 _rfc3253ToWvcmMap.put("preserve-versioning-properties", FORBIDDEN); //$NON-NLS-1$
370 // UNLOCK
371 _rfc3253ToWvcmMap.put("version-history-is-tree", VERSION_HISTORY_MUST_BE_A_TREE); //$NON-NLS-1$
372 _rfc3253ToWvcmMap.put("auto-checkin", FORBIDDEN); //$NON-NLS-1$
373 // CHECKOUT
374 _rfc3253ToWvcmMap.put("must-be-checked-in", MUST_BE_CHECKED_IN); //$NON-NLS-1$
375 _rfc3253ToWvcmMap.put("checkout-of-version-with-descendant-is-forbidden", CANNOT_CHECKOUT_FORKING_IS_FORBIDDEN); //$NON-NLS-1$
376 _rfc3253ToWvcmMap.put("checkout-of-version-with-descendant-is-discouraged", CANNOT_CHECKOUT_FORKING_IS_DISCOURAGED); //$NON-NLS-1$
377 _rfc3253ToWvcmMap.put("checkout-of-checked-out-version-is-forbidden", CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_FORBIDDEN); //$NON-NLS-1$
378 _rfc3253ToWvcmMap.put("checkout-of-checked-out-version-is-discouraged", CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_DISCOURAGED); //$NON-NLS-1$
379 _rfc3253ToWvcmMap.put("is-checked-out", FORBIDDEN); //$NON-NLS-1$
380 _rfc3253ToWvcmMap.put("initialize-predecessor-set", FORBIDDEN); //$NON-NLS-1$
381 // CHECKIN
382 _rfc3253ToWvcmMap.put("must-be-checked-out", MUST_BE_CHECKED_OUT); //$NON-NLS-1$
383 _rfc3253ToWvcmMap.put("version-history-is-tree", VERSION_HISTORY_MUST_BE_A_TREE); //$NON-NLS-1$
384 _rfc3253ToWvcmMap.put("checkin-fork-forbidden", CANNOT_FORK); //$NON-NLS-1$
385 _rfc3253ToWvcmMap.put("checkin-fork-discouraged", CANNOT_CHECKIN_FORK_DISCOURAGED); //$NON-NLS-1$
386 _rfc3253ToWvcmMap.put("create-version", FORBIDDEN); //$NON-NLS-1$
387 _rfc3253ToWvcmMap.put("initialize-version-content-and-properties", FORBIDDEN); //$NON-NLS-1$
388 _rfc3253ToWvcmMap.put("checked-in", FORBIDDEN); //$NON-NLS-1$
389 _rfc3253ToWvcmMap.put("keep-checked-out", FORBIDDEN); //$NON-NLS-1$
390 // UNCHECKOUT
391 _rfc3253ToWvcmMap.put("must-be-checked-out-version-controlled-resource", MUST_BE_CHECKED_OUT); //$NON-NLS-1$
392 _rfc3253ToWvcmMap.put("cancel-checked-out", FORBIDDEN); //$NON-NLS-1$
393 _rfc3253ToWvcmMap.put("restore-content-and-dead-properties", FORBIDDEN); //$NON-NLS-1$
394 // REPORT (DAV:locate-by-history)
395 _rfc3253ToWvcmMap.put("must-be-version-history", BAD_ARGUMENT_TYPE); //$NON-NLS-1$
396 // DELETE (version history feature)
397 _rfc3253ToWvcmMap.put("delete-version-set", FORBIDDEN); //$NON-NLS-1$
398 _rfc3253ToWvcmMap.put("version-history-has-root", FORBIDDEN); //$NON-NLS-1$
399 // COPY (version history feature)
400 _rfc3253ToWvcmMap.put("cannot-copy-history", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
401 // MOVE (version history feature)
402 _rfc3253ToWvcmMap.put("cannot-rename-history", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
403 // VERSION-CONTROL (version history feature)
404 _rfc3253ToWvcmMap.put("new-version-history", FORBIDDEN); //$NON-NLS-1$
405 // CHECKIN (version history feature)
406 _rfc3253ToWvcmMap.put("add-to-history", FORBIDDEN); //$NON-NLS-1$
407 // MKWORKSPACE
408 _rfc3253ToWvcmMap.put("resource-must-be-null", RESOURCE_ALREADY_EXISTS_AT_LOCATION); //$NON-NLS-1$
409 _rfc3253ToWvcmMap.put("workspace-location-ok", CANNOT_CREATE_AT_THIS_LOCATION); //$NON-NLS-1$
410 _rfc3253ToWvcmMap.put("initialize-workspace", FORBIDDEN); //$NON-NLS-1$
411 // DELETE (workspace)
412 _rfc3253ToWvcmMap.put("delete-workspace-members", FORBIDDEN); //$NON-NLS-1$
413 // MOVE (workspace)
414 _rfc3253ToWvcmMap.put("workspace-member-moved", FORBIDDEN); //$NON-NLS-1$
415 _rfc3253ToWvcmMap.put("workspace-moved", FORBIDDEN); //$NON-NLS-1$
416 // VERSION-CONTROL (workspace)
417 _rfc3253ToWvcmMap.put("cannot-add-to-existing-history", RESOURCE_ALREADY_EXISTS_AT_LOCATION); //$NON-NLS-1$
418 _rfc3253ToWvcmMap.put("must-be-version", FORBIDDEN); //$NON-NLS-1$
419 _rfc3253ToWvcmMap.put("one-version-controlled-resource-per-history-per-workspace", ONE_CONTROLLED_RESOURCE_PER_HISTORY_PER_WORKSPACE); //$NON-NLS-1$
420 _rfc3253ToWvcmMap.put("new-version-controlled-resource", FORBIDDEN); //$NON-NLS-1$
421 // UPDATE (workspace)
422 _rfc3253ToWvcmMap.put("update-content-and-properties", FORBIDDEN); //$NON-NLS-1$
423 _rfc3253ToWvcmMap.put("report-properties", FORBIDDEN); //$NON-NLS-1$
424 // LABEL
425 _rfc3253ToWvcmMap.put("must-be-checked-in", MUST_BE_CHECKED_IN); //$NON-NLS-1$
426 _rfc3253ToWvcmMap.put("add-must-be-new-label", ADD_MUST_BE_NEW_LABEL); //$NON-NLS-1$
427 _rfc3253ToWvcmMap.put("label-must-exist", CANNOT_REMOVE_LABEL_DOES_NOT_EXIST); //$NON-NLS-1$
428 _rfc3253ToWvcmMap.put("add-or-set-label", FORBIDDEN); //$NON-NLS-1$
429 _rfc3253ToWvcmMap.put("remove-label", FORBIDDEN); //$NON-NLS-1$
430 // GET (label)
431 _rfc3253ToWvcmMap.put("apply-request-to-labeled-version", FORBIDDEN); //$NON-NLS-1$
432 // PROPFIND (label)
433 _rfc3253ToWvcmMap.put("must-select-version-in-history", FORBIDDEN); //$NON-NLS-1$
434 _rfc3253ToWvcmMap.put("apply-request-to-labeled-version", FORBIDDEN); //$NON-NLS-1$
435 // COPY (label)
436 _rfc3253ToWvcmMap.put("apply-request-to-labeled-version", FORBIDDEN); //$NON-NLS-1$
437 // CHECKOUT (label)
438 _rfc3253ToWvcmMap.put("must-not-have-label-and-apply-to-version", FORBIDDEN); //$NON-NLS-1$
439 _rfc3253ToWvcmMap.put("apply-request-to-labeled-version", FORBIDDEN); //$NON-NLS-1$
440 // UPDATE (label)
441 _rfc3253ToWvcmMap.put("depth-update", FORBIDDEN); //$NON-NLS-1$
442 _rfc3253ToWvcmMap.put("apply-request-to-labeled-version", FORBIDDEN); //$NON-NLS-1$
443 // CHECKOUT (working resource)
444 _rfc3253ToWvcmMap.put("checkout-of-version-with-descendant-is-discouraged", CANNOT_CHECKOUT_FORKING_IS_DISCOURAGED); //$NON-NLS-1$
445 _rfc3253ToWvcmMap.put("checkout-of-checked-out-version-is-forbidden", CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_FORBIDDEN); //$NON-NLS-1$
446 _rfc3253ToWvcmMap.put("checkout-of-checked-out-version-is-discouraged", CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_DISCOURAGED); //$NON-NLS-1$
447 _rfc3253ToWvcmMap.put("create-working-resource", FORBIDDEN); //$NON-NLS-1$
448 _rfc3253ToWvcmMap.put("create-working-resource-from-checked-in-version", FORBIDDEN); //$NON-NLS-1$
449 // CHECKIN (working resource)
450 _rfc3253ToWvcmMap.put("must-be-checked-in", MUST_BE_CHECKED_IN); //$NON-NLS-1$
451 _rfc3253ToWvcmMap.put("version-history-is-tree", VERSION_HISTORY_MUST_BE_A_TREE); //$NON-NLS-1$
452 _rfc3253ToWvcmMap.put("checkin-fork-forbidden", CANNOT_FORK); //$NON-NLS-1$
453 _rfc3253ToWvcmMap.put("checkin-fork-discouraged", CANNOT_CHECKIN_FORK_DISCOURAGED); //$NON-NLS-1$
454 _rfc3253ToWvcmMap.put("no-overwrite-by-auto-update", FORBIDDEN); //$NON-NLS-1$
455 _rfc3253ToWvcmMap.put("create-version", FORBIDDEN); //$NON-NLS-1$
456 _rfc3253ToWvcmMap.put("initialize-version-content-and-properties", FORBIDDEN); //$NON-NLS-1$
457 _rfc3253ToWvcmMap.put("auto-update", FORBIDDEN); //$NON-NLS-1$
458 _rfc3253ToWvcmMap.put("delete-working-resource", FORBIDDEN); //$NON-NLS-1$
459 // COPY (working resource)
460 _rfc3253ToWvcmMap.put("copy-creates-new-resource", FORBIDDEN); //$NON-NLS-1$
461 // MOVE (working resource)
462 _rfc3253ToWvcmMap.put("cannot-rename-working-resource", FORBIDDEN); //$NON-NLS-1$
463 _rfc3253ToWvcmMap.put("update-auto-update", FORBIDDEN); //$NON-NLS-1$
464 // MERGE
465 _rfc3253ToWvcmMap.put("cannot-merge-checked-out-resource", FORBIDDEN); //$NON-NLS-1$
466 _rfc3253ToWvcmMap.put("checkout-not-allowed", CANNOT_MERGE_CHECKOUT_NOT_ALLOWED); //$NON-NLS-1$
467 _rfc3253ToWvcmMap.put("ancestor-version", FORBIDDEN); //$NON-NLS-1$
468 _rfc3253ToWvcmMap.put("decendent-version", FORBIDDEN); //$NON-NLS-1$
469 _rfc3253ToWvcmMap.put("checked-out-for-merge", FORBIDDEN); //$NON-NLS-1$
470 _rfc3253ToWvcmMap.put("update-merge-set", FORBIDDEN); //$NON-NLS-1$
471 _rfc3253ToWvcmMap.put("report-properties", FORBIDDEN); //$NON-NLS-1$
472 // DELETE (merge)
473 _rfc3253ToWvcmMap.put("delete-version-reference", FORBIDDEN); //$NON-NLS-1$
474 // CHECKIN (merge)
475 _rfc3253ToWvcmMap.put("merge-must-be-complete", FORBIDDEN); //$NON-NLS-1$
476 // BASELINE-CONTROL
477 _rfc3253ToWvcmMap.put("configuration-must-not-exist", FORBIDDEN); //$NON-NLS-1$
478 _rfc3253ToWvcmMap.put("must-be-baseline", BAD_ARGUMENT_TYPE); //$NON-NLS-1$
479 _rfc3253ToWvcmMap.put("must-have-no-version-controlled-members", CANNOT_HAVE_CONTROLLED_MEMBERS); //$NON-NLS-1$
480 _rfc3253ToWvcmMap.put("one-baseline-controlled-collection-per-history-per-workspace", CANNOT_HAVE_MULTIPLE_BASELINE_CONTROLLED_FOLDERS); //$NON-NLS-1$
481 _rfc3253ToWvcmMap.put("create-configuration", FORBIDDEN); //$NON-NLS-1$
482 _rfc3253ToWvcmMap.put("reference-configuration", FORBIDDEN); //$NON-NLS-1$
483 _rfc3253ToWvcmMap.put("select-existing-baseline", FORBIDDEN); //$NON-NLS-1$
484 _rfc3253ToWvcmMap.put("create-new-baseline", FORBIDDEN); //$NON-NLS-1$
485 // REPORT (DAV:compare-baseline report)
486 _rfc3253ToWvcmMap.put("must-be-baseline", BAD_ARGUMENT_TYPE); //$NON-NLS-1$
487 _rfc3253ToWvcmMap.put("baselines-from-same-history", FORBIDDEN); //$NON-NLS-1$
488 // CHECKOUT (baseline)
489 _rfc3253ToWvcmMap.put("must-not-update-baseline-collection", FORBIDDEN); //$NON-NLS-1$
490 // CHECKIN (baseline)
491 _rfc3253ToWvcmMap.put("no-checked-out-baseline-controlled-collection-members", NO_CHECKED_OUT_BASELINE_CONTROLLED_FOLDER_MEMBERS); //$NON-NLS-1$
492 _rfc3253ToWvcmMap.put("one-version-per-history-per-baseline", FORBIDDEN); //$NON-NLS-1$
493 _rfc3253ToWvcmMap.put("cannot-modify-configuration", FORBIDDEN); //$NON-NLS-1$
494 _rfc3253ToWvcmMap.put("create-baseline-collection", FORBIDDEN); //$NON-NLS-1$
495 _rfc3253ToWvcmMap.put("modify-configuration", FORBIDDEN); //$NON-NLS-1$
496 // UPDATE (baseline)
497 _rfc3253ToWvcmMap.put("baseline-controlled-members-must-be-checked-in", NO_CHECKED_OUT_BASELINE_CONTROLLED_FOLDER_MEMBERS); //$NON-NLS-1$
498 _rfc3253ToWvcmMap.put("must-not-update-baseline-collection", FORBIDDEN); //$NON-NLS-1$
499 _rfc3253ToWvcmMap.put("cannot-modify-version-controlled-configuration", FORBIDDEN); //$NON-NLS-1$
500 _rfc3253ToWvcmMap.put("set-baseline-controlled-collection-members", FORBIDDEN); //$NON-NLS-1$
501 _rfc3253ToWvcmMap.put("modify-configuration", FORBIDDEN); //$NON-NLS-1$
502 // MERGE (baseline)
503 _rfc3253ToWvcmMap.put("must-not-update-baseline-collection", FORBIDDEN); //$NON-NLS-1$
504 _rfc3253ToWvcmMap.put("cannot-modify-configuration", FORBIDDEN); //$NON-NLS-1$
505 _rfc3253ToWvcmMap.put("merge-baseline", FORBIDDEN); //$NON-NLS-1$
506 _rfc3253ToWvcmMap.put("set-baseline-controlled-collection-members", FORBIDDEN); //$NON-NLS-1$
507 _rfc3253ToWvcmMap.put("modify-configuration", FORBIDDEN); //$NON-NLS-1$
508 // ACTIVITY
509 _rfc3253ToWvcmMap.put("resource-must-be-null", RESOURCE_ALREADY_EXISTS_AT_LOCATION); //$NON-NLS-1$
510 _rfc3253ToWvcmMap.put("activity-location-ok", CANNOT_CREATE_AT_THIS_LOCATION); //$NON-NLS-1$
511 _rfc3253ToWvcmMap.put("initialize-activity", FORBIDDEN); //$NON-NLS-1$
512 // REPORT (DAV:latest-activity-version)
513 _rfc3253ToWvcmMap.put("must-be-activity", BAD_ARGUMENT_TYPE); //$NON-NLS-1$
514 _rfc3253ToWvcmMap.put("delete-activity-reference", FORBIDDEN); //$NON-NLS-1$
515 _rfc3253ToWvcmMap.put("update-checked-out-reference", FORBIDDEN); //$NON-NLS-1$
516 _rfc3253ToWvcmMap.put("update-activity-reference", FORBIDDEN); //$NON-NLS-1$
517 _rfc3253ToWvcmMap.put("update-workspace-reference", FORBIDDEN); //$NON-NLS-1$
518 // CHECKOUT (activity)
519 _rfc3253ToWvcmMap.put("one-checkout-per-activity-per-history", ONE_CHECKOUT_PER_ACTIVITY_PER_HISTORY); //$NON-NLS-1$
520 _rfc3253ToWvcmMap.put("linear-activity", CANNOT_CREATE_BRANCH_IN_ACTIVITY); //$NON-NLS-1$
521 _rfc3253ToWvcmMap.put("initialize-activity-set", FORBIDDEN); //$NON-NLS-1$
522 _rfc3253ToWvcmMap.put("initialize-reserved", FORBIDDEN); //$NON-NLS-1$
523 // CHECKIN (activity)
524 _rfc3253ToWvcmMap.put("linear-activity", CANNOT_CREATE_BRANCH_IN_ACTIVITY); //$NON-NLS-1$
525 _rfc3253ToWvcmMap.put("atomic-activity-checkin", MULTI_STATUS); //$NON-NLS-1$
526 _rfc3253ToWvcmMap.put("initialize-activity-set", FORBIDDEN); //$NON-NLS-1$
527 _rfc3253ToWvcmMap.put("activity-checkin", FORBIDDEN); //$NON-NLS-1$
528 // MERGE (activity)
529 _rfc3253ToWvcmMap.put("checkin-activity", FORBIDDEN); //$NON-NLS-1$
530 // DELETE (version-controlled-collection)
531 _rfc3253ToWvcmMap.put("cannot-modify-checked-in-parent", FORBIDDEN); //$NON-NLS-1$
532 _rfc3253ToWvcmMap.put("delete-working-collection-binding", FORBIDDEN); //$NON-NLS-1$
533 // COPY (version-controlled-collection)
534 _rfc3253ToWvcmMap.put("cannot-copy-collection-version", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
535 _rfc3253ToWvcmMap.put("cannot-modify-checked-in-parent", FORBIDDEN); //$NON-NLS-1$
536 _rfc3253ToWvcmMap.put("cannot-modify-destination-checked-in-parent", FORBIDDEN); //$NON-NLS-1$
537 // VERSION-CONTROL (version-controlled-collection)
538 _rfc3253ToWvcmMap.put("cannot-modify-checked-in-parent", FORBIDDEN); //$NON-NLS-1$
539 _rfc3253ToWvcmMap.put("new-version-controlled-collection", FORBIDDEN); //$NON-NLS-1$
540 // CHECKOUT (version-controlled-collection)
541 _rfc3253ToWvcmMap.put("initialize-version-history-bindings", FORBIDDEN); //$NON-NLS-1$
542 // CHECKIN (version-controlled-collection)
543 _rfc3253ToWvcmMap.put("initialize-version-controlled-bindings", FORBIDDEN); //$NON-NLS-1$
544 _rfc3253ToWvcmMap.put("version-control-working-collection-members", FORBIDDEN); //$NON-NLS-1$
545 // UNCHECKOUT, UPDATE, and MERGE (version-controlled-collection)
546 _rfc3253ToWvcmMap.put("update-version-controlled-collection-members", FORBIDDEN); //$NON-NLS-1$
547 // BIND
548 _rfc3253ToWvcmMap.put("bind-source-exists", NOT_FOUND); //$NON-NLS-1$
549 _rfc3253ToWvcmMap.put("name-allowed", CANNOT_CREATE_AT_THIS_LOCATION); //$NON-NLS-1$
550 _rfc3253ToWvcmMap.put("binding-allowed", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
551 _rfc3253ToWvcmMap.put("cross-server-binding", NO_CROSS_SERVER_BINDING); //$NON-NLS-1$
552 _rfc3253ToWvcmMap.put("can-overwrite", CANNOT_OVERWRITE); //$NON-NLS-1$
553 _rfc3253ToWvcmMap.put("cycle-allowed", CYCLE_NOT_ALLOWED); //$NON-NLS-1$
554 _rfc3253ToWvcmMap.put("new-binding", FORBIDDEN); //$NON-NLS-1$
555 // UNBIND
556 _rfc3253ToWvcmMap.put("unbind-source-exists", NOT_FOUND); //$NON-NLS-1$
557 // REBIND
558 _rfc3253ToWvcmMap.put("rebind-source-exists", NOT_FOUND); //$NON-NLS-1$
559 }
560
561 /** Hidden constuctor for type-safety. */
562 private ReasonCode(String codeImage) {
563 _codeImage = codeImage;
564 }
565
566 /**
567 * The ReasonCode for an RFC 3253 pre- or post-condition.
568 *
569 * @param condition the RFC 3253 pre- or post- condition local name.
570 * @return the corresponding ReasonCode.
571 */
572 public static ReasonCode getReasonCodeForRFC3253Condition(String condition)
573 {
574 return _rfc3253ToWvcmMap.get(condition);
575 }
576
577 /**
578 * Returns a string representation of this ReasonCode suitable for diagnostics.
579 */
580 @Override
581 public String toString() {
582 return _codeImage;
583 }
584
585 /**
586 * Return the string form of this ReasonCode.
587 */
588 private final String _codeImage;
589 }
590
591 /**
592 * The resource that caused the exception.
593 */
594 private Resource _resource;
595
596 /**
597 * The reason for the exception.
598 */
599 private ReasonCode _reasonCode;
600
601 /**
602 * An array of nested exceptions that further explain the cause of the error.
603 */
604 private Throwable[] _nestedExceptions = null;
605
606 /**
607 * Constructs a WvcmException.
608 *
609 * @param message the detail message for the exception.
610 * @param reasonCode the reason for the exception.
611 */
612 public WvcmException(
613 String message,
614 ReasonCode reasonCode) {
615 super(message);
616 _resource = null;
617 _reasonCode = reasonCode;
618 _nestedExceptions = null;
619 }
620
621 /**
622 * Constructs a WvcmException.
623 *
624 * @param message the detail message for the exception.
625 * @param resource the resource causing the exception.
626 * @param reasonCode the reason for the exception.
627 */
628 public WvcmException(
629 String message,
630 Resource resource,
631 ReasonCode reasonCode) {
632 super(message);
633 _resource = resource;
634 _reasonCode = reasonCode;
635 _nestedExceptions = null;
636 }
637
638 /**
639 * Constructs a WvcmException.
640 *
641 * @param message the detail message for the exception.
642 * @param resource the resource causing the exception.
643 * @param reasonCode the reason for the exception.
644 * @param cause the exception that caused this exception.
645 */
646 public WvcmException(
647 String message,
648 Resource resource,
649 ReasonCode reasonCode,
650 Throwable cause) {
651 super(message, cause);
652 _resource = resource;
653 _reasonCode = reasonCode;
654 _nestedExceptions = null;
655 }
656
657 /**
658 * Constructs a WvcmException.
659 *
660 * @param message the detail message for the exception.
661 * @param resource the resource causing the exception.
662 * @param reasonCode the reason for the exception.
663 * @param nestedExceptions any nested exception.
664 */
665 public WvcmException(
666 String message,
667 Resource resource,
668 ReasonCode reasonCode,
669 Throwable[] nestedExceptions) {
670 super(message);
671 _resource = resource;
672 _reasonCode = reasonCode;
673 _nestedExceptions = nestedExceptions;
674 }
675
676 /**
677 * Constructs a WvcmException.
678 *
679 * @param message the detail message for the exception.
680 * @param resource the resource causing the exception.
681 * @param reasonCode the reason for the exception.
682 * @param cause the exception that caused this exception.
683 * @param nestedExceptions any nested exception.
684 */
685 public WvcmException(
686 String message,
687 Resource resource,
688 ReasonCode reasonCode,
689 Throwable cause,
690 Throwable[] nestedExceptions) {
691 super(message, cause);
692 _resource = resource;
693 _reasonCode = reasonCode;
694 _nestedExceptions = nestedExceptions;
695 }
696
697 /**
698 * Get the resource causing the exception.
699 *
700 * @return the resource causing the exception.
701 */
702 public Resource getResource() {
703 return _resource;
704 }
705
706 /**
707 * Get the reason code that describes the nature of the error.
708 *
709 * @return the reason code that describes the nature of the error.
710 */
711 public ReasonCode getReasonCode() {
712 return _reasonCode;
713 }
714
715 /**
716 * Get any nested exceptions that further explain the cause of the error.
717 *
718 * @return any nested exceptions that further explain the cause of the error.
719 */
720 public Throwable[] getNestedExceptions() {
721 return _nestedExceptions;
722 }
723
724 /**
725 * The serial version UID.
726 */
727 private static final long serialVersionUID = -663023054869664237L;
728 }