JWS-17 re-design behaviour of Option.toString
[jabaws.git] / webservices / compbio / ws / client / MetadataHelper.java
index 4803e16..20a9f76 100644 (file)
@@ -22,6 +22,8 @@ import static compbio.ws.client.Constraints.pseparator;
 import java.util.ArrayList;\r
 import java.util.Collections;\r
 import java.util.List;\r
+import java.net.MalformedURLException;\r
+import java.net.URL;\r
 \r
 import compbio.data.msa.Metadata;\r
 import compbio.metadata.Limit;\r
@@ -53,6 +55,30 @@ public class MetadataHelper {
        }\r
 \r
        /**\r
+        * Returns a list of options supported by web service\r
+        * \r
+        * @param <T>\r
+        *            web service type\r
+        * @param msaws\r
+        *            web service proxy\r
+        * @param host\r
+        *            the server URL, as a string\r
+        * @return List of options supported by a web service\r
+        */\r
+       static <T> List<Option<T>> getParametersList(Metadata<T> msaws, String host) throws MalformedURLException {\r
+               assert msaws != null;\r
+               RunnerConfig<T> config = msaws.getRunnerOptions();\r
+               if (config == null) {\r
+                       return Collections.emptyList();\r
+               }\r
+               List<Option<T>> opts = config.getArguments();\r
+               for (Option<T> o : opts) {\r
+                       o.setBasicURL(new URL(host + "/"));\r
+               }\r
+               return opts;\r
+       }\r
+\r
+       /**\r
         * Returns an objects from which the list of presets supported by web\r
         * service <T> can be obtained\r
         * \r
@@ -98,14 +124,12 @@ public class MetadataHelper {
                assert presetName != null;\r
                PresetManager<T> presets = MetadataHelper.getPresetList(msaws);\r
                if (presets == null) {\r
-                       System.out\r
-                                       .println("No presets are supported by the service! Ignoring -r directive!");\r
+                       System.out.println("No presets are supported by the service! Ignoring -r directive!");\r
                        return null;\r
                }\r
                Preset<T> pre = presets.getPresetByName(presetName);\r
                if (pre == null) {\r
-                       System.out.println("Cannot find preset: " + presetName\r
-                                       + " WARN: ignoring -r directive!");\r
+                       System.out.println("Cannot find preset: " + presetName + " WARN: ignoring -r directive!");\r
                }\r
                return pre;\r
        }\r
@@ -131,17 +155,14 @@ public class MetadataHelper {
                        }\r
                        Option<T> o = options.getArgumentByOptionName(oname);\r
                        if (o == null) {\r
-                               System.out.println("WARN ignoring unsuppoted parameter: "\r
-                                               + oname);\r
+                               System.out.println("WARN ignoring unsuppoted parameter: " + oname);\r
                                continue;\r
                        }\r
                        if (isParameter(param)) {\r
                                try {\r
                                        o.setValue(getParamValue(param));\r
                                } catch (WrongParameterException e) {\r
-                                       System.out\r
-                                                       .println("Problem setting value for the parameter: "\r
-                                                                       + param);\r
+                                       System.out.println("Problem setting value for the parameter: " + param);\r
                                        e.printStackTrace();\r
                                }\r
                        }\r