JAL-4199 Update slivka client
[jalview.git] / src / jalview / ws / slivkaws / SlivkaWSDiscoverer.java
index e849f97..104560a 100644 (file)
@@ -1,9 +1,12 @@
 package jalview.ws.slivkaws;
 
 import jalview.bin.Cache;
+import jalview.bin.Console;
 import jalview.ws.ServiceChangeListener;
 import jalview.ws.WSDiscovererI;
 import jalview.ws.api.ServiceWithParameters;
+import javajs.http.HttpClientFactory;
+
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -85,13 +88,13 @@ public class SlivkaWSDiscoverer implements WSDiscovererI
 
   private List<ServiceWithParameters> reloadServices()
   {
-    Cache.log.info("Reloading Slivka services");
+    Console.info("Reloading Slivka services");
     notifyServiceListeners(Collections.emptyList());
     ArrayList<ServiceWithParameters> instances = new ArrayList<>();
 
     for (String url : getServiceUrls())
     {
-      SlivkaClient client = new SlivkaClient(url);
+      SlivkaClient client = SlivkaClient.newInstance(url);
 
       List<SlivkaService> services;
       try
@@ -113,6 +116,10 @@ public class SlivkaWSDiscoverer implements WSDiscovererI
           {
             switch (path[path.length - 1].toLowerCase())
             {
+            case "rna secondary structure prediction":
+              newInstance = new RNAalifoldServiceInstance(client,
+                      service, "Secondary Structure Prediction");
+              break;
             case "sequence alignment analysis (conservation)":
               newInstance = new SlivkaAnnotationServiceInstance(client,
                       service, Category.CATEGORY_CONSERVATION);
@@ -140,7 +147,7 @@ public class SlivkaWSDiscoverer implements WSDiscovererI
     }
 
     services = instances;
-    Cache.log.info("Slivka services reloading finished");
+    Console.info("Slivka services reloading finished");
     notifyServiceListeners(instances);
     return instances;
   }
@@ -190,13 +197,13 @@ public class SlivkaWSDiscoverer implements WSDiscovererI
         valid.add(url);
       } catch (MalformedURLException e)
       {
-        Cache.log.warn("Problem whilst trying to make a URL from '"
+        Console.warn("Problem whilst trying to make a URL from '"
                 + ((url != null) ? url : "<null>") + "'");
-        Cache.log.warn(
+        Console.warn(
                 "This was probably due to a malformed comma separated list"
                         + " in the " + SLIVKA_HOST_URLS
                         + " entry of $(HOME)/.jalview_properties)");
-        Cache.log.debug("Exception was ", e);
+        Console.debug("Exception was ", e);
       }
     }
     return valid;
@@ -213,11 +220,11 @@ public class SlivkaWSDiscoverer implements WSDiscovererI
   {
     try
     {
-      List<?> services = new SlivkaClient(url).getServices();
+      List<?> services = SlivkaClient.newInstance(url).getServices();
       return services.isEmpty() ? STATUS_NO_SERVICES : STATUS_OK;
-    } catch (IOException e)
+    } catch (IOException | org.json.JSONException e)
     {
-      Cache.log.error("Slivka could not retrieve services list", e);
+      Console.error("Slivka could not retrieve services list", e);
       return STATUS_INVALID;
     }
   }