Merge branch 'feature/JAL-3690_callback-based-web-services' into alpha/JAL-3066_Jalvi...
[jalview.git] / src / jalview / ws / slivkaws / SlivkaWSInstance.java
index 8a16edb..75e5722 100644 (file)
@@ -54,7 +54,7 @@ public abstract class SlivkaWSInstance extends ServiceWithParameters
     stateMap.put(JobState.QUEUED, WsJob.JobState.QUEUED);
     stateMap.put(JobState.RUNNING, WsJob.JobState.RUNNING);
     stateMap.put(JobState.COMPLETED, WsJob.JobState.FINISHED);
-    stateMap.put(JobState.INTERRUPED, WsJob.JobState.CANCELLED);
+    stateMap.put(JobState.INTERRUPTED, WsJob.JobState.CANCELLED);
     stateMap.put(JobState.DELETED, WsJob.JobState.CANCELLED);
     stateMap.put(JobState.FAILED, WsJob.JobState.FAILED);
     stateMap.put(JobState.ERROR, WsJob.JobState.SERVERERROR);
@@ -67,7 +67,7 @@ public abstract class SlivkaWSInstance extends ServiceWithParameters
 
   public SlivkaWSInstance(SlivkaClient client, SlivkaService service, String action)
   {
-    super(service.getName(), action, service.getLabel(), "Slivka", client.getUrl().toString());
+    super(action, action, service.getLabel(), "Slivka", client.getUrl().toString());
     this.client = client;
     this.service = service;
   }
@@ -145,13 +145,20 @@ public abstract class SlivkaWSInstance extends ServiceWithParameters
   public final boolean updateJobProgress(WsJob job) throws IOException
   {
     List<RemoteFile> files = client.getJobResults(job.getJobId());
-    Optional<RemoteFile> logFile = files.stream()
-            .filter(f -> f.getLabel().equals("log")).findFirst();
+    RemoteFile logFile=null;
+    for (RemoteFile f : files)
+    {
+      if (f.getLabel().equals("log"))
+      {
+        logFile = f; break;
+      }
+    }
+
     boolean newContent = false;
-    if (logFile.isPresent())
+    if (logFile!=null)
     {
       ByteArrayOutputStream output = new ByteArrayOutputStream();
-      logFile.get().writeTo(output);
+      logFile.writeTo(output);
       if (output.size() > job.getNextChunk())
       {
         newContent = true;
@@ -161,12 +168,21 @@ public abstract class SlivkaWSInstance extends ServiceWithParameters
     }
     if (failedStates.contains(job.getJobState()))
     {
-      Optional<RemoteFile> errLogFile = files.stream()
-              .filter(f -> f.getLabel().equals("error-log")).findFirst();
-      if (errLogFile.isPresent())
+      
+      RemoteFile errLogFile = null;
+      for (RemoteFile f : files)
+      {
+        if (f.getLabel().equals("error-log"))
+        {
+          errLogFile = f;
+          break;
+        }
+      }
+
+      if (errLogFile!=null)
       {
         ByteArrayOutputStream output = new ByteArrayOutputStream();
-        errLogFile.get().writeTo(output);
+        errLogFile.writeTo(output);
         if (output.size() > 0)
         {
           newContent = true;