WStester & registry are completed
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Wed, 8 Jun 2011 10:09:43 +0000 (10:09 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Wed, 8 Jun 2011 10:09:43 +0000 (10:09 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4230 e3abac25-378b-4346-85de-24260fe3988d

webservices/compbio/ws/client/WSTester.java

index a0e635b..4db6778 100644 (file)
@@ -40,16 +40,13 @@ import compbio.data.sequence.FastaSequence;
 import compbio.data.sequence.ScoreManager;\r
 import compbio.data.sequence.SequenceUtil;\r
 import compbio.metadata.JobStatus;\r
-import compbio.metadata.JobSubmissionException;\r
 import compbio.metadata.Limit;\r
 import compbio.metadata.LimitsManager;\r
 import compbio.metadata.Option;\r
 import compbio.metadata.Preset;\r
 import compbio.metadata.PresetManager;\r
-import compbio.metadata.ResultNotAvailableException;\r
 import compbio.metadata.RunnerConfig;\r
 import compbio.metadata.UnsupportedRuntimeException;\r
-import compbio.metadata.WrongParameterException;\r
 import compbio.util.FileUtil;\r
 import compbio.util.Util;\r
 \r
@@ -170,31 +167,15 @@ public class WSTester {
                                        writer.println(OK);\r
                                }\r
                                succeed = true;\r
-                       } catch (UnsupportedRuntimeException e) {\r
-                               writer.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
-                               writer.println(FAILED);\r
-                               writer.println();\r
-                               writer.println(e.getLocalizedMessage());\r
-                               e.printStackTrace(writer);\r
-                               continue;\r
-                       } catch (WrongParameterException e) {\r
-                               // TODO custom message\r
-                               writer.println(FAILED);\r
-                               writer.println();\r
-                               writer.println(e.getLocalizedMessage());\r
-                               e.printStackTrace(writer);\r
-                               continue;\r
-                       } catch (ResultNotAvailableException e) {\r
-                               // TODO custom message\r
-                               writer.println(FAILED);\r
-                               writer.println();\r
-                               writer.println(e.getLocalizedMessage());\r
-                               e.printStackTrace(writer);\r
+                       } catch (Exception e) {\r
+                               if (e instanceof UnsupportedRuntimeException) {\r
+                                       // If executable is not supported than none of the presets\r
+                                       // are\r
+                                       // going to work\r
+                                       throw (UnsupportedRuntimeException) e;\r
+                               } else {\r
+                                       reportException(e);\r
+                               }\r
                                continue;\r
                        }\r
                }\r
@@ -245,15 +226,14 @@ public class WSTester {
                                                + wservice.getClass() + " is not supported! ");\r
                        }\r
                } catch (UnsupportedRuntimeException e) {\r
-                       writer.println(e.getLocalizedMessage());\r
-                       e.printStackTrace(writer);\r
+                       reportException(e);\r
                        return false;\r
                }\r
        }\r
 \r
        private <T> boolean testSequenceAnnotationWS(SequenceAnnotation<T> wservice)\r
                        throws UnsupportedRuntimeException {\r
-               writer.println("Calling analyse.........");\r
+               writer.print("Calling analyse.........");\r
                boolean success = testDefaultAnalyse(loadAlignment(), wservice, null,\r
                                null);\r
 \r
@@ -262,7 +242,7 @@ public class WSTester {
                        List<Preset<T>> presets = presetman.getPresets();\r
                        if (presets != null && !presets.isEmpty()) {\r
                                Preset<T> preset = presets.get(0);\r
-                               writer.println("Calling analyse with Preset.........");\r
+                               writer.print("Calling analyse with Preset.........");\r
                                success = testDefaultAnalyse(loadAlignment(), wservice, preset,\r
                                                null);\r
                        }\r
@@ -287,29 +267,27 @@ public class WSTester {
                        }\r
                        Thread.sleep(1000);\r
                        scores = wsproxy.getAnnotation(jobId);\r
-\r
-               } catch (JobSubmissionException e) {\r
-                       writer.println("Exception while submitting job to a web server. "\r
-                                       + "Exception details are below:");\r
-                       e.printStackTrace(writer);\r
-               } catch (ResultNotAvailableException e) {\r
-                       writer.println("Exception while waiting for results. "\r
-                                       + "Exception details are below:");\r
-                       e.printStackTrace(writer);\r
-               } catch (InterruptedException e) {\r
-                       // ignore and propagate an interruption\r
-                       Thread.currentThread().interrupt();\r
-                       writer.println("Exception while waiting for results. "\r
-                                       + "Exception details are below:");\r
-                       e.printStackTrace(writer);\r
-               } catch (WrongParameterException e) {\r
-                       writer.println("Exception while parsing the web method input parameters. "\r
-                                       + "Exception details are below:");\r
-                       e.printStackTrace(writer);\r
+                       if (scores != null) {\r
+                               writer.println(OK);\r
+                       }\r
+               } catch (Exception e) {\r
+                       if (e instanceof UnsupportedRuntimeException) {\r
+                               throw (UnsupportedRuntimeException) e;\r
+                       } else {\r
+                               reportException(e);\r
+                       }\r
                }\r
                return scores != null;\r
        }\r
 \r
+       private void reportException(Exception e) {\r
+               writer.println(FAILED);\r
+               writer.println("Exception while waiting for results. "\r
+                               + "Exception details are below:");\r
+               writer.println(e.getLocalizedMessage());\r
+               e.printStackTrace(writer);\r
+       }\r
+\r
        private <T> void testMetadata(Metadata<T> msaws)\r
                        throws UnsupportedRuntimeException {\r
 \r
@@ -375,9 +353,7 @@ public class WSTester {
                        if (e instanceof UnsupportedRuntimeException) {\r
                                throw (UnsupportedRuntimeException) e;\r
                        } else {\r
-                               writer.println(FAILED);\r
-                               writer.println(e.getLocalizedMessage());\r
-                               e.printStackTrace(writer);\r
+                               reportException(e);\r
                        }\r
                }\r
                if (al != null) {\r
@@ -385,7 +361,6 @@ public class WSTester {
                }\r
                return succeed;\r
        }\r
-\r
        /**\r
         * Test JWS2 web services\r
         * \r