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.

92 lines
2.4 KiB

  1. package altk.comm.engine;
  2. /**
  3. * Derived classes may add more class attributes, e.g. list of phone numbers, call status.
  4. * @author Yuk-Ming
  5. *
  6. */
  7. public class Job
  8. {
  9. /**
  10. * Because enum has no inheritance, JobStatus is the union of
  11. * all possible job status from all backend engines built on CommEngine.
  12. */
  13. static public enum JobStatus
  14. {
  15. // TODO: Some of them, like CANCELED and EXPIRED, should not be used, and should be cleaned out.
  16. TRYING(false), // VoiceEngine
  17. GO_NEXT_PHONE(false), // VoiceEngine
  18. //TRUNK_ERROR(false),
  19. LONG_DURATION(true), // VoiceEngine
  20. SUCCESS(true),
  21. NO_MORE_RETRY(true), // VoiceEngine
  22. ADDRESS_ERROR(true), // All
  23. SERVICE_PROVIDER_PROTOCOL_ERROR(true), // SMS
  24. SERVICE_PROVIDER_GENERATED_ERROR(true), // SMS
  25. SERVICE_PROVIDER_HTTP_ERROR(true), // SMS
  26. SERVICE_PROVIDER_CONNECT_ERROR(true), // SMS
  27. SERVICE_PROVIDER_OTHER_ERROR(true), // Email
  28. CANCELED(true), // Voice - is it really?
  29. EXPIRED(true), // Voice - is it really?
  30. MESSAGE_ERROR(true), // Email, SMS
  31. SERVICE_ACCESS_BLOCKED(true), // SMS
  32. PLATFORM_ERROR(true), // SMS
  33. FAILED(true), // SMS
  34. UNKNOWN_ERROR(true), // SMS
  35. NOT_AUTHORIZED(true), // SMS
  36. BAD_REQUEST(true), // SMS
  37. THROTTLE_LIMIT_REACHED(true), // SMS
  38. UNPROCESSABLE_ENTITY(true), // SMS
  39. ABORT(true), // Voice
  40. ;
  41. private boolean isTerminal;
  42. private JobStatus(boolean isTerminal)
  43. {
  44. this.isTerminal = isTerminal;
  45. }
  46. public boolean isTerminal()
  47. {
  48. return isTerminal;
  49. }
  50. }
  51. public Recipient recipient;
  52. public long startTime;
  53. public JobStatus jobStatus;
  54. public String errorText;
  55. public Job(Recipient recipient)
  56. {
  57. this.recipient = recipient;
  58. jobStatus = null;
  59. }
  60. public void setStatus(JobStatus jobStatus)
  61. {
  62. this.jobStatus = jobStatus;
  63. }
  64. public void setStatus(JobStatus jobStatus, String errorText)
  65. {
  66. this.jobStatus = jobStatus;
  67. this.errorText = errorText;
  68. }
  69. /**
  70. *
  71. * @return error in text form.
  72. */
  73. public String getErrorText()
  74. {
  75. return errorText;
  76. }
  77. }