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, 2008. 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 /** Version being checked out is not the latest **/ 317 CHECKOUT_NOT_LATEST(ReasonCode.CONFLICT), 318 319 // /** 320 // * Thrown when a referenced project checkpoint is not the latest. 321 // */ 322 // @Deprecated 323 // CHECKPOINT_MUST_BE_LATEST(ReasonCode.CONFLICT), 324 // 325 /** The client location is not within a file area */ 326 CLIENT_LOCATION_NOT_IN_FILE_AREA(ReasonCode.CONFLICT), 327 328 /** A communication precondition failed */ 329 CONDITIONAL_EXECUTION(ReasonCode.CONFLICT), 330 331 // /** 332 // * Failed to write a property that should be writable. A potentially 333 // * recoverable condition prevented the server from writing the property 334 // * value. 335 // */ 336 // @Deprecated 337 // PROPERTY_NOT_CURRENTLY_WRITABLE(ReasonCode.CONFLICT), 338 // 339 /** 340 * An operation failed because the connection to the remote server could 341 * not be established or terminated prematurely after being established. 342 */ 343 CONNECTION_FAILED(ReasonCode.CONFLICT), 344 345 // /** 346 // * An activity, specified to be made current to a workspace, is not in 347 // * that workspace's accepted set. 348 // */ 349 // @Deprecated 350 // CURRENT_ACTIVITY_MUST_BE_ACCEPTED(ReasonCode.CONFLICT), 351 // 352 /** 353 * An attempt to deliver a resource from the change context to the 354 * database failed. 355 */ 356 DELIVERY_ERROR(ReasonCode.CONFLICT), 357 358 /** Version discordance detected **/ 359 DISCORDANCE_VERSION(ReasonCode.CONFLICT), 360 361 /** Duplicate activity name **/ 362 DUPLICATE_ACTIVITY_NAME(ReasonCode.CONFLICT), 363 364 /** Duplicate stream name **/ 365 DUPLICATE_STREAM_NAME(ReasonCode.CONFLICT), 366 367 /** 368 * This code indicates that an external lock couldn't be acquired 369 * because the lock already exists. 370 */ 371 EXTERNAL_LOCK_ALREADY_PRESENT(ReasonCode.CONFLICT), 372 373 /** 374 * Some dependency required by the communication channel failed. 375 */ 376 FAILED_DEPENDENCY(ReasonCode.CONFLICT), 377 378 /** 379 * A field did not pass validation during an attempted delivery. 380 */ 381 FIELD_VALIDATION(ReasonCode.CONFLICT), 382 383 /** 384 * The client resource resides in a file area whose version is not 385 * compatible with the currently running software. The file area needs 386 * to be upgraded in order to work with this software. 387 */ 388 FILE_AREA_NEEDS_UPGRADE(ReasonCode.CONFLICT), 389 390 /** A file error was encountered */ 391 FILE_ERROR(ReasonCode.CONFLICT), 392 393 // /** 394 // * This code indicates that the server URL stored in the file area 395 // * doesn't match the server URL of the current Provider. E.g., the two 396 // * URLs could differ in the hostname (consider that UCM2 server was 397 // * restored / relocated to another server), web server port identifier, 398 // * general change in the segment names leading up to the UCM2 namespace 399 // * root, ... 400 // */ 401 // @Deprecated 402 // FILEAREA_SERVER_MISMATCH(ReasonCode.CONFLICT), 403 // 404 // /** 405 // * Another process already has a write lock on the file area database. 406 // * This code should only be present for a FileAreaWriteLockException. 407 // */ 408 // @Deprecated 409 // FILEAREA_WRITE_LOCKED_EXTERNAL(ReasonCode.CONFLICT), 410 // 411 // /** 412 // * Another thread in the process already has a write lock on the file 413 // * area database. 414 // */ 415 // @Deprecated 416 // FILEAREA_WRITE_LOCKED_INTERNAL(ReasonCode.CONFLICT), 417 // 418 // /** The resource is currently a hijacked checkout */ 419 // @Deprecated 420 // HIJACKED_CHECKOUT(ReasonCode.CONFLICT), 421 // 422 /** 423 * While firing a named ClearQuest hook, the hook returned a message, 424 * which generally represents an error or need for additional 425 * information 426 */ 427 HOOK_RETURNED_MESSAGE(ReasonCode.CONFLICT), 428 429 // /** A runtime error occurred in the HTTP subsystem */ 430 // @Deprecated 431 // HTTP_RUNTIME(ReasonCode.CONFLICT), 432 // 433 // /** The HTTP subsystem state is not proper for the request */ 434 // @Deprecated 435 // HTTP_STATE(ReasonCode.CONFLICT), 436 // 437 /** 438 * An in-line query definition during query execution 439 */ 440 ILLEGAL_QUERY(ReasonCode.CONFLICT), 441 442 /** 443 * The client resource resides in a file area whose version is not 444 * compatible with the currently running software. The software needs to 445 * be upgraded to handle this file area. 446 */ 447 INCOMPATIBLE_FILE_AREA_VERSION(ReasonCode.CONFLICT), 448 449 /** Insufficient permission for the requested operation */ 450 INSUFFICIENT_PERMISSION(ReasonCode.CONFLICT), 451 452 /** An interaction request has occurred */ 453 INTERACTION_REQUEST(ReasonCode.CONFLICT), 454 455 /** An internal error has occurred */ 456 INTERNAL_ERROR(ReasonCode.CONFLICT), 457 458 /** 459 * The provider's server encountered an unexpected internal error 460 * condition which prevented it from fulfilling the request. This 461 * loosely corresponds to an HTTP 500 Internal Server Error response 462 * from the server. 463 * 464 * @see #SERVER_ERROR 465 */ 466 INTERNAL_SERVER_ERROR(ReasonCode.CONFLICT), 467 468 /** 469 * A required field is missing from or malformed in an StpLocation 470 * specification. 471 */ 472 INVALID_OBJECT_SELECTOR(ReasonCode.CONFLICT), 473 474 /** An invalid response was received */ 475 INVALID_RESPONSE(ReasonCode.CONFLICT), 476 477 /** 478 * Completion of operation was prevented because one or more properties 479 * have invalid values 480 */ 481 INVALID_VALUES(ReasonCode.CONFLICT), 482 483 /** License error occurred **/ 484 LICENSE_ERROR(ReasonCode.CONFLICT), 485 486 // /** 487 // * An operation attempted to create a conflict in the copy based file 488 // * area's loaded scope set. 489 // * 490 // * E.g., an operation (such as checkout, create or load) attempted to 491 // * add an include-scope for an item that is a child of an exclude-scope 492 // * specification. 493 // */ 494 // @Deprecated 495 // LOADED_SCOPES_CONFLICT(ReasonCode.CONFLICT), 496 // 497 /** The database to be affected is currently locked */ 498 LOCKED_DATABASE(ReasonCode.CONFLICT), 499 500 // /** 501 // * Maximum logon attempts exceeded. 502 // */ 503 // @Deprecated 504 // MAX_LOGON_ATTEMPTS_EXCEEDED(ReasonCode.CONFLICT), 505 // 506 // /** The destination associated with the request is missing */ 507 // @Deprecated 508 // MISSING_DESTINATION(ReasonCode.CONFLICT), 509 // 510 // /** 511 // * A supplied location, which must be a client location, is not a client 512 // * location. 513 // */ 514 // @Deprecated 515 // MUST_BE_CLIENT_LOCATION(ReasonCode.CONFLICT), 516 // 517 // /** 518 // * Checkin with identical data not allowed and identical data was 519 // * provided. 520 // */ 521 // @Deprecated 522 // MUST_BE_DIFFERENT(ReasonCode.CONFLICT), 523 // 524 // /** 525 // * Two locations refer to different workspaces and the 526 // * operation requires that they be in the same workspace. 527 // */ 528 // @Deprecated 529 // MUST_BE_SAME_WORKSPACE(ReasonCode.CONFLICT), 530 // 531 /** The name supplied for a new resource is invalid */ 532 NAME_MUST_BE_VALID(ReasonCode.CONFLICT), 533 534 /** Resource needs to be merged from latest version **/ 535 NEEDS_MERGE_FROM_LATEST(ReasonCode.CONFLICT), 536 537 /** For use when StpException is just a wrapper for a WvcmException */ 538 NONE(ReasonCode.CONFLICT), 539 540 /** 541 * A duplicate record is specified but the action is not a duplicate 542 * action. 543 */ 544 NOT_DUPLICATE_ACTION(ReasonCode.CONFLICT), 545 546 // /** object not found error **/ 547 // @Deprecated 548 // OBJECT_NOT_FOUND_ERROR(ReasonCode.CONFLICT), 549 // 550 /** A parameter mismatch was detected in a response */ 551 PARAMETER_MISMATCH(ReasonCode.CONFLICT), 552 553 // /** The parent resource is not under version control but needs to be */ 554 // @Deprecated 555 // PARENT_MUST_BE_VERSION_CONTROLLED(ReasonCode.CONFLICT), 556 // 557 /** The parent of a targeted resource needs to exist, but doesn't */ 558 PARENT_MUST_EXIST(ReasonCode.CONFLICT), 559 560 /** 561 * This exception is reporting failure in an operation that was applied 562 * independently to multiple resources and failed on some of them. 563 * 564 * @see StpPartialResultsException 565 */ 566 PARTIAL_RESULTS(ReasonCode.CONFLICT), 567 568 /** Used when delivering change contexts */ 569 PRIOR_COMMIT_FAILURE(ReasonCode.CONFLICT), 570 571 /** 572 * Some other property error such as 573 * <ul> 574 * <li>Can't update value because it is inappropriate for property. 575 * <li>Can't update value because of server-specific restriction such 576 * as length of string or list. 577 * <li> 578 * </ul> 579 */ 580 PROPERTY_ERROR(ReasonCode.CONFLICT), 581 582 /** 583 * An exception with this StpReasonCode is thrown by the execution of 584 * any property "getter" method when the targeted property could not be 585 * retrieved from the server. Exceptions of this type wrap the exception 586 * generated by the server, which is accessible via the getCause() or 587 * {@link javax.wvcm.WvcmException#getNestedExceptions()} methods of 588 * this wrapping exception. 589 * <p> 590 * The traceback for the outer, PROPERTY_RETRIEVAL_FAILED exception will 591 * identify the context in which the attempt was made to get the 592 * property value from the proxy, while the traceback for the cause of 593 * that exception will identify the context in which the attempt was 594 * made to read the value into the proxy. 595 */ 596 PROPERTY_RETRIEVAL_FAILED(ReasonCode.CONFLICT), 597 598 /** 599 * Thrown by CreateRecord when an attempt is made to create a record with 600 * the same name as one that already exists on the server. 601 */ 602 RECORD_WITH_SAME_DISPLAYNAME_EXISTS(ReasonCode.CONFLICT), 603 604 /** Request failed error **/ 605 REQUEST_FAILED_ERROR(ReasonCode.CONFLICT), 606 607 // /** Errors were encountered during ResourceLocation deserialization */ 608 // @Deprecated 609 // RESOURCE_LOCATION_DESERIALIZE(ReasonCode.CONFLICT), 610 // 611 // /** 612 // * Thrown when the location for a resource in a creation method is not 613 // * valid. 614 // */ 615 // @Deprecated 616 // RESOURCE_LOCATION_OK(ReasonCode.CONFLICT), 617 // 618 // /** A typecast attempt on a Resource failed */ 619 // @Deprecated 620 // RESOURCE_TYPE_CAST(ReasonCode.CONFLICT), 621 // /* 622 // * Note: the WebDAV protocol requires distinct error codes for CHECKIN 623 // * and UNCHECKOUT, in the case where the method is applied to a 624 // * non-checked-out resource. Since WVCM defines a single reason code for 625 // * both cases, this class defines two different reason codes that both 626 // * map to the same WVCM reason code, but different XML tags. 627 // * 628 // * BIGGER NOTE: regarding why the following are now mapping to 629 // * ReasonCode.CONFLICT and why they can't map to 630 // * ReasonCode.MUST_BE_CHECKED_OUT (note using CONFLICT causes API level 631 // * regression test failures -- sigh)... 632 // * 633 // * John says: I think the problem was with 634 // * PropInfo.initWvcmMappingTables(). It creates the association between 635 // * XmlTags and WvcmException.ReasonCode. But it also looks for a mapping 636 // * from a WVCM reason code to an STP reason code, and if there is one, 637 // * also links the XmlTag to the STP reason code. So if two different STP 638 // * reason codes map to the same WVCM reason code (which has a tag 639 // * mapping), then the last one entered into the map wins, and that one 640 // * will then get mapped to a possibly different XML tag then the one it 641 // * is supposed to be mapped to. (Or an exception will get thrown when 642 // * the map initializer code finds a conflicting mapping). He intends to 643 // * rewrite the tag mapping stuff once things settle down getting EUCM 644 // * working in this merged Baltic / SelfHosting code. 645 // */ 646 // /** A general runtime error occurred */ 647 // @Deprecated 648 // RUNTIME(ReasonCode.CONFLICT), 649 // 650 // /** Used by the SelectionErrorException subclass */ 651 // @Deprecated 652 // SELECTION_ERROR(ReasonCode.CONFLICT), 653 // 654 /** 655 * The provider has detected something inappropriate with a server's 656 * response. It could be the result of a bug in the server's response or 657 * a bug in the provider's processing of the response. 658 * 659 * @see #INTERNAL_SERVER_ERROR 660 */ 661 SERVER_ERROR(ReasonCode.CONFLICT), 662 663 /** View update cancel failed **/ 664 SYNC_CANCEL_FAILED(ReasonCode.CONFLICT), 665 666 /** 667 * View's config spec is not synchronized with stream's configuration. 668 * An update view operation is required. 669 */ 670 VIEW_OUT_OF_SYNC_WITH_STREAM(ReasonCode.CONFLICT), 671 672 // /** 673 // * This code indicates that the client location (file area) for a 674 // * client-side workspace is not defined or unavailable. 675 // */ 676 // @Deprecated 677 // WORKSPACE_CLIENT_LOCATION_UNDEFINED(ReasonCode.CONFLICT), 678 // 679 // /** The precondition of "workspace location OK" was not met */ 680 // @Deprecated 681 // WORKSPACE_LOCATION_OK(ReasonCode.CONFLICT), 682 // 683 // /** 684 // * <code>Precondition:</code> This folder already has a project 685 // * configuration. 686 // */ 687 // @Deprecated 688 // CONTROLLED_CONFIGURATION_ALREADY_EXISTS, 689 // 690 // /** Cannot create location cycle. */ 691 // @Deprecated 692 // CYCLE_NOT_ALLOWED, 693 // 694 /** 695 * The provider was unable to complete the operation for an unspecified 696 * reason. 697 */ 698 FORBIDDEN, 699 700 /** Request not understood or contextually incorrect for the provider. */ 701 BAD_REQUEST(ReasonCode.FORBIDDEN), 702 703 // /** 704 // * <code>Precondition:</code> The operation failed because the server 705 // * does not allow compare/merge of baselines from different baseline 706 // * histories. 707 // */ 708 // @Deprecated 709 // BASELINES_FROM_SAME_HISTORY(ReasonCode.FORBIDDEN), 710 // 711 /** Used by REVERT method */ 712 CHILD_ORIGINAL_SOURCE_DIRECTORY_NO_LONGER_EXISTS(ReasonCode.FORBIDDEN), 713 714 /** Used by REVERT method */ 715 CHILDREN_OF_FOLDER_MUST_BE_REVERTED_FIRST(ReasonCode.FORBIDDEN), 716 717 /** 718 * Used when an operation is forbidden due to operating in disconnected 719 * mode 720 */ 721 DISCONNECTED(ReasonCode.FORBIDDEN), 722 723 /** Used when trying to delete query folders */ 724 FOLDER_HAS_CHILDREN(ReasonCode.FORBIDDEN), 725 726 /** An illegal argument was specified */ 727 ILLEGAL_ARG(ReasonCode.FORBIDDEN), 728 729 /** The request or operation in not valid */ 730 INVALID(ReasonCode.FORBIDDEN), 731 732 /** 733 * Thrown by OpenRecord when a duplicate record is not specified with a 734 * duplicate action. 735 */ 736 NO_DUPLICATE_RECORD(ReasonCode.FORBIDDEN), 737 738 /** Request not allowed by the provider. */ 739 NOT_ALLOWED(ReasonCode.FORBIDDEN), 740 741 /** The request or operation is not supported */ 742 NOT_SUPPORTED(ReasonCode.FORBIDDEN), 743 744 // /** 745 // * <code>Precondition:</code> Cannot checkin the project configuration 746 // * because more than one member exists for a given version history. 747 // */ 748 // @Deprecated 749 // ONE_VERSION_PER_HISTORY_PER_BASELINE(ReasonCode.FORBIDDEN), 750 // 751 /** The submit request is not allowed */ 752 SUBMIT_NOT_ALLOWED(ReasonCode.FORBIDDEN), 753 754 /** 755 * Thrown by OpenRecord when the specified action is not defined for the 756 * record type. 757 */ 758 UNKNOWN_ACTION(ReasonCode.FORBIDDEN), 759 760 /** 761 * Thrown when a report has been requested on resource that does not 762 * support that report type. 763 */ 764 UNSUPPORTED_REPORT(ReasonCode.FORBIDDEN), 765 766 /** Illegal syntax for location string value. */ 767 ILLEGAL_LOCATION_SYNTAX, 768 769 // /** 770 // * Report failed since the resource does not support the specified 771 // * report. 772 // */ 773 // @Deprecated 774 // METHOD_NOT_SUPPORTED, 775 // 776 /** 777 * <code>Precondition:</code> Report failed since the resource does 778 * not support the specified report. 779 */ 780 BAD_REPORT(ReasonCode.METHOD_NOT_SUPPORTED), 781 782 // //////////////////////////////////////////////////////////////// 783 // These are all from the original ServerConflictException.java, 784 // and each had a "CTG_" prefix, which has been removed here. 785 // //////////////////////////////////////////////////////////////// 786 787 // /** 788 // * <code>Precondition:</code> Failed because the resource specified is 789 // * a folder version. 790 // */ 791 // @Deprecated 792 // CANNOT_COPY_FOLDER_VERSION(ReasonCode.METHOD_NOT_SUPPORTED), 793 // 794 // /** 795 // * <code>Precondition:</code> Copy failed because you cannot copy a 796 // * history resource. 797 // */ 798 // @Deprecated 799 // CANNOT_COPY_HISTORY(ReasonCode.METHOD_NOT_SUPPORTED), 800 // 801 // /** 802 // * <code>Precondition:</code> Delete failed because you cannot delete 803 // * a version. 804 // */ 805 // @Deprecated 806 // CANNOT_DELETE_VERSION(ReasonCode.METHOD_NOT_SUPPORTED), 807 // 808 // /** <code>Precondition:</code> A version history cannot be renamed. */ 809 // @Deprecated 810 // CANNOT_RENAME_HISTORY(ReasonCode.METHOD_NOT_SUPPORTED), 811 // 812 // /** <code>Precondition:</code> A version resource cannot be renamed. */ 813 // @Deprecated 814 // CANNOT_RENAME_VERSION(ReasonCode.METHOD_NOT_SUPPORTED), 815 // 816 // /** Cannot create multiple bindings to one resource. */ 817 // @Deprecated 818 // MULTIPLE_BINDINGS_NOT_ALLOWED(ReasonCode.METHOD_NOT_SUPPORTED), 819 // 820 /** The resource has no content. */ 821 NO_CONTENT(ReasonCode.METHOD_NOT_SUPPORTED), 822 823 824 // /** 825 // * Method failed on some of the specified resources. 826 // */ 827 // @Deprecated 828 // MULTI_STATUS, 829 // 830 // /** 831 // * <code>Precondition:</code> Activity cannot be checked-in because 832 // * checkin of all referenced resources failed. 833 // */ 834 // @Deprecated 835 // CANNOT_CHECKIN_ALL_RESOURCES(ReasonCode.MULTI_STATUS), 836 // 837 // /** 838 // * <code>Precondition:</code> The operation failed because the 839 // * resource must be in the checked-in state. 840 // */ 841 // @Deprecated 842 // MUST_BE_CHECKED_IN, 843 // 844 // /** 845 // * STP Reason codes to support Legacy CCRC server 846 // */ 847 // 848 // /** 849 // * The operation failed because the resource must be in the checked-out 850 // * state. 851 // */ 852 // @Deprecated 853 // MUST_BE_CHECKED_OUT, 854 // 855 // /** 856 // * <code>Precondition:</code> Failed to checkin the project 857 // * configuration because some of it's members are still checked-out. 858 // */ 859 // @Deprecated 860 // NO_CHECKED_OUT_BASELINE_CONTROLLED_FOLDER_MEMBERS, 861 // 862 // /** Cannot create cross-server binding. */ 863 // @Deprecated 864 // NO_CROSS_SERVER_BINDING, 865 // 866 /** 867 * The corresponding remote resource no longer exists or was never 868 * created. 869 */ 870 NOT_FOUND, 871 872 // /** 873 // * <code>Precondition:</code> Failed because more than one version of 874 // * this resource is referenced in the specified activity. 875 // */ 876 // @Deprecated 877 // ONE_CHECKOUT_PER_ACTIVITY_PER_HISTORY, 878 // 879 // /** 880 // * <code>Precondition:</code> The operation failed because it would 881 // * result in more than one controlled resource for this version history 882 // * in a workspace. 883 // */ 884 // @Deprecated 885 // ONE_CONTROLLED_RESOURCE_PER_HISTORY_PER_WORKSPACE, 886 // 887 /** 888 * <code>Precondition:</code> Failed to retrieve a property that 889 * should be supported. A potentially recoverable condition prevented 890 * the server from retrieving the property value. 891 */ 892 PROPERTY_NOT_CURRENTLY_AVAILABLE, 893 894 /** 895 * The requested property value is unavailable because it is not valid 896 * for the targeted resource--the property name used is not defined in 897 * the targeted resource's interface nor is it included in the 898 * PropertyRequest returned by 899 * {@link javax.wvcm.Resource#doGetPropertyNameList(Feedback)} for the 900 * resource. 901 */ 902 PROPERTY_NOT_DEFINED_FOR_RESOURCE, 903 904 /** 905 * The property value is maintained only on the server and so is not 906 * available locally 907 */ 908 PROPERTY_NOT_AVAILABLE_LOCALLY(ReasonCode.PROPERTY_NOT_DEFINED_FOR_RESOURCE), 909 910 /** 911 * The property value is unavailable because it was not in the property 912 * name list when the proxy was created nor has it subsequently been 913 * added via {@link Resource#setProperty} or one of the other property 914 * setters. 915 */ 916 PROPERTY_NOT_REQUESTED, 917 918 /** 919 * Even though this API says the property is valid for the targeted 920 * resource, the server does not support it. For properties the server 921 * intends to support in the release under development, the exception 922 * message should say “NOT YET IMPLEMENTED”. 923 */ 924 PROPERTY_NOT_SUPPORTED_BY_SERVER, 925 926 /** The property value update would overwrite an earlier change. */ 927 PROPERTY_OVERWRITE_FORBIDDEN, 928 929 /** The provider suffered an I/O failure, the operation may be retried. */ 930 READ_FAILED, 931 932 /** 933 * <code>Precondition:</code> Creating a resource failed because a 934 * resource already exists at the specified location. 935 */ 936 RESOURCE_ALREADY_EXISTS_AT_LOCATION, 937 938 /** View update was canceled **/ 939 SYNC_CANCELLED (ReasonCode.CONFLICT), 940 941 /** The user is not authorized to execute the attempted operation. */ 942 UNAUTHORIZED, 943 944 /** Login on server failed**/ 945 LOGIN_FAILED(ReasonCode.UNAUTHORIZED), 946 947 // /** 948 // * The referenced record exists but is hidden from the accessing user. 949 // */ 950 // @Deprecated 951 // RECORD_NOT_VISIBLE(ReasonCode.UNAUTHORIZED), 952 // 953 // /** 954 // * <code>Precondition:</code> Cannot checkin because the resources 955 // * predecessors are not descendents of the root of the version history. 956 // */ 957 // @Deprecated 958 // VERSION_HISTORY_MUST_BE_A_TREE, 959 // 960 /** The provider suffered an I/O failure, the operation may be retried. */ 961 WRITE_FAILED, 962 963 /** 964 * Session does not exist or the session has expired. 965 */ 966 SESSION_EXPIRED_OR_DOES_NOT_EXIST(ReasonCode.UNAUTHORIZED), 967 968 /** 969 * Used if an operation requires credentials but none were provided 970 */ 971 CREDENTIALS_REQUIRED(ReasonCode.UNAUTHORIZED), 972 973 /** 974 * Used when the server capacity has been reached. 975 */ 976 SERVER_BUSY(ReasonCode.CONFLICT), 977 978 ; 979 /* end of enum StpReasonCode */; 980 981 // ==================================================================== 982 983 /** 984 * Returns the WVCM base reason code associated with this STP reason 985 * code. 986 * 987 * @return The WVCM reason code associated with this STP reason code. 988 */ 989 public ReasonCode getWvcmReasonCode() 990 { 991 return m_wvcmReasonCode; 992 } 993 994 /* 995 * A string representation of this reason code. 996 */ 997 public String toString() 998 { 999 return name().toLowerCase().replaceAll("_", "-"); 1000 } 1001 1002 /** 1003 * Constructs an StpReasonCode that is semantically equivalent to the 1004 * WVCM ReasonCode of the same name. 1005 */ 1006 private StpReasonCode() 1007 { 1008 m_wvcmReasonCode = ReasonCode.valueOf(ReasonCode.class, name()); 1009 } 1010 1011 /** 1012 * Constructs an StpReasonCode as a refinement of a WVCM base 1013 * ReasonCode. 1014 * 1015 * @param wvcmBaseCode The WVCM reason code that this StpReasonCode 1016 * refines. Cannot be <code>null</code>. 1017 */ 1018 private StpReasonCode(ReasonCode wvcmBaseCode) 1019 { 1020 m_wvcmReasonCode = wvcmBaseCode; 1021 } 1022 1023 /** 1024 * The WVCM reason code classification for this SubReasonCode. 1025 */ 1026 private final ReasonCode m_wvcmReasonCode; 1027 } 1028 1029 /** 1030 * Casts an Object to a Type, avoiding a type safety warning. Use sparingly. 1031 * May throw ClassCastException at runtime. Some Java compilers can deduce 1032 * U from context, such as in an assignment or a return statement; however, 1033 * others may not. It is suggested, therefore, that all uses of this method 1034 * should include the target type explicitly. 1035 * <pre> 1036 * StpException.<desired-type>unchecked_cast(x) 1037 * </pre> 1038 * The ugliness of this construct matches the sledge hammer that is being 1039 * used to make the code compile without warnings. 1040 * 1041 * @param <U> The Type to which the object should be cast 1042 * @param obj The Object to be cast 1043 * @return The argument Object cast to Type U. 1044 */ 1045 @SuppressWarnings("unchecked") 1046 public static <U> U unchecked_cast(Object obj) 1047 { 1048 return (U)obj; 1049 } 1050 1051 /** 1052 * @return Returns an implementation object that stores the fields of this 1053 * exception not defined by WvcmException and implements the other 1054 * methods of this exception. Will never be <b>null</b>. 1055 */ 1056 public abstract Data data(); 1057 1058 /** 1059 * Localizes the message contained within this exception and returns it. 1060 */ 1061 public String getMessage() { return data().getMessage(); } 1062 1063 /** 1064 * @return The StpReasonCode assigned to this exception. 1065 */ 1066 public StpReasonCode getStpReasonCode() 1067 { return data().getStpReasonCode(); } 1068 1069 /** 1070 * @return A String image of this StpException and any nested Exceptions 1071 */ 1072 public String toString() { return data().toString(); } 1073 1074 /** 1075 * Constructs this exception object for its subclasses. 1076 * 1077 * @param resource The Resource argument to WvcmException 1078 * @param reasonCode The ReasonCode argument to WvcmException 1079 * @param nestedExceptions The Throwable[] argument to WvcmException 1080 * 1081 * @see javax.wvcm.WvcmException 1082 */ 1083 protected StpException(Resource resource, 1084 ReasonCode reasonCode, 1085 Throwable... nestedExceptions) 1086 { 1087 super(null, resource, reasonCode, nestedExceptions); 1088 } 1089 }