JWS-17: fix problem with undefined URL for the furtherDetails tag
[jabaws.git] / webservices / compbio / ws / client / MetadataHelper.java
index 4803e16..d5d8b06 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
@@ -42,16 +44,26 @@ public class MetadataHelper {
         * @param msaws\r
         *            web service proxy\r
         * @return List of options supported by a web service\r
+        * @throws MalformedURLException \r
         */\r
-       static <T> List<Option<T>> getParametersList(Metadata<T> msaws) {\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
-               return config.getArguments();\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
+       static <T> List<Option<T>> getParametersList(Metadata<T> msaws) throws MalformedURLException {\r
+               return getParametersList (msaws, "http://unknown.jabaws.server.ac.uk");\r
+       }\r
+       \r
+       \r
        /**\r
         * Returns an objects from which the list of presets supported by web\r
         * service <T> can be obtained\r
@@ -98,14 +110,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 +141,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