cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r497227 - in /incubator/cxf/trunk/tools2: common/src/main/java/org/apache/cxf/tools/common/ common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/ validator/src/main/java/org/apache/cxf/tools/validator/internal/ validator/sr...
Date Wed, 17 Jan 2007 23:01:32 GMT
Author: mmao
Date: Wed Jan 17 15:01:31 2007
New Revision: 497227

URL: http://svn.apache.org/viewvc?view=rev&rev=497227
Log:
Tools Refactoring

* Remove the xml binding extensions from tools since we reuse the service model
* Add ServiceValidator to validate the service model
* Move the XMLFormatValidator into jaxws, since it depends on xml binding 

Added:
    incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java
  (with props)
    incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/ServiceValidator.java
  (with props)
    incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/validator/
    incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/validator/XMLFormatValidator.java
      - copied, changed from r497017, incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/XMLFormatValidator.java
    incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/
    incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java
  (with props)
    incubator/cxf/trunk/tools2/wsdlto/test/src/test/resources/wsdl2java_wsdl/xml_format_root.wsdl
  (with props)
Removed:
    incubator/cxf/trunk/tools2/common/src/main/java/org/apache/cxf/tools/common/extensions/xmlformat/
    incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/XMLFormatValidator.java
Modified:
    incubator/cxf/trunk/tools2/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java
    incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractValidator.java
    incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/MIMEBindingValidator.java
    incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
    incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
    incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
    incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
    incubator/cxf/trunk/tools2/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
    incubator/cxf/trunk/tools2/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
    incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSContainer.java
    incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java

Modified: incubator/cxf/trunk/tools2/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java?view=diff&rev=497227&r1=497226&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools2/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java
(original)
+++ incubator/cxf/trunk/tools2/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java
Wed Jan 17 15:01:31 2007
@@ -106,4 +106,5 @@
     public static final int RPC_WRAPPED = 3;
     public static final int ERORR_STYLE_USE = -1;
 
+    public static final String XML_BINDING_NS = "http://cxf.apache.org/bindings/xformat";
 }

Added: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java?view=auto&rev=497227
==============================================================================
--- incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java
(added)
+++ incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java
Wed Jan 17 15:01:31 2007
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.tools.validator.internal;
+
+import javax.wsdl.Definition;
+import javax.xml.stream.Location;
+import org.apache.cxf.tools.common.ToolContext;
+
+public abstract class AbstractDefinitionValidator extends AbstractValidator {
+    protected Definition def;
+
+    public AbstractDefinitionValidator() {
+        super();
+    }
+
+    public AbstractDefinitionValidator(Definition definition) {
+        this.def = definition;
+    }
+
+    public AbstractDefinitionValidator(Definition definition, ToolContext pEnv) {
+        this.def = definition;
+        this.env = pEnv;
+    }
+
+    public void addError(Location loc, String msg) {
+        String errMsg = loc != null ? "line " + loc.getLineNumber() + " of " : "";
+        errMsg = errMsg + def.getDocumentBaseURI() + " " + msg;
+        addErrorMessage(errMsg);
+    }
+}

Propchange: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractValidator.java?view=diff&rev=497227&r1=497226&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractValidator.java
(original)
+++ incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractValidator.java
Wed Jan 17 15:01:31 2007
@@ -22,33 +22,16 @@
 import java.util.List;
 import java.util.Vector;
 
-import javax.wsdl.Definition;
-import javax.xml.stream.Location;
-
 import org.apache.cxf.tools.common.ToolContext;
