[MOBY-guts] biomoby commit
Martin Senger
senger at dev.open-bio.org
Fri Feb 22 09:37:39 UTC 2008
senger
Fri Feb 22 04:37:38 EST 2008
Update of /home/repository/moby/moby-live/Java/src/Clients
In directory dev.open-bio.org:/tmp/cvs-serv29790/src/Clients
Modified Files:
MobyCmdLineClient.java MobyGraphs.java MosesGenerators.java
Log Message:
* Change, Fixed: On various places (starting with
org.biomoby.shared.Utils), starting to use Apache commons-io
library (it was necessary in Utils.java because the method
inputStreamToString() was broken anyway).
* Added: a common parent to the command-line clients
(org.biomoby.client.CmdLineHelper) - brinking more and unified
features to these clients.
moby-live/Java/src/Clients MobyCmdLineClient.java,1.15,1.16 MobyGraphs.java,1.11,1.12 MosesGenerators.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java 2007/05/31 13:42:51 1.15
+++ /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java 2008/02/22 09:37:38 1.16
@@ -5,8 +5,19 @@
// February 2003
//
-import org.biomoby.shared.*;
-import org.biomoby.client.*;
+import org.biomoby.shared.MobyResourceRef;
+import org.biomoby.shared.MobyNamespace;
+import org.biomoby.shared.MobyDataType;
+import org.biomoby.shared.MobyPrimaryDataSimple;
+import org.biomoby.shared.MobyService;
+import org.biomoby.shared.MobyServiceType;
+import org.biomoby.shared.MobySecondaryData;
+import org.biomoby.shared.MobyPrimaryDataSet;
+import org.biomoby.shared.NoSuccessException;
+import org.biomoby.shared.PendingCurationException;
+import org.biomoby.shared.Central;
+import org.biomoby.client.CmdLineHelper;
+import org.biomoby.client.CentralImpl;
import org.tulsoft.tools.BaseCmdLine;
import org.tulsoft.shared.FileUtils;
@@ -50,24 +61,8 @@
* @version $Id$
*/
-public class MobyCmdLineClient {
-
- /*************************************************************************
- * Return a help text how to use this client.
- *************************************************************************/
- public static String getUsage() {
- String helpFile = "help/MobyCmdLineClient_usage.txt";
- try {
- return new String (FileUtils.findAndGetBinaryFile (helpFile));
- } catch (GException e) {
- return
- "Sorry but an error occured.\n" +
- "I cannot find the help file '" + helpFile + "'.\n" +
- e.getMessage();
- }
- }
-
- static boolean verbose;
+public class MobyCmdLineClient
+ extends CmdLineHelper {
/*************************************************************************
*
@@ -77,43 +72,20 @@
public static void main (String [] args) {
try {
- BaseCmdLine cmd = new BaseCmdLine (args, true);
- if (cmd.hasParam ("-help") || cmd.hasParam ("-h")) {
- System.out.print (MobyCmdLineClient.getUsage());
- System.exit (0);
- }
-
- verbose = !cmd.hasOption ("-q");
+ BaseCmdLine cmd = getCmdLine (args, MobyCmdLineClient.class);
String param;
// where is a Moby registry
- Central worker = null;
- if ((param = cmd.getParam ("-registry")) == null) {
- worker = new CentralImpl (cmd.getParam ("-e"),
- cmd.getParam ("-uri"));
- } else {
- final Registries regList = RegistriesList.getInstance();
- Registry reg = regList.get (param);
- if (reg == null) {
- System.err.println ("ERROR: Failed to find registry " + param);
- System.exit (1);
- }
- worker = new CentralImpl (reg.getEndpoint(),
- reg.getNamespace());
- }
-
- if (cmd.hasOption ("-debug")) {
- worker.setDebug (true);
- }
+ Central worker = getRegistryWorker (cmd);
//
// no other arguments => say what endpoint and URI are in used
//
if (cmd.params.length == 0) {
decoration ("Registry endpoint: ");
- System.out.println (worker.getRegistryEndpoint());
+ msgln (worker.getRegistryEndpoint());
decoration ("Registry namespace: ");
- System.out.println (worker.getRegistryNamespace());
+ msgln (worker.getRegistryNamespace());
}
//
@@ -128,8 +100,8 @@
Map.Entry entry = (Map.Entry)it.next();
String[] names = (String[])entry.getValue();
for (int i = 0; i < names.length; i++) {
- System.out.println (names[i]);
- System.out.println ("\t" + entry.getKey());
+ msgln (names[i]);
+ msgln ("\t" + entry.getKey());
}
}
}
@@ -141,10 +113,10 @@
for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = (Map.Entry)it.next();
- System.out.println (entry.getKey());
+ msgln (entry.getKey());
String[] names = (String[])entry.getValue();
for (int i = 0; i < names.length; i++)
- System.out.println ("\t" + names[i]);
+ msgln ("\t" + names[i]);
}
}
@@ -154,7 +126,7 @@
String[] names = worker.getProviders();
for (int i = 0; i < names.length; i++) {
decoration ("\t");
- System.out.println (names[i]);
+ msgln (names[i]);
}
}
@@ -165,8 +137,8 @@
for (Iterator it = types.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = (Map.Entry)it.next();
- System.out.println (entry.getKey());
- System.out.println ("\t" + entry.getValue());
+ msgln (entry.getKey());
+ msgln ("\t" + entry.getValue());
}
}
@@ -175,7 +147,7 @@
decorationLn ("-----------");
MobyNamespace[] nms = worker.getFullNamespaces();
for (int i = 0; i < nms.length; i++) {
- System.out.println (nms[i]);
+ msgln (nms[i]);
}
}
@@ -186,8 +158,8 @@
for (Iterator it = types.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = (Map.Entry)it.next();
- System.out.println (entry.getKey());
- System.out.println ("\t" + entry.getValue());
+ msgln (entry.getKey());
+ msgln ("\t" + entry.getValue());
}
}
@@ -196,8 +168,8 @@
decorationLn ("--------------");
MobyResourceRef[] resourceRefs = worker.getResourceRefs();
for (int i = 0; i < resourceRefs.length; i++) {
- System.out.println (resourceRefs[i].getResourceName());
- System.out.println ("\t" + resourceRefs[i].getResourceLocation());
+ msgln (resourceRefs[i].getResourceName());
+ msgln ("\t" + resourceRefs[i].getResourceLocation());
}
}
@@ -207,7 +179,7 @@
decorationLn ("-------------------------");
final Registries regList = RegistriesList.getInstance();
for (Registry reg: regList.getAll()) {
- System.out.println (onlyNames ? reg.getSynonym() : reg.toString());
+ msgln (onlyNames ? reg.getSynonym() : reg.toString());
}
}
@@ -217,7 +189,7 @@
if ((param = cmd.getParam ("-data")) != null ) {
decorationLn ("Data type '" + param + "':");
decorationLn ("---------");
- System.out.println (worker.getDataType (param));
+ msgln (worker.getDataType (param));
}
if ((param = cmd.getParam ("-wsdl")) != null ) {
@@ -225,18 +197,18 @@
decorationLn ("----------------");
int pos = param.indexOf (",");
if (pos == -1)
- System.out.println (worker.getServiceWSDL (param));
+ msgln (worker.getServiceWSDL (param));
else if (pos == param.length() - 1)
- System.out.println (worker.getServiceWSDL (param, ""));
+ msgln (worker.getServiceWSDL (param, ""));
else
- System.out.println (worker.getServiceWSDL (param.substring (0, pos),
+ msgln (worker.getServiceWSDL (param.substring (0, pos),
param.substring (pos+1)));
}
if ((param = cmd.getParam ("-ot")) != null ) {
decorationLn ("Service type '" + param + "' is-a:");
decorationLn ("------------");
- System.out.println (StringUtils.join (worker.getServiceTypeRelationships (param, true),
+ msgln (StringUtils.join (worker.getServiceTypeRelationships (param, true),
"\n"));
}
@@ -247,8 +219,8 @@
for (Iterator it = types.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = (Map.Entry)it.next();
- System.out.println (entry.getKey());
- System.out.println ("\t" +
+ msgln (entry.getKey());
+ msgln ("\t" +
StringUtils.join ((String[])entry.getValue(),
"\n\t"));
}
@@ -258,7 +230,7 @@
if ((params != null && params[0] != null && params[1] != null)) {
decorationLn ("Relationships of data type '" + params[0] + "' of type '" + params[1] + "':");
decorationLn ("--------------------------");
- System.out.println (StringUtils.join (worker.getDataTypeRelationships (params[0], params[1]),
+ msgln (StringUtils.join (worker.getDataTypeRelationships (params[0], params[1]),
"\n"));
}
@@ -276,7 +248,7 @@
new BufferedReader (new InputStreamReader (worker.getResource (resourceName)));
String inputLine;
while ((inputLine = in.readLine()) != null)
- System.out.println (inputLine);
+ msgln (inputLine);
in.close();
}
}
@@ -404,16 +376,10 @@
data.setDataType (value);
if ((value = props.getProperty ("default")) != null)
data.setDefaultValue (value);
- if ((value = props.getProperty ("max")) != null) {
- try {
- data.setMaximumValue (Integer.valueOf (value).intValue());
- } catch (java.lang.NumberFormatException e) { }
- }
- if ((value = props.getProperty ("min")) != null) {
- try {
- data.setMinimumValue (Integer.valueOf (value).intValue());
- } catch (java.lang.NumberFormatException e) { }
- }
+ if ((value = props.getProperty ("max")) != null)
+ data.setMaxValue (value);
+ if ((value = props.getProperty ("min")) != null)
+ data.setMinValue (value);
for (Enumeration en = props.propertyNames(); en.hasMoreElements(); ) {
String propName = (String)en.nextElement();
if (propName.startsWith ("enum"))
@@ -640,7 +606,7 @@
decorationLn (params[1]);
}
decorationLn ("--------------");
- System.out.println (worker.call (params[0], params[1]));
+ msgln (worker.call (params[0], params[1]));
}
}
@@ -695,36 +661,34 @@
decorationLn (params[1]);
decorationLn ("---------------");
Central serviceWorker = new CentralImpl (serviceURL, "http://biomoby.org/");
- System.out.println (serviceWorker.call (methodName, params[1]));
+ msgln (serviceWorker.call (methodName, params[1]));
}
}
}
} catch (PendingCurationException e) {
- System.err.println ("===ERROR===");
- System.err.println ("Pending Curation");
- System.err.println ("===========");
+ emsgln ("===ERROR===");
+ emsgln ("Pending Curation");
+ emsgln ("===========");
} catch (NoSuccessException e) {
- System.err.println ("===ERROR===");
- System.err.println (e.getMessage());
- System.err.println (e.getCulprit());
- System.err.println ("===========");
-
- } catch (Exception e) {
- System.err.println ("===ERROR===");
- e.printStackTrace();
- System.err.println ("===========");
+ emsgln ("===ERROR===");
+ emsgln (e.getMessage());
+ emsgln ("" + e.getCulprit());
+ emsgln ("===========");
+
+ } catch (Throwable e) {
+ processErrorAndExit (e);
}
}
// print 'msg' but only if in verbose mode
static void decoration (String msg) {
- if (verbose) System.out.print (msg);
+ if (verbose) msg (msg);
}
static void decorationLn (String msg) {
- if (verbose) System.out.println (msg);
+ if (verbose) msgln (msg);
}
static MobyPrimaryDataSimple createSimple (String fname) {
@@ -742,7 +706,7 @@
}
return data;
} catch (IOException e) {
- System.err.println ("ERROR: Failed to read " + fname + " (" + e.toString() + ").");
+ emsgln ("ERROR: Failed to read " + fname + " (" + e.toString() + ").");
return null;
}
}
@@ -751,9 +715,9 @@
if (services != null) {
for (int i = 0; i < services.length; i++) {
if (onlyNames)
- System.out.println (services[i].getUniqueName());
+ msgln (services[i].getUniqueName());
else
- System.out.println (services[i]);
+ msgln (services[i]);
}
}
}
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java 2008/02/14 06:13:36 1.11
+++ /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java 2008/02/22 09:37:38 1.12
@@ -6,12 +6,21 @@
//
import org.biomoby.shared.*;
-import org.biomoby.client.*;
+import org.biomoby.shared.CentralAll;
+
+import org.biomoby.client.CmdLineHelper;
+import org.biomoby.client.CentralDigestCachedImpl;
+import org.biomoby.client.Graphviz;
+import org.biomoby.client.RDF;
+import org.biomoby.client.FilterServices;
+import org.biomoby.client.ServicesEdge;
+import org.biomoby.client.DataServiceEdge;
+import org.biomoby.client.ServiceConnections;
+import org.biomoby.client.Taverna;
import org.tulsoft.tools.BaseCmdLine;
-import org.tulsoft.shared.UUtils;
-import org.tulsoft.shared.FileUtils;
-import org.tulsoft.shared.GException;
+
+import org.apache.commons.lang.math.NumberUtils;
import java.util.*;
import java.io.*;
@@ -25,24 +34,8 @@
* @version $Id$
*/
-public class MobyGraphs {
-
- /*************************************************************************
- * Return a help text how to use this client.
- *************************************************************************/
- public static String getUsage() {
- String helpFile = "help/MobyGraphs_usage.txt";
- try {
- return new String (FileUtils.findAndGetBinaryFile (helpFile));
- } catch (GException e) {
- return
- "Sorry but an error occured.\n" +
- "I cannot find the help file '" + helpFile + "'.\n" +
- e.getMessage();
- }
- }
-
- static boolean verbose;
+public class MobyGraphs
+ extends CmdLineHelper {
/*************************************************************************
*
@@ -52,24 +45,11 @@
public static void main (String [] args) {
try {
- BaseCmdLine cmd = new BaseCmdLine (args, true);
- if (cmd.hasParam ("-help") || cmd.hasParam ("-h")) {
- System.out.print (MobyGraphs.getUsage());
- System.exit (0);
- }
-
- verbose = !cmd.hasOption ("-q");
-
- // where is a Moby registry
- CentralAll worker =
- new CentralDigestCachedImpl (cmd.getParam ("-e"),
- cmd.getParam ("-uri"),
- cmd.getParam ("-cachedir"));
+ BaseCmdLine cmd = getCmdLine (args, MobyGraphs.class);
String param;
- if (cmd.hasOption ("-debug")) {
- worker.setDebug (true);
- }
+ // where is a Moby registry
+ CentralAll worker = getCachableRegistryWorker (cmd);
// collect properties customizing graphs
Properties props = new Properties();
@@ -98,7 +78,7 @@
if (param == null)
param = cmd.getParam ("-f");
if (param == null)
- System.out.println (graph);
+ msgln (graph);
else
createFile (param, graph);
}
@@ -115,7 +95,7 @@
if (param == null)
param = cmd.getParam ("-f");
if (param == null)
- System.out.println (graph);
+ msgln (graph);
else
createFile (param, graph);
}
@@ -137,9 +117,9 @@
boolean xfileing = (xfile != null);
if (xfileing) {
- Vector ev = new Vector();
- Vector evs = new Vector();
- Vector eve = new Vector();
+ Vector<ServicesEdge> ev = new Vector<ServicesEdge>();
+ Vector<DataServiceEdge> evs = new Vector<DataServiceEdge>();
+ Vector<DataServiceEdge> eve = new Vector<DataServiceEdge>();
String line;
BufferedReader data = null;
data = new BufferedReader
@@ -175,7 +155,7 @@
edges = ServiceConnections.build (dataTypes, services);
}
- System.out.println ("EDGES: " + edges.length);
+ msgln ("EDGES: " + edges.length);
// filter edges
String[] authorities = null;
@@ -193,27 +173,27 @@
}
edges = FilterServices.filter (edges, authorities, serviceNames, depth);
- System.out.println ("Filtered EDGES: " + edges.length);
+ msgln ("Filtered EDGES: " + edges.length);
if (xfileing) {
- System.out.println ("List of EDGES: ");
+ msgln ("List of EDGES: ");
for (int i = 0; i < edges.length; i++) {
- System.out.println ("\t" + edges[i].toString());
+ msgln ("\t" + edges[i].toString());
}
}
if (cmd.hasParam ("-path")) {
String[] pathEnds = cmd.getParam ("-path", 2);
if (pathEnds[0] == null || pathEnds[1] == null) {
- System.err.println ("Missing value for parameter '-path'. It should be followed by two service names.");
- System.exit (1);
+ emsgln ("Missing value for parameter '-path'. It should be followed by two service names.");
+ exit (1);
}
// edges = FilterServices.pathes (edges, pathEnds[0], pathEnds[1]);
edges = FilterServices.pathes2 (edges, pathEnds[0], pathEnds[1]);
if (edges == null) {
- System.err.println ("No connection found between '" +
- pathEnds[0] + "' and '" + pathEnds[1] + "'");
- System.exit(1);
+ emsgln ("No connection found between '" +
+ pathEnds[0] + "' and '" + pathEnds[1] + "'");
+ exit(1);
}
}
@@ -223,8 +203,8 @@
if (cmd.hasParam ("-datapath")) {
pathEnds = cmd.getParam ("-datapath", 2);
if (pathEnds[0] == null || pathEnds[1] == null) {
- System.err.println ("Missing value for parameter '-datapath'. It should be followed by two data type names.");
- System.exit (1);
+ emsgln ("Missing value for parameter '-datapath'. It should be followed by two data type names.");
+ exit (1);
}
MobyPrimaryDataSimple sourceData = createSimpleData (pathEnds[0]);
MobyPrimaryDataSimple targetData = createSimpleData (pathEnds[1]);
@@ -240,58 +220,57 @@
else
endingEdges = debugEndingEdges;
- System.out.println ("SE: " + startingEdges.length);
+ msgln ("SE: " + startingEdges.length);
if (xfileing) {
for (int i = 0; i < startingEdges.length; i++) {
- System.out.println ("\t" + startingEdges[i].toString());
+ msgln ("\t" + startingEdges[i].toString());
}
}
- System.out.println ("EE: " + endingEdges.length);
+ msgln ("EE: " + endingEdges.length);
if (xfileing) {
for (int i = 0; i < endingEdges.length; i++) {
- System.out.println ("\t" + endingEdges[i].toString());
+ msgln ("\t" + endingEdges[i].toString());
}
}
// this creates *all* pathes, but some of them have cycles and inside branches
separatePaths = FilterServices.dataPaths (startingEdges, edges, endingEdges);
if (separatePaths.length == 0) {
- System.err.println ("No connection found between '" +
- pathEnds[0] + "' and '" + pathEnds[1] + "'");
- System.exit(1);
+ emsgln ("No connection found between '" +
+ pathEnds[0] + "' and '" + pathEnds[1] + "'");
+ exit(1);
}
- System.out.println ("After dataPaths: " + separatePaths.length);
+ msgln ("After dataPaths: " + separatePaths.length);
if (xfileing) {
for (int i = 0; i < separatePaths.length; i++) {
- System.out.println ("Separate data path " + (i+1));
+ msgln ("Separate data path " + (i+1));
for (int j = 0; j < separatePaths[i].length; j++) {
- System.out.println ("\t" + separatePaths[i][j]);
+ msgln ("\t" + separatePaths[i][j]);
}
}
}
allPaths = FilterServices.joinPaths (separatePaths);
- System.out.println ("After joinPaths: " + allPaths.length);
+ msgln ("After joinPaths: " + allPaths.length);
if (xfileing) {
- System.out.println ("Join paths: ");
+ msgln ("Join paths: ");
for (int i = 0; i < allPaths.length; i++) {
- System.out.println ("\t" + allPaths[i].toString());
+ msgln ("\t" + allPaths[i].toString());
}
}
// separate paths to straight paths (no cycles, no branches)
separatePaths = FilterServices.straightDataPaths (startingEdges, allPaths, endingEdges);
- System.out.println ("After straightDataPaths: " + separatePaths.length);
-// System.exit (1);
+ msgln ("After straightDataPaths: " + separatePaths.length);
}
// create a graph (in whatever format)
if (cmd.hasParam ("-datapath")) {
boolean generateScufl = ( cmd.hasOption ("-scufl") || cmd.hasOption ("-onlyscufl") );
boolean generateGraph = (! cmd.hasOption ("-onlyscufl") );
- int pageSize = UUtils.toInt (cmd.getParam ("-join"));
+ int pageSize = NumberUtils.toInt (cmd.getParam ("-join"));
String[] graphs = null;
String[] pathNames = null;
String[] scufls = null;
@@ -330,9 +309,9 @@
}
}
} else {
- System.err.println ("No straight path exitsts between '" +
- pathEnds[0] + "' and '" + pathEnds[1] + "'. Only cyclic paths found.");
- System.exit(1);
+ emsgln ("No straight path exitsts between '" +
+ pathEnds[0] + "' and '" + pathEnds[1] + "'. Only cyclic paths found.");
+ exit(1);
}
} else {
@@ -349,7 +328,7 @@
boolean usePathNames = (pathNames != null && graphs.length == pathNames.length);
for (int i = 0; i < graphs.length; i++) {
if (fn == null)
- System.out.println (graphs[i]);
+ msgln (graphs[i]);
else {
if (graphs.length == 1)
createFile (fn, graphs[i]);
@@ -369,7 +348,7 @@
if (scufls != null) {
for (int i = 0; i < scufls.length; i++) {
if (fn == null)
- System.out.println (scufls[i]);
+ msgln (scufls[i]);
else
createFile (replaceExtension (modifyFileName (fn, pathNames [i]),
"xml"),
@@ -389,16 +368,14 @@
if (param == null)
param = cmd.getParam ("-f");
if (param == null)
- System.out.println (graph);
+ msgln (graph);
else
createFile (param, graph);
}
}
- } catch (Exception e) {
- System.err.println ("===ERROR===");
- e.printStackTrace();
- System.err.println ("===========");
+ } catch (Throwable e) {
+ processErrorAndExit (e);
}
}
@@ -477,11 +454,11 @@
/*************************************************************************
* Print 'msg' but only if in verbose mode
*************************************************************************/
- static void decoration (String msg) {
- if (verbose) System.out.print (msg);
- }
- static void decorationLn (String msg) {
- if (verbose) System.out.println (msg);
- }
+ static void decoration (String msg) { qmsg (msg); }
+
+ /*************************************************************************
+ * Print 'msg' and a newline but only if in verbose mode
+ *************************************************************************/
+ static void decorationLn (String msg) { qmsgln (msg); }
}
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/Clients/MosesGenerators.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/Clients/MosesGenerators.java 2005/09/04 13:45:37 1.2
+++ /home/repository/moby/moby-live/Java/src/Clients/MosesGenerators.java 2008/02/22 09:37:38 1.3
@@ -6,11 +6,11 @@
// Copyright Martin Senger (martin.senger at gmail.com).
//
+import org.biomoby.client.CmdLineHelper;
import org.biomoby.service.generator.DataTypesGenerator;
import org.biomoby.service.generator.ServicesGenerator;
import org.biomoby.service.generator.Generator;
-import org.biomoby.shared.MobyException;
-import org.biomoby.shared.Utils;
+import org.biomoby.shared.Central;
import org.tulsoft.tools.BaseCmdLine;
import java.util.Properties;
@@ -30,20 +30,8 @@
* @author <A HREF="mailto:martin.senger at gmail.com">Martin Senger</A>
* @version $Id$
*/
-public class MosesGenerators {
-
- /*************************************************************************
- * Return a help text about this this client.
- *************************************************************************/
- public String getUsage() {
- String helpFile = "help/MosesGenerators_usage.txt";
- try {
- String help = Utils.readResource (helpFile, this);
- return (help == null ? "" : help);
- } catch (MobyException e) {
- return e.getMessage();
- }
- }
+public class MosesGenerators
+ extends CmdLineHelper {
/*************************************************************************
*
@@ -60,20 +48,16 @@
public static void main (String [] args) {
try {
- BaseCmdLine cmd = new BaseCmdLine (args, true);
- if (cmd.hasParam ("-help") || cmd.hasParam ("-h")) {
- System.out.print (new MosesGenerators().getUsage());
- System.exit (0);
- }
+ BaseCmdLine cmd = getCmdLine (args, MosesGenerators.class);
+
+ Central worker = getRegistryWorker (cmd);
+ String registryEndpoint = worker.getRegistryEndpoint();
+ String registryNamespace = worker.getRegistryNamespace();
- boolean verbose = !cmd.hasOption ("-q");
boolean generateDataTypes = cmd.hasOption ("-dt");
boolean generateServices = cmd.hasOption ("-s");
boolean nogenerate = cmd.hasOption ("-n");
boolean nographs = cmd.hasOption ("-ng");
-
- String registryEndpoint = cmd.getParam ("-e");
- String registryNamespace = cmd.getParam ("-uri");
String cacheDir = cmd.getParam ("-cacheDir");
String filter = cmd.getParam ("-filter");
String outdir = cmd.getParam ("-outdir");
@@ -85,15 +69,14 @@
generateServices = true;
if (generateDataTypes) {
- if (verbose && notEmpty (filter))
- System.out.println ("Using filter: '" + filter + "'");
+ if (notEmpty (filter))
+ qmsgln ("Using filter: '" + filter + "'");
if (nogenerate)
- System.out.print ("It WOULD generate for the following data types:\n");
- else if (verbose) {
- System.out.println ("Generating data types" +
- (outdir == null ? "..." : " into '" + outdir + "'... "));
- }
+ msg ("It WOULD generate for the following data types:\n");
+ else
+ qmsgln ("Generating data types" +
+ (outdir == null ? "..." : " into '" + outdir + "'... "));
DataTypesGenerator dtg
= new DataTypesGenerator (registryEndpoint, registryNamespace, cacheDir);
Properties props = new Properties();
@@ -108,19 +91,16 @@
}
if (generateServices) {
- if (verbose) {
- if (notEmpty (authority))
- System.out.println ("Using filter for authorities: '" + authority + "'");
- if (notEmpty (service))
- System.out.println ("Using filter for services: '" + service + "'");
- }
+ if (notEmpty (authority))
+ qmsgln ("Using filter for authorities: '" + authority + "'");
+ if (notEmpty (service))
+ qmsgln ("Using filter for services: '" + service + "'");
if (nogenerate)
- System.out.println ("It WOULD generate for the following services:\n");
- else if (verbose) {
- System.out.println ("Generating services" +
- (outdir == null ? "..." : " into '" + outdir + "'... "));
- }
+ msgln ("It WOULD generate for the following services:\n");
+ else
+ qmsgln ("Generating services" +
+ (outdir == null ? "..." : " into '" + outdir + "'... "));
ServicesGenerator sg
= new ServicesGenerator (registryEndpoint, registryNamespace, cacheDir);
Properties props = new Properties();
@@ -135,17 +115,8 @@
sg.generate (props);
}
- } catch (MobyException e) {
- System.err.println ("===ERROR===");
- System.err.println (e.getMessage());
- System.err.println ("===========");
- System.exit (1);
-
- } catch (Exception e) {
- System.err.println ("===ERROR===");
- e.printStackTrace();
- System.err.println ("===========");
- System.exit (1);
+ } catch (Throwable e) {
+ processErrorAndExit (e);
}
}
}
More information about the MOBY-guts
mailing list