PageRenderTime 37ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/association/DeleteTxnResp.java

http://mobicents.googlecode.com/
Java | 157 lines | 53 code | 20 blank | 84 comment | 15 complexity | 5eaddd9e382592d99102589bf60359d1 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  1. /**
  2. * Start time:14:03:29 2009-01-30<br>
  3. * Project: mobicents-media-server-controllers<br>
  4. *
  5. * @author <a href="mailto:baranowb@gmail.com">baranowb - Bartosz Baranowski
  6. * </a>
  7. * @author <a href="mailto:brainslog@gmail.com"> Alexandre Mendonca </a>
  8. */
  9. package javax.megaco.association;
  10. import javax.megaco.AssociationEvent;
  11. import javax.megaco.ErrorCode;
  12. import javax.megaco.MethodInvocationException;
  13. import javax.megaco.ReturnStatus;
  14. public class DeleteTxnResp extends AssociationEvent {
  15. private int txnHandle = -1;
  16. protected ReturnStatus eventStatus = null;
  17. protected ErrorCode errorCode = null;
  18. public DeleteTxnResp(Object source, int assocHandle) throws IllegalArgumentException {
  19. super(source, assocHandle);
  20. // TODO Auto-generated constructor stub
  21. }
  22. public DeleteTxnResp(Object source, int assocHandle, int txnHandle) throws IllegalArgumentException {
  23. super(source, assocHandle);
  24. this.setTxnHandle(txnHandle);
  25. }
  26. @Override
  27. public final int getAssocOperIdentifier() {
  28. return AssocEventType.M_DELETE_TXN_RESP;
  29. }
  30. /**
  31. * This method returns whether the delete transaction event was successful
  32. * or not.
  33. *
  34. * @return Returns an integer value that identifies whether the delete
  35. * transaction event issued earlier could be performed successfuly
  36. * or not. The values are field constants defined in class
  37. * ReturnStatus. If the returnStatus is not set, then this method
  38. * would return value null.
  39. */
  40. public final ReturnStatus getEventStatus() {
  41. // return eventStatus == null ? 0 : eventStatus.getReturnStatus();
  42. return eventStatus;
  43. }
  44. /**
  45. * This method sets the status of whether the processing of the delete
  46. * transaction event was successful or not.
  47. *
  48. * @param returnStatus
  49. * - The return status of the processing of the delete
  50. * transaction event. The static object corresponding to the
  51. * return status which are one of the derived classes of the
  52. * ReturnStatus shall be set.
  53. * @throws IllegalArgumentException
  54. * This exception is raised if the reference of Return Status
  55. * passed to this method is NULL.
  56. */
  57. public final void setEventStatus(ReturnStatus returnStatus) throws IllegalArgumentException {
  58. if (returnStatus == null)
  59. throw new IllegalArgumentException("Event status can not be null.");
  60. this.eventStatus = returnStatus;
  61. }
  62. /**
  63. * This method returns the error code qualifying why the modify association
  64. * event could not be processed successfuly.
  65. *
  66. * @return Returns an integer value that identifies the error code
  67. * specifying why the execution of the modify association event
  68. * could not be successful. The possible values are field constants
  69. * defined for the class ErrorCode. If the error code is not set,
  70. * then this method would return value null.
  71. * @throws IllegalStateException
  72. * - This exception would be raised if the return status is set
  73. * to M_SUCCESS, the error code is not set and hence should not
  74. * invoke this method.
  75. */
  76. public final ErrorCode getErrorCode() throws IllegalStateException {
  77. if (getEventStatus() == null || getEventStatus().getReturnStatus() == ReturnStatus.M_SUCCESS) {
  78. throw new IllegalStateException("Event status is success or not set, error code is not premited.");
  79. }
  80. // return errorCode == null ? 0 : errorCode.getErrorCode();
  81. return errorCode;
  82. }
  83. /**
  84. * This method sets the error code specifying why the delete transaction
  85. * event could not be executed successfuly.
  86. *
  87. * @param errorCode
  88. * - The error code correspondingto why the delete transaction
  89. * event could not be executed successfuly. The values are
  90. * defined in AssocEventType.
  91. * @throws IllegalArgumentException
  92. * This exception would be raised in following conditions <br>
  93. * 1. If the return status is not set to M_FAILURE, the error
  94. * code should not be set. <br>
  95. * 2. If the error code is not valid for the DeleteTxnReq event.
  96. */
  97. public final void setErrorCode(ErrorCode errorCode) throws IllegalArgumentException {
  98. if (errorCode == null)
  99. throw new IllegalArgumentException("Error code can not be null.");
  100. if (getEventStatus() == null || getEventStatus().getReturnStatus() != ReturnStatus.M_FAILURE) {
  101. throw new IllegalArgumentException("Event status is not failure or nto set, error code is not premited.");
  102. }
  103. this.errorCode = errorCode;
  104. }
  105. // FIXME those are nto defined in jdoc....
  106. /**
  107. * Gets an object identifier that specifies the transaction identifier. If
  108. * the transaction identifier is set to 0, then this would be the case when
  109. * the transaction identifier is to represent all transactions.<br>
  110. * <br>
  111. * If the transaction identifier is not set, then this method returns 0,
  112. * indicating all transactions.
  113. *
  114. * @return Returns an integer value that specifies the transaction
  115. * identifier.
  116. */
  117. public final int getTxnHandle() {
  118. if (txnHandle == -1)
  119. return 0;
  120. return txnHandle;
  121. }
  122. /**
  123. * This method sets the transaction identifier. To delete all transactions,
  124. * the transaction identifier is set to 0.
  125. *
  126. * @param transactionHandle
  127. * A reference to transaction identifier.
  128. * @throws IllegalArgumentException
  129. * This exception is raised if the value of transaction handle
  130. * passed to this method is less than 0.
  131. */
  132. public final void setTxnHandle(int transactionHandle) throws IllegalArgumentException {
  133. if (transactionHandle < 0)
  134. throw new IllegalArgumentException("Txn Handle can not be less than zero");
  135. this.txnHandle = transactionHandle;
  136. }
  137. }