-import org.apache.cxf.tools.common.ToolException;
 
 public abstract class AbstractValidator {
     protected List<String> errorMessages = new Vector<String>();
-    protected Definition def;
     protected ToolContext env;
     
     public AbstractValidator() {
         
     }
     
-    public AbstractValidator(Definition definition) {
-        this.def = definition;
-    }
-
-    public AbstractValidator(String schemaDir) throws ToolException {
-    }
-
-    public AbstractValidator(Definition definition, ToolContext pEnv) {
-        this.def = definition;
-        this.env = pEnv;
-    }
-
     public abstract boolean isValid();
 
     public void addErrorMessage(String err) {
@@ -62,11 +45,5 @@
             strbuffer.append(System.getProperty("line.separator"));
         }
         return strbuffer.toString();
-    }
-
-    public void addError(Location loc, String msg) {
-        String errMsg = loc != null ? "line " + loc.getLineNumber() + " of " : "";
-        errMsg = errMsg + def.getDocumentBaseURI() + " " + msg;
-        addErrorMessage(errMsg);
     }
 }

Modified: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/MIMEBindingValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/MIMEBindingValidator.java?view=diff&rev=497227&r1=497226&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/MIMEBindingValidator.java
(original)
+++ incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/MIMEBindingValidator.java
Wed Jan 17 15:01:31 2007
@@ -34,7 +34,7 @@
 import org.apache.cxf.tools.util.SOAPBindingUtil;
 
 public class MIMEBindingValidator
