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