JAL-4090 JAL-1551 spotlessApply
[jalview.git] / src / jalview / ws / jws2 / JabaWsServerQuery.java
index 74dce4d..84aa1a6 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -23,7 +23,7 @@
  */
 package jalview.ws.jws2;
 
-import jalview.bin.Cache;
+import jalview.bin.Console;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
 import jalview.ws.jws2.jabaws2.Jws2InstanceFactory;
 
@@ -74,15 +74,15 @@ public class JabaWsServerQuery implements Runnable
     this.jwsserver = server;
   }
 
-  Services[] JABAWS1SERVERS = new Services[]
-  { Services.ClustalWS, Services.MuscleWS, Services.MafftWS,
-      Services.ProbconsWS, Services.TcoffeeWS };
+  Services[] JABAWS1SERVERS = new Services[] { Services.ClustalWS,
+      Services.MuscleWS, Services.MafftWS, Services.ProbconsWS,
+      Services.TcoffeeWS };
 
-  Services[] JABAWS2SERVERS = new Services[]
-  { Services.ClustalWS, Services.MuscleWS, Services.MafftWS,
-      Services.ProbconsWS, Services.TcoffeeWS, Services.AAConWS,
-      Services.DisemblWS, Services.GlobPlotWS, Services.IUPredWS,
-      Services.JronnWS, Services.RNAalifoldWS };
+  Services[] JABAWS2SERVERS = new Services[] { Services.ClustalWS,
+      Services.MuscleWS, Services.MafftWS, Services.ProbconsWS,
+      Services.TcoffeeWS, Services.AAConWS, Services.DisemblWS,
+      Services.GlobPlotWS, Services.IUPredWS, Services.JronnWS,
+      Services.RNAalifoldWS };
 
   /*
    * (non-Javadoc)
@@ -117,7 +117,7 @@ public class JabaWsServerQuery implements Runnable
           registry = Jws2Client.connectToRegistry(jwsserver);
           if (registry != null)
           {
-            // System.err.println("Test Services Output\n"
+            // jalview.bin.Console.errPrintln("Test Services Output\n"
             // + registry.testAllServices());
             // TODO: enumerate services and test those that haven't been tested
             // in the last n-days/hours/etc.
@@ -126,23 +126,25 @@ public class JabaWsServerQuery implements Runnable
             srv_set = registry.getSupportedServices();
 
             // dan test
-            System.out.println("registry.getSupportedServices: "
-                    + srv_set.toString());
+            jalview.bin.Console.outPrintln(
+                    "registry.getSupportedServices: " + srv_set.toString());
 
             svccategories = registry.getServiceCategories();
 
             // dan test
-            // System.out.println("registry.getServiceCategories: " +
+            // jalview.bin.Console.outPrintln("registry.getServiceCategories: "
+            // +
             // svccategories.toString());
 
           }
         } catch (Exception ex)
         {
-          System.err.println("Exception whilst trying to get at registry:");
+          jalview.bin.Console.errPrintln(
+                  "Exception whilst trying to get at registry:");
           ex.printStackTrace();
           // if that failed, then we are probably working with a JABAWS1 server.
           // in that case, look for each service endpoint
-          System.err.println("JWS2 Discoverer: " + jwsserver
+          jalview.bin.Console.errPrintln("JWS2 Discoverer: " + jwsserver
                   + " is a JABAWS1 server. Using hardwired list.");
           for (Services srv : JABAWS1SERVERS)
           {
@@ -169,7 +171,7 @@ public class JabaWsServerQuery implements Runnable
               service = Jws2Client.connect(jwsserver, srv);
             } catch (Exception e)
             {
-              System.err.println("Jws2 Discoverer: Problem on "
+              jalview.bin.Console.errPrintln("Jws2 Discoverer: Problem on "
                       + jwsserver + " with service " + srv + ":\n"
                       + e.getMessage());
               if (!(e instanceof javax.xml.ws.WebServiceException))
@@ -180,7 +182,8 @@ public class JabaWsServerQuery implements Runnable
               jws2Discoverer.addInvalidServiceUrl(jwsserver);
             }
             ;
-            if (service != null)
+            if (service != null
+                    && !Jws2InstanceFactory.ignoreService(srv.toString()))
             {
               noservices = false;
               Jws2Instance svc = null;
@@ -212,16 +215,16 @@ public class JabaWsServerQuery implements Runnable
       else
       {
         jws2Discoverer.addInvalidServiceUrl(jwsserver);
-        Cache.log.info("Ignoring invalid Jws2 service url " + jwsserver);
+        Console.warn("Ignoring invalid Jws2 service url " + jwsserver);
       }
     } catch (Exception e)
     {
       e.printStackTrace();
-      Cache.log.warn("Exception when discovering Jws2 services.", e);
+      Console.warn("Exception when discovering Jws2 services.", e);
       jws2Discoverer.addInvalidServiceUrl(jwsserver);
     } catch (Error e)
     {
-      Cache.log.error("Exception when discovering Jws2 services.", e);
+      Console.error("Exception when discovering Jws2 services.", e);
       jws2Discoverer.addInvalidServiceUrl(jwsserver);
     }
     running = false;
@@ -236,19 +239,21 @@ public class JabaWsServerQuery implements Runnable
   {
     // return Jws2Client.validURL(jwsserver); // checks syntax only
     boolean result = false;
-    if (server != null) {
-      try {
+    if (server != null)
+    {
+      try
+      {
         URL url = new URL(server);
         url.openStream().close();
         result = true;
       } catch (MalformedURLException e)
       {
-        System.err.println("Invalid server URL: " + server);
+        jalview.bin.Console.errPrintln("Invalid server URL: " + server);
         result = false;
       } catch (IOException e)
       {
-        System.err.println("Error connecting to server: " + server + ": "
-                + e.toString());
+        jalview.bin.Console.errPrintln("Error connecting to server: "
+                + server + ": " + e.toString());
         result = false;
       }
     }