JAL-3878 Move WebServiceJob class to jalview.ws2.api package
[jalview.git] / src / jalview / ws2 / client / api / WebServiceClientI.java
1 package jalview.ws2.client.api;
2
3 import java.io.IOException;
4 import java.util.List;
5
6 import jalview.datamodel.SequenceI;
7 import jalview.ws.params.ArgumentI;
8 import jalview.ws2.api.Credentials;
9 import jalview.ws2.api.WebServiceJob;
10
11 public interface WebServiceClientI
12 {
13   /**
14    * Get the hostname/url of the remote server which is supplying the service.
15    * 
16    * @return host name
17    */
18   String getUrl();
19
20   /**
21    * Get the name of the web service client.
22    * 
23    * @return client name
24    */
25   String getClientName();
26
27   /**
28    * Submit new job to the service with the supplied input sequences and
29    * arguments. Optionally, some services may require additional credentials to
30    * run. Implementations should perform all data serialization necessary for
31    * the job submission, start a new job on the remote server and return a
32    * handler for that job.
33    * 
34    * @param sequences
35    *          input sequences
36    * @param args
37    *          user provided arguments
38    * @param credentials
39    *          optional user credentials needed to run the job
40    * @return job handler
41    * @throws IOException
42    *           submission failed due to a connection error
43    */
44   WebServiceJob submit(List<SequenceI> sequences, List<ArgumentI> args,
45       Credentials credentials) throws IOException;
46
47   /**
48    * Poll the server and update the progress of the running job accordingly.
49    * Implementations should fetch the current job status from the server and
50    * update the status and log strings on the provided job object.
51    * 
52    * @param job
53    *          job to update
54    * @throws IOException
55    *           server error occurred
56    */
57   void updateProgress(WebServiceJob job) throws IOException;
58
59   /**
60    * Send the cancellation request to the server for the specified job.
61    * 
62    * @param job
63    *          job to cancel
64    * @throws IOException
65    *           server error occurred
66    * @throws UnsupportedOperationException
67    *           server does not support job cancellation
68    */
69   void cancel(WebServiceJob job) throws IOException, UnsupportedOperationException;
70 }