BiBusHeaderException.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: DOCS
  4. (C) Copyright IBM Corp. 2005
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. */
  8. /**
  9. * BiBusHeaderException.java
  10. *
  11. * Copyright (C) 2005 Cognos ULC, an IBM Company. All rights reserved.
  12. * Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  13. */
  14. // sn_dg_sdk_headerexception_start_1
  15. import org.apache.axis.client.Stub;
  16. import org.apache.axis.message.SOAPHeaderElement;
  17. import javax.xml.namespace.QName;
  18. import com.cognos.developer.schemas.bibus._3.BiBusHeader;
  19. import com.cognos.developer.schemas.bibus._3.CAMException;
  20. import com.cognos.developer.schemas.bibus._3.Message;
  21. import com.cognos.developer.schemas.bibus._3.PromptInfo;
  22. import com.cognos.developer.schemas.bibus._3.ContentManagerService_PortType;
  23. /**
  24. * Extract the interesting bits from a biBusHeader after a biBusHeader
  25. * fault.
  26. */
  27. public class BiBusHeaderException
  28. {
  29. private CAMException _exception = null;
  30. /**
  31. * Create a BiBusHeaderException object.
  32. *
  33. * @param cmService ContentManagerService object in use during the last exception.
  34. */
  35. public BiBusHeaderException(ContentManagerService_PortType cmService)
  36. {
  37. // Pull the CAM exception out of the biBusHeader.
  38. // BiBusHeader bibus_header =
  39. // ((Stub)cmService).getHeaderObject("", "biBusHeader");
  40. // BiBusHeader bibus = (BiBusHeader)bibus_header.getObjectValue();
  41. // _exception = bibus.getCAM().getException();
  42. // try {
  43. // SOAPHeaderElement temp = ((Stub)cmService).getResponseHeader("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader");
  44. // BiBusHeader bibus_header = (BiBusHeader)temp.getValueAsType(new QName("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader"));
  45. // ((Stub)cmService).setHeader("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader", bibus_header);
  46. // }
  47. // catch(Exception e) {
  48. // }
  49. }
  50. /**
  51. * Get the Severity string from this BiBusHeaderException.
  52. *
  53. * @return The Serverity string (a severityEnum in string form).
  54. */
  55. public String getSeverity()
  56. {
  57. return new String(_exception.getSeverity().toString());
  58. }
  59. /**
  60. * Get the errorCodeString from this BiBusHeaderException.
  61. *
  62. * @return The errorCodeString.
  63. */
  64. public String getErrorCode()
  65. {
  66. return new String(_exception.getErrorCodeString());
  67. }
  68. /**
  69. * Get the details (messageString), if any, from this BiBusHeaderException.
  70. *
  71. * @return An array of strings containing the detail messages.
  72. */
  73. public String[] getDetails()
  74. {
  75. Message msg[] = _exception.getMessages();
  76. if(msg == null)
  77. {
  78. return new String[] {"null"};
  79. }
  80. String retval[] = new String[msg.length];
  81. for (int idx = 0; idx < msg.length; idx++)
  82. {
  83. retval[idx] = new String(msg[idx].getMessageString());
  84. }
  85. return retval;
  86. }
  87. /**
  88. * Get the promptInfo (and useful captions/displayObjects inside) to
  89. * facilitate prompting the user, if this is a recoverable exception.
  90. *
  91. * @return The promptInfo object from the exception.
  92. */
  93. public PromptInfo getPromptInfo()
  94. {
  95. return _exception.getPromptInfo();
  96. }
  97. /**
  98. * Convert this BiBusHeaderException into a string for printing.
  99. *
  100. * @return A string representation of the BiBusHeaderException.
  101. */
  102. public String toString()
  103. {
  104. StringBuffer str = new StringBuffer();
  105. str.append("Severity :").append(getSeverity()).append("\n");
  106. str.append("ErrorCode :").append(getErrorCode()).append("\n");
  107. str.append("Details :\n");
  108. String details[] = getDetails();
  109. for (int i = 0; i < details.length; i++)
  110. {
  111. str.append("\t").append(details[i]).append("\n");
  112. }
  113. return str.toString();
  114. }
  115. /**
  116. * Convert a biBusHeader exception into a BiBusHeaderException string.
  117. *
  118. * This is the same as creating a BiBusHeaderException and calling
  119. * its toString() method.
  120. *
  121. * @param crn The Service object that experienced the exception.
  122. * @return A string representation.
  123. */
  124. static public String convertToString(ContentManagerService_PortType cmService)
  125. {
  126. BiBusHeaderException exception = new BiBusHeaderException(cmService);
  127. return exception.toString();
  128. }
  129. }
  130. // sn_dg_sdk_headerexception_end_1