You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/05/03 22:32:44 UTC

svn commit: r1333608 - in /cxf/trunk: maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/ maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/ systests/jaxws/ tools/common/src/main/java/org/apach...

Author: dkulp
Date: Thu May  3 20:32:43 2012
New Revision: 1333608

URL: http://svn.apache.org/viewvc?rev=1333608&view=rev
Log:
[CXF-4287] Modify -validate switch to allow completely turning off all
validation.

Modified:
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java
    cxf/trunk/systests/jaxws/pom.xml
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
    cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
    cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
    cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
    cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
    cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/Option.java Thu May  3 20:32:43 2012
@@ -139,7 +139,7 @@ public class Option {
     /**
      * Enables validating the WSDL before generating the code. 
      */
-    Boolean validateWsdl;
+    String validateWsdl;
     
     
     /**
@@ -340,13 +340,18 @@ public class Option {
         this.extendedSoapHeaders = extendedSoapHeaders;
     }
 
-    public boolean isValidateWsdl() {
-        return validateWsdl == null ? false : validateWsdl;
+    public String getValidateWsdl() {
+        return validateWsdl;
     }
 
-    public void setValidateWsdl(boolean validateWsdl) {
+    public void setValidateWsdl(String validateWsdl) {
+        System.out.println("Validate: " + validateWsdl);
         this.validateWsdl = validateWsdl;
     }
+    public void setValidate(String v) {
+        System.out.println("Validate: " + v);
+        this.validateWsdl = v;
+    }
     
     public boolean isNoTypes() {
         return noTypes == null ? false : noTypes;
@@ -446,7 +451,7 @@ public class Option {
         destination.setOutputDir(getOutputDir());
         destination.setPackagenames(getPackagenames());
         destination.setServiceName(getServiceName());
-        destination.setValidateWsdl(isValidateWsdl());
+        destination.setValidateWsdl(getValidateWsdl());
         destination.setNoTypes(isNoTypes());
         destination.setFaultSerialVersionUID(getFaultSerialVersionUID());
         destination.setMarkGenerated(isMarkGenerated());

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOption.java Thu May  3 20:32:43 2012
@@ -165,7 +165,9 @@ public class WsdlOption extends Option i
         }
         addIfTrue(list, isNoTypes(), "-noTypes");
         addIfTrue(list, isAllowElementRefs(), "-" + ToolConstants.CFG_ALLOW_ELEMENT_REFS);
-        addIfTrue(list, isValidateWsdl(), "-" + ToolConstants.CFG_VALIDATE_WSDL);
+        if (getValidateWsdl() != null) {
+            list.add("-validate=" + getValidateWsdl());
+        }
         addIfTrue(list, isMarkGenerated() != null && isMarkGenerated(),
             "-" + ToolConstants.CFG_MARK_GENERATED);
         addIfNotNull(list, getDefaultExcludesNamespace(), "-dex");

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/Option.java Thu May  3 20:32:43 2012
@@ -81,7 +81,7 @@ public class Option {
     /**
      * Whether to validate the WSDL. 
      */
-    Boolean validate;
+    String validate;
     /**
      * The wsdl version.
      */
@@ -103,7 +103,7 @@ public class Option {
             output = other.getOutput();
         }
         if (validate == null) {
-            validate = other.isValidate();
+            validate = other.getValidate();
         }
         if (wsdlVersion == null) {
             wsdlVersion = other.getWsdlVersion();
@@ -159,15 +159,15 @@ public class Option {
     /**
      * @return Validating the WSDL?
      */
-    public Boolean isValidate() {
+    public String getValidate() {
         return validate;
     }
 
     /**
      * Control WSDL validation.
-     * @param validate true to validate.
+     * @param validate true or all to validate.
      */
-    public void setValidate(Boolean validate) {
+    public void setValidate(String validate) {
         this.validate = validate;
     }
 

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java (original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WsdlOption.java Thu May  3 20:32:43 2012
@@ -98,8 +98,8 @@ public class WsdlOption extends Option i
         } else {
             options.add(outputDirFile.getAbsolutePath());
         }
-        if (validate != null && validate) {
-            options.add("-validate");
+        if (validate != null) {
+            options.add("-validate=" + validate);
         }
         if (debug) {
             options.add("-v");

Modified: cxf/trunk/systests/jaxws/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/pom.xml?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/pom.xml (original)
+++ cxf/trunk/systests/jaxws/pom.xml Thu May  3 20:32:43 2012
@@ -46,6 +46,9 @@
                             <fork>${cxf.codegenplugin.forkmode}</fork>
                             <testSourceRoot>${basedir}/target/generated/src/test/java</testSourceRoot>
                             <testWsdlRoot>${basedir}/src/test/resources/wsdl_systest_jaxws</testWsdlRoot>
+                            <defaultOptions>
+                                <validate>basic</validate>
+                            </defaultOptions>
                         </configuration>
                         <goals>
                             <goal>wsdl2java</goal>

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java Thu May  3 20:32:43 2012
@@ -167,9 +167,25 @@ public class ToolContext {
     }
 
     // REVIST: Prefer using optionSet, to keep the context clean
-    public boolean validateWSDL() {
-        return get(ToolConstants.CFG_VALIDATE_WSDL) != null;
-
+    public boolean fullValidateWSDL() {
+        Object s = get(ToolConstants.CFG_VALIDATE_WSDL);
+        if (s instanceof String && ((String)s).length() > 0 && ((String)s).charAt(0) == '=') {
+            s = ((String)s).substring(1);
+        }
+        if (s == null || "none".equals(s) || "false".equals(s) || "basic".equals(s)) {
+            return false;
+        }
+        return true;
+    }
+    public boolean basicValidateWSDL() {
+        Object s = get(ToolConstants.CFG_VALIDATE_WSDL);
+        if (s instanceof String && ((String)s).length() > 0 && ((String)s).charAt(0) == '=') {
+            s = ((String)s).substring(1);
+        }
+        if ("none".equals(s) || "false".equals(s)) {
+            return false;
+        }
+        return true;
     }
 
     public void addNamespacePackageMap(String namespace, String pn) {

Modified: cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java (original)
+++ cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java Thu May  3 20:32:43 2012
@@ -56,7 +56,7 @@ public class WSDLValidator extends Abstr
         if (isVerboseOn()) {
             env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
         }
-        env.put(ToolConstants.CFG_VALIDATE_WSDL, Boolean.TRUE);
+        env.put(ToolConstants.CFG_VALIDATE_WSDL, "all");
         env.put(ToolConstants.CFG_CMD_ARG, getArgument());
 
       
@@ -73,7 +73,7 @@ public class WSDLValidator extends Abstr
                 if (isVerboseOn()) {
                     env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
                 }
-                env.put(ToolConstants.CFG_VALIDATE_WSDL, Boolean.TRUE);
+                env.put(ToolConstants.CFG_VALIDATE_WSDL, "all");
                 env.put(ToolConstants.CFG_CMD_ARG, getArgument());
 
               

Modified: cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java (original)
+++ cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java Thu May  3 20:32:43 2012
@@ -121,7 +121,8 @@ public class WSDL11Validator extends Abs
         wsdlRefValidator.setSuppressWarnings(env.optionSet(ToolConstants.CFG_SUPPRESS_WARNINGS));        
         validators.add(wsdlRefValidator);
         
-        if (env.optionSet(ToolConstants.CFG_VALIDATE_WSDL)) {
+        
+        if (env.fullValidateWSDL()) {
             validators.add(new UniqueBodyPartsValidator(this.def));
             validators.add(new WSIBPValidator(this.def));
             validators.add(new MIMEBindingValidator(this.def));
@@ -139,7 +140,7 @@ public class WSDL11Validator extends Abs
         }
 
         // By default just use WsdlRefValidator
-        if (!env.optionSet(ToolConstants.CFG_VALIDATE_WSDL)) {
+        if (!env.fullValidateWSDL()) {
             return true;
         }
 

Modified: cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java (original)
+++ cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java Thu May  3 20:32:43 2012
@@ -242,10 +242,11 @@ public class WSDLToJavaContainer extends
         generateTypes();
 
         for (ServiceInfo service : serviceList) {
-
             context.put(ServiceInfo.class, service);
 
-            validate(service);
+            if (context.basicValidateWSDL()) {
+                validate(service);
+            }
 
             // Build the JavaModel from the ServiceModel
             processor.setEnvironment(context);

Modified: cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java (original)
+++ cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java Thu May  3 20:32:43 2012
@@ -578,7 +578,7 @@ public class JAXBDataBinding implements 
                 }
                 Element ele = docs[0].getDocumentElement();
                 ele = removeImportElement(ele, key, catalog);
-                if (context.get(ToolConstants.CFG_VALIDATE_WSDL) != null) {
+                if (context.fullValidateWSDL()) {
                     String uri = null;
                     try {
                         uri = docs[0].getDocumentURI();
@@ -653,7 +653,7 @@ public class JAXBDataBinding implements 
                 ids.add(key);
                 Element ele = sci.getElement();
                 ele = removeImportElement(ele, key, catalog);
-                if (context.get(ToolConstants.CFG_VALIDATE_WSDL) != null) {
+                if (context.fullValidateWSDL()) {
                     validateSchema(ele, sci.getSystemId(), catalog);
                 }
                 InputSource is = new InputSource((InputStream)null);

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml (original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml Thu May  3 20:32:43 2012
@@ -265,8 +265,14 @@ Examples:
             <option id="validate" maxOccurs="1">
                 <annotation>
                     Specifies that the WSDL is validated before generating the code. Using 
-                    this option is highly recommended.
+                    this option is highly recommended.  By default, only very basic validation
+                    is done to make sure the WSDL meets the WSI-BasicProfile standards that
+                    CXF requires.  -validate=none can turn off those checks while -validate or 
+                    -validate=all turns on additional schema validation and other checks.
                 </annotation>
+                <associatedArgument placement="immediate">
+                    <annotation>[=all|basic|none]</annotation>
+                </associatedArgument>
                 <switch>validate</switch>
             </option>
 

Modified: cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java?rev=1333608&r1=1333607&r2=1333608&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java (original)
+++ cxf/trunk/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java Thu May  3 20:32:43 2012
@@ -115,7 +115,7 @@ public class AbstractWSDLToProcessor imp
         }
         WSDLDefinitionBuilder builder = new WSDLDefinitionBuilder(bus);
         wsdlDefinition = builder.build(wsdlURL);
-        if (env.optionSet(ToolConstants.CFG_VALIDATE_WSDL)) {
+        if (env.fullValidateWSDL()) {
             validate(wsdlDefinition, env, bus);
         }
         WSDLManager mgr = bus.getExtension(WSDLManager.class);
@@ -154,7 +154,7 @@ public class AbstractWSDLToProcessor imp
     }
 
     public void validateWSDL() throws ToolException {
-        if (env.validateWSDL()) {
+        if (env.fullValidateWSDL()) {
             WSDL11Validator validator = new WSDL11Validator(this.wsdlDefinition, this.env);
             validator.isValid();
         }