From cb8e1cabf853c4d952ee1bbcda542a5d231db80a Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Thu, 19 Sep 2013 13:46:16 +0100 Subject: [PATCH] JWS-17: fix problem with undefined URL for the furtherDetails tag --- datamodel/compbio/metadata/Argument.java | 46 ++++++++--------- datamodel/compbio/metadata/Limit.java | 5 +- datamodel/compbio/metadata/LimitsManager.java | 9 ++-- datamodel/compbio/metadata/Option.java | 39 +++++++++++---- datamodel/compbio/metadata/Parameter.java | 4 +- datamodel/compbio/metadata/Preset.java | 3 +- datamodel/compbio/metadata/PresetManager.java | 4 +- datamodel/compbio/metadata/ValueConstrain.java | 4 +- runner/compbio/runner/Util.java | 55 ++++++--------------- webservices/compbio/ws/client/Jws2Client.java | 23 +++++++-- webservices/compbio/ws/client/MetadataHelper.java | 29 ++++++----- 11 files changed, 118 insertions(+), 103 deletions(-) diff --git a/datamodel/compbio/metadata/Argument.java b/datamodel/compbio/metadata/Argument.java index 60a8f86..ac8d02a 100644 --- a/datamodel/compbio/metadata/Argument.java +++ b/datamodel/compbio/metadata/Argument.java @@ -32,35 +32,35 @@ import java.util.List; * Date December 2009 * @param * executable type - */ +*/ public interface Argument { - URL getFurtherDetails(); + String getFurtherDetails(); - String getDefaultValue(); + String getDefaultValue(); - String getDescription(); + String getDescription(); - String getName(); + String getName(); - /** - * - * @return List of values allowed for an Argument - */ - List getPossibleValues(); + /** + * + * @return List of values allowed for an Argument + */ + List getPossibleValues(); - /** - * Set default values for the parameter or an option - * - * @param defaultValue - * the value to be set - * @throws WrongParameterException - * - when the value to be set is illegal. Wrong value for - * numeric parameter is the value defined outside it , for - * string type parameter, wrong value is the one which is not - * listed in possible values list - * @see ValueConstrain - */ - void setValue(String defaultValue) throws WrongParameterException; + /** + * Set default values for the parameter or an option + * + * @param defaultValue + * the value to be set + * @throws WrongParameterException + * - when the value to be set is illegal. Wrong value for + * numeric parameter is the value defined outside it , for + * string type parameter, wrong value is the one which is not + * listed in possible values list + * @see ValueConstrain + */ + void setValue(String defaultValue) throws WrongParameterException; } diff --git a/datamodel/compbio/metadata/Limit.java b/datamodel/compbio/metadata/Limit.java index 9910e73..8132832 100644 --- a/datamodel/compbio/metadata/Limit.java +++ b/datamodel/compbio/metadata/Limit.java @@ -157,13 +157,12 @@ public class Limit { public String toString() { String value = ""; if (isDefault) { - value = "Default Limit" + SysPrefs.newlinechar; + value = "Default Limits:" + SysPrefs.newlinechar; } else { - value = "Limit for Preset '" + preset + "'" + SysPrefs.newlinechar; + value = "Limits for Preset '" + preset + "'" + SysPrefs.newlinechar; } value += "Maximum sequence number=" + seqNumber + SysPrefs.newlinechar; value += "Average sequence length=" + seqLength + SysPrefs.newlinechar; - value += SysPrefs.newlinechar; return value; } diff --git a/datamodel/compbio/metadata/LimitsManager.java b/datamodel/compbio/metadata/LimitsManager.java index 94de517..ee40a94 100644 --- a/datamodel/compbio/metadata/LimitsManager.java +++ b/datamodel/compbio/metadata/LimitsManager.java @@ -54,12 +54,11 @@ public class LimitsManager { @Override public String toString() { - if (limit == null) { - return ""; - } String value = ""; - for (Limit lim : limit) { - value += lim.toString(); + if (null != limit) { + for (Limit lim : limit) { + value += lim.toString(); + } } return value; } diff --git a/datamodel/compbio/metadata/Option.java b/datamodel/compbio/metadata/Option.java index 3f47bb0..93361dd 100644 --- a/datamodel/compbio/metadata/Option.java +++ b/datamodel/compbio/metadata/Option.java @@ -18,6 +18,7 @@ package compbio.metadata; +import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.HashSet; @@ -30,6 +31,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlTransient; import compbio.util.SysPrefs; import compbio.util.Util; @@ -59,15 +61,17 @@ public class Option implements Argument { @XmlAttribute protected boolean isRequired; @XmlElement - protected URL furtherDetails; + protected String furtherDetails; @XmlElement protected String defaultValue; + @XmlTransient + private URL basicURL; Option() { // Has to have no arg constructor for JAXB } - public Option(String name, String description) { + public Option(String name, String description) throws MalformedURLException { this.name = name; this.description = description; } @@ -83,6 +87,16 @@ public class Option implements Argument { this.name = name; } + public void setBasicURL(URL url) { + this.basicURL = url; + } + public URL getBasicURL() throws MalformedURLException { + URL out = new URL ("http://unknown.jabaws.server.ac.uk"); + if (null != basicURL) { + out = basicURL; + } + return out; + } /** * A long description of the Option */ @@ -96,12 +110,13 @@ public class Option implements Argument { /** * The URL where further details about the option can be found + * @throws MalformedURLException */ - public URL getFurtherDetails() { + public String getFurtherDetails() { return furtherDetails; } - public void setFurtherDetails(URL furtherDetails) { + public void setFurtherDetails(String furtherDetails) { this.furtherDetails = furtherDetails; } @@ -190,17 +205,23 @@ public class Option implements Argument { String value = "Option name: " + this.name + SysPrefs.newlinechar; value += "Description: " + this.description + SysPrefs.newlinechar; if (!Util.isEmpty(defaultValue)) { - value += "Default value: " + this.defaultValue - + SysPrefs.newlinechar; + value += "Default value: " + this.defaultValue + SysPrefs.newlinechar; + } + if (null != this.furtherDetails) { + value += "URL: " + this.basicURL + this.furtherDetails + SysPrefs.newlinechar; + } else { + value += "URL: unknown URL" + SysPrefs.newlinechar; } - value += "URL: " + this.furtherDetails + SysPrefs.newlinechar; value += "Is required: " + this.isRequired + SysPrefs.newlinechar; if (!this.optionNames.isEmpty()) { Set sortedPosval = new TreeSet(this.optionNames); - value += "Option Names: " + SysPrefs.newlinechar; + value += "Option(s): "; + String delim = ""; for (String val : sortedPosval) { - value += val + SysPrefs.newlinechar; + value += delim + val; + delim = ", "; } + value += SysPrefs.newlinechar; } return value; } diff --git a/datamodel/compbio/metadata/Parameter.java b/datamodel/compbio/metadata/Parameter.java index dcbf3d3..b89f150 100644 --- a/datamodel/compbio/metadata/Parameter.java +++ b/datamodel/compbio/metadata/Parameter.java @@ -18,6 +18,7 @@ package compbio.metadata; +import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -57,7 +58,7 @@ public class Parameter extends Option { // JAXB noargs const } - public Parameter(String name, String description) { + public Parameter(String name, String description) throws MalformedURLException { super(name, description); } @@ -85,7 +86,6 @@ public class Parameter extends Option { value += val + SysPrefs.newlinechar; } } - value += SysPrefs.newlinechar; return value; } diff --git a/datamodel/compbio/metadata/Preset.java b/datamodel/compbio/metadata/Preset.java index 06f0fd5..bca49d4 100644 --- a/datamodel/compbio/metadata/Preset.java +++ b/datamodel/compbio/metadata/Preset.java @@ -149,11 +149,10 @@ public class Preset { public String toString() { String value = "Preset name: '" + name + "'" + SysPrefs.newlinechar; value += "Description: " + description + SysPrefs.newlinechar; - value += "Options: " + SysPrefs.newlinechar; + value += "Options used: " + SysPrefs.newlinechar; for (String oname : this.option) { value += oname + SysPrefs.newlinechar; } - value += SysPrefs.newlinechar; return value; } diff --git a/datamodel/compbio/metadata/PresetManager.java b/datamodel/compbio/metadata/PresetManager.java index ed12fc0..b49bfc3 100644 --- a/datamodel/compbio/metadata/PresetManager.java +++ b/datamodel/compbio/metadata/PresetManager.java @@ -161,9 +161,9 @@ public class PresetManager { @Override public String toString() { - String value = "Runner: " + this.runnerClassName; + String value = "Runner: " + this.runnerClassName + "\n"; for (Preset p : preset) { - value += p.toString() + "\n"; + value += "##############################################################################\n" + p.toString() + "\n"; } return value; } diff --git a/datamodel/compbio/metadata/ValueConstrain.java b/datamodel/compbio/metadata/ValueConstrain.java index 375a02c..2b99ecd 100644 --- a/datamodel/compbio/metadata/ValueConstrain.java +++ b/datamodel/compbio/metadata/ValueConstrain.java @@ -126,10 +126,10 @@ public class ValueConstrain { public String toString() { String value = "Type: " + this.type + "\n"; if (this.min != null) { - value += "Min: " + this.min + "\n"; + value += "Minimal value: " + this.min + "\n"; } if (this.max != null) { - value += "Max: " + this.max + "\n"; + value += "Maximal value: " + this.max + "\n"; } return value; } diff --git a/runner/compbio/runner/Util.java b/runner/compbio/runner/Util.java index a0123a2..f8d7b80 100644 --- a/runner/compbio/runner/Util.java +++ b/runner/compbio/runner/Util.java @@ -52,12 +52,9 @@ public final class Util { try { return ConfExecutable.getRunnerOptions(clazz); } catch (FileNotFoundException e) { - log.error( - "Could not load " + clazz + " Parameters !" - + e.getMessage(), e.getCause()); + log.error("Could not load " + clazz + " parameters !" + e.getMessage(), e.getCause()); } catch (IOException e) { - log.error("IO exception while reading " + clazz + " Parameters !" - + e.getMessage(), e.getCause()); + log.error("IO exception while reading " + clazz + " parameters !" + e.getMessage(), e.getCause()); } return null; } @@ -67,28 +64,21 @@ public final class Util { try { return ConfExecutable.getRunnerPresets(clazz); } catch (FileNotFoundException e) { - log.warn( - "No presets are found for " + clazz + " executable! " - + e.getLocalizedMessage(), e.getCause()); + log.warn("No presets are found for " + clazz + "! " + e.getLocalizedMessage(), e.getCause()); } catch (IOException e) { - log.warn("IO exception while reading presents! for " + clazz - + " executable! " + e.getLocalizedMessage(), e.getCause()); + log.warn("IO exception while reading presets for " + clazz + "! " + e.getLocalizedMessage(), e.getCause()); } return null; } - public static final Alignment readClustalFile(String workDirectory, - String clustFile) throws UnknownFileFormatException, IOException, - FileNotFoundException, NullPointerException { + public static final Alignment readClustalFile(String workDirectory, String clustFile) + throws UnknownFileFormatException, IOException, FileNotFoundException, NullPointerException { assert !compbio.util.Util.isEmpty(workDirectory); assert !compbio.util.Util.isEmpty(clustFile); - File cfile = new File(compbio.engine.client.Util.getFullPath( - workDirectory, clustFile)); + File cfile = new File(compbio.engine.client.Util.getFullPath(workDirectory, clustFile)); log.trace("CLUSTAL OUTPUT FILE PATH: " + cfile.getAbsolutePath()); if (!(cfile.exists() && cfile.length() > 0)) { - throw new FileNotFoundException("Result for the jobId " - + workDirectory + " with file name " + clustFile - + " is not found!"); + throw new FileNotFoundException("Result for the jobId " + workDirectory + " with file name " + clustFile + " is not found!"); } return ClustalAlignmentUtil.readClustalFile(cfile); } @@ -102,9 +92,7 @@ public final class Util { workDirectory, clustFile)); log.trace("Jronn OUTPUT FILE PATH: " + cfile.getAbsolutePath()); if (!(cfile.exists() && cfile.length() > 0)) { - throw new FileNotFoundException("Result for the jobId " - + workDirectory + " with file name " + clustFile - + " is not found!"); + throw new FileNotFoundException("Result for the jobId " + workDirectory + " with file name " + clustFile + " is not found!"); } return SequenceUtil.readJRonn(cfile); } @@ -118,17 +106,13 @@ public final class Util { SequenceUtil.writeFasta(fout, sequences); fout.close(); } catch (IOException e) { - log.error("IOException while writing input file into the disk: " - + e.getLocalizedMessage(), e); - throw new JobSubmissionException( - "We are sorry by JABAWS server seems to have a problem! " - + e.getLocalizedMessage(), e); + log.error("IOException while writing input file into the disk: " + e.getLocalizedMessage(), e); + throw new JobSubmissionException("We are sorry by JABAWS server seems to have a problem! " + e.getLocalizedMessage(), e); } } public static void writeClustalInput(List sequences, ConfiguredExecutable exec, char gapChar) throws JobSubmissionException { - try { File filein = new File(exec.getInput()); FileOutputStream fout = new FileOutputStream(filein); @@ -136,11 +120,8 @@ public final class Util { SequenceUtil.writeClustal(fout, sequences, gapChar); fout.close(); } catch (IOException e) { - log.error("IOException while writing input file into the disk: " - + e.getLocalizedMessage(), e); - throw new JobSubmissionException( - "We are sorry but JABAWS server seems to have a problem! " - + e.getLocalizedMessage(), e); + log.error("IOException while writing input file into the disk: " + e.getLocalizedMessage(), e); + throw new JobSubmissionException("We are sorry but JABAWS server seems to have a problem! " + e.getLocalizedMessage(), e); } } @@ -150,16 +131,12 @@ public final class Util { assert !compbio.util.Util.isEmpty(workDirectory); assert !compbio.util.Util.isEmpty(structFile); // The stdout from RNAalifold - File sFile = new File(compbio.engine.client.Util.getFullPath( - workDirectory, structFile)); + File sFile = new File(compbio.engine.client.Util.getFullPath( workDirectory, structFile)); // Base pair probability matrix (-p option) - File aliFile = new File(compbio.engine.client.Util.getFullPath( - workDirectory, "alifold.out")); + File aliFile = new File(compbio.engine.client.Util.getFullPath( workDirectory, "alifold.out")); // Check that stdout file exists if(!(sFile.exists() && sFile.length() > 0)) { - throw new FileNotFoundException("Result for the jobId " - + workDirectory + "with file name " + structFile - + " is not found!"); + throw new FileNotFoundException("Result for the jobId " + workDirectory + "with file name " + structFile + " is not found!"); } // Check that base pair probability file exists if(!aliFile.exists()) { diff --git a/webservices/compbio/ws/client/Jws2Client.java b/webservices/compbio/ws/client/Jws2Client.java index 666fa58..dbe999a 100644 --- a/webservices/compbio/ws/client/Jws2Client.java +++ b/webservices/compbio/ws/client/Jws2Client.java @@ -57,7 +57,9 @@ import compbio.data.sequence.SequenceUtil; import compbio.data.sequence.UnknownFileFormatException; import compbio.metadata.JobSubmissionException; import compbio.metadata.Option; +import compbio.metadata.Limit; import compbio.metadata.Preset; +import compbio.metadata.PresetManager; import compbio.metadata.ResultNotAvailableException; import compbio.metadata.WrongParameterException; import compbio.util.FileUtil; @@ -193,13 +195,24 @@ public class Jws2Client { } if (CmdHelper.listParameters(cmd)) { - System.out.println(MetadataHelper.getParametersList(thews)); + List> opts = MetadataHelper.getParametersList(thews, hostname); + for (Option o : opts) { + System.out.println("##############################################################################\n" + o.toString()); + } } if (CmdHelper.listPresets(cmd)) { - System.out.println(MetadataHelper.getPresetList(thews)); + PresetManager psm = MetadataHelper.getPresetList(thews); + if (null != psm) { + System.out.print(psm); + } else { + System.out.println("No presets are defined for the Web service"); + } } if (CmdHelper.listLimits(cmd)) { - System.out.println(MetadataHelper.getLimits(thews)); + List> lims = MetadataHelper.getLimits(thews); + for (Limit l : lims) { + System.out.println("##############################################################################\n" + l.toString()); + } } log.fine("Disconnecting..."); ((Closeable) thews).close(); @@ -307,8 +320,8 @@ public class Jws2Client { private static void listAllServices(String hostname) throws WebServiceException, IOException { RegistryWS registry = connectToRegistry(hostname); - Set func_services = Collections.EMPTY_SET; - Set nonfunc_services = Collections.EMPTY_SET; + Set func_services = Collections.emptySet(); + Set nonfunc_services = Collections.emptySet(); if (registry != null) { func_services = registry.getSupportedServices(); nonfunc_services = registry.getNonoperatedServices(); diff --git a/webservices/compbio/ws/client/MetadataHelper.java b/webservices/compbio/ws/client/MetadataHelper.java index 4803e16..d5d8b06 100644 --- a/webservices/compbio/ws/client/MetadataHelper.java +++ b/webservices/compbio/ws/client/MetadataHelper.java @@ -22,6 +22,8 @@ import static compbio.ws.client.Constraints.pseparator; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.net.MalformedURLException; +import java.net.URL; import compbio.data.msa.Metadata; import compbio.metadata.Limit; @@ -42,16 +44,26 @@ public class MetadataHelper { * @param msaws * web service proxy * @return List of options supported by a web service + * @throws MalformedURLException */ - static List> getParametersList(Metadata msaws) { + static List> getParametersList(Metadata msaws, String host) throws MalformedURLException { assert msaws != null; RunnerConfig config = msaws.getRunnerOptions(); if (config == null) { return Collections.emptyList(); } - return config.getArguments(); + List> opts = config.getArguments(); + for (Option o : opts) { + o.setBasicURL(new URL(host + "/")); + } + return opts; } + static List> getParametersList(Metadata msaws) throws MalformedURLException { + return getParametersList (msaws, "http://unknown.jabaws.server.ac.uk"); + } + + /** * Returns an objects from which the list of presets supported by web * service can be obtained @@ -98,14 +110,12 @@ public class MetadataHelper { assert presetName != null; PresetManager presets = MetadataHelper.getPresetList(msaws); if (presets == null) { - System.out - .println("No presets are supported by the service! Ignoring -r directive!"); + System.out.println("No presets are supported by the service! Ignoring -r directive!"); return null; } Preset pre = presets.getPresetByName(presetName); if (pre == null) { - System.out.println("Cannot find preset: " + presetName - + " WARN: ignoring -r directive!"); + System.out.println("Cannot find preset: " + presetName + " WARN: ignoring -r directive!"); } return pre; } @@ -131,17 +141,14 @@ public class MetadataHelper { } Option o = options.getArgumentByOptionName(oname); if (o == null) { - System.out.println("WARN ignoring unsuppoted parameter: " - + oname); + System.out.println("WARN ignoring unsuppoted parameter: " + oname); continue; } if (isParameter(param)) { try { o.setValue(getParamValue(param)); } catch (WrongParameterException e) { - System.out - .println("Problem setting value for the parameter: " - + param); + System.out.println("Problem setting value for the parameter: " + param); e.printStackTrace(); } } -- 1.7.10.2