|
- package altk.comm.engine;
-
- import altk.comm.engine.Job.CommJobStatus;
-
- /**
- * Derived classes may add more class attributes, e.g. list of phone numbers, call status.
- * @author Yuk-Ming
- *
- */
-
- public class Job
- {
- /**
- * Named but empty interface designed for the purpose of extending a specific enum.
- */
- public interface JobStatus
- {
- }
-
- /**
- * Base JobStatus values common to all CommEngine's.
- */
- static public enum CommJobStatus implements JobStatus
- {
- SUCCESS,
- ADDRESS_ERROR,
- CANCELED,
- SERVICE_PROVIDER_PROTOCOL_ERROR,
- SERVICE_PROVIDER_CONNECT_ERROR,
- SERVICE_PROVIDER_HTTP_ERROR,
- SERVICE_PROVIDER_GENERATED_ERROR,
- SERVICE_PROVIDER_OTHER_ERROR,
- FORBIDDEN,
- UNKNOWN_ERROR,
- NOT_AUTHORIZED,
- BAD_REQUEST,
- ABORT,
- PLATFORM_ERROR,
- FAILED,
- NOT_FOUND,
- PAYMENT_REQUIRED;
- }
-
- public Recipient recipient;
-
- public long startTime;
-
- public JobStatus jobStatus;
-
- public String errorText;
-
- public Job(Recipient recipient)
- {
- this.recipient = recipient;
- jobStatus = null;
- }
-
- public void setStatus(JobStatus jobStatus)
- {
- this.jobStatus = jobStatus;
- }
-
- public void setStatus(JobStatus jobStatus, String errorText)
- {
- this.jobStatus = jobStatus;
- this.errorText = errorText;
- }
-
- /**
- *
- * @return error in text form.
- */
- public String getErrorText()
- {
- return errorText;
- }
-
- /**
- *
- * @return true to indicate that broadcast should abort.
- */
- protected boolean isBroadcastFatal()
- {
- return false;
- }
-
- /**
- * Derived class must augment this method to handle its own JobStatus
- */
- protected boolean statusIsFinal() {
- if (jobStatus instanceof CommJobStatus)
- {
- return true;
- }
- throw new IllegalArgumentException("Job status is not a CommJobStatus");
- }
-
-
-
- }
|