ask user if they want to run the JabaWS tester on new URLs
authorjprocter <Jim Procter>
Wed, 11 Aug 2010 14:14:34 +0000 (14:14 +0000)
committerjprocter <Jim Procter>
Wed, 11 Aug 2010 14:14:34 +0000 (14:14 +0000)
src/jalview/gui/WsPreferences.java
src/jalview/ws/jws2/Jws2Discoverer.java

index 45654f2..7ca4fd5 100644 (file)
@@ -143,7 +143,7 @@ public class WsPreferences extends GWsPreferences
   private String editUrl(String initUrl, String title)
   {
     String url=initUrl;
-    URL foo;
+    URL foo=null;
     if (url==null)
     {
       url = "";
@@ -170,7 +170,14 @@ public class WsPreferences extends GWsPreferences
     }
     if (valid && resp==JOptionPane.OK_OPTION)
     {
-      return urltf.getText().trim();
+      int validate = JOptionPane.showInternalConfirmDialog(Desktop.desktop, null, "Validate JabaWS Server ?\n(Look in console output for results)", JOptionPane.YES_NO_OPTION);
+      if (validate == JOptionPane.OK_OPTION)
+      {
+        if (jalview.ws.jws2.Jws2Discoverer.testServiceUrl(foo)) 
+        {
+          return foo.toString();
+        }
+      }
     }
     return initUrl; 
   }
index 9897d79..cb1f49b 100644 (file)
@@ -482,4 +482,28 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
             : new Vector<Jws2Instance>(services);
   }
 
+  /**
+   * test the given URL with the JabaWS test code
+   * @param foo
+   * @return
+   */
+  public static boolean testServiceUrl(URL foo)
+  {
+    try {
+      compbio.ws.client.WSTester.main(new String[] { "-h="+foo.toString()});
+    } catch (Exception e)
+    {
+      return false;
+    }
+    catch (OutOfMemoryError e)
+    {
+      return false;
+    }
+    catch (Error e)
+    {
+      return false;
+    }
+    return true;
+  }
+
 }