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

http://mobicents.googlecode.com/ · Java · 108 lines · 43 code · 12 blank · 53 comment · 10 complexity · bcbdeb19b96e15227f7b80717f92d7ed MD5 · raw file

  1. package javax.megaco.association;
  2. import javax.megaco.AssociationEvent;
  3. import javax.megaco.ErrorCode;
  4. import javax.megaco.MethodInvocationException;
  5. import javax.megaco.ReturnStatus;
  6. public class AssociationConfigResp extends AssociationEvent {
  7. protected ReturnStatus eventStatus = null;
  8. protected ErrorCode errorCode = null;
  9. public AssociationConfigResp(Object source, int assocHandle)
  10. throws IllegalArgumentException {
  11. super(source, assocHandle);
  12. // TODO Auto-generated constructor stub
  13. }
  14. @Override
  15. public int getAssocOperIdentifier() {
  16. return AssocEventType.M_ASSOC_CONFIG_RESP;
  17. }
  18. /**
  19. * This method returns whether the execution of create association request
  20. * was success or not.
  21. *
  22. * @return Returns an integer value that identifies whether the association
  23. * configuration event issued earlier could be performed successfuly
  24. * or not. The values are field constants defined in class
  25. * ReturnStatus. If the returnStatus is not set, then this method
  26. * would return value null.
  27. */
  28. public final ReturnStatus getEventStatus() {
  29. //return eventStatus == null ? 0 : eventStatus.getReturnStatus();
  30. return eventStatus;
  31. }
  32. /**
  33. * This method sets the status of whether the execution of the association
  34. * configuration request was success or not.
  35. *
  36. * @param returnStatus
  37. * - The return status of the processing of the association
  38. * configuration event. The static object corresponding to the
  39. * return status which are one of the derived classes of the
  40. * ReturnStatus shall be set.
  41. * @throws IllegalArgumentException
  42. * This exception is raised if the reference of Return Status
  43. * passed to this method is NULL.
  44. */
  45. public final void setEventStatus(ReturnStatus returnStatus)
  46. throws IllegalArgumentException {
  47. if (returnStatus == null)
  48. throw new IllegalArgumentException("Event status can not be null.");
  49. this.eventStatus = returnStatus;
  50. }
  51. /**
  52. * This method returns the error code qualifying why the association
  53. * configuration event could not be processed successfuly.
  54. *
  55. * @return Returns an integer value that identifies the error code
  56. * specifying why the execution of the association configuration
  57. * event could not be successful. The possible values are field
  58. * constants defined for the class ErrorCode. If the error code is
  59. * not set, then this method would return value 0.
  60. *
  61. * @throws IllegalStateException
  62. * - This exception would be raised if the return status is set
  63. * to M_SUCCESS, the error code is not set and hence should not
  64. * invoke this method.
  65. */
  66. public final ErrorCode getErrorCode() throws IllegalStateException {
  67. if (getEventStatus() == null || getEventStatus().getReturnStatus() ==ReturnStatus.M_SUCCESS) {
  68. throw new IllegalStateException(
  69. "Event status is success, error code is not premited.");
  70. }
  71. //return errorCode == null ? 0 : errorCode.getErrorCode();
  72. return errorCode;
  73. }
  74. /**
  75. * This method sets the error code specifying why the association configuration event could not be executed successfuly.
  76. *
  77. * @param errorCode
  78. * The error code corresponding to why the association configuration event could not be executed successfuly.
  79. * @throws IllegalArgumentException
  80. * This exception would be raised in following conditions <br>
  81. * 1. If the return status is not set to M_FAILURE, the error
  82. * code should not be set. <br>
  83. * 2. If the error code object passed to this method is set to
  84. * NULL.
  85. */
  86. public final void setErrorCode(ErrorCode errorCode)
  87. throws IllegalArgumentException {
  88. if (errorCode == null)
  89. throw new IllegalArgumentException("Error code can not be null.");
  90. if (getEventStatus()==null || getEventStatus().getReturnStatus() != ReturnStatus.M_FAILURE) {
  91. throw new IllegalArgumentException(
  92. "Event status is not failure, error code is not premited.");
  93. }
  94. this.errorCode = errorCode;
  95. }
  96. }