Command line options are described and added to the client. Registry is modified...
[jabaws.git] / webservices / compbio / ws / client / Jws2Client.java
index 48d107d..c18f100 100644 (file)
@@ -32,6 +32,7 @@ import java.net.MalformedURLException;
 import java.net.URL;\r
 import java.util.Arrays;\r
 import java.util.List;\r
+import java.util.Set;\r
 import java.util.logging.Level;\r
 import java.util.logging.Logger;\r
 \r
@@ -42,6 +43,7 @@ import javax.xml.ws.WebServiceException;
 import compbio.data.msa.JABAService;\r
 import compbio.data.msa.Metadata;\r
 import compbio.data.msa.MsaWS;\r
+import compbio.data.msa.RegistryWS;\r
 import compbio.data.msa.SequenceAnnotation;\r
 import compbio.data.sequence.Alignment;\r
 import compbio.data.sequence.FastaSequence;\r
@@ -115,6 +117,13 @@ public class Jws2Client {
                        System.err.println("Host name is not valid!");\r
                        printUsage(1);\r
                }\r
+               // Just list available services and quit\r
+               boolean listServices = CmdHelper.listServices(cmd);\r
+               if (listServices) {\r
+                       listServices(hostname);\r
+                       System.exit(0);\r
+               }\r
+\r
                String serviceName = CmdHelper.getServiceName(cmd);\r
                if (serviceName == null) {\r
                        System.err.println("Service name is no provided!");\r
@@ -123,10 +132,17 @@ public class Jws2Client {
                Services service = Services.getService(serviceName);\r
                if (service == null) {\r
                        System.err.println("Service " + serviceName\r
-                                       + " is no supported! Valid values are: "\r
+                                       + " is no recognized! Valid values are: "\r
                                        + Arrays.toString(Services.values()));\r
                        printUsage(1);\r
                }\r
+               // Test service and quit\r
+               boolean testService = CmdHelper.testService(cmd);\r
+               if (testService) {\r
+                       testService(hostname, service);\r
+                       System.exit(0);\r
+               }\r
+\r
                File inputFile = IOHelper.getFile(cmd, inputkey, true);\r
                File outFile = IOHelper.getFile(cmd, outputkey, false);\r
                File parametersFile = IOHelper.getFile(cmd, paramFile, true);\r
@@ -182,6 +198,30 @@ public class Jws2Client {
                ((Closeable) msaws).close();\r
                log.fine("Disconnected successfully!");\r
        }\r
+\r
+       private void testService(String hostname, Services service)\r
+                       throws IOException {\r
+               RegistryWS registry = connectToRegistry(hostname);\r
+               if (registry != null) {\r
+                       String message = registry.testService(service);\r
+                       System.out.println("Service " + service + " testing results: ");\r
+                       System.out.println(message);\r
+                       ((Closeable) registry).close();\r
+               }\r
+       }\r
+\r
+       private void listServices(String hostname) throws IOException {\r
+               RegistryWS registry = connectToRegistry(hostname);\r
+               if (registry != null) {\r
+                       Set<Services> services = registry.getSupportedServices();\r
+                       System.out.println("Supported services are: "\r
+                                       + Services.toString(services));\r
+                       ((Closeable) registry).close();\r
+               } else {\r
+                       System.out.println("Failed to connect to the registry! ");\r
+               }\r
+       }\r
+\r
        /**\r
         * Calculate conservation for sequences loaded from the file\r
         * \r