Index: test/wsdl/Wsdl2javaAntTask.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/test/wsdl/Wsdl2javaAntTask.java,v
retrieving revision 1.26
diff -u -r1.26 Wsdl2javaAntTask.java
--- test/wsdl/Wsdl2javaAntTask.java	10 May 2002 13:30:35 -0000	1.26
+++ test/wsdl/Wsdl2javaAntTask.java	10 May 2002 23:38:40 -0000
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 2001 The Apache Software Foundation.  All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -70,7 +70,8 @@
 
 /**
  * Simple Ant task for running Wsdl2java utility. 
- *
+ * @ant.task category="xml"
+ * @author steve loughran
  * @author Davanum Srinivas (dims@yahoo.com)
  */
 public class Wsdl2javaAntTask extends Task
@@ -90,25 +91,72 @@
     private String tm = "1.2";
     private long timeout = 45000;
 
-    // The method executing the task
-    public void execute() throws BuildException {
+    /**
+     * do we print a stack trace when someting goes wrong
+     */
+    private boolean printStackTraceOnFailure=false;
+    /**
+     * what action to take when there was a failure and the source was some
+     * URL
+     */
+    private boolean failOnNetworkErrors=false;
+    
+    /**
+     * validation code
+     * @throws  BuildException  if validation failed
+     */ 
+    protected void validate() 
+            throws BuildException {
+        if(url==null || url.length()==0) {
+            throw new BuildException("No url specified");
+        }
+        if(timeout<0) {
+            throw new BuildException("negative timeout supplied");
+        }
+        /*
+        if (deployScope!=null &&
+            !"application".equalsIgnoreCase(deployScope) 
+            && !"request".equalsIgnoreCase(deployScope)
+            && !"session".equalsIgnoreCase(deployScope)
+            && !"none".equalsIgnoreCase(deployScope)) {
+                throw new BuildException("Unrecognized scope:  " + deployScope);
+            }
+        */            
+    }
+    
+    /**
+     * trace out parameters
+     * @param level to log at
+     * @see org.apache.tools.ant.Project#log
+     */
+    public void traceParams(int logLevel) {
+        log("Running Wsdl2javaAntTask with parameters:", logLevel);
+        log("\tverbose:" + verbose, logLevel);
+        log("\tserver-side:" + server, logLevel);
+        log("\tskeletonDeploy:" + skeletonDeploy, logLevel);
+        log("\thelperGen:" + helperGen, logLevel);
+        log("\tfactory:" + factory, logLevel);
+        log("\ttestCase:" + testCase, logLevel);
+        log("\tnoImports:" + noImports, logLevel);
+        log("\tNStoPkg:" + namespaceMap, logLevel);
+        log("\toutput:" + output, logLevel);
+        log("\tdeployScope:" + deployScope, logLevel);
+        log("\tURL:" + url, logLevel);
+        log("\tall:" + all, logLevel);
+        log("\ttypeMappingVersion:" + tm, logLevel);
+        log("\ttimeout:" + timeout, logLevel);
+        log("\tfailOnNetworkErrors:" + failOnNetworkErrors, logLevel);
+        log("\tprintStackTraceOnFailure:" + printStackTraceOnFailure, logLevel);
+    }
+    
+    /**
+     * The method executing the task
+     * @throws  BuildException  if validation or execution failed
+     */ 
+     public void execute() throws BuildException {
+        traceParams(Project.MSG_DEBUG);
+        validate();
         try {
-            log("Running Wsdl2javaAntTask with parameters:", Project.MSG_VERBOSE);
-            log("\tverbose:" + verbose, Project.MSG_VERBOSE);
-            log("\tserver-side:" + server, Project.MSG_VERBOSE);
-            log("\tskeletonDeploy:" + skeletonDeploy, Project.MSG_VERBOSE);
-            log("\thelperGen:" + helperGen, Project.MSG_VERBOSE);
-            log("\tfactory:" + factory, Project.MSG_VERBOSE);
-            log("\ttestCase:" + testCase, Project.MSG_VERBOSE);
-            log("\tnoImports:" + noImports, Project.MSG_VERBOSE);
-            log("\tNStoPkg:" + namespaceMap, Project.MSG_VERBOSE);
-            log("\toutput:" + output, Project.MSG_VERBOSE);
-            log("\tdeployScope:" + deployScope, Project.MSG_VERBOSE);
-            log("\tURL:" + url, Project.MSG_VERBOSE);
-            log("\tall:" + all, Project.MSG_VERBOSE);
-            log("\ttypeMappingVersion:" + tm, Project.MSG_VERBOSE);
-            log("\ttimeout:" + timeout, Project.MSG_VERBOSE);
-
             // Instantiate the emitter
             Emitter emitter = new Emitter();
 
@@ -125,7 +173,7 @@
                 emitter.setScope(emitter.NO_EXPLICIT_SCOPE);
             }
             else {
-                log("Unrecognized scope:  " + deployScope + ".  Ignoring it.", Project.MSG_VERBOSE);
+                log("Unrecognized (or no) scope, ignoring it.", Project.MSG_VERBOSE);
             }
             if (!namespaceMap.isEmpty()) {
                 emitter.setNamespaceMap(namespaceMap);
@@ -152,15 +200,25 @@
                 if (url.startsWith("http://")) {
                     // What we have is either a network error or invalid XML -
                     // the latter most likely an HTML error page.  This makes
-                    // it impossible to continue with the test, so issue
-                    // a warning, and return without reporting a fatal error.
-                    log(e.toString(), Project.MSG_WARN);
-                    return;
+                    // it impossible to continue with the test, so 
+                    if(!failOnNetworkErrors) {
+                        // test mode, issue a warning, and return without
+                        //reporting a fatal error.
+                        log(e.toString(), Project.MSG_WARN);
+                        return;
+                    } else {
+                        //in 'consumer' mode, bail out with the URL
+                        throw new BuildException("when fetching "+url,e);
+                    }
+                } else {
+                    throw e;
                 }
-                throw e;
             }
         } catch (Throwable t) {
-            t.printStackTrace();
+            if(printStackTraceOnFailure) {
+                traceParams(Project.MSG_INFO);
+                t.printStackTrace();
+            }
             throw new BuildException("Error while running " + getClass().getName(), t); 
         }
     }
