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            /**
320             * Map of RFC 3253 pre & post condition names to
321             * WvcmException.ReasonCode.
322             */
323            private static final HashMap<String, ReasonCode> _rfc3253ToWvcmMap 
324                = new HashMap<String, ReasonCode>();
325    
326            static
327            {
328                //  VERSION-CONTROL
329                _rfc3253ToWvcmMap.put("put-under-version-control", FORBIDDEN ); //$NON-NLS-1$
330                _rfc3253ToWvcmMap.put("must-not-change-existing-checked-in-out", FORBIDDEN); //$NON-NLS-1$
331                // REPORT
332                _rfc3253ToWvcmMap.put("supported-report", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
333                _rfc3253ToWvcmMap.put("acceptable-depth", FORBIDDEN); //$NON-NLS-1$
334                _rfc3253ToWvcmMap.put("no-modification", FORBIDDEN); //$NON-NLS-1$
335                // PUT
336                _rfc3253ToWvcmMap.put("cannot-modify-version-controlled-content", FORBIDDEN); //$NON-NLS-1$
337                _rfc3253ToWvcmMap.put("cannot-modify-version", CANNOT_MODIFY_VERSION); //$NON-NLS-1$
338                _rfc3253ToWvcmMap.put("auto-checkout", FORBIDDEN); //$NON-NLS-1$
339                _rfc3253ToWvcmMap.put("auto-checkout-checkin", FORBIDDEN); //$NON-NLS-1$
340                // PROPFIND
341                _rfc3253ToWvcmMap.put("supported-live-property", PROPERTY_NOT_CURRENTLY_AVAILABLE); //$NON-NLS-1$
342                // PROPPATCH
343                _rfc3253ToWvcmMap.put("cannot-modify-version-controlled-property", FORBIDDEN); //$NON-NLS-1$
344                _rfc3253ToWvcmMap.put("cannot-modify-version", CANNOT_MODIFY_VERSION); //$NON-NLS-1$
345                _rfc3253ToWvcmMap.put("cannot-modify-protected-property", CANNOT_MODIFY_PROTECTED_PROPERTY); //$NON-NLS-1$
346                _rfc3253ToWvcmMap.put("supported-live-property", PROPERTY_NOT_CURRENTLY_AVAILABLE); //$NON-NLS-1$
347                _rfc3253ToWvcmMap.put("auto-checkout", FORBIDDEN); //$NON-NLS-1$
348                _rfc3253ToWvcmMap.put("auto-checkout-checkin", FORBIDDEN); //$NON-NLS-1$
349                // DELETE
350                _rfc3253ToWvcmMap.put("no-version-delete", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
351                _rfc3253ToWvcmMap.put("update-predecessor-set", FORBIDDEN); //$NON-NLS-1$
352                // COPY
353                _rfc3253ToWvcmMap.put("must-not-copy-versioning-property", FORBIDDEN); //$NON-NLS-1$
354                _rfc3253ToWvcmMap.put("auto-checkout", FORBIDDEN); //$NON-NLS-1$
355                _rfc3253ToWvcmMap.put("auto-checkout-checkin", FORBIDDEN); //$NON-NLS-1$
356                _rfc3253ToWvcmMap.put("copy-creates-new-resource", FORBIDDEN); //$NON-NLS-1$
357                // MOVE
358                _rfc3253ToWvcmMap.put("cannot-rename-version", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
359                _rfc3253ToWvcmMap.put("preserve-versioning-properties", FORBIDDEN); //$NON-NLS-1$
360                // UNLOCK
361                _rfc3253ToWvcmMap.put("version-history-is-tree", VERSION_HISTORY_MUST_BE_A_TREE); //$NON-NLS-1$
362                _rfc3253ToWvcmMap.put("auto-checkin", FORBIDDEN); //$NON-NLS-1$
363                // CHECKOUT
364                _rfc3253ToWvcmMap.put("must-be-checked-in", MUST_BE_CHECKED_IN); //$NON-NLS-1$
365                _rfc3253ToWvcmMap.put("checkout-of-version-with-descendant-is-forbidden", CANNOT_CHECKOUT_FORKING_IS_FORBIDDEN); //$NON-NLS-1$
366                _rfc3253ToWvcmMap.put("checkout-of-version-with-descendant-is-discouraged", CANNOT_CHECKOUT_FORKING_IS_DISCOURAGED); //$NON-NLS-1$
367                _rfc3253ToWvcmMap.put("checkout-of-checked-out-version-is-forbidden", CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_FORBIDDEN); //$NON-NLS-1$
368                _rfc3253ToWvcmMap.put("checkout-of-checked-out-version-is-discouraged", CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_DISCOURAGED); //$NON-NLS-1$
369                _rfc3253ToWvcmMap.put("is-checked-out", FORBIDDEN); //$NON-NLS-1$
370                _rfc3253ToWvcmMap.put("initialize-predecessor-set", FORBIDDEN); //$NON-NLS-1$
371                // CHECKIN
372                _rfc3253ToWvcmMap.put("must-be-checked-out", MUST_BE_CHECKED_OUT); //$NON-NLS-1$
373                _rfc3253ToWvcmMap.put("version-history-is-tree", VERSION_HISTORY_MUST_BE_A_TREE); //$NON-NLS-1$
374                _rfc3253ToWvcmMap.put("checkin-fork-forbidden", CANNOT_FORK); //$NON-NLS-1$
375                _rfc3253ToWvcmMap.put("checkin-fork-discouraged", CANNOT_CHECKIN_FORK_DISCOURAGED); //$NON-NLS-1$
376                _rfc3253ToWvcmMap.put("create-version", FORBIDDEN); //$NON-NLS-1$
377                _rfc3253ToWvcmMap.put("initialize-version-content-and-properties", FORBIDDEN); //$NON-NLS-1$
378                _rfc3253ToWvcmMap.put("checked-in", FORBIDDEN); //$NON-NLS-1$
379                _rfc3253ToWvcmMap.put("keep-checked-out", FORBIDDEN); //$NON-NLS-1$
380                // UNCHECKOUT
381                _rfc3253ToWvcmMap.put("must-be-checked-out-version-controlled-resource", MUST_BE_CHECKED_OUT); //$NON-NLS-1$
382                _rfc3253ToWvcmMap.put("cancel-checked-out", FORBIDDEN); //$NON-NLS-1$
383                _rfc3253ToWvcmMap.put("restore-content-and-dead-properties", FORBIDDEN); //$NON-NLS-1$
384                // REPORT (DAV:locate-by-history)
385                _rfc3253ToWvcmMap.put("must-be-version-history", BAD_ARGUMENT_TYPE); //$NON-NLS-1$
386                // DELETE (version history feature)
387                _rfc3253ToWvcmMap.put("delete-version-set", FORBIDDEN); //$NON-NLS-1$
388                _rfc3253ToWvcmMap.put("version-history-has-root", FORBIDDEN); //$NON-NLS-1$
389                // COPY (version history feature)
390                _rfc3253ToWvcmMap.put("cannot-copy-history", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
391                // MOVE (version history feature)
392                _rfc3253ToWvcmMap.put("cannot-rename-history", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
393                // VERSION-CONTROL (version history feature)
394                _rfc3253ToWvcmMap.put("new-version-history", FORBIDDEN); //$NON-NLS-1$
395                // CHECKIN (version history feature)
396                _rfc3253ToWvcmMap.put("add-to-history", FORBIDDEN); //$NON-NLS-1$
397                // MKWORKSPACE
398                _rfc3253ToWvcmMap.put("resource-must-be-null", RESOURCE_ALREADY_EXISTS_AT_LOCATION); //$NON-NLS-1$
399                _rfc3253ToWvcmMap.put("workspace-location-ok", CANNOT_CREATE_AT_THIS_LOCATION); //$NON-NLS-1$
400                _rfc3253ToWvcmMap.put("initialize-workspace", FORBIDDEN); //$NON-NLS-1$
401                // DELETE (workspace)
402                _rfc3253ToWvcmMap.put("delete-workspace-members", FORBIDDEN); //$NON-NLS-1$
403                // MOVE (workspace)
404                _rfc3253ToWvcmMap.put("workspace-member-moved", FORBIDDEN); //$NON-NLS-1$
405                _rfc3253ToWvcmMap.put("workspace-moved", FORBIDDEN); //$NON-NLS-1$
406                // VERSION-CONTROL (workspace)
407                _rfc3253ToWvcmMap.put("cannot-add-to-existing-history", RESOURCE_ALREADY_EXISTS_AT_LOCATION); //$NON-NLS-1$
408                _rfc3253ToWvcmMap.put("must-be-version", FORBIDDEN); //$NON-NLS-1$
409                _rfc3253ToWvcmMap.put("one-version-controlled-resource-per-history-per-workspace", ONE_CONTROLLED_RESOURCE_PER_HISTORY_PER_WORKSPACE); //$NON-NLS-1$
410                _rfc3253ToWvcmMap.put("new-version-controlled-resource", FORBIDDEN); //$NON-NLS-1$
411                // UPDATE (workspace)
412                _rfc3253ToWvcmMap.put("update-content-and-properties", FORBIDDEN); //$NON-NLS-1$
413                _rfc3253ToWvcmMap.put("report-properties", FORBIDDEN); //$NON-NLS-1$
414                // LABEL
415                _rfc3253ToWvcmMap.put("must-be-checked-in", MUST_BE_CHECKED_IN); //$NON-NLS-1$
416                _rfc3253ToWvcmMap.put("add-must-be-new-label", ADD_MUST_BE_NEW_LABEL); //$NON-NLS-1$
417                _rfc3253ToWvcmMap.put("label-must-exist", CANNOT_REMOVE_LABEL_DOES_NOT_EXIST); //$NON-NLS-1$
418                _rfc3253ToWvcmMap.put("add-or-set-label", FORBIDDEN); //$NON-NLS-1$
419                _rfc3253ToWvcmMap.put("remove-label", FORBIDDEN); //$NON-NLS-1$
420                // GET (label)
421                _rfc3253ToWvcmMap.put("apply-request-to-labeled-version", FORBIDDEN); //$NON-NLS-1$
422                // PROPFIND (label)
423                _rfc3253ToWvcmMap.put("must-select-version-in-history", FORBIDDEN); //$NON-NLS-1$
424                _rfc3253ToWvcmMap.put("apply-request-to-labeled-version", FORBIDDEN); //$NON-NLS-1$
425                // COPY (label)
426                _rfc3253ToWvcmMap.put("apply-request-to-labeled-version", FORBIDDEN); //$NON-NLS-1$
427                // CHECKOUT (label)
428                _rfc3253ToWvcmMap.put("must-not-have-label-and-apply-to-version", FORBIDDEN); //$NON-NLS-1$
429                _rfc3253ToWvcmMap.put("apply-request-to-labeled-version", FORBIDDEN); //$NON-NLS-1$
430                // UPDATE (label)
431                _rfc3253ToWvcmMap.put("depth-update", FORBIDDEN); //$NON-NLS-1$
432                _rfc3253ToWvcmMap.put("apply-request-to-labeled-version", FORBIDDEN); //$NON-NLS-1$
433                // CHECKOUT (working resource)
434                _rfc3253ToWvcmMap.put("checkout-of-version-with-descendant-is-discouraged", CANNOT_CHECKOUT_FORKING_IS_DISCOURAGED); //$NON-NLS-1$
435                _rfc3253ToWvcmMap.put("checkout-of-checked-out-version-is-forbidden", CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_FORBIDDEN); //$NON-NLS-1$
436                _rfc3253ToWvcmMap.put("checkout-of-checked-out-version-is-discouraged", CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_DISCOURAGED); //$NON-NLS-1$
437                _rfc3253ToWvcmMap.put("create-working-resource", FORBIDDEN); //$NON-NLS-1$
438                _rfc3253ToWvcmMap.put("create-working-resource-from-checked-in-version", FORBIDDEN); //$NON-NLS-1$
439                // CHECKIN (working resource)
440                _rfc3253ToWvcmMap.put("must-be-checked-in", MUST_BE_CHECKED_IN); //$NON-NLS-1$
441                _rfc3253ToWvcmMap.put("version-history-is-tree", VERSION_HISTORY_MUST_BE_A_TREE); //$NON-NLS-1$
442                _rfc3253ToWvcmMap.put("checkin-fork-forbidden", CANNOT_FORK); //$NON-NLS-1$
443                _rfc3253ToWvcmMap.put("checkin-fork-discouraged", CANNOT_CHECKIN_FORK_DISCOURAGED); //$NON-NLS-1$
444                _rfc3253ToWvcmMap.put("no-overwrite-by-auto-update", FORBIDDEN); //$NON-NLS-1$
445                _rfc3253ToWvcmMap.put("create-version", FORBIDDEN); //$NON-NLS-1$
446                _rfc3253ToWvcmMap.put("initialize-version-content-and-properties", FORBIDDEN); //$NON-NLS-1$
447                _rfc3253ToWvcmMap.put("auto-update", FORBIDDEN); //$NON-NLS-1$
448                _rfc3253ToWvcmMap.put("delete-working-resource", FORBIDDEN); //$NON-NLS-1$
449                // COPY (working resource)
450                _rfc3253ToWvcmMap.put("copy-creates-new-resource", FORBIDDEN); //$NON-NLS-1$
451                // MOVE (working resource)
452                _rfc3253ToWvcmMap.put("cannot-rename-working-resource", FORBIDDEN); //$NON-NLS-1$
453                _rfc3253ToWvcmMap.put("update-auto-update", FORBIDDEN); //$NON-NLS-1$
454                // MERGE
455                _rfc3253ToWvcmMap.put("cannot-merge-checked-out-resource", FORBIDDEN); //$NON-NLS-1$
456                _rfc3253ToWvcmMap.put("checkout-not-allowed", CANNOT_MERGE_CHECKOUT_NOT_ALLOWED); //$NON-NLS-1$
457                _rfc3253ToWvcmMap.put("ancestor-version", FORBIDDEN); //$NON-NLS-1$
458                _rfc3253ToWvcmMap.put("decendent-version", FORBIDDEN); //$NON-NLS-1$
459                _rfc3253ToWvcmMap.put("checked-out-for-merge", FORBIDDEN); //$NON-NLS-1$
460                _rfc3253ToWvcmMap.put("update-merge-set", FORBIDDEN); //$NON-NLS-1$
461                _rfc3253ToWvcmMap.put("report-properties", FORBIDDEN); //$NON-NLS-1$
462                // DELETE (merge)
463                _rfc3253ToWvcmMap.put("delete-version-reference", FORBIDDEN); //$NON-NLS-1$
464                // CHECKIN (merge)
465                _rfc3253ToWvcmMap.put("merge-must-be-complete", FORBIDDEN); //$NON-NLS-1$
466                // BASELINE-CONTROL
467                _rfc3253ToWvcmMap.put("configuration-must-not-exist", FORBIDDEN); //$NON-NLS-1$
468                _rfc3253ToWvcmMap.put("must-be-baseline", BAD_ARGUMENT_TYPE); //$NON-NLS-1$
469                _rfc3253ToWvcmMap.put("must-have-no-version-controlled-members", CANNOT_HAVE_CONTROLLED_MEMBERS); //$NON-NLS-1$
470                _rfc3253ToWvcmMap.put("one-baseline-controlled-collection-per-history-per-workspace", CANNOT_HAVE_MULTIPLE_BASELINE_CONTROLLED_FOLDERS); //$NON-NLS-1$
471                _rfc3253ToWvcmMap.put("create-configuration", FORBIDDEN); //$NON-NLS-1$
472                _rfc3253ToWvcmMap.put("reference-configuration", FORBIDDEN); //$NON-NLS-1$
473                _rfc3253ToWvcmMap.put("select-existing-baseline", FORBIDDEN); //$NON-NLS-1$
474                _rfc3253ToWvcmMap.put("create-new-baseline", FORBIDDEN); //$NON-NLS-1$
475                // REPORT (DAV:compare-baseline report)
476                _rfc3253ToWvcmMap.put("must-be-baseline", BAD_ARGUMENT_TYPE); //$NON-NLS-1$
477                _rfc3253ToWvcmMap.put("baselines-from-same-history", FORBIDDEN); //$NON-NLS-1$
478                // CHECKOUT (baseline)
479                _rfc3253ToWvcmMap.put("must-not-update-baseline-collection", FORBIDDEN); //$NON-NLS-1$
480                // CHECKIN (baseline)
481                _rfc3253ToWvcmMap.put("no-checked-out-baseline-controlled-collection-members", NO_CHECKED_OUT_BASELINE_CONTROLLED_FOLDER_MEMBERS); //$NON-NLS-1$
482                _rfc3253ToWvcmMap.put("one-version-per-history-per-baseline", FORBIDDEN); //$NON-NLS-1$
483                _rfc3253ToWvcmMap.put("cannot-modify-configuration", FORBIDDEN); //$NON-NLS-1$
484                _rfc3253ToWvcmMap.put("create-baseline-collection", FORBIDDEN); //$NON-NLS-1$
485                _rfc3253ToWvcmMap.put("modify-configuration", FORBIDDEN); //$NON-NLS-1$
486                // UPDATE (baseline)
487                _rfc3253ToWvcmMap.put("baseline-controlled-members-must-be-checked-in", NO_CHECKED_OUT_BASELINE_CONTROLLED_FOLDER_MEMBERS); //$NON-NLS-1$
488                _rfc3253ToWvcmMap.put("must-not-update-baseline-collection", FORBIDDEN); //$NON-NLS-1$
489                _rfc3253ToWvcmMap.put("cannot-modify-version-controlled-configuration", FORBIDDEN); //$NON-NLS-1$
490                _rfc3253ToWvcmMap.put("set-baseline-controlled-collection-members", FORBIDDEN); //$NON-NLS-1$
491                _rfc3253ToWvcmMap.put("modify-configuration", FORBIDDEN); //$NON-NLS-1$
492                // MERGE (baseline)
493                _rfc3253ToWvcmMap.put("must-not-update-baseline-collection", FORBIDDEN); //$NON-NLS-1$
494                _rfc3253ToWvcmMap.put("cannot-modify-configuration", FORBIDDEN); //$NON-NLS-1$
495                _rfc3253ToWvcmMap.put("merge-baseline", FORBIDDEN); //$NON-NLS-1$
496                _rfc3253ToWvcmMap.put("set-baseline-controlled-collection-members", FORBIDDEN); //$NON-NLS-1$
497                _rfc3253ToWvcmMap.put("modify-configuration", FORBIDDEN); //$NON-NLS-1$
498                // ACTIVITY
499                _rfc3253ToWvcmMap.put("resource-must-be-null", RESOURCE_ALREADY_EXISTS_AT_LOCATION); //$NON-NLS-1$
500                _rfc3253ToWvcmMap.put("activity-location-ok", CANNOT_CREATE_AT_THIS_LOCATION); //$NON-NLS-1$
501                _rfc3253ToWvcmMap.put("initialize-activity", FORBIDDEN); //$NON-NLS-1$
502                // REPORT (DAV:latest-activity-version)
503                _rfc3253ToWvcmMap.put("must-be-activity", BAD_ARGUMENT_TYPE); //$NON-NLS-1$
504                _rfc3253ToWvcmMap.put("delete-activity-reference", FORBIDDEN); //$NON-NLS-1$
505                _rfc3253ToWvcmMap.put("update-checked-out-reference", FORBIDDEN); //$NON-NLS-1$
506                _rfc3253ToWvcmMap.put("update-activity-reference", FORBIDDEN); //$NON-NLS-1$
507                _rfc3253ToWvcmMap.put("update-workspace-reference", FORBIDDEN); //$NON-NLS-1$
508                // CHECKOUT (activity)
509                _rfc3253ToWvcmMap.put("one-checkout-per-activity-per-history", ONE_CHECKOUT_PER_ACTIVITY_PER_HISTORY); //$NON-NLS-1$
510                _rfc3253ToWvcmMap.put("linear-activity", CANNOT_CREATE_BRANCH_IN_ACTIVITY); //$NON-NLS-1$
511                _rfc3253ToWvcmMap.put("initialize-activity-set", FORBIDDEN); //$NON-NLS-1$
512                _rfc3253ToWvcmMap.put("initialize-reserved", FORBIDDEN); //$NON-NLS-1$
513                // CHECKIN (activity)
514                _rfc3253ToWvcmMap.put("linear-activity", CANNOT_CREATE_BRANCH_IN_ACTIVITY); //$NON-NLS-1$
515                _rfc3253ToWvcmMap.put("atomic-activity-checkin", MULTI_STATUS); //$NON-NLS-1$
516                _rfc3253ToWvcmMap.put("initialize-activity-set", FORBIDDEN); //$NON-NLS-1$
517                _rfc3253ToWvcmMap.put("activity-checkin", FORBIDDEN); //$NON-NLS-1$
518                // MERGE (activity)
519                _rfc3253ToWvcmMap.put("checkin-activity", FORBIDDEN); //$NON-NLS-1$
520                // DELETE (version-controlled-collection)
521                _rfc3253ToWvcmMap.put("cannot-modify-checked-in-parent", FORBIDDEN); //$NON-NLS-1$
522                _rfc3253ToWvcmMap.put("delete-working-collection-binding", FORBIDDEN); //$NON-NLS-1$
523                // COPY (version-controlled-collection)
524                _rfc3253ToWvcmMap.put("cannot-copy-collection-version", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
525                _rfc3253ToWvcmMap.put("cannot-modify-checked-in-parent", FORBIDDEN); //$NON-NLS-1$
526                _rfc3253ToWvcmMap.put("cannot-modify-destination-checked-in-parent", FORBIDDEN); //$NON-NLS-1$
527                // VERSION-CONTROL (version-controlled-collection)
528                _rfc3253ToWvcmMap.put("cannot-modify-checked-in-parent", FORBIDDEN); //$NON-NLS-1$
529                _rfc3253ToWvcmMap.put("new-version-controlled-collection", FORBIDDEN); //$NON-NLS-1$
530                // CHECKOUT (version-controlled-collection)
531                _rfc3253ToWvcmMap.put("initialize-version-history-bindings", FORBIDDEN); //$NON-NLS-1$
532                // CHECKIN (version-controlled-collection)
533                _rfc3253ToWvcmMap.put("initialize-version-controlled-bindings", FORBIDDEN); //$NON-NLS-1$
534                _rfc3253ToWvcmMap.put("version-control-working-collection-members", FORBIDDEN); //$NON-NLS-1$
535                // UNCHECKOUT, UPDATE, and MERGE (version-controlled-collection)
536                _rfc3253ToWvcmMap.put("update-version-controlled-collection-members", FORBIDDEN); //$NON-NLS-1$
537                // BIND
538                _rfc3253ToWvcmMap.put("bind-source-exists", NOT_FOUND); //$NON-NLS-1$
539                _rfc3253ToWvcmMap.put("name-allowed", CANNOT_CREATE_AT_THIS_LOCATION); //$NON-NLS-1$
540                _rfc3253ToWvcmMap.put("binding-allowed", METHOD_NOT_SUPPORTED); //$NON-NLS-1$
541                _rfc3253ToWvcmMap.put("cross-server-binding", NO_CROSS_SERVER_BINDING); //$NON-NLS-1$
542                _rfc3253ToWvcmMap.put("can-overwrite", CANNOT_OVERWRITE); //$NON-NLS-1$
543                _rfc3253ToWvcmMap.put("cycle-allowed", CYCLE_NOT_ALLOWED); //$NON-NLS-1$
544                _rfc3253ToWvcmMap.put("new-binding", FORBIDDEN); //$NON-NLS-1$
545                // UNBIND
546                _rfc3253ToWvcmMap.put("unbind-source-exists", NOT_FOUND); //$NON-NLS-1$
547                // REBIND
548                _rfc3253ToWvcmMap.put("rebind-source-exists", NOT_FOUND); //$NON-NLS-1$
549            }
550    
551            /**  Hidden constuctor for type-safety. */
552            private ReasonCode(String codeImage) {
553                _codeImage = codeImage;
554            }
555    
556            /**
557             * The ReasonCode for an RFC 3253 pre- or post-condition.
558             * 
559             * @param condition the RFC 3253 pre- or post- condition local name.
560             * @return the corresponding ReasonCode.
561             */
562            public static ReasonCode getReasonCodeForRFC3253Condition(String condition)
563            {
564                return _rfc3253ToWvcmMap.get(condition);
565            }
566    
567            /**
568             * Returns a string representation of this ReasonCode suitable for diagnostics.
569             */
570            @Override
571            public String toString() {
572                return _codeImage;
573            }
574    
575            /**
576             * Return the string form of this ReasonCode.
577             */
578            private final String _codeImage;
579        }
580    
581        /**
582         * The resource that caused the exception.
583         */
584        private Resource _resource;
585    
586        /** 
587         * The reason for the exception.
588         */
589        private ReasonCode _reasonCode;
590    
591        /** 
592         * An array of nested exceptions that further explain the cause of the error.
593         */
594        private Throwable[] _nestedExceptions = null;
595    
596        /**
597         * Constructs a WvcmException.
598         * 
599         * @param message the detail message for the exception.
600         * @param reasonCode the reason for the exception.
601         */
602        public WvcmException(
603                String message,
604                ReasonCode reasonCode) {
605            super(message);
606            _resource = null;
607            _reasonCode = reasonCode;
608            _nestedExceptions = null;
609        }
610    
611        /**
612         * Constructs a WvcmException.
613         * 
614         * @param message the detail message for the exception.
615         * @param resource the resource causing the exception.
616         * @param reasonCode the reason for the exception.
617         */
618        public WvcmException(
619                String message,
620                Resource resource,
621                ReasonCode reasonCode) {
622            super(message);
623            _resource = resource;
624            _reasonCode = reasonCode;
625            _nestedExceptions = null;
626        }
627    
628        /**
629         * Constructs a WvcmException.
630         * 
631         * @param message the detail message for the exception.
632         * @param resource the resource causing the exception.
633         * @param reasonCode the reason for the exception.
634         * @param cause the exception that caused this exception.
635         */
636        public WvcmException(
637                String message,
638                Resource resource,
639                ReasonCode  reasonCode,
640                Throwable cause) {
641            super(message, cause);
642            _resource = resource;
643            _reasonCode = reasonCode;
644            _nestedExceptions = null;
645        }
646    
647        /**
648         * Constructs a WvcmException.
649         * 
650         * @param message the detail message for the exception.
651         * @param resource the resource causing the exception.
652         * @param reasonCode the reason for the exception.
653         * @param nestedExceptions any nested exception.
654         */
655        public WvcmException(
656                String message,
657                Resource resource,
658                ReasonCode  reasonCode,
659                Throwable[] nestedExceptions) {
660            super(message);
661            _resource = resource;
662            _reasonCode = reasonCode;
663            _nestedExceptions = nestedExceptions;
664        }
665    
666        /**
667         * Constructs a WvcmException.
668         * 
669         * @param message the detail message for the exception.
670         * @param resource the resource causing the exception.
671         * @param reasonCode the reason for the exception.
672         * @param cause the exception that caused this exception.
673         * @param nestedExceptions any nested exception.
674         */
675        public WvcmException(
676                String message,
677                Resource resource,
678                ReasonCode  reasonCode,
679                Throwable cause,
680                Throwable[] nestedExceptions) {
681            super(message, cause);
682            _resource = resource;
683            _reasonCode = reasonCode;
684            _nestedExceptions = nestedExceptions;
685        }
686    
687        /**
688         * Get the resource causing the exception.
689         * 
690         * @return the resource causing the exception.
691         */
692        public Resource getResource() {
693            return _resource;
694        }
695    
696        /**
697         * Get the reason code that describes the nature of the error.
698         * 
699         * @return the reason code that describes the nature of the error.
700         */
701        public ReasonCode getReasonCode() {
702            return _reasonCode;
703        }
704    
705        /**
706         * Get any nested exceptions that further explain the cause of the error.
707         * 
708         * @return any nested exceptions that further explain the cause of the error.
709         */
710        public Throwable[] getNestedExceptions() {
711            return _nestedExceptions;
712        }
713    
714        /**
715         * The serial version UID.
716         */
717        private static final long serialVersionUID = -663023054869664237L;
718    }