-    extends AbstractValidator {
+    extends AbstractDefinitionValidator {
 
     public MIMEBindingValidator(Definition def) {
         super(def);

Modified: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java?view=diff&rev=497227&r1=497226&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
(original)
+++ incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/SchemaValidator.java
Wed Jan 17 15:01:31 2007
@@ -66,7 +66,7 @@
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolException;
 
-public class SchemaValidator extends AbstractValidator {
+public class SchemaValidator extends AbstractDefinitionValidator {
     
     protected static final Logger LOG = LogUtils.getL7dLogger(SchemaValidator.class);
     
@@ -86,13 +86,11 @@
     
 
     public SchemaValidator(String schemaDir) throws ToolException {
-        super(schemaDir);
         schemaLocation = schemaDir;
         defaultSchemas = getDefaultSchemas();
     }
 
     public SchemaValidator(String schemaDir, String wsdl, String[] schemas) throws ToolException
{
-        super(schemaDir);
         schemaLocation = schemaDir;
         defaultSchemas = getDefaultSchemas();
         wsdlsrc = wsdl;

Added: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/ServiceValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/ServiceValidator.java?view=auto&rev=497227
==============================================================================
--- incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/ServiceValidator.java
(added)
+++ incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/ServiceValidator.java
Wed Jan 17 15:01:31 2007
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.tools.validator.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cxf.tools.common.ToolException;
+
+public class ServiceValidator extends AbstractValidator {
+    private final List<AbstractValidator> validators = new ArrayList<AbstractValidator>();
+
+    public ServiceValidator() {
+    }
+
+    public void addValidators(List<AbstractValidator> v) {
+        validators.addAll(v);
+    }
+    
+    public boolean isValid() throws ToolException {
+        System.err.println("==== servicevalidator");
+        for (AbstractValidator validator : validators) {
+            System.err.println("validator: " + validator.getClass());
+            if (!validator.isValid()) {
+                addErrorMessage(validator.getErrorMessage());
+                throw new ToolException(this.getErrorMessage());
+            }
+        }
+        return true;
+    }
+}

Propchange: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/ServiceValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/ServiceValidator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java?view=diff&rev=497227&r1=497226&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
(original)
+++ incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/UniqueBodyPartsValidator.java
Wed Jan 17 15:01:31 2007
@@ -30,7 +30,7 @@
 import javax.wsdl.PortType;
 import javax.xml.namespace.QName;
 
-public class UniqueBodyPartsValidator extends AbstractValidator {
+public class UniqueBodyPartsValidator extends AbstractDefinitionValidator {
     private Map<QName, String> uniqueBodyPartsMap;
 
     public UniqueBodyPartsValidator(Definition def) {

Modified: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java?view=diff&rev=497227&r1=497226&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
(original)
+++ incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
Wed Jan 17 15:01:31 2007
@@ -44,7 +44,7 @@
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
 
-public class WSDL11Validator extends AbstractValidator {
+public class WSDL11Validator extends AbstractDefinitionValidator {
 
     private final List<AbstractValidator> validators = new ArrayList<AbstractValidator>();
 
@@ -89,7 +89,7 @@
         validators.add(new UniqueBodyPartsValidator(this.def));
         validators.add(new WSIBPValidator(this.def));
         validators.add(new MIMEBindingValidator(this.def));
-        validators.add(new XMLFormatValidator(this.def));
+        //validators.add(new XMLFormatValidator(this.def));
 
         for (AbstractValidator validator : validators) {
             if (!validator.isValid()) {

Modified: incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java?view=diff&rev=497227&r1=497226&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
(original)
+++ incubator/cxf/trunk/tools2/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSIBPValidator.java
Wed Jan 17 15:01:31 2007
@@ -39,7 +39,7 @@
 import org.apache.cxf.tools.common.extensions.soap.SoapHeader;
 import org.apache.cxf.tools.util.SOAPBindingUtil;
 
-public class WSIBPValidator extends AbstractValidator {
+public class WSIBPValidator extends AbstractDefinitionValidator {
     private List<String> operationMap = new ArrayList<String>();
     private WSDLHelper wsdlHelper = new WSDLHelper();
     

Modified: incubator/cxf/trunk/tools2/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java?view=diff&rev=497227&r1=497226&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools2/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
(original)
+++ incubator/cxf/trunk/tools2/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
Wed Jan 17 15:01:31 2007
@@ -24,6 +24,8 @@
 import java.util.Enumeration;
 
 import org.apache.cxf.tools.common.ToolTestBase;
+//import org.apache.cxf.wsdl11.WSDLBuilder;
+//import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
 
 public class WSDLValidationTest extends ToolTestBase {
     public void setUp() {
@@ -140,7 +142,7 @@
         }
 
     }
-    
+
     private String getLocation(String wsdlFile) throws IOException {
         Enumeration<URL> e = WSDLValidationTest.class.getClassLoader().getResources(wsdlFile);
         while (e.hasMoreElements()) {

Modified: incubator/cxf/trunk/tools2/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?view=diff&rev=497227&r1=497226&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools2/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
(original)
+++ incubator/cxf/trunk/tools2/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
Wed Jan 17 15:01:31 2007
@@ -24,6 +24,7 @@
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -49,12 +50,14 @@
 import org.apache.cxf.tools.common.toolspec.parser.CommandDocument;
 import org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor;
 import org.apache.cxf.tools.util.ClassCollector;
+import org.apache.cxf.tools.validator.internal.AbstractValidator;
+import org.apache.cxf.tools.validator.internal.ServiceValidator;
 import org.apache.cxf.tools.wsdlto.core.AbstractWSDLBuilder;
 import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
 import org.apache.cxf.tools.wsdlto.core.FrontEndProfile;
 import org.apache.cxf.tools.wsdlto.core.PluginLoader;
 import org.apache.cxf.wsdl11.WSDLServiceBuilder;
-
+    
 public class WSDLToJavaContainer extends AbstractCXFToolContainer {
 
     private static final String DEFAULT_NS2PACKAGE = "http://www.w3.org/2005/08/addressing";
@@ -124,6 +127,7 @@
                         (AbstractWSDLBuilder<Definition>) frontend.getWSDLBuilder();
                     builder.setContext(context);
                     Definition definition = builder.build(wsdlURL);
+                    
                     builder.customize();
                     context.put(Definition.class, builder.getWSDLModel());
                     if (context.optionSet(ToolConstants.CFG_VALIDATE_WSDL)) {
@@ -132,12 +136,14 @@
 
                     WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
                     service = serviceBuilder.buildService(definition, getServiceQName(definition));
-                    context.put(ServiceInfo.class, service);
                     context.put(ClassCollector.class, new ClassCollector());
                 } else {
                     // TODO: wsdl2.0 support
                 }
-
+                context.put(ServiceInfo.class, service);
+                if (context.optionSet(ToolConstants.CFG_VALIDATE_WSDL)) {
+                    validate(service);
+                }
                 // Generate types
                 
                 generateTypes();                
@@ -413,5 +419,15 @@
         }
         DataBindingProfile dataBindingProfile = context.get(DataBindingProfile.class);
         dataBindingProfile.generate(context);
+    }
+
+    public void validate(ServiceInfo service) throws ToolException {
+        ServiceValidator validator = new ServiceValidator();
+        validator.addValidators(getServiceValidators());
+        validator.isValid();
+    }
+
+    public List<AbstractValidator> getServiceValidators() {
+        return new ArrayList<AbstractValidator>();
     }
 }

Modified: incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSContainer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSContainer.java?view=diff&rev=497227&r1=497226&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSContainer.java
(original)
+++ incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSContainer.java
Wed Jan 17 15:01:31 2007
@@ -22,14 +22,17 @@
 import java.io.File;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.Set;
+import java.util.*;
 
 import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.common.toolspec.ToolSpec;
+import org.apache.cxf.tools.validator.internal.AbstractValidator;
 import org.apache.cxf.tools.wsdlto.WSDLToJavaContainer;
+import org.apache.cxf.tools.wsdlto.frontend.jaxws.validator.XMLFormatValidator;
 
 public class JAXWSContainer extends WSDLToJavaContainer {
     
@@ -73,6 +76,12 @@
             }
             env.put(ToolConstants.CFG_BINDING, bindings);
         }        
+    }
+
+    public List<AbstractValidator> getServiceValidators() {
+        List<AbstractValidator> validators = new ArrayList<AbstractValidator>();
+        validators.add(new XMLFormatValidator(context.get(ServiceInfo.class)));
+        return validators;
     }
     
 }

Modified: incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java?view=diff&rev=497227&r1=497226&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
(original)
+++ incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ServiceProcessor.java
Wed Jan 17 15:01:31 2007
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -323,6 +324,9 @@
         List<ExtensibilityElement> inbindings = null;
         if (operation.getInput() != null) {
             inbindings = operation.getInput().getExtensors(ExtensibilityElement.class);
+            if (inbindings == null) {
+                inbindings = new ArrayList<ExtensibilityElement>();
+            }
         }
         String use = null;
         for (ExtensibilityElement ext : inbindings) {
@@ -367,6 +371,9 @@
         if (operation.getOutput() != null) {
             List<ExtensibilityElement> outbindings =
                 operation.getOutput().getExtensors(ExtensibilityElement.class);
+            if (outbindings == null) {
+                outbindings = new ArrayList<ExtensibilityElement>();
+            }
             for (ExtensibilityElement ext : outbindings) {
                 if (SOAPBindingUtil.isSOAPHeader(ext)) {
                     SoapHeader soapHeader = SOAPBindingUtil.getSoapHeader(ext);
@@ -454,15 +461,18 @@
 
         // begin process input
         if (bop.getInput() != null) {
-            for (ExtensibilityElement ext : bop.getInput().getExtensors(ExtensibilityElement.class))
{
-                if (SOAPBindingUtil.isSOAPBody(ext)) {
-                    bodyMessage = getMessage(operationName, true);
-                }
-                if (SOAPBindingUtil.isSOAPHeader(ext)) {
-                    header = SOAPBindingUtil.getSoapHeader(ext);
-                    headerMessage = header.getMessage();
-                    if (header.getPart().length() > 0) {
-                        containParts = true;
+            List<ExtensibilityElement> extensors = bop.getInput().getExtensors(ExtensibilityElement.class);
+            if (extensors != null) {
+                for (ExtensibilityElement ext : extensors) {
+                    if (SOAPBindingUtil.isSOAPBody(ext)) {
+                        bodyMessage = getMessage(operationName, true);
+                    }
+                    if (SOAPBindingUtil.isSOAPHeader(ext)) {
+                        header = SOAPBindingUtil.getSoapHeader(ext);
+                        headerMessage = header.getMessage();
+                        if (header.getPart().length() > 0) {
+                            containParts = true;
+                        }
                     }
                 }
             }
@@ -484,15 +494,18 @@
 
         // process output
         if (bop.getOutput() != null) {
-            for (ExtensibilityElement ext : bop.getOutput().getExtensors(ExtensibilityElement.class))
{
-                if (SOAPBindingUtil.isSOAPBody(ext)) {
-                    bodyMessage = getMessage(operationName, false);
-                }
-                if (SOAPBindingUtil.isSOAPHeader(ext)) {
-                    header = SOAPBindingUtil.getSoapHeader(ext);
-                    headerMessage = header.getMessage();
-                    if (header.getPart().length() > 0) {
-                        containParts = true;
+            List<ExtensibilityElement> extensors = bop.getOutput().getExtensors(ExtensibilityElement.class);
+            if (extensors != null) {
+                for (ExtensibilityElement ext : extensors) {
+                    if (SOAPBindingUtil.isSOAPBody(ext)) {
+                        bodyMessage = getMessage(operationName, false);
+                    }
+                    if (SOAPBindingUtil.isSOAPHeader(ext)) {
+                        header = SOAPBindingUtil.getSoapHeader(ext);
+                        headerMessage = header.getMessage();
+                        if (header.getPart().length() > 0) {
+                            containParts = true;
+                        }
                     }
                 }
             }

Copied: incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/validator/XMLFormatValidator.java
(from r497017, incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/XMLFormatValidator.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/validator/XMLFormatValidator.java?view=diff&rev=497227&p1=incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/XMLFormatValidator.java&r1=497017&p2=incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/validator/XMLFormatValidator.java&r2=497227
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/XMLFormatValidator.java
(original)
+++ incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/validator/XMLFormatValidator.java
Wed Jan 17 15:01:31 2007
@@ -17,46 +17,47 @@
  * under the License.
  */
 
-package org.apache.cxf.tools.validator.internal; 
+package org.apache.cxf.tools.wsdlto.frontend.jaxws.validator; 
 
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
-import javax.wsdl.Binding;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.Definition;
-import javax.wsdl.Operation;
+
+import javax.wsdl.extensions.ExtensibilityElement;
 import javax.xml.namespace.QName;
 
-import org.apache.cxf.tools.common.extensions.xmlformat.XMLFormat;
-import org.apache.cxf.tools.common.extensions.xmlformat.XMLFormatBinding;
+import org.apache.cxf.bindings.xformat.XMLBindingMessageFormat;
+
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.tools.common.WSDLConstants;
+import org.apache.cxf.tools.validator.internal.AbstractValidator;
 
-public class XMLFormatValidator
-    extends AbstractValidator {
+public class XMLFormatValidator extends AbstractValidator {
 
-    public XMLFormatValidator(Definition def) {
-        super(def);
+    private ServiceInfo service;
+
+    public XMLFormatValidator(ServiceInfo s) {
+        this.service = s;
     }
 
     @Override
     public boolean isValid() {
-        // TODO Auto-generated method stub
         return checkXMLBindingFormat();
     }
 
     @SuppressWarnings("unchecked")
     private boolean checkXMLBindingFormat() {
-        Collection<Binding> bindings = def.getBindings().values();
+        Collection<BindingInfo> bindings = service.getBindings();
         if (bindings != null) {
-            for (Binding binding : bindings) {
-                Iterator it = binding.getExtensibilityElements().iterator();
-                while (it.hasNext()) {
-                    if (it.next() instanceof XMLFormatBinding) {
-                        if (!checkXMLFormat(binding)) {
-                            return false;
-                        }
-                    } else {
-                        break;
+            for (BindingInfo binding : bindings) {
+                System.err.println(binding.getBindingId());
+                System.err.println(WSDLConstants.XML_BINDING_NS);
+                if (WSDLConstants.XML_BINDING_NS.equalsIgnoreCase(binding.getBindingId()))
{
+                    if (!checkXMLFormat(binding)) {
+                        return false;
                     }
                 }
             }
@@ -65,32 +66,45 @@
     }
 
     @SuppressWarnings("unchecked")
-    private boolean checkXMLFormat(Binding binding) {
-        List<BindingOperation> bos = binding.getBindingOperations();
+    private boolean checkXMLFormat(BindingInfo binding) {
+        Collection<BindingOperationInfo> bos = binding.getOperations();
+        System.err.println("operation size: " + bos.size());
         boolean result = true;
         boolean needRootNode = false;
-        for (BindingOperation bo : bos) {
-            Operation op = binding.getPortType().getOperation(bo.getName(), null, null);
+        for (BindingOperationInfo bo : bos) {
+            OperationInfo op = binding.getInterface().getOperation(bo.getName());
+            System.err.println("operation: " + op.getName());
             needRootNode = false;
-            if (op.getInput().getMessage().getParts().size() == 0
-                || op.getInput().getMessage().getParts().size() > 1) {
+            if (op.getInput().getMessageParts().size() == 0
+                || op.getInput().getMessageParts().size() > 1) {
                 needRootNode = true;
             }
+            System.err.println("needRootNode " + needRootNode);
             if (needRootNode) {
-                String path = "Binding(" + binding.getQName().getLocalPart()
-                              + "):BindingOperation(" + bo.getName() + ")";
-                Iterator itIn = bo.getBindingInput().getExtensibilityElements().iterator();
+                String path = "Binding(" + binding.getName().getLocalPart()
+                    + "):BindingOperation(" + bo.getName() + ")";
+                List<ExtensibilityElement> inExtensors =
+                    bo.getInput().getExtensors(ExtensibilityElement.class);
+                Iterator itIn = null;
+                if (inExtensors != null) {
+                    itIn = inExtensors.iterator();
+                }
                 if (findXMLFormatRootNode(itIn, bo, path + "-input")) {
                     // Input check correct, continue to check output binding
                     needRootNode = false;
-                    if (op.getOutput().getMessage().getParts().size() == 0
-                        || op.getOutput().getMessage().getParts().size() > 1) {
+                    if (op.getOutput().getMessageParts().size() == 0
+                        || op.getOutput().getMessageParts().size() > 1) {
                         needRootNode = true;
                     }
                     if (needRootNode) {
-                        Iterator itOut = bo.getBindingInput().getExtensibilityElements().iterator();
+                        List<ExtensibilityElement> outExtensors =
+                            bo.getOutput().getExtensors(ExtensibilityElement.class);
+                        Iterator itOut = null;
+                        if (outExtensors != null) {
+                            itOut = outExtensors.iterator();
+                        }
                         result = result
-                                 && findXMLFormatRootNode(itOut, bo, path + "-Output");
+                            && findXMLFormatRootNode(itOut, bo, path + "-Output");
                         if (!result) {
                             return false;
                         }
@@ -103,13 +117,12 @@
         return true;
     }
 
-    private boolean findXMLFormatRootNode(Iterator it, BindingOperation bo, String errorPath)
{
-        while (it.hasNext()) {
+    private boolean findXMLFormatRootNode(Iterator it, BindingOperationInfo bo, String errorPath)
{
+        while (it != null && it.hasNext()) {
             Object ext = it.next();
-            if (ext instanceof XMLFormat) {
-                XMLFormat xmlFormat = (XMLFormat)ext;
-                // String rootNodeValue = def.getPrefix(def.getTargetNamespace()) + ":" +
bo.getName();
-                QName rootNodeName = new QName(def.getTargetNamespace(), bo.getName());
+            if (ext instanceof XMLBindingMessageFormat) {
+                XMLBindingMessageFormat xmlFormat = (XMLBindingMessageFormat)ext;
+                QName rootNodeName = bo.getName();
                 if (xmlFormat.getRootNode() != null) {
                     if (xmlFormat.getRootNode().equals(rootNodeName)) {
                         return true;

Added: incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java?view=auto&rev=497227
==============================================================================
--- incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java
(added)
+++ incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java
Wed Jan 17 15:01:31 2007
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.tools.wsdlto.validator;
+
+import org.apache.cxf.tools.common.ProcessorTestBase;
+import org.apache.cxf.tools.common.ToolConstants;
+import org.apache.cxf.tools.wsdlto.WSDLToJavaContainer;
+import org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSContainer;
+    
+public class ValidatorTest extends ProcessorTestBase {
+    private WSDLToJavaContainer processor;
+
+    public void setUp() throws Exception {
+        super.setUp();
+        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+        env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
+        //env.put(ToolConstants.CFG_VALIDATE_WSDL, ToolConstants.CFG_VALIDATE_WSDL);
+    }
+    
+    public void testXMLFormat() throws Exception {
+        processor = new JAXWSContainer(null);
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/xml_format_root.wsdl"));
+        processor.setContext(env);
+
+        processor.execute(false);
+
+        // TODO 1: check the exception here:
+        // Binding(Greeter_XMLBinding):BindingOperation({http://apache.org/xml_http_bare}sayHi)-input:
+        //   missing xml format body element
+
+        // TODO 2: turn the validate on
+
+        // TODO 3: change the jaxwscontainer to jaxws_wsdl_to_java_processor, so we can catch
the exception
+    }
+    
+    private String getLocation(String wsdlFile) {
+        return this.getClass().getResource(wsdlFile).getFile();
+    }
+
+}

Propchange: incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/validator/ValidatorTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/tools2/wsdlto/test/src/test/resources/wsdl2java_wsdl/xml_format_root.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/test/src/test/resources/wsdl2java_wsdl/xml_format_root.wsdl?view=auto&rev=497227
==============================================================================
--- incubator/cxf/trunk/tools2/wsdlto/test/src/test/resources/wsdl2java_wsdl/xml_format_root.wsdl
(added)
+++ incubator/cxf/trunk/tools2/wsdlto/test/src/test/resources/wsdl2java_wsdl/xml_format_root.wsdl
Wed Jan 17 15:01:31 2007
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<wsdl:definitions name="XMLOverHttp" 
+	     targetNamespace="http://apache.org/xml_http_bare" 
+	     xmlns="http://schemas.xmlsoap.org/wsdl/" 
+	     xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
+	     xmlns:tns="http://apache.org/xml_http_bare" 
+	     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+	     xmlns:xformat="http://cxf.apache.org/bindings/xformat" 
+	     xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+  <wsdl:types>
+    <schema targetNamespace="http://apache.org/xml_http_bare"
+	    xmlns="http://www.w3.org/2001/XMLSchema">
+      <element name="responseType" type="xsd:string"/>
+      <element name="requestType" type="xsd:string"/>
+    </schema>
+  </wsdl:types>
+
+  <wsdl:message name="sayHiRequest"/>
+  <wsdl:message name="sayHiResponse">
+    <wsdl:part element="tns:responseType" name="theResponse"/>
+  </wsdl:message>
+  <wsdl:message name="greetMeRequest">
+    <wsdl:part element="tns:requestType" name="me"/>
+  </wsdl:message>
+
+  <wsdl:portType name="Greeter">
+    <wsdl:operation name="sayHi">
+      <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+      <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+    </wsdl:operation>
+    <wsdl:operation name="greetMe">
+      <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+      <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+    </wsdl:operation>
+  </wsdl:portType>
+
+  <wsdl:binding name="Greeter_XMLBinding" type="tns:Greeter">
+    <xformat:binding/>
+    <wsdl:operation name="sayHi">
+      <wsdl:input name="sayHiRequest">
+	<!--xformat:body rootNode="tns:sayHi"/-->
+      </wsdl:input>
+      <wsdl:output name="sayHiResponse">
+      </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="greetMe">
+      <wsdl:input name="greetMeRequest"/>
+      <wsdl:output name="greetMeResponse"/>
+    </wsdl:operation>
+  </wsdl:binding>
+
+  <wsdl:service name="XMLService">
+
+	<wsdl:port binding="tns:Greeter_XMLBinding" name="XMLPort">
+	<http:address location="http://localhost:9090/some_url"/>
+	</wsdl:port>
+
+  </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file

Propchange: incubator/cxf/trunk/tools2/wsdlto/test/src/test/resources/wsdl2java_wsdl/xml_format_root.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools2/wsdlto/test/src/test/resources/wsdl2java_wsdl/xml_format_root.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/tools2/wsdlto/test/src/test/resources/wsdl2java_wsdl/xml_format_root.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message