Java doc and package infos from JWS" branch. Also rethink of MSAWS interface in light...
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Mon, 22 Nov 2010 15:38:01 +0000 (15:38 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Mon, 22 Nov 2010 15:38:01 +0000 (15:38 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@3345 e3abac25-378b-4346-85de-24260fe3988d

webservices/compbio/data/msa/JManagement.java
webservices/compbio/data/msa/Metadata.java
webservices/compbio/data/msa/MsaWS.java
webservices/compbio/data/msa/package-info.java [new file with mode: 0644]
webservices/compbio/ws/client/WSTester.java
webservices/compbio/ws/client/package-info.java [new file with mode: 0644]

index b9b2f01..8232260 100644 (file)
@@ -10,43 +10,44 @@ import compbio.metadata.JobStatus;
 public interface JManagement {\r
 \r
        /**\r
-        * Stop running job but leave its output untouched\r
+        * Stop running the job <code>jobId</code> but leave its output untouched\r
         * \r
         * @return true if job was cancelled successfully, false otherwise\r
         * @throws InvalidParameterException\r
-        *             thrown if jobId is empty or cannot be recognised e.g. in\r
+        *             is thrown if jobId is empty or cannot be recognised e.g. in\r
         *             invalid format\r
         */\r
        boolean cancelJob(@WebParam(name = "jobId") String jobId);\r
 \r
        /**\r
-        * Return the status of the job. @see JobStatus\r
+        * Return the status of the job.\r
         * \r
         * @param jobId\r
         *            - unique job identifier\r
         * @return JobStatus - status of the job\r
         * @throws InvalidParameterException\r
-        *             thrown if jobId is empty or cannot be recognised e.g. in\r
+        *             is thrown if jobId is empty or cannot be recognised e.g. in\r
         *             invalid format\r
+        * @see JobStatus\r
         */\r
        JobStatus getJobStatus(@WebParam(name = "jobId") String jobId);\r
 \r
        /**\r
         * Reads 1kb chunk from the statistics file which is specific to a given web\r
-        * service from the position. If in time of a request less then 1kb data is\r
-        * available from the position to the end of the file, then it returns all\r
-        * the data available from the position to the end of the file.\r
+        * service from the <code>position</code>. If in time of a request less then\r
+        * 1kb data is available from the position to the end of the file, then it\r
+        * returns all the data available from the position to the end of the file.\r
         * \r
         * @param jobId\r
         *            - unique job identifier\r
         * @param position\r
         *            - next position within the file to read\r
-        * @return ChunkHolder - @see ChunkHolder which contains a chuink of data\r
-        *         and a next position within the file from which no data has been\r
-        *         read\r
+        * @return ChunkHolder - which contains a chunk of data and a next position\r
+        *         within the file from which no data has been read\r
         * @throws InvalidParameterException\r
         *             thrown if jobId is empty or cannot be recognised e.g. in\r
         *             invalid format and also if the position value is negative\r
+        * @see ChunkHolder\r
         */\r
        ChunkHolder pullExecStatistics(@WebParam(name = "jobId") String jobId,\r
                        @WebParam(name = "position") long position);\r
index 67abb5d..e73e01d 100644 (file)
@@ -39,10 +39,6 @@ public interface Metadata<T> {
        /**\r
         * List Limits supported by a web service.\r
         * \r
-        * @param presetName\r
-        *            the name of the preset. if no name is provided, then the\r
-        *            default preset is returned. If no limit for a particular\r
-        *            preset is defined then the default preset is returned\r
         * @return LimitManager\r
         */\r
        LimitsManager<T> getLimits();\r
index b1735fb..d5b64f8 100644 (file)
@@ -50,8 +50,8 @@ public interface MsaWS<T> extends JManagement, Metadata<T> {
        /**\r
         * Align a list of sequences with default settings.\r
         * \r
-        * Any dataset containing a greater number of sequences or the average\r
-        * length of the sequences are greater then defined in the default Limit\r
+        * Any dataset containing a greater number of sequences or when the average\r
+        * length of the sequences are greater then defined in the default Limit,\r
         * will not be accepted for an alignment operation and\r
         * JobSubmissionException will be thrown.\r
         * \r
@@ -59,25 +59,25 @@ public interface MsaWS<T> extends JManagement, Metadata<T> {
         *            List of FastaSequence objects. The programme does not perform\r
         *            any sequence validity checks. Nor does it checks whether the\r
         *            sequences names are unique. It is responsibility of the caller\r
-        *            to validate this information\r
+        *            to make sure of this\r
         * @return jobId - unique identifier for the job\r
-        * @throws JobSubmissionException. This\r
-        *             exception is thrown when the job could not be submitted due\r
-        *             to the following reasons: 1) The number of sequences in the\r
+        * @throws JobSubmissionException\r
+        *             is thrown when the job could not be submitted due to the\r
+        *             following reasons: 1) The number of sequences in the\r
         *             submission or their average length is greater then defined by\r
         *             the default Limit. 2) Any problems on the server side e.g. it\r
         *             is misconfigured or malfunction, is reported via this\r
         *             exception. In the first case the information on the limit\r
         *             could be obtained from an exception.\r
         * @throws InvalidParameterException\r
-        *             thrown if input list of fasta sequence is null or empty\r
+        *             thrown if input list of FASTA sequences is null or empty\r
         * @throws UnsupportedRuntimeException\r
         *             thrown if server OS does not support native executables for a\r
-        *             given web service, e.g. JWS2 is deployed on Windows and Mafft\r
-        *             service is called\r
+        *             given web service, e.g. JABAWS is deployed on Windows and\r
+        *             Mafft service is called\r
         * @throws LimitExceededException\r
-        *             is throw if the input sequences number or average length\r
-        *             exceeds what is defined by the limit\r
+        *             is throw if the input sequences number or their average\r
+        *             length exceeds what is defined by the limit\r
         */\r
        String align(\r
                        @WebParam(name = "fastaSequences") List<FastaSequence> sequences)\r
@@ -100,9 +100,9 @@ public interface MsaWS<T> extends JManagement, Metadata<T> {
         * @param options\r
         *            A list of Options\r
         * @return jobId - unique identifier for the job\r
-        * @throws JobSubmissionException. This\r
-        *             exception is thrown when the job could not be submitted due\r
-        *             to the following reasons: 1) The number of sequences in the\r
+        * @throws JobSubmissionException\r
+        *             is thrown when the job could not be submitted due to the\r
+        *             following reasons: 1) The number of sequences in the\r
         *             submission or their average length is greater then defined by\r
         *             the default Limit. 2) Any problems on the server side e.g. it\r
         *             is misconfigured or malfunction, is reported via this\r
@@ -114,14 +114,14 @@ public interface MsaWS<T> extends JManagement, Metadata<T> {
         *             boundaries. In both cases exception object contain the\r
         *             information on the violating Option.\r
         * @throws InvalidParameterException\r
-        *             thrown if input list of fasta sequence is null or empty\r
+        *             thrown if input list of FASTA sequence is null or empty\r
         * @throws UnsupportedRuntimeException\r
         *             thrown if server OS does not support native executables for a\r
-        *             given web service, e.g. JWS2 is deployed on Windows and Mafft\r
-        *             service is called\r
+        *             given web service, e.g. JABAWS is deployed on Windows and\r
+        *             Mafft service is called\r
         * @throws LimitExceededException\r
-        *             is throw if the input sequences number or average length\r
-        *             exceeds what is defined by the limit\r
+        *             is throw if the input sequences number or their average\r
+        *             length exceeds what is defined by the limit\r
         */\r
        String customAlign(\r
                        @WebParam(name = "fastaSequences") List<FastaSequence> sequences,\r
@@ -130,7 +130,7 @@ public interface MsaWS<T> extends JManagement, Metadata<T> {
                        JobSubmissionException, WrongParameterException;\r
 \r
        /**\r
-        * Align a list of sequences with preset. @see Preset\r
+        * Align a list of sequences with preset.\r
         * \r
         * Limit for a presetName is used whether the calculation will be permitted\r
         * or denied. If no Limit was defined for a presetName, than default limit\r
@@ -144,9 +144,9 @@ public interface MsaWS<T> extends JManagement, Metadata<T> {
         * @param preset\r
         *            A list of Options\r
         * @return String - jobId - unique identifier for the job\r
-        * @throws JobSubmissionException. This\r
-        *             exception is thrown when the job could not be submitted due\r
-        *             to the following reasons: 1) The number of sequences in the\r
+        * @throws JobSubmissionException\r
+        *             is thrown when the job could not be submitted due to the\r
+        *             following reasons: 1) The number of sequences in the\r
         *             submission or their average length is greater then defined by\r
         *             the default Limit. 2) Any problems on the server side e.g. it\r
         *             is misconfigured or malfunction, is reported via this\r
@@ -158,14 +158,15 @@ public interface MsaWS<T> extends JManagement, Metadata<T> {
         *             boundaries. In both cases exception object contain the\r
         *             information on the violating Option.\r
         * @throws InvalidParameterException\r
-        *             thrown if input list of fasta sequence is null or empty\r
+        *             thrown if input list of FASTA sequence is null or empty\r
         * @throws UnsupportedRuntimeException\r
         *             thrown if server OS does not support native executables for a\r
-        *             given web service, e.g. JWS2 is deployed on Windows and Mafft\r
-        *             service is called\r
+        *             given web service, e.g. JABAWS is deployed on Windows and\r
+        *             Mafft service is called\r
         * @throws LimitExceededException\r
         *             is throw if the input sequences number or average length\r
         *             exceeds what is defined by the limit\r
+        * @see Preset\r
         */\r
        String presetAlign(\r
                        @WebParam(name = "fastaSequences") List<FastaSequence> sequences,\r
@@ -174,7 +175,8 @@ public interface MsaWS<T> extends JManagement, Metadata<T> {
                        JobSubmissionException, WrongParameterException;\r
 \r
        /**\r
-        * Return the result of the job.\r
+        * Return the result of the job. This method waits for the job\r
+        * <code>jobId</code> to complete before return.\r
         * \r
         * @param jobId\r
         *            a unique job identifier\r
@@ -182,13 +184,13 @@ public interface MsaWS<T> extends JManagement, Metadata<T> {
         * @throws ResultNotAvailableException\r
         *             this exception is throw if the job execution was not\r
         *             successful or the result of the execution could not be found.\r
-        *             (e.g. removed). Exception could also be thrown is dues to the\r
+        *             (e.g. removed). Exception could also be thrown due to the\r
         *             lower level problems on the server i.e. IOException,\r
         *             FileNotFoundException problems as well as\r
         *             UnknownFileFormatException.\r
         * @throws InvalidParameterException\r
-        *             thrown if jobId is empty or cannot be recognised e.g. in\r
-        *             invalid format\r
+        *             thrown if jobId is empty or is not recognised e.g. in invalid\r
+        *             format\r
         */\r
        Alignment getResult(@WebParam(name = "jobId") String jobId)\r
                        throws ResultNotAvailableException;\r
diff --git a/webservices/compbio/data/msa/package-info.java b/webservices/compbio/data/msa/package-info.java
new file mode 100644 (file)
index 0000000..49990db
--- /dev/null
@@ -0,0 +1,9 @@
+/**\r
+ * Web Service interfaces for JAva Bioinformatics Analysis Web Services. \r
+ * \r
+ * @author Peter Troshin \r
+ * @version 1.0        April 2010\r
+ * \r
+ */\r
+package compbio.data.msa;\r
+\r
index 6223de0..ddd6742 100644 (file)
@@ -50,317 +50,317 @@ import compbio.metadata.WrongParameterException;
  */\r
 public class WSTester {\r
 \r
-    /**\r
-     * Sequences to be used as input for all WS\r
-     */\r
-    static final String fastaInput = ">Foobar\n"\r
-           + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQLLPEEPYITAQLLNWRRRLCDWRALDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKA"\r
-           + "\n>Barbar\n"\r
-           + "ASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVAQGVGAVEPFAFLSEDASAAESVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESGVFEMDGFADDFGALLQALARRHGWLGI"\r
-           + "\n>Foofriend\n"\r
-           + "MTADGPRELLQLRAAVRHRPQDVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDHQLLPEEPYITAQLDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESI\n";\r
+       /**\r
+        * Sequences to be used as input for all WS\r
+        */\r
+       static final String fastaInput = ">Foobar\n"\r
+                       + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQLLPEEPYITAQLLNWRRRLCDWRALDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKA"\r
+                       + "\n>Barbar\n"\r
+                       + "ASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVAQGVGAVEPFAFLSEDASAAESVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESGVFEMDGFADDFGALLQALARRHGWLGI"\r
+                       + "\n>Foofriend\n"\r
+                       + "MTADGPRELLQLRAAVRHRPQDVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDHQLLPEEPYITAQLDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESI\n";\r
 \r
-    static final List<FastaSequence> seqs = loadSeqs();\r
+       static final List<FastaSequence> seqs = loadSeqs();\r
 \r
-    private static final String FAILED = "FAILED";\r
-    private static final String OK = "OK";\r
+       private static final String FAILED = "FAILED";\r
+       private static final String OK = "OK";\r
 \r
-    /**\r
-     * Converting input to a form accepted by WS\r
-     * \r
-     * @return List of FastaSequence records\r
-     */\r
-    static List<FastaSequence> loadSeqs() {\r
-       try {\r
-           return SequenceUtil.readFasta(new ByteArrayInputStream(fastaInput\r
-                   .getBytes()));\r
-       } catch (IOException ignored) {\r
-           // Should not happen as a source is not a external stream\r
-           ignored.printStackTrace();\r
+       /**\r
+        * Converting input to a form accepted by WS\r
+        * \r
+        * @return List of FastaSequence records\r
+        */\r
+       static List<FastaSequence> loadSeqs() {\r
+               try {\r
+                       return SequenceUtil.readFasta(new ByteArrayInputStream(fastaInput\r
+                                       .getBytes()));\r
+               } catch (IOException ignored) {\r
+                       // Should not happen as a source is not a external stream\r
+                       ignored.printStackTrace();\r
+               }\r
+               return null;\r
        }\r
-       return null;\r
-    }\r
 \r
-    /**\r
-     * Prints usage\r
-     */\r
-    static void printUsage() {\r
-       System.out.println("Usage: <Class or Jar file name> "\r
-               + Jws2Client.hostkey + Jws2Client.pseparator\r
-               + "host_and_context " + "<" + Jws2Client.servicekey\r
-               + Jws2Client.pseparator + "serviceName>");\r
-       System.out.println();\r
-       System.out\r
-               .println(Jws2Client.hostkey\r
-                       + Jws2Client.pseparator\r
-                       + "<host_and_context> - a full URL to the JWS2 web server including context path e.g. http://10.31.1.159:8080/ws");\r
-       System.out\r
-               .println(Jws2Client.servicekey\r
-                       + Jws2Client.pseparator\r
-                       + "<ServiceName> - optional if unspecified all services are tested otherwise one of "\r
-                       + Arrays.toString(Services.values()));\r
-       System.out.println();\r
+       /**\r
+        * Prints usage\r
+        */\r
+       static void printUsage() {\r
+               System.out.println("Usage: <Class or Jar file name> "\r
+                               + Jws2Client.hostkey + Jws2Client.pseparator\r
+                               + "host_and_context " + "<" + Jws2Client.servicekey\r
+                               + Jws2Client.pseparator + "serviceName>");\r
+               System.out.println();\r
+               System.out\r
+                               .println(Jws2Client.hostkey\r
+                                               + Jws2Client.pseparator\r
+                                               + "<host_and_context> - a full URL to the JABAWS web server including context path e.g. http://10.31.1.159:8080/ws");\r
+               System.out\r
+                               .println(Jws2Client.servicekey\r
+                                               + Jws2Client.pseparator\r
+                                               + "<ServiceName> - optional if unspecified all services are tested otherwise one of "\r
+                                               + Arrays.toString(Services.values()));\r
+               System.out.println();\r
 \r
-    }\r
+       }\r
 \r
-    /**\r
-     * Calls alignment with preset\r
-     * \r
-     * @param <T>\r
-     * @param msaws\r
-     * @param presets\r
-     *            list of the Preset\r
-     * @throws UnsupportedRuntimeException\r
-     */\r
-    static <T> boolean presetAlign(MsaWS<T> msaws, List<Preset<T>> presets)\r
-           throws UnsupportedRuntimeException {\r
-       boolean succeed = false;\r
-       for (Preset<T> preset : presets) {\r
-           System.out.print("Aligning with preset '" + preset.getName()\r
-                   + "'... ");\r
-           Alignment al = null;\r
-           try {\r
-               String taskId = msaws.presetAlign(seqs, preset);\r
-               al = msaws.getResult(taskId);\r
-               if (al != null) {\r
-                   System.out.println(OK);\r
+       /**\r
+        * Calls alignment with preset\r
+        * \r
+        * @param <T>\r
+        * @param msaws\r
+        * @param presets\r
+        *            list of the Preset\r
+        * @throws UnsupportedRuntimeException\r
+        */\r
+       static <T> boolean presetAlign(MsaWS<T> msaws, List<Preset<T>> presets)\r
+                       throws UnsupportedRuntimeException {\r
+               boolean succeed = false;\r
+               for (Preset<T> preset : presets) {\r
+                       System.out.print("Aligning with preset '" + preset.getName()\r
+                                       + "'... ");\r
+                       Alignment al = null;\r
+                       try {\r
+                               String taskId = msaws.presetAlign(seqs, preset);\r
+                               al = msaws.getResult(taskId);\r
+                               if (al != null) {\r
+                                       System.out.println(OK);\r
+                               }\r
+                               succeed = true;\r
+                       } catch (UnsupportedRuntimeException e) {\r
+                               System.out.println(FAILED);\r
+                               // If executable is not supported than none of the presets are\r
+                               // going to work\r
+                               throw new UnsupportedRuntimeException(e);\r
+                       } catch (JobSubmissionException e) {\r
+                               // TODO custom message\r
+                               System.out.println(FAILED);\r
+                               System.out.println();\r
+                               e.printStackTrace();\r
+                               continue;\r
+                       } catch (WrongParameterException e) {\r
+                               // TODO custom message\r
+                               System.out.println(FAILED);\r
+                               System.out.println();\r
+                               e.printStackTrace();\r
+                               continue;\r
+                       } catch (ResultNotAvailableException e) {\r
+                               // TODO custom message\r
+                               System.out.println(FAILED);\r
+                               System.out.println();\r
+                               e.printStackTrace();\r
+                               continue;\r
+                       }\r
                }\r
-               succeed = true;\r
-           } catch (UnsupportedRuntimeException e) {\r
-               System.out.println(FAILED);\r
-               // If executable is not supported than none of the presets are\r
-               // going to work\r
-               throw new UnsupportedRuntimeException(e);\r
-           } catch (JobSubmissionException e) {\r
-               // TODO custom message\r
-               System.out.println(FAILED);\r
-               System.out.println();\r
-               e.printStackTrace();\r
-               continue;\r
-           } catch (WrongParameterException e) {\r
-               // TODO custom message\r
-               System.out.println(FAILED);\r
-               System.out.println();\r
-               e.printStackTrace();\r
-               continue;\r
-           } catch (ResultNotAvailableException e) {\r
-               // TODO custom message\r
-               System.out.println(FAILED);\r
-               System.out.println();\r
-               e.printStackTrace();\r
-               continue;\r
-           }\r
+               return succeed;\r
        }\r
-       return succeed;\r
-    }\r
 \r
-    /**\r
-     * Call most of web services functions and check the output\r
-     * \r
-     * @param <T>\r
-     *            web service type\r
-     * @param msaws\r
-     * @throws UnsupportedRuntimeException\r
-     *             is thrown if the connection to a web service was made, but\r
-     *             the web service is not functional. e.g. when native\r
-     *             executable does not exists for a server platform\r
-     */\r
-    static <T> boolean checkService(MsaWS<T> msaws)\r
-           throws UnsupportedRuntimeException {\r
+       /**\r
+        * Call most of web services functions and check the output\r
+        * \r
+        * @param <T>\r
+        *            web service type\r
+        * @param msaws\r
+        * @throws UnsupportedRuntimeException\r
+        *             is thrown if the connection to a web service was made, but\r
+        *             the web service is not functional. e.g. when native\r
+        *             executable does not exists for a server platform\r
+        */\r
+       static <T> boolean checkService(MsaWS<T> msaws)\r
+                       throws UnsupportedRuntimeException {\r
 \r
-       boolean succeed = testDefaultAlignment(msaws);\r
+               boolean succeed = testDefaultAlignment(msaws);\r
 \r
-       // If exception above is thrown than the tests below is not run\r
+               // If exception above is thrown than the tests below is not run\r
 \r
-       PresetManager<T> pmanager = msaws.getPresets();\r
-       if (pmanager != null && pmanager.getPresets().size() > 0) {\r
-           System.out.println("Testing alignment with presets:");\r
-           List<Preset<T>> plist = pmanager.getPresets();\r
-           succeed = !succeed ? presetAlign(msaws, plist) : succeed;\r
-       }\r
+               PresetManager<T> pmanager = msaws.getPresets();\r
+               if (pmanager != null && pmanager.getPresets().size() > 0) {\r
+                       System.out.println("Testing alignment with presets:");\r
+                       List<Preset<T>> plist = pmanager.getPresets();\r
+                       succeed = !succeed ? presetAlign(msaws, plist) : succeed;\r
+               }\r
 \r
-       System.out.print("Querying presets...");\r
+               System.out.print("Querying presets...");\r
 \r
-       if (pmanager != null && pmanager.getPresets().size() > 0) {\r
-           System.out.println(OK);\r
-       } else {\r
-           System.out.println("UNSUPPORTED");\r
-       }\r
+               if (pmanager != null && pmanager.getPresets().size() > 0) {\r
+                       System.out.println(OK);\r
+               } else {\r
+                       System.out.println("UNSUPPORTED");\r
+               }\r
 \r
-       System.out.print("Querying Parameters...");\r
-       RunnerConfig<T> options = msaws.getRunnerOptions();\r
-       if (options != null && options.getArguments().size() > 0) {\r
-           System.out.println(OK);\r
-       } else {\r
-           System.out.println(FAILED);\r
-           succeed = false;\r
-       }\r
+               System.out.print("Querying Parameters...");\r
+               RunnerConfig<T> options = msaws.getRunnerOptions();\r
+               if (options != null && options.getArguments().size() > 0) {\r
+                       System.out.println(OK);\r
+               } else {\r
+                       System.out.println(FAILED);\r
+                       succeed = false;\r
+               }\r
 \r
-       System.out.print("Querying Limits...");\r
-       LimitsManager<T> limits = msaws.getLimits();\r
-       if (limits != null && limits.getLimits().size() > 0) {\r
-           System.out.println(OK);\r
-       } else {\r
-           System.out.println("UNSUPPORTED");\r
-       }\r
+               System.out.print("Querying Limits...");\r
+               LimitsManager<T> limits = msaws.getLimits();\r
+               if (limits != null && limits.getLimits().size() > 0) {\r
+                       System.out.println(OK);\r
+               } else {\r
+                       System.out.println("UNSUPPORTED");\r
+               }\r
 \r
-       System.out.print("Querying Local Engine Limits...");\r
-       Limit<T> localLimit = msaws\r
-               .getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET);\r
-       if (localLimit != null) {\r
-           System.out.println(OK);\r
-       } else {\r
-           System.out.println("UNSUPPORTED");\r
+               System.out.print("Querying Local Engine Limits...");\r
+               Limit<T> localLimit = msaws\r
+                               .getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET);\r
+               if (localLimit != null) {\r
+                       System.out.println(OK);\r
+               } else {\r
+                       System.out.println("UNSUPPORTED");\r
+               }\r
+               return succeed;\r
        }\r
-       return succeed;\r
-    }\r
 \r
-    /**\r
-     * Align using default settings\r
-     * \r
-     * @param <T>\r
-     * @param msaws\r
-     * @throws UnsupportedRuntimeException\r
-     */\r
-    static <T> boolean testDefaultAlignment(MsaWS<T> msaws)\r
-           throws UnsupportedRuntimeException {\r
-       System.out.print("Testing alignment with default parameters:");\r
-       Alignment al = null;\r
-       boolean succeed = false;\r
-       try {\r
-           String taskId = msaws.align(seqs);\r
-           System.out.print("\nQuerying job status...");\r
-           JobStatus status = msaws.getJobStatus(taskId);\r
-           while (status != JobStatus.FINISHED) {\r
-               Thread.sleep(1000);\r
-               status = msaws.getJobStatus(taskId);\r
-           }\r
-           System.out.println(OK);\r
-           System.out.print("Retrieving results...");\r
-           al = msaws.getResult(taskId);\r
-           succeed = true;\r
-       } catch (ResultNotAvailableException e) {\r
-           System.out.println(FAILED);\r
-           e.printStackTrace();\r
-       } catch (JobSubmissionException e) {\r
-           System.out.println(FAILED);\r
-           System.out.println();\r
-           e.printStackTrace();\r
-       } catch (InterruptedException e) {\r
-           System.out.println(FAILED);\r
-           System.out.println();\r
-           e.printStackTrace();\r
-       }\r
-       if (al != null) {\r
-           System.out.println(OK);\r
+       /**\r
+        * Align using default settings\r
+        * \r
+        * @param <T>\r
+        * @param msaws\r
+        * @throws UnsupportedRuntimeException\r
+        */\r
+       static <T> boolean testDefaultAlignment(MsaWS<T> msaws)\r
+                       throws UnsupportedRuntimeException {\r
+               System.out.print("Testing alignment with default parameters:");\r
+               Alignment al = null;\r
+               boolean succeed = false;\r
+               try {\r
+                       String taskId = msaws.align(seqs);\r
+                       System.out.print("\nQuerying job status...");\r
+                       JobStatus status = msaws.getJobStatus(taskId);\r
+                       while (status != JobStatus.FINISHED) {\r
+                               Thread.sleep(1000);\r
+                               status = msaws.getJobStatus(taskId);\r
+                       }\r
+                       System.out.println(OK);\r
+                       System.out.print("Retrieving results...");\r
+                       al = msaws.getResult(taskId);\r
+                       succeed = true;\r
+               } catch (ResultNotAvailableException e) {\r
+                       System.out.println(FAILED);\r
+                       e.printStackTrace();\r
+               } catch (JobSubmissionException e) {\r
+                       System.out.println(FAILED);\r
+                       System.out.println();\r
+                       e.printStackTrace();\r
+               } catch (InterruptedException e) {\r
+                       System.out.println(FAILED);\r
+                       System.out.println();\r
+                       e.printStackTrace();\r
+               }\r
+               if (al != null) {\r
+                       System.out.println(OK);\r
+               }\r
+               return succeed;\r
        }\r
-       return succeed;\r
-    }\r
 \r
-    /**\r
-     * Connect to a WS using the host and the service name\r
-     * \r
-     * @param <T>\r
-     * @param host\r
-     * @param service\r
-     * @return\r
-     */\r
-    static <T> MsaWS<T> connect(String host, Services service) {\r
-       MsaWS<T> msaws = null;\r
-       try {\r
-           System.out.print("Connecting to service " + service + " on " + host\r
-                   + " ... ");\r
-           msaws = Jws2Client.connect(host, service);\r
-           System.out.println(OK);\r
-       } catch (WebServiceException e) {\r
-           System.out.println(FAILED);\r
+       /**\r
+        * Connect to a WS using the host and the service name\r
+        * \r
+        * @param <T>\r
+        * @param host\r
+        * @param service\r
+        * @return\r
+        */\r
+       static <T> MsaWS<T> connect(String host, Services service) {\r
+               MsaWS<T> msaws = null;\r
+               try {\r
+                       System.out.print("Connecting to service " + service + " on " + host\r
+                                       + " ... ");\r
+                       msaws = Jws2Client.connect(host, service);\r
+                       System.out.println(OK);\r
+               } catch (WebServiceException e) {\r
+                       System.out.println(FAILED);\r
+               }\r
+               return msaws;\r
        }\r
-       return msaws;\r
-    }\r
 \r
-    /**\r
-     * Test JWS2 web services\r
-     * \r
-     * @param <T>\r
-     *            web service type\r
-     * @param args\r
-     *            -h=<Your web application server host name, port and JWS2\r
-     *            context path>\r
-     * \r
-     *            -s=<ServiceName> which is optional. If service name is not\r
-     *            provided then all known JWS2 web services are tested\r
-     * @throws IOException\r
-     */\r
-    public static <T> void main(String[] args) throws IOException {\r
+       /**\r
+        * Test JWS2 web services\r
+        * \r
+        * @param <T>\r
+        *            web service type\r
+        * @param args\r
+        *            -h=<Your web application server host name, port and JWS2\r
+        *            context path>\r
+        * \r
+        *            -s=<ServiceName> which is optional. If service name is not\r
+        *            provided then all known JWS2 web services are tested\r
+        * @throws IOException\r
+        */\r
+       public static <T> void main(String[] args) throws IOException {\r
 \r
-       if (args == null || args.length < 1) {\r
-           printUsage();\r
-           System.exit(0);\r
-       }\r
-       String host = Jws2Client.getHost(args);\r
-       String serviceName = Jws2Client.getServiceName(args);\r
-       if (!Jws2Client.validURL(host)) {\r
-           System.out\r
-                   .println("<host_and_context> parameter is not provided or is incorrect!");\r
-           System.exit(1);\r
-       }\r
-       boolean succeed = false;\r
-       MsaWS<T> msaws = null;\r
-       if (serviceName != null) {\r
-           Services service = Services.getService(serviceName);\r
-           if (service == null) {\r
-               System.out.println("Service '" + serviceName\r
-                       + "' is not supported. Valid values are: "\r
-                       + Arrays.toString(Services.values()));\r
-               System.out.println();\r
-               printUsage();\r
-               System.exit(1);\r
-           }\r
+               if (args == null || args.length < 1) {\r
+                       printUsage();\r
+                       System.exit(0);\r
+               }\r
+               String host = Jws2Client.getHost(args);\r
+               String serviceName = Jws2Client.getServiceName(args);\r
+               if (!Jws2Client.validURL(host)) {\r
+                       System.out\r
+                                       .println("<host_and_context> parameter is not provided or is incorrect!");\r
+                       System.exit(1);\r
+               }\r
+               boolean succeed = false;\r
+               MsaWS<T> msaws = null;\r
+               if (serviceName != null) {\r
+                       Services service = Services.getService(serviceName);\r
+                       if (service == null) {\r
+                               System.out.println("Service '" + serviceName\r
+                                               + "' is not supported. Valid values are: "\r
+                                               + Arrays.toString(Services.values()));\r
+                               System.out.println();\r
+                               printUsage();\r
+                               System.exit(1);\r
+                       }\r
 \r
-           msaws = connect(host, service);\r
-           if (msaws == null) {\r
-               System.exit(1);\r
-           }\r
-           try {\r
-               succeed = checkService(msaws);\r
-           } catch (UnsupportedRuntimeException ignored) {\r
-               System.exit(1);\r
-           } finally {\r
-               ((Closeable) msaws).close();\r
-           }\r
-           reportResults(service, succeed);\r
-           System.exit(0);\r
-       }\r
+                       msaws = connect(host, service);\r
+                       if (msaws == null) {\r
+                               System.exit(1);\r
+                       }\r
+                       try {\r
+                               succeed = checkService(msaws);\r
+                       } catch (UnsupportedRuntimeException ignored) {\r
+                               System.exit(1);\r
+                       } finally {\r
+                               ((Closeable) msaws).close();\r
+                       }\r
+                       reportResults(service, succeed);\r
+                       System.exit(0);\r
+               }\r
 \r
-       System.out\r
-               .println("<ServiceName> is not provided checking all known services...");\r
+               System.out\r
+                               .println("<ServiceName> is not provided checking all known services...");\r
 \r
-       for (Services serv : Services.values()) {\r
-           System.out.println();\r
-           msaws = connect(host, serv);\r
-           if (msaws == null) {\r
-               continue;\r
-           }\r
-           try {\r
-               succeed = checkService(msaws);\r
-           } catch (UnsupportedRuntimeException ignored) {\r
-               System.out.println("Service " + serv + " IS NOT FUNCTIONAL");\r
-               continue;\r
-           } finally {\r
-               ((Closeable) msaws).close();\r
-           }\r
-           reportResults(serv, succeed);\r
-       }\r
+               for (Services serv : Services.values()) {\r
+                       System.out.println();\r
+                       msaws = connect(host, serv);\r
+                       if (msaws == null) {\r
+                               continue;\r
+                       }\r
+                       try {\r
+                               succeed = checkService(msaws);\r
+                       } catch (UnsupportedRuntimeException ignored) {\r
+                               System.out.println("Service " + serv + " IS NOT FUNCTIONAL");\r
+                               continue;\r
+                       } finally {\r
+                               ((Closeable) msaws).close();\r
+                       }\r
+                       reportResults(serv, succeed);\r
+               }\r
 \r
-    }\r
+       }\r
 \r
-    private static void reportResults(Services serv, boolean succeed) {\r
-       if (succeed) {\r
-           System.out.println("Check is completed. The Service " + serv\r
-                   + " IS WORKING");\r
-       } else {\r
-           System.out.println("Check is completed. The Service " + serv\r
-                   + " HAS SOME PROBLEMS");\r
+       private static void reportResults(Services serv, boolean succeed) {\r
+               if (succeed) {\r
+                       System.out.println("Check is completed. The Service " + serv\r
+                                       + " IS WORKING");\r
+               } else {\r
+                       System.out.println("Check is completed. The Service " + serv\r
+                                       + " HAS SOME PROBLEMS");\r
+               }\r
        }\r
-    }\r
 }\r
diff --git a/webservices/compbio/ws/client/package-info.java b/webservices/compbio/ws/client/package-info.java
new file mode 100644 (file)
index 0000000..303d76d
--- /dev/null
@@ -0,0 +1,10 @@
+/**\r
+ * A command line client and web services testing client for    \r
+ * JAva Bioinformatics Analysis Web Services. \r
+ * \r
+ * @author Peter Troshin \r
+ * @version 1.0        April 2010\r
+ * \r
+ */\r
+package compbio.ws.client;\r
+\r