001 /*
002 * file StpException.java
003 *
004 * Licensed Materials - Property of IBM
005 * Restricted Materials of IBM
006 *
007 * com.ibm.rational.wvcm.stp.StpException
008 *
009 * © Copyright IBM Corporation 2006, 2009. All Rights Reserved.
010 * Note to U.S. Government Users Restricted Rights: Use, duplication or
011 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
012 */
013
014 package com.ibm.rational.wvcm.stp;
015
016 import java.lang.reflect.InvocationTargetException;
017 import java.lang.reflect.Method;
018 import java.util.HashMap;
019 import java.util.Locale;
020
021 import javax.wvcm.Feedback;
022 import javax.wvcm.Resource;
023 import javax.wvcm.WvcmException;
024 import javax.wvcm.WvcmException.ReasonCode;
025
026 import com.ibm.rational.wvcm.stpex.StpExEnumeration;
027 import com.ibm.rational.wvcm.stpex.StpExEnumerationBase;
028
029 /**
030 * An extension of {@link javax.wvcm.WvcmException javax.wvcm.WvcmException}
031 * used throughout this API. Although API methods are declared to throw
032 * WvcmException, the exception actually thrown is StpException or one of its
033 * subclasses.
034 * <p>
035 * This class extends the WvcmException class, adding a <i>sub-reason code</i>
036 * field that encodes conditions specific to this API more finely than the
037 * {@link javax.wvcm.WvcmException.ReasonCode}
038 * <p>
039 * This class (unlike the WvcmException class) leverages the Java 1.4 chained
040 * exception mechanism. By default, if an StpException is constructed from one
041 * or more nested Throwables, the first nested Throwable in the list is also set
042 * as the StpException's {@link java.lang.Throwable#initCause cause}. In
043 * certain special cases, the cause may be set to something other than the first
044 * nested Throwable.
045 *
046 * Exception classes that extend StpException because they convey additional
047 * information, are as follows:
048 * <ul>
049 * <li>{@link StpPropertyException} - adds name of property responsible for the
050 * exception
051 * <p>
052 * <li>{@link StpPartialResultsException} - holds a ResourceList of child
053 * resources successfully received, a nested list of Exceptions for child
054 * resources that could not be retrieved, and an indicator of whether the two
055 * lists completely identify all resources that were supposed to be retrieved.
056 * <p>
057 * </ul>
058 */
059 public abstract class StpException extends WvcmException
060 {
061 /**
062 * The specification for the data implementation object associated with this
063 * exception.
064 */
065 public interface Data {
066 public String getMessage();
067 public StpReasonCode getStpReasonCode();
068 public String toString();
069 }
070
071 /**
072 * An encoding of exception conditions specific to this API. Each
073 * StpReasonCode maps to one WvcmException.ReasonCode, but, because the
074 * granularity of the StpReasonCode enumeration is finer than that of the
075 * ReasonCode, the mapping may be many-to-one.
076 * <p>
077 *
078 * When the correspondence between an StpReasonCode and a ReasonCode is not
079 * obvious, the StpReasonCode is mapped to either ReasonCode.CONFLICT or
080 * ReasonCode.FORBIDDEN
081 * using the following rationale:
082 * <p>
083 * <ul>
084 * <li>{@link javax.wvcm.WvcmException.ReasonCode#CONFLICT CONFLICT} - the exception
085 * relates to an issue where the client may be able to retry the method
086 * after changing the state on some object.
087 *
088 * <li>{@link javax.wvcm.WvcmException.ReasonCode#FORBIDDEN FORBIDDEN} - the
089 * exception relates to an issue where the client cannot do anything to
090 * retry the method.
091 * </ul>
092 *
093 * For conditions where there is not enough information to decide whether or
094 * not there is anything the client could do to retry the method, the
095 * StpReasonCode is classified as CONFLICT.
096 * <p>
097 */
098
099 public static enum StpReasonCode implements StpExEnumeration
100 {
101 // /**
102 // * Method execution was aborted via notification to the Feedback object.
103 // */
104 // @Deprecated
105 // ABORTED,
106 //
107 /**
108 * The request timed out waiting for a resource to become free.
109 */
110 REQUEST_TIMED_OUT(ReasonCode.ABORTED),
111
112 // /**
113 // * <code>Precondition:</code> The label is already in use by this
114 // * resource.
115 // */
116 // @Deprecated
117 // ADD_MUST_BE_NEW_LABEL,
118 //
119 // /**
120 // * The type of the persistent resource identified by this argument was
121 // * not compatible with the specified argument type.
122 // */
123 // @Deprecated
124 // BAD_ARGUMENT_TYPE,
125 //
126 // /**
127 // * <code>Precondition:</code> Operation failed because the resource
128 // * passed in was not a baseline.
129 // */
130 // @Deprecated
131 // NOT_A_BASELINE(ReasonCode.BAD_ARGUMENT_TYPE),
132 //
133 // /** <code>Precondition:</code> Resource specified was not an activity. */
134 // @Deprecated
135 // NOT_AN_ACTIVITY(ReasonCode.BAD_ARGUMENT_TYPE),
136 //
137 // /**
138 // * <code>Precondition:</code> Cannot checkin since it would cause a
139 // * fork and forking is discouraged.
140 // */
141 // @Deprecated
142 // CANNOT_CHECKIN_FORK_DISCOURAGED,
143 //
144 // /**
145 // * There is a reserved checkout of a version in this version history.
146 // */
147 // @Deprecated
148 // CANNOT_CHECKIN_TO_RESERVED_ACTIVITY,
149 //
150 // /**
151 // * <code>Precondition:</code> Failed to checkout because descendent
152 // * already exists and forking is discouraged.
153 // */
154 // @Deprecated
155 // CANNOT_CHECKOUT_FORKING_IS_DISCOURAGED,
156 //
157 // /**
158 // * <code>Precondition:</code> Failed to checkout the resource because
159 // * a descendent exists and forking is forbidden.
160 // */
161 // @Deprecated
162 // CANNOT_CHECKOUT_FORKING_IS_FORBIDDEN,
163 //
164 // /**
165 // * <code>Precondition:</code> Failed to checkout resource because
166 // * multiple checkout is discouraged and the caller did not specify
167 // * fork-ok.
168 // */
169 // @Deprecated
170 // CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_DISCOURAGED,
171 //
172 // /**
173 // * <code>Precondition:</code> Checkout of an already checked-out
174 // * resource is forbidden.
175 // */
176 // @Deprecated
177 // CANNOT_CHECKOUT_MULTI_CHECKOUT_IS_FORBIDDEN,
178 //
179 /**
180 * <code>Precondition:</code> Cannot create this resource at the
181 * specified location.
182 */
183 CANNOT_CREATE_AT_THIS_LOCATION,
184
185 // /**
186 // * <code>Precondition:</code> Each version in an activity for a given
187 // * version history must be on the same line of descent.
188 // */
189 // @Deprecated
190 // CANNOT_CREATE_BRANCH_IN_ACTIVITY,
191 //
192 // /**
193 // * Each version in a stream for a given version history must be on the
194 // * same line of descent.
195 // */
196 // @Deprecated
197 // CANNOT_CREATE_BRANCH_IN_STREAM,
198 //
199 // /**
200 // * <code>Precondition:</code> A fork in the version tree is not
201 // * allowed.
202 // */
203 // @Deprecated
204 // CANNOT_FORK,
205 //
206 // /**
207 // * <code>Precondition:</code> baseline control failed because the
208 // * folder already has controlled resources.
209 // */
210 // @Deprecated
211 // CANNOT_HAVE_CONTROLLED_MEMBERS,
212 //
213 // /**
214 // * <code>Precondition:</code> A baseline controlled folder already
215 // * exists in this workspace for this baseline history.
216 // */
217 // @Deprecated
218 // CANNOT_HAVE_MULTIPLE_BASELINE_CONTROLLED_FOLDERS,
219 //
220 // /**
221 // * <code>Precondition:</code> Failed to perform the merge because the
222 // * target could not be checked-out.
223 // */
224 // @Deprecated
225 // CANNOT_MERGE_CHECKOUT_NOT_ALLOWED,
226 //
227 /**
228 * <code>Precondition:</code> Operation failed because it attempted to
229 * set a protected property.
230 */
231 CANNOT_MODIFY_PROTECTED_PROPERTY,
232
233 // /**
234 // * <code>Precondition:</code> Failed to modify content/properties
235 // * because the resource specified was a version.
236 // */
237 // @Deprecated
238 // CANNOT_MODIFY_VERSION,
239 //
240 /** Cannot overwrite existing binding. */
241 CANNOT_OVERWRITE,
242
243 // /**
244 // * <code>Precondition:</code> Cannot remove the specified label
245 // * because it is not used by this resource.
246 // */
247 // @Deprecated
248 // CANNOT_REMOVE_LABEL_DOES_NOT_EXIST,
249 //
250 /**
251 * The operation cannot be performed because of a conflict with resource
252 * state.
253 */
254 CONFLICT,
255
256 // /**
257 // * The activity specified for the operation is not accepted into the
258 // * workspace.
259 // */
260 // @Deprecated
261 // ACTIVITY_MUST_BE_ACCEPTED(ReasonCode.CONFLICT),
262 //
263 /**
264 * A checkout was attempted with no explicit activity and no current
265 * activity in the workspace.
266 */
267 ACTIVITY_NEEDED(ReasonCode.CONFLICT),
268
269 /**
270 * The specified record is already being edited (by the same user).
271 */
272 ALREADY_BEING_EDITED(ReasonCode.CONFLICT),
273
274 /**
275 * Authentication information is required but client didn't provide any.
276 */
277 AUTHENTICATION_INFO_REQUIRED(ReasonCode.CONFLICT),
278
279 // /** The duplicated query cannot be found on the server */
280 // @Deprecated
281 // BAD_DUPLICATE_HREF(ReasonCode.CONFLICT),
282 //
283 /**
284 * The requested action is inappropriate for the current state of the
285 * query (precondition failure)
286 */
287 BAD_SOURCE_STATE(ReasonCode.CONFLICT),
288
289 /**
290 * The checkin operation failed because the resource is not checked out.
291 */
292 CANNOT_CHECKIN_MUST_BE_CHECKED_OUT(ReasonCode.CONFLICT),
293
294 /**
295 * Used when a string is not supported by the server's operating system.
296 */
297 CANNOT_ENCODE_STRING(ReasonCode.CONFLICT),
298
299 // /** The resource's version controlled content cannot be modified */
300 // @Deprecated
301 // CANNOT_MODIFY_VERSION_CONTROLLED_CONTENT(ReasonCode.CONFLICT),
302 //
303 // /**
304 // * doRebind() was requested to move a controlled resource to an
305 // * uncontrolled parent directory.
306 // */
307 // @Deprecated
308 // CANNOT_RENAME_TO_UNCONTROLLED_PARENT(ReasonCode.CONFLICT),
309 //
310 /**
311 * The uncheckout operation failed because the resource is not checked
312 * out.
313 */
314 CANNOT_UNCHECKOUT_MUST_BE_CHECKED_OUT(ReasonCode.CONFLICT),
315
316 /**
317 * Checkout failed because the branch was not mastered locally.
318 */
319 CHECKOUT_BRANCH_NOT_MASTERED(ReasonCode.CONFLICT),
320
321 /** Version being checked out is not the latest **/
322 CHECKOUT_NOT_LATEST(ReasonCode.CONFLICT),
323
324 // /**
325 // * Thrown when a referenced project checkpoint is not the latest.
326 // */
327 // @Deprecated
328 // CHECKPOINT_MUST_BE_LATEST(ReasonCode.CONFLICT),
329 //
330 /** The client location is not within a file area */
331 CLIENT_LOCATION_NOT_IN_FILE_AREA(ReasonCode.CONFLICT),
332
333 /** A communication precondition failed */
334 CONDITIONAL_EXECUTION(ReasonCode.CONFLICT),
335
336 // /**
337 // * Failed to write a property that should be writable. A potentially
338 // * recoverable condition prevented the server from writing the property
339 // * value.
340 // */
341 // @Deprecated
342 // PROPERTY_NOT_CURRENTLY_WRITABLE(ReasonCode.CONFLICT),
343 //
344 /**
345 * An operation failed because the connection to the remote server could
346 * not be established or terminated prematurely after being established.
347 */
348 CONNECTION_FAILED(ReasonCode.CONFLICT),
349
350 // /**
351 // * An activity, specified to be made current to a workspace, is not in
352 // * that workspace's accepted set.
353 // */
354 // @Deprecated
355 // CURRENT_ACTIVITY_MUST_BE_ACCEPTED(ReasonCode.CONFLICT),
356 //
357 /**
358 * An attempt to deliver a resource from the change context to the
359 * database failed.
360 */
361 DELIVERY_ERROR(ReasonCode.CONFLICT),
362
363 /** Version discordance detected **/
364 DISCORDANCE_VERSION(ReasonCode.CONFLICT),
365
366 /** Duplicate activity name **/
367 DUPLICATE_ACTIVITY_NAME(ReasonCode.CONFLICT),
368
369 /** Duplicate stream name **/
370 DUPLICATE_STREAM_NAME(ReasonCode.CONFLICT),
371
372 /**
373 * This code indicates that an external lock couldn't be acquired
374 * because the lock already exists.
375 */
376 EXTERNAL_LOCK_ALREADY_PRESENT(ReasonCode.CONFLICT),
377
378 /**
379 * Some dependency required by the communication channel failed.
380 */
381 FAILED_DEPENDENCY(ReasonCode.CONFLICT),
382
383 /**
384 * A field did not pass validation during an attempted delivery.
385 */
386 FIELD_VALIDATION(ReasonCode.CONFLICT),
387
388 /**
389 * The client resource resides in a file area whose version is not
390 * compatible with the currently running software. The file area needs
391 * to be upgraded in order to work with this software.
392 */
393 FILE_AREA_NEEDS_UPGRADE(ReasonCode.CONFLICT),
394
395 /** A file error was encountered */
396 FILE_ERROR(ReasonCode.CONFLICT),
397
398 // /**
399 // * This code indicates that the server URL stored in the file area
400 // * doesn't match the server URL of the current Provider. E.g., the two
401 // * URLs could differ in the hostname (consider that UCM2 server was
402 // * restored / relocated to another server), web server port identifier,
403 // * general change in the segment names leading up to the UCM2 namespace
404 // * root, ...
405 // */
406 // @Deprecated
407 // FILEAREA_SERVER_MISMATCH(ReasonCode.CONFLICT),
408 //
409 // /**
410 // * Another process already has a write lock on the file area database.
411 // * This code should only be present for a FileAreaWriteLockException.
412 // */
413 // @Deprecated
414 // FILEAREA_WRITE_LOCKED_EXTERNAL(ReasonCode.CONFLICT),
415 //
416 // /**
417 // * Another thread in the process already has a write lock on the file
418 // * area database.
419 // */
420 // @Deprecated
421 // FILEAREA_WRITE_LOCKED_INTERNAL(ReasonCode.CONFLICT),
422 //
423 // /** The resource is currently a hijacked checkout */
424 // @Deprecated
425 // HIJACKED_CHECKOUT(ReasonCode.CONFLICT),
426 //
427 /**
428 * While firing a named ClearQuest hook, the hook returned a message,
429 * which generally represents an error or need for additional
430 * information
431 */
432 HOOK_RETURNED_MESSAGE(ReasonCode.CONFLICT),
433
434 // /** A runtime error occurred in the HTTP subsystem */
435 // @Deprecated
436 // HTTP_RUNTIME(ReasonCode.CONFLICT),
437 //
438 // /** The HTTP subsystem state is not proper for the request */
439 // @Deprecated
440 // HTTP_STATE(ReasonCode.CONFLICT),
441 //
442 /**
443 * An in-line query definition during query execution
444 */
445 ILLEGAL_QUERY(ReasonCode.CONFLICT),
446
447 /**
448 * The client resource resides in a file area whose version is not
449 * compatible with the currently running software. The software needs to
450 * be upgraded to handle this file area.
451 */
452 INCOMPATIBLE_FILE_AREA_VERSION(ReasonCode.CONFLICT),
453
454 /** Insufficient permission for the requested operation */
455 INSUFFICIENT_PERMISSION(ReasonCode.CONFLICT),
456
457 /** An interaction request has occurred */
458 INTERACTION_REQUEST(ReasonCode.CONFLICT),
459
460 /** An internal error has occurred */
461 INTERNAL_ERROR(ReasonCode.CONFLICT),
462
463 /**
464 * The provider's server encountered an unexpected internal error
465 * condition which prevented it from fulfilling the request. This
466 * loosely corresponds to an HTTP 500 Internal Server Error response
467 * from the server.
468 *
469 * @see #SERVER_ERROR
470 */
471 INTERNAL_SERVER_ERROR(ReasonCode.CONFLICT),
472
473 /**
474 * A required field is missing from or malformed in an StpLocation
475 * specification.
476 */
477 INVALID_OBJECT_SELECTOR(ReasonCode.CONFLICT),
478
479 /** An invalid response was received */
480 INVALID_RESPONSE(ReasonCode.CONFLICT),
481
482 /**
483 * Completion of operation was prevented because one or more properties
484 * have invalid values
485 */
486 INVALID_VALUES(ReasonCode.CONFLICT),
487
488 /** License error occurred **/
489 LICENSE_ERROR(ReasonCode.CONFLICT),
490
491 // /**
492 // * An operation attempted to create a conflict in the copy based file
493 // * area's loaded scope set.
494 // *
495 // * E.g., an operation (such as checkout, create or load) attempted to
496 // * add an include-scope for an item that is a child of an exclude-scope
497 // * specification.
498 // */
499 // @Deprecated
500 // LOADED_SCOPES_CONFLICT(ReasonCode.CONFLICT),
501 //
502 /** The database to be affected is currently locked */
503 LOCKED_DATABASE(ReasonCode.CONFLICT),
504
505 // /**
506 // * Maximum logon attempts exceeded.
507 // */
508 // @Deprecated
509 // MAX_LOGON_ATTEMPTS_EXCEEDED(ReasonCode.CONFLICT),
510 //
511 // /** The destination associated with the request is missing */
512 // @Deprecated
513 // MISSING_DESTINATION(ReasonCode.CONFLICT),
514 //
515 // /**
516 // * A supplied location, which must be a client location, is not a client
517 // * location.
518 // */
519 // @Deprecated
520 // MUST_BE_CLIENT_LOCATION(ReasonCode.CONFLICT),
521 //
522 // /**
523 // * Checkin with identical data not allowed and identical data was
524 // * provided.
525 // */
526 // @Deprecated
527 // MUST_BE_DIFFERENT(ReasonCode.CONFLICT),
528 //
529 // /**
530 // * Two locations refer to different workspaces and the
531 // * operation requires that they be in the same workspace.
532 // */
533 // @Deprecated
534 // MUST_BE_SAME_WORKSPACE(ReasonCode.CONFLICT),
535 //
536 /** The name supplied for a new resource is invalid */
537 NAME_MUST_BE_VALID(ReasonCode.CONFLICT),
538
539 /** Resource needs to be merged from latest version **/
540 NEEDS_MERGE_FROM_LATEST(ReasonCode.CONFLICT),
541
542 /** For use when StpException is just a wrapper for a WvcmException */
543 NONE(ReasonCode.CONFLICT),
544
545 /**
546 * A duplicate record is specified but the action is not a duplicate
547 * action.
548 */
549 NOT_DUPLICATE_ACTION(ReasonCode.CONFLICT),
550
551 // /** object not found error **/
552 // @Deprecated
553 // OBJECT_NOT_FOUND_ERROR(ReasonCode.CONFLICT),
554 //
555 /** A parameter mismatch was detected in a response */
556 PARAMETER_MISMATCH(ReasonCode.CONFLICT),
557
558 // /** The parent resource is not under version control but needs to be */
559 // @Deprecated
560 // PARENT_MUST_BE_VERSION_CONTROLLED(ReasonCode.CONFLICT),
561 //
562 /** The parent of a targeted resource needs to exist, but doesn't */
563 PARENT_MUST_EXIST(ReasonCode.CONFLICT),
564
565 /**
566 * This exception is reporting failure in an operation that was applied
567 * independently to multiple resources and failed on some of them.
568 *
569 * @see StpPartialResultsException
570 */
571 PARTIAL_RESULTS(ReasonCode.CONFLICT),
572
573 /** Used when delivering change contexts */
574 PRIOR_COMMIT_FAILURE(ReasonCode.CONFLICT),
575
576 /**
577 * Some other property error such as
578 * <ul>
579 * <li>Can't update value because it is inappropriate for property.
580 * <li>Can't update value because of server-specific restriction such
581 * as length of string or list.
582 * <li>
583 * </ul>
584 */
585 PROPERTY_ERROR(ReasonCode.CONFLICT),
586
587 /**
588 * An exception with this StpReasonCode is thrown by the execution of
589 * any property "getter" method when the targeted property could not be
590 * retrieved from the server. Exceptions of this type wrap the exception
591 * generated by the server, which is accessible via the getCause() or
592 * {@link javax.wvcm.WvcmException#getNestedExceptions()} methods of
593 * this wrapping exception.
594 * <p>
595 * The traceback for the outer, PROPERTY_RETRIEVAL_FAILED exception will
596 * identify the context in which the attempt was made to get the
597 * property value from the proxy, while the traceback for the cause of
598 * that exception will identify the context in which the attempt was
599 * made to read the value into the proxy.
600 */
601 PROPERTY_RETRIEVAL_FAILED(ReasonCode.CONFLICT),
602
603 /**
604 * Thrown by CreateRecord when an attempt is made to create a record with
605 * the same name as one that already exists on the server.
606 */
607 RECORD_WITH_SAME_DISPLAYNAME_EXISTS(ReasonCode.CONFLICT),
608
609 /** Request failed error **/
610 REQUEST_FAILED_ERROR(ReasonCode.CONFLICT),
611
612 // /** Errors were encountered during ResourceLocation deserialization */
613 // @Deprecated
614 // RESOURCE_LOCATION_DESERIALIZE(ReasonCode.CONFLICT),
615 //
616 // /**
617 // * Thrown when the location for a resource in a creation method is not
618 // * valid.
619 // */
620 // @Deprecated
621 // RESOURCE_LOCATION_OK(ReasonCode.CONFLICT),
622 //
623 // /** A typecast attempt on a Resource failed */
624 // @Deprecated
625 // RESOURCE_TYPE_CAST(ReasonCode.CONFLICT),
626 // /*
627 // * Note: the WebDAV protocol requires distinct error codes for CHECKIN
628 // * and UNCHECKOUT, in the case where the method is applied to a
629 // * non-checked-out resource. Since WVCM defines a single reason code for
630 // * both cases, this class defines two different reason codes that both
631 // * map to the same WVCM reason code, but different XML tags.
632 // *
633 // * BIGGER NOTE: regarding why the following are now mapping to
634 // * ReasonCode.CONFLICT and why they can't map to
635 // * ReasonCode.MUST_BE_CHECKED_OUT (note using CONFLICT causes API level
636 // * regression test failures -- sigh)...
637 // *
638 // * John says: I think the problem was with
639 // * PropInfo.initWvcmMappingTables(). It creates the association between
640 // * XmlTags and WvcmException.ReasonCode. But it also looks for a mapping
641 // * from a WVCM reason code to an STP reason code, and if there is one,
642 // * also links the XmlTag to the STP reason code. So if two different STP
643 // * reason codes map to the same WVCM reason code (which has a tag
644 // * mapping), then the last one entered into the map wins, and that one
645 // * will then get mapped to a possibly different XML tag then the one it
646 // * is supposed to be mapped to. (Or an exception will get thrown when
647 // * the map initializer code finds a conflicting mapping). He intends to
648 // * rewrite the tag mapping stuff once things settle down getting EUCM
649 // * working in this merged Baltic / SelfHosting code.
650 // */
651 // /** A general runtime error occurred */
652 // @Deprecated
653 // RUNTIME(ReasonCode.CONFLICT),
654 //
655 // /** Used by the SelectionErrorException subclass */
656 // @Deprecated
657 // SELECTION_ERROR(ReasonCode.CONFLICT),
658 //
659 /**
660 * The provider has detected something inappropriate with a server's
661 * response. It could be the result of a bug in the server's response or
662 * a bug in the provider's processing of the response.
663 *
664 * @see #INTERNAL_SERVER_ERROR
665 */
666 SERVER_ERROR(ReasonCode.CONFLICT),
667
668 /** View update cancel failed **/
669 SYNC_CANCEL_FAILED(ReasonCode.CONFLICT),
670
671 /**
672 * View's config spec is not synchronized with stream's configuration.
673 * An update view operation is required.
674 */
675 VIEW_OUT_OF_SYNC_WITH_STREAM(ReasonCode.CONFLICT),
676
677 // /**
678 // * This code indicates that the client location (file area) for a
679 // * client-side workspace is not defined or unavailable.
680 // */
681 // @Deprecated
682 // WORKSPACE_CLIENT_LOCATION_UNDEFINED(ReasonCode.CONFLICT),
683 //
684 // /** The precondition of "workspace location OK" was not met */
685 // @Deprecated
686 // WORKSPACE_LOCATION_OK(ReasonCode.CONFLICT),
687 //
688 // /**
689 // * <code>Precondition:</code> This folder already has a project
690 // * configuration.
691 // */
692 // @Deprecated
693 // CONTROLLED_CONFIGURATION_ALREADY_EXISTS,
694 //
695 // /** Cannot create location cycle. */
696 // @Deprecated
697 // CYCLE_NOT_ALLOWED,
698 //
699 /**
700 * The provider was unable to complete the operation for an unspecified
701 * reason.
702 */
703 FORBIDDEN,
704
705 /** Request not understood or contextually incorrect for the provider. */
706 BAD_REQUEST(ReasonCode.FORBIDDEN),
707
708 // /**
709 // * <code>Precondition:</code> The operation failed because the server
710 // * does not allow compare/merge of baselines from different baseline
711 // * histories.
712 // */
713 // @Deprecated
714 // BASELINES_FROM_SAME_HISTORY(ReasonCode.FORBIDDEN),
715 //
716 /** Used by REVERT method */
717 CHILD_ORIGINAL_SOURCE_DIRECTORY_NO_LONGER_EXISTS(ReasonCode.FORBIDDEN),
718
719 /** Used by REVERT method */
720 CHILDREN_OF_FOLDER_MUST_BE_REVERTED_FIRST(ReasonCode.FORBIDDEN),
721
722 /**
723 * Used when an operation is forbidden due to operating in disconnected
724 * mode
725 */
726 DISCONNECTED(ReasonCode.FORBIDDEN),
727
728 /** Used when trying to delete query folders */
729 FOLDER_HAS_CHILDREN(ReasonCode.FORBIDDEN),
730
731 /** An illegal argument was specified */
732 ILLEGAL_ARG(ReasonCode.FORBIDDEN),
733
734 /** The request or operation in not valid */
735 INVALID(ReasonCode.FORBIDDEN),
736
737 /**
738 * Thrown by OpenRecord when a duplicate record is not specified with a
739 * duplicate action.
740 */
741 NO_DUPLICATE_RECORD(ReasonCode.FORBIDDEN),
742
743 /** Request not allowed by the provider. */
744 NOT_ALLOWED(ReasonCode.FORBIDDEN),
745
746 /** The request or operation is not supported */
747 NOT_SUPPORTED(ReasonCode.FORBIDDEN),
748
749 // /**
750 // * <code>Precondition:</code> Cannot checkin the project configuration
751 // * because more than one member exists for a given version history.
752 // */
753 // @Deprecated
754 // ONE_VERSION_PER_HISTORY_PER_BASELINE(ReasonCode.FORBIDDEN),
755 //
756 /** The submit request is not allowed */
757 SUBMIT_NOT_ALLOWED(ReasonCode.FORBIDDEN),
758
759 /**
760 * Thrown by OpenRecord when the specified action is not defined for the
761 * record type.
762 */
763 UNKNOWN_ACTION(ReasonCode.FORBIDDEN),
764
765 /**
766 * Thrown when a report has been requested on resource that does not
767 * support that report type.
768 */
769 UNSUPPORTED_REPORT(ReasonCode.FORBIDDEN),
770
771 /** Illegal syntax for location string value. */
772 ILLEGAL_LOCATION_SYNTAX,
773
774 // /**
775 // * Report failed since the resource does not support the specified
776 // * report.
777 // */
778 // @Deprecated
779 // METHOD_NOT_SUPPORTED,
780 //
781 /**
782 * <code>Precondition:</code> Report failed since the resource does
783 * not support the specified report.
784 */
785 BAD_REPORT(ReasonCode.METHOD_NOT_SUPPORTED),
786
787 // ////////////////////////////////////////////////////////////////
788 // These are all from the original ServerConflictException.java,
789 // and each had a "CTG_" prefix, which has been removed here.
790 // ////////////////////////////////////////////////////////////////
791
792 // /**
793 // * <code>Precondition:</code> Failed because the resource specified is
794 // * a folder version.
795 // */
796 // @Deprecated
797 // CANNOT_COPY_FOLDER_VERSION(ReasonCode.METHOD_NOT_SUPPORTED),
798 //
799 // /**
800 // * <code>Precondition:</code> Copy failed because you cannot copy a
801 // * history resource.
802 // */
803 // @Deprecated
804 // CANNOT_COPY_HISTORY(ReasonCode.METHOD_NOT_SUPPORTED),
805 //
806 // /**
807 // * <code>Precondition:</code> Delete failed because you cannot delete
808 // * a version.
809 // */
810 // @Deprecated
811 // CANNOT_DELETE_VERSION(ReasonCode.METHOD_NOT_SUPPORTED),
812 //
813 // /** <code>Precondition:</code> A version history cannot be renamed. */
814 // @Deprecated
815 // CANNOT_RENAME_HISTORY(ReasonCode.METHOD_NOT_SUPPORTED),
816 //
817 // /** <code>Precondition:</code> A version resource cannot be renamed. */
818 // @Deprecated
819 // CANNOT_RENAME_VERSION(ReasonCode.METHOD_NOT_SUPPORTED),
820 //
821 // /** Cannot create multiple bindings to one resource. */
822 // @Deprecated
823 // MULTIPLE_BINDINGS_NOT_ALLOWED(ReasonCode.METHOD_NOT_SUPPORTED),
824 //
825 /** The resource has no content. */
826 NO_CONTENT(ReasonCode.METHOD_NOT_SUPPORTED),
827
828
829 // /**
830 // * Method failed on some of the specified resources.
831 // */
832 // @Deprecated
833 // MULTI_STATUS,
834 //
835 // /**
836 // * <code>Precondition:</code> Activity cannot be checked-in because
837 // * checkin of all referenced resources failed.
838 // */
839 // @Deprecated
840 // CANNOT_CHECKIN_ALL_RESOURCES(ReasonCode.MULTI_STATUS),
841 //
842 // /**
843 // * <code>Precondition:</code> The operation failed because the
844 // * resource must be in the checked-in state.
845 // */
846 // @Deprecated
847 // MUST_BE_CHECKED_IN,
848 //
849 // /**
850 // * STP Reason codes to support Legacy CCRC server
851 // */
852 //
853 // /**
854 // * The operation failed because the resource must be in the checked-out
855 // * state.
856 // */
857 // @Deprecated
858 // MUST_BE_CHECKED_OUT,
859 //
860 // /**
861 // * <code>Precondition:</code> Failed to checkin the project
862 // * configuration because some of it's members are still checked-out.
863 // */
864 // @Deprecated
865 // NO_CHECKED_OUT_BASELINE_CONTROLLED_FOLDER_MEMBERS,
866 //
867 // /** Cannot create cross-server binding. */
868 // @Deprecated
869 // NO_CROSS_SERVER_BINDING,
870 //
871 /**
872 * The corresponding remote resource no longer exists or was never
873 * created.
874 */
875 NOT_FOUND,
876
877 // /**
878 // * <code>Precondition:</code> Failed because more than one version of
879 // * this resource is referenced in the specified activity.
880 // */
881 // @Deprecated
882 // ONE_CHECKOUT_PER_ACTIVITY_PER_HISTORY,
883 //
884 // /**
885 // * <code>Precondition:</code> The operation failed because it would
886 // * result in more than one controlled resource for this version history
887 // * in a workspace.
888 // */
889 // @Deprecated
890 // ONE_CONTROLLED_RESOURCE_PER_HISTORY_PER_WORKSPACE,
891 //
892 /**
893 * <code>Precondition:</code> Failed to retrieve a property that
894 * should be supported. A potentially recoverable condition prevented
895 * the server from retrieving the property value.
896 */
897 PROPERTY_NOT_CURRENTLY_AVAILABLE,
898
899 /**
900 * The requested property value is unavailable because it is not valid
901 * for the targeted resource--the property name used is not defined in
902 * the targeted resource's interface nor is it included in the
903 * PropertyRequest returned by
904 * {@link javax.wvcm.Resource#doGetPropertyNameList(Feedback)} for the
905 * resource.
906 */
907 PROPERTY_NOT_DEFINED_FOR_RESOURCE,
908
909 /**
910 * The property value is maintained only on the server and so is not
911 * available locally
912 */
913 PROPERTY_NOT_AVAILABLE_LOCALLY(ReasonCode.PROPERTY_NOT_DEFINED_FOR_RESOURCE),
914
915 /**
916 * The property value is unavailable because it was not in the property
917 * name list when the proxy was created nor has it subsequently been
918 * added via {@link Resource#setProperty} or one of the other property
919 * setters.
920 */
921 PROPERTY_NOT_REQUESTED,
922
923 /**
924 * Even though this API says the property is valid for the targeted
925 * resource, the server does not support it. For properties the server
926 * intends to support in the release under development, the exception
927 * message should say “NOT YET IMPLEMENTED”.
928 */
929 PROPERTY_NOT_SUPPORTED_BY_SERVER,
930
931 /** The property value update would overwrite an earlier change. */
932 PROPERTY_OVERWRITE_FORBIDDEN,
933
934 /** The provider suffered an I/O failure, the operation may be retried. */
935 READ_FAILED,
936
937 /**
938 * <code>Precondition:</code> Creating a resource failed because a
939 * resource already exists at the specified location.
940 */
941 RESOURCE_ALREADY_EXISTS_AT_LOCATION,
942
943 /** View update was canceled **/
944 SYNC_CANCELLED (ReasonCode.CONFLICT),
945
946 /** The user is not authorized to execute the attempted operation. */
947 UNAUTHORIZED,
948
949 /** Login on server failed**/
950 LOGIN_FAILED(ReasonCode.UNAUTHORIZED),
951
952 // /**
953 // * The referenced record exists but is hidden from the accessing user.
954 // */
955 // @Deprecated
956 // RECORD_NOT_VISIBLE(ReasonCode.UNAUTHORIZED),
957 //
958 // /**
959 // * <code>Precondition:</code> Cannot checkin because the resources
960 // * predecessors are not descendents of the root of the version history.
961 // */
962 // @Deprecated
963 // VERSION_HISTORY_MUST_BE_A_TREE,
964 //
965 /** The provider suffered an I/O failure, the operation may be retried. */
966 WRITE_FAILED,
967
968 /**
969 * Session does not exist or the session has expired.
970 */
971 SESSION_EXPIRED_OR_DOES_NOT_EXIST(ReasonCode.UNAUTHORIZED),
972
973 /**
974 * Used if an operation requires credentials but none were provided
975 */
976 CREDENTIALS_REQUIRED(ReasonCode.UNAUTHORIZED),
977
978 /**
979 * Used when the server capacity has been reached.
980 */
981 SERVER_BUSY(ReasonCode.CONFLICT),
982
983 /**
984 * Used when the client is not compatible with the server. (This may
985 * be caused by a client that is too old, or too new.)
986 */
987 INCOMPATIBLE_SERVER(ReasonCode.VERSION_NOT_SUPPORTED),
988
989 ;
990 /* end of enum StpReasonCode */;
991
992 // ====================================================================
993
994 /**
995 * Returns the WVCM base reason code associated with this STP reason
996 * code.
997 *
998 * @return The WVCM reason code associated with this STP reason code.
999 */
1000 public ReasonCode getWvcmReasonCode()
1001 {
1002 return m_wvcmReasonCode;
1003 }
1004
1005 /*
1006 * A string representation of this reason code.
1007 */
1008 public String toString()
1009 {
1010 return name().toLowerCase().replaceAll("_", "-");
1011 }
1012
1013 /**
1014 * Constructs an StpReasonCode that is semantically equivalent to the
1015 * WVCM ReasonCode of the same name.
1016 */
1017 private StpReasonCode()
1018 {
1019 m_wvcmReasonCode = ReasonCode.valueOf(ReasonCode.class, name());
1020 }
1021
1022 /**
1023 * Constructs an StpReasonCode as a refinement of a WVCM base
1024 * ReasonCode.
1025 *
1026 * @param wvcmBaseCode The WVCM reason code that this StpReasonCode
1027 * refines. Cannot be <code>null</code>.
1028 */
1029 private StpReasonCode(ReasonCode wvcmBaseCode)
1030 {
1031 m_wvcmReasonCode = wvcmBaseCode;
1032 }
1033
1034 /**
1035 * The WVCM reason code classification for this SubReasonCode.
1036 */
1037 private final ReasonCode m_wvcmReasonCode;
1038 }
1039
1040 /**
1041 * Casts an Object to a Type, avoiding a type safety warning. Use sparingly.
1042 * May throw ClassCastException at runtime. Some Java compilers can deduce
1043 * U from context, such as in an assignment or a return statement; however,
1044 * others may not. It is suggested, therefore, that all uses of this method
1045 * should include the target type explicitly.
1046 * <pre>
1047 * StpException.<desired-type>unchecked_cast(x)
1048 * </pre>
1049 * The ugliness of this construct matches the sledge hammer that is being
1050 * used to make the code compile without warnings.
1051 *
1052 * @param <U> The Type to which the object should be cast
1053 * @param obj The Object to be cast
1054 * @return The argument Object cast to Type U.
1055 */
1056 @SuppressWarnings("unchecked")
1057 public static <U> U unchecked_cast(Object obj)
1058 {
1059 return (U)obj;
1060 }
1061
1062 /**
1063 * @return Returns an implementation object that stores the fields of this
1064 * exception not defined by WvcmException and implements the other
1065 * methods of this exception. Will never be <b>null</b>.
1066 */
1067 public abstract Data data();
1068
1069 /**
1070 * Localizes the message contained within this exception and returns it.
1071 */
1072 public String getMessage() { return data().getMessage(); }
1073
1074 /**
1075 * @return The StpReasonCode assigned to this exception.
1076 */
1077 public StpReasonCode getStpReasonCode()
1078 { return data().getStpReasonCode(); }
1079
1080 /**
1081 * @return A String image of this StpException and any nested Exceptions
1082 */
1083 public String toString() { return data().toString(); }
1084
1085 /**
1086 * Constructs this exception object for its subclasses.
1087 *
1088 * @param resource The Resource argument to WvcmException
1089 * @param reasonCode The ReasonCode argument to WvcmException
1090 * @param nestedExceptions The Throwable[] argument to WvcmException
1091 *
1092 * @see javax.wvcm.WvcmException
1093 */
1094 protected StpException(Resource resource,
1095 ReasonCode reasonCode,
1096 Throwable... nestedExceptions)
1097 {
1098 super(null, resource, reasonCode, nestedExceptions);
1099 }
1100 }