@@ -171,37 +229,37 @@
     }
 
     // The setter for the "server-side" attribute
-    public void setServerSide(String parameter) {
-        this.server = Project.toBoolean(parameter);
+    public void setServerSide(boolean parameter) {
+        this.server = parameter;
     }
 
     // The setter for the "skeletonDeploy" attribute
-    public void setSkeletonDeploy(String parameter) {
-        this.skeletonDeploy = Project.toBoolean(parameter);
+    public void setSkeletonDeploy(boolean parameter) {
+        this.skeletonDeploy = parameter;
     }
 
     // The setter for the "testcase" attribute
-    public void setTestCase(String parameter) {
-        this.testCase = Project.toBoolean(parameter);
+    public void setTestCase(boolean parameter) {
+        this.testCase = parameter;
     }
 
     // The setter for the "helperGen" attribute
-    public void setHelperGen(String parameter) {
-        this.helperGen = Project.toBoolean(parameter);
+    public void setHelperGen(boolean parameter) {
+        this.helperGen = parameter;
     }
 
     // The setter for the "factory" attribute
     public void setFactory(String parameter) {
         this.factory = parameter;
     }
-
+    
     // The setter for the "noimports" attribute
-    public void setNoImports(String parameter) {
-        this.noImports = Project.toBoolean(parameter);
+    public void setNoImports(boolean parameter) {
+        this.noImports = parameter;
     }
 
     // The setter for the "output" attribute
-    public void setOutput(File parameter) {
+    public void setOutput(File parameter) throws BuildException {
         try {
             this.output = parameter.getCanonicalPath();
         } catch (IOException ioe) {
@@ -220,8 +278,8 @@
     }
 
     // The setter for the "all" attribute
-    public void setAll(String parameter) {
-        this.all = Project.toBoolean(parameter);
+    public void setAll(boolean parameter) {
+        this.all = parameter;
     }
 
     // The setter for the "typeMappingVersion" attribute
@@ -230,12 +288,23 @@
     }
 
     // The setter for the "timeout" attribute
-    public void setTimeout(String parameter) {
-        try {
-            this.timeout = new Long(parameter).longValue();
-        } catch (NumberFormatException e) {
-            // Sorry, stick with default.
-        }
+    public void setTimeout(long parameter) {
+        this.timeout = parameter;
+    }
+
+    /**
+     * if we get an error and the url was remote, do we fail
+     */ 
+    public void setFailOnNetworkErrors(boolean failOnNetworkErrors) {
+        this.failOnNetworkErrors = failOnNetworkErrors;
+    }
+
+    /**
+     * do we want a stack trace when the build fails. useful for 
+     * debugging wsdl2java.
+     */ 
+    public void setPrintStackTraceOnFailure(boolean printStackTraceOnFailure) {
+        this.printStackTraceOnFailure = printStackTraceOnFailure;
     }
 
     /** the command arguments */
Index: test/wsdl/Wsdl2javaAntTask.java
===================================================================
RCS file: /home/cvspublic/xml-axis/java/test/wsdl/Wsdl2javaAntTask.java,v
retrieving revision 1.26
diff -u -r1.26 Wsdl2javaAntTask.java
--- test/wsdl/Wsdl2javaAntTask.java	10 May 2002 13:30:35 -0000	1.26
+++ test/wsdl/Wsdl2javaAntTask.java	10 May 2002 23:42:45 -0000
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 2001 The Apache Software Foundation.  All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -70,7 +70,8 @@
 
 /**
  * Simple Ant task for running Wsdl2java utility. 
- *
+ * @ant.task category="xml"
+ * @author steve loughran
  * @author Davanum Srinivas (dims@yahoo.com)
  */
 public class Wsdl2javaAntTask extends Task
@@ -90,25 +91,63 @@
     private String tm = "1.2";
     private long timeout = 45000;
 
-    // The method executing the task
-    public void execute() throws BuildException {
+    /**
+     * do we print a stack trace when someting goes wrong
+     */
+    private boolean printStackTraceOnFailure=false;
+    /**
+     * what action to take when there was a failure and the source was some
+     * URL
+     */
+    private boolean failOnNetworkErrors=false;
+    
+    /**
+     * validation code
+     * @throws  BuildException  if validation failed
+     */ 
+    protected void validate() 
+            throws BuildException {
+        if(url==null || url.length()==0) {
+            throw new BuildException("No url specified");
+        }
+        if(timeout<0) {
+            throw new BuildException("negative timeout supplied");
+        }
+    }
+    
+    /**
+     * trace out parameters
+     * @param level to log at
+     * @see org.apache.tools.ant.Project#log
+     */
+    public void traceParams(int logLevel) {
+        log("Running Wsdl2javaAntTask with parameters:", logLevel);
+        log("\tverbose:" + verbose, logLevel);
+        log("\tserver-side:" + server, logLevel);
+        log("\tskeletonDeploy:" + skeletonDeploy, logLevel);
+        log("\thelperGen:" + helperGen, logLevel);
+        log("\tfactory:" + factory, logLevel);
+        log("\ttestCase:" + testCase, logLevel);
+        log("\tnoImports:" + noImports, logLevel);
+        log("\tNStoPkg:" + namespaceMap, logLevel);
+        log("\toutput:" + output, logLevel);
+        log("\tdeployScope:" + deployScope, logLevel);
+        log("\tURL:" + url, logLevel);
+        log("\tall:" + all, logLevel);
+        log("\ttypeMappingVersion:" + tm, logLevel);
+        log("\ttimeout:" + timeout, logLevel);
+        log("\tfailOnNetworkErrors:" + failOnNetworkErrors, logLevel);
+        log("\tprintStackTraceOnFailure:" + printStackTraceOnFailure, logLevel);
+    }
+    
+    /**
+     * The method executing the task
+     * @throws  BuildException  if validation or execution failed
+     */ 
+     public void execute() throws BuildException {
+        traceParams(Project.MSG_DEBUG);
+        validate();
         try {
-            log("Running Wsdl2javaAntTask with parameters:", Project.MSG_VERBOSE);
-            log("\tverbose:" + verbose, Project.MSG_VERBOSE);
-            log("\tserver-side:" + server, Project.MSG_VERBOSE);
-            log("\tskeletonDeploy:" + skeletonDeploy, Project.MSG_VERBOSE);
-            log("\thelperGen:" + helperGen, Project.MSG_VERBOSE);
-            log("\tfactory:" + factory, Project.MSG_VERBOSE);
-            log("\ttestCase:" + testCase, Project.MSG_VERBOSE);
-            log("\tnoImports:" + noImports, Project.MSG_VERBOSE);
-            log("\tNStoPkg:" + namespaceMap, Project.MSG_VERBOSE);
-            log("\toutput:" + output, Project.MSG_VERBOSE);
-            log("\tdeployScope:" + deployScope, Project.MSG_VERBOSE);
-            log("\tURL:" + url, Project.MSG_VERBOSE);
-            log("\tall:" + all, Project.MSG_VERBOSE);
-            log("\ttypeMappingVersion:" + tm, Project.MSG_VERBOSE);
-            log("\ttimeout:" + timeout, Project.MSG_VERBOSE);
-
             // Instantiate the emitter
             Emitter emitter = new Emitter();
 
@@ -125,7 +164,9 @@
                 emitter.setScope(emitter.NO_EXPLICIT_SCOPE);
             }
             else {
-                log("Unrecognized scope:  " + deployScope + ".  Ignoring it.", Project.MSG_VERBOSE);
+                log("Unrecognized (or no) scope: " + deployScope
+                    +"; ignoring it.", 
+                    Project.MSG_VERBOSE);
             }
             if (!namespaceMap.isEmpty()) {
                 emitter.setNamespaceMap(namespaceMap);
@@ -152,15 +193,25 @@
                 if (url.startsWith("http://")) {
                     // What we have is either a network error or invalid XML -
                     // the latter most likely an HTML error page.  This makes
-                    // it impossible to continue with the test, so issue
-                    // a warning, and return without reporting a fatal error.
-                    log(e.toString(), Project.MSG_WARN);
-                    return;
+                    // it impossible to continue with the test, so 
+                    if(!failOnNetworkErrors) {
+                        // test mode, issue a warning, and return without
+                        //reporting a fatal error.
+                        log(e.toString(), Project.MSG_WARN);
+                        return;
+                    } else {
+                        //in 'consumer' mode, bail out with the URL
+                        throw new BuildException("when fetching "+url,e);
+                    }
+                } else {
+                    throw e;
                 }
-                throw e;
             }
         } catch (Throwable t) {
-            t.printStackTrace();
+            if(printStackTraceOnFailure) {
+                traceParams(Project.MSG_INFO);
+                t.printStackTrace();
+            }
             throw new BuildException("Error while running " + getClass().getName(), t); 
         }
     }
@@ -171,37 +222,37 @@
     }
 
     // The setter for the "server-side" attribute
-    public void setServerSide(String parameter) {
-        this.server = Project.toBoolean(parameter);
+    public void setServerSide(boolean parameter) {
+        this.server = parameter;
     }
 
     // The setter for the "skeletonDeploy" attribute
-    public void setSkeletonDeploy(String parameter) {
-        this.skeletonDeploy = Project.toBoolean(parameter);
+    public void setSkeletonDeploy(boolean parameter) {
+        this.skeletonDeploy = parameter;
     }
 
     // The setter for the "testcase" attribute
-    public void setTestCase(String parameter) {
-        this.testCase = Project.toBoolean(parameter);
+    public void setTestCase(boolean parameter) {
+        this.testCase = parameter;
     }
 
     // The setter for the "helperGen" attribute
-    public void setHelperGen(String parameter) {
-        this.helperGen = Project.toBoolean(parameter);
+    public void setHelperGen(boolean parameter) {
+        this.helperGen = parameter;
     }
 
     // The setter for the "factory" attribute
     public void setFactory(String parameter) {
         this.factory = parameter;
     }
-
+    
     // The setter for the "noimports" attribute
-    public void setNoImports(String parameter) {
-        this.noImports = Project.toBoolean(parameter);
+    public void setNoImports(boolean parameter) {
+        this.noImports = parameter;
     }
 
     // The setter for the "output" attribute
-    public void setOutput(File parameter) {
+    public void setOutput(File parameter) throws BuildException {
         try {
             this.output = parameter.getCanonicalPath();
         } catch (IOException ioe) {
@@ -220,8 +271,8 @@
     }
 
     // The setter for the "all" attribute
-    public void setAll(String parameter) {
-        this.all = Project.toBoolean(parameter);
+    public void setAll(boolean parameter) {
+        this.all = parameter;
     }
 
     // The setter for the "typeMappingVersion" attribute
@@ -230,12 +281,23 @@
     }
 
     // The setter for the "timeout" attribute
-    public void setTimeout(String parameter) {
-        try {
-            this.timeout = new Long(parameter).longValue();
-        } catch (NumberFormatException e) {
-            // Sorry, stick with default.
-        }
+    public void setTimeout(long parameter) {
+        this.timeout = parameter;
+    }
+
+    /**
+     * if we get an error and the url was remote, do we fail
+     */ 
+    public void setFailOnNetworkErrors(boolean failOnNetworkErrors) {
+        this.failOnNetworkErrors = failOnNetworkErrors;
+    }
+
+    /**
+     * do we want a stack trace when the build fails. useful for 
+     * debugging wsdl2java.
+     */ 
+    public void setPrintStackTraceOnFailure(boolean printStackTraceOnFailure) {
+        this.printStackTraceOnFailure = printStackTraceOnFailure;
     }
 
     /** the command arguments */
