Imported from dev1.link2tek.net CommEngine.git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
1.9 KiB

  1. package altk.comm.engine;
  2. import altk.comm.engine.Job.CommJobStatus;
  3. /**
  4. * Derived classes may add more class attributes, e.g. list of phone numbers, call status.
  5. * @author Yuk-Ming
  6. *
  7. */
  8. public class Job
  9. {
  10. /**
  11. * Named but empty interface designed for the purpose of extending a specific enum.
  12. */
  13. public interface JobStatus
  14. {
  15. }
  16. /**
  17. * Base JobStatus values common to all CommEngine's.
  18. */
  19. static public enum CommJobStatus implements JobStatus
  20. {
  21. SUCCESS,
  22. ADDRESS_ERROR,
  23. CANCELED,
  24. SERVICE_PROVIDER_PROTOCOL_ERROR,
  25. SERVICE_PROVIDER_CONNECT_ERROR,
  26. SERVICE_PROVIDER_HTTP_ERROR,
  27. SERVICE_PROVIDER_GENERATED_ERROR,
  28. SERVICE_PROVIDER_OTHER_ERROR,
  29. FORBIDDEN,
  30. UNKNOWN_ERROR,
  31. NOT_AUTHORIZED,
  32. BAD_REQUEST,
  33. ABORT,
  34. PLATFORM_ERROR,
  35. FAILED,
  36. NOT_FOUND,
  37. PAYMENT_REQUIRED;
  38. }
  39. public Recipient recipient;
  40. public long startTime;
  41. public JobStatus jobStatus;
  42. public String errorText;
  43. public Job(Recipient recipient)
  44. {
  45. this.recipient = recipient;
  46. jobStatus = null;
  47. }
  48. public void setStatus(JobStatus jobStatus)
  49. {
  50. this.jobStatus = jobStatus;
  51. }
  52. public void setStatus(JobStatus jobStatus, String errorText)
  53. {
  54. this.jobStatus = jobStatus;
  55. this.errorText = errorText;
  56. }
  57. /**
  58. *
  59. * @return error in text form.
  60. */
  61. public String getErrorText()
  62. {
  63. return errorText;
  64. }
  65. /**
  66. *
  67. * @return true to indicate that broadcast should abort.
  68. */
  69. protected boolean isBroadcastFatal()
  70. {
  71. return false;
  72. }
  73. /**
  74. * Derived class must augment this method to handle its own JobStatus
  75. */
  76. protected boolean statusIsFinal() {
  77. if (jobStatus instanceof CommJobStatus)
  78. {
  79. return true;
  80. }
  81. throw new IllegalArgumentException("Job status is not a CommJobStatus");
  82. }
  83. }