cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1102788 - in /cxf/trunk: rt/core/src/main/java/org/apache/cxf/catalog/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/simple/src/main/java/org/apach...
Date Fri, 13 May 2011 15:20:15 GMT
Author: sergeyb
Date: Fri May 13 15:20:14 2011
New Revision: 1102788

URL: http://svn.apache.org/viewvc?rev=1102788&view=rev
Log:
[CXF-3498] Better support for grammars with referenced schemas

Added:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManagerHelper.java   (with props)
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImport.xml   (with props)
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImportCatalog.xml   (with props)
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/jax-rs-catalog.xml   (with props)
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/book.xsd   (with props)
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/chapter.xsd   (with props)
Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
    cxf/trunk/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java
    cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/singleResource.xml
    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/customization/CustomizationParser.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java Fri May 13 15:20:14 2011
@@ -99,19 +99,13 @@ public class CatalogWSDLLocator implemen
 
     public InputSource getImportInputSource(String parent, String importLocation) {
         String resolvedImportLocation = null;
-        if (manager != null) {
-            try {
-                resolvedImportLocation = this.manager.resolveSystem(importLocation);
-                if (resolvedImportLocation == null) {
-                    resolvedImportLocation = manager.resolveURI(importLocation);
-                }
-                if (resolvedImportLocation == null) {
-                    resolvedImportLocation = manager.resolvePublic(importLocation, parent);
-                }
-            } catch (IOException e) {
-                throw new RuntimeException("Catalog resolution failed", e);
-            }
+        try {
+            resolvedImportLocation = new OASISCatalogManagerHelper().resolve(manager, 
+                                         importLocation, parent);
+        } catch (IOException e) {
+            throw new RuntimeException("Catalog resolution failed", e);
         }
+        
 
         InputSource in = null;
         if (resolvedImportLocation == null) {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java Fri May 13 15:20:14 2011
@@ -54,20 +54,13 @@ public class CatalogXmlSchemaURIResolver
     public InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri) {
         String resolvedSchemaLocation = null;
         OASISCatalogManager catalogResolver = OASISCatalogManager.getCatalogManager(bus);
-        if (catalogResolver != null) {
-            try {
-                resolvedSchemaLocation = catalogResolver.resolveSystem(schemaLocation);
-                
-                if (resolvedSchemaLocation == null) {
-                    resolvedSchemaLocation = catalogResolver.resolveURI(schemaLocation);
-                }
-                if (resolvedSchemaLocation == null) {
-                    resolvedSchemaLocation = catalogResolver.resolvePublic(schemaLocation, baseUri);
-                }
-            } catch (IOException e) {
-                throw new RuntimeException("Catalog resolution failed", e);
-            }
+        try {
+            resolvedSchemaLocation = new OASISCatalogManagerHelper().resolve(catalogResolver, 
+                                          schemaLocation, baseUri);
+        } catch (Exception e) {
+            throw new RuntimeException("Catalog resolution failed", e);
         }
+        
         InputSource in = null;
         if (resolvedSchemaLocation == null) {
             in = this.resolver.resolve(schemaLocation, baseUri);

Added: cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManagerHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManagerHelper.java?rev=1102788&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManagerHelper.java (added)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManagerHelper.java Fri May 13 15:20:14 2011
@@ -0,0 +1,39 @@
+/**
+ * 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.catalog;
+
+import java.io.IOException;
+
+public class OASISCatalogManagerHelper {
+    public String resolve(OASISCatalogManager catalogResolver,
+                          String target, String base) throws IOException {
+        String resolvedLocation = null;
+        if (catalogResolver != null) {
+            resolvedLocation  = catalogResolver.resolveSystem(target);
+            
+            if (resolvedLocation == null) {
+                resolvedLocation = catalogResolver.resolveURI(target);
+            }
+            if (resolvedLocation == null) {
+                resolvedLocation = catalogResolver.resolvePublic(target, base);
+            }                
+        }
+        return resolvedLocation;
+    }
+}

Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManagerHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManagerHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java Fri May 13 15:20:14 2011
@@ -23,7 +23,11 @@ import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
 import java.io.StringReader;
+import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -62,6 +66,9 @@ import org.w3c.dom.Node;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXParseException;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.catalog.OASISCatalogManager;
+import org.apache.cxf.catalog.OASISCatalogManagerHelper;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.ReflectionInvokationHandler;
@@ -74,6 +81,8 @@ import org.apache.cxf.jaxb.JAXBUtils.S2J
 import org.apache.cxf.jaxb.JAXBUtils.SchemaCompiler;
 import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.ResourceUtils;
+import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.cxf.staxutils.StaxUtils;
 
 /**
@@ -116,11 +125,13 @@ public class SourceGenerator {
     private boolean generateImpl;
     private String resourcePackageName;
     private String resourceName;
+    private String baseWadlPath;
     
     private Map<String, String> properties; 
     
     private List<String> generatedServiceClasses = new ArrayList<String>(); 
     private List<String> generatedTypeClasses = new ArrayList<String>();
+    private Bus bus;
     
     public SourceGenerator() {
         this(Collections.<String, String>emptyMap());
@@ -154,7 +165,7 @@ public class SourceGenerator {
         Element appElement = readWadl(wadl);
         
         Set<String> typeClassNames = new HashSet<String>();
-        List<Element> schemaElements = getSchemaElements(appElement);
+        List<SchemaInfo> schemaElements = getSchemaElements(appElement);
         if (schemaElements != null && !schemaElements.isEmpty()) {
             // generate classes from schema
             JCodeModel codeModel = createCodeModel(schemaElements, typeClassNames);
@@ -168,7 +179,7 @@ public class SourceGenerator {
         }
     }
     
-    private void generateResourceClasses(Element appElement, List<Element> schemaElements, 
+    private void generateResourceClasses(Element appElement, List<SchemaInfo> schemaElements, 
                                          Set<String> typeClassNames, File src) {
         List<Element> resourcesEls = DOMUtils.getChildrenWithName(appElement, 
             WadlGenerator.WADL_NS, "resources");
@@ -198,7 +209,7 @@ public class SourceGenerator {
         
     }
     
-    private GrammarInfo getGrammarInfo(Element appElement, List<Element> schemaElements) {
+    private GrammarInfo getGrammarInfo(Element appElement, List<SchemaInfo> schemaElements) {
         
         if (schemaElements == null || schemaElements.isEmpty()) {
             return null;
@@ -215,8 +226,8 @@ public class SourceGenerator {
             }
         }
         Map<String, String> elementTypeMap = new HashMap<String, String>();
-        for (Element schemaEl : schemaElements) {
-            List<Element> elementEls = DOMUtils.getChildrenWithName(schemaEl, 
+        for (SchemaInfo schemaEl : schemaElements) {
+            List<Element> elementEls = DOMUtils.getChildrenWithName(schemaEl.getElement(), 
                  XmlSchemaConstants.XSD_NAMESPACE_URI, "element");
             for (Element el : elementEls) {
                 String type = el.getAttribute("type");
@@ -700,8 +711,12 @@ public class SourceGenerator {
     }
     
     private Element readWadl(String wadl) {
+        return readXmlDocument(new StringReader(wadl));
+    }
+    
+    private Element readXmlDocument(Reader reader) {
         try {
-            return StaxUtils.read(new InputSource(new StringReader(wadl))).getDocumentElement();
+            return StaxUtils.read(new InputSource(reader)).getDocumentElement();
         } catch (Exception ex) {
             throw new IllegalStateException("Unable to read wadl", ex);
         }
@@ -718,20 +733,72 @@ public class SourceGenerator {
         }
     }
 
-    private List<Element> getSchemaElements(Element appElement) {
+    private List<SchemaInfo> getSchemaElements(Element appElement) {
         List<Element> grammarEls = DOMUtils.getChildrenWithName(appElement, 
                                                                 WadlGenerator.WADL_NS, "grammars");
         if (grammarEls.size() != 1) {
             return null;
         }
         
+        List<SchemaInfo> schemas = new ArrayList<SchemaInfo>();
         List<Element> schemasEls = DOMUtils.getChildrenWithName(grammarEls.get(0), 
              XmlSchemaConstants.XSD_NAMESPACE_URI, "schema");
-        //TODO : check remote referencs if size() == 0
-        return schemasEls;
+        for (Element schemaEl : schemasEls) {
+            schemas.add(createSchemaInfo(schemaEl, baseWadlPath));
+        }
+        List<Element> includeEls = DOMUtils.getChildrenWithName(grammarEls.get(0), 
+             WadlGenerator.WADL_NS, "include");
+        for (Element includeEl : includeEls) {
+            String href = includeEl.getAttribute("href");
+            
+            String schemaURI = resolveLocationWithCatalog(href);
+            if (schemaURI == null) {
+                schemaURI = baseWadlPath != null ? baseWadlPath + href : href;
+            }
+            schemas.add(createSchemaInfo(readIncludedSchema(schemaURI),
+                                            schemaURI));
+        }
+        return schemas;
+    }
+    
+    private SchemaInfo createSchemaInfo(Element schemaEl, String systemId) { 
+        SchemaInfo info = new SchemaInfo(schemaEl.getAttribute("targetNamespace"));
+        info.setElement(schemaEl);
+        info.setSystemId(systemId);
+        return info;
+    }
+    
+    private String resolveLocationWithCatalog(String href) {
+        if (bus != null) {
+            OASISCatalogManager catalogResolver = OASISCatalogManager.getCatalogManager(bus);
+            try {
+                return new OASISCatalogManagerHelper().resolve(catalogResolver, 
+                                                               href, null);
+            } catch (Exception e) {
+                throw new RuntimeException("Catalog resolution failed", e);
+            }
+        } else {
+            return null;
+        }
     }
     
-    private JCodeModel createCodeModel(List<Element> schemaElements, Set<String> type) {
+    private Element readIncludedSchema(String href) {
+        
+        try {
+            InputStream is = null;
+            if (!href.startsWith("http")) {
+                is = ResourceUtils.getResourceStream(href, bus);
+            }
+            if (is == null) {
+                is = URI.create(href).toURL().openStream();
+            }
+            return readXmlDocument(new InputStreamReader(is, "UTF-8"));
+        } catch (Exception ex) {
+            throw new RuntimeException("Schema " + href + " can not be read");
+        }
+    }
+    
+    private JCodeModel createCodeModel(List<SchemaInfo> schemaElements, Set<String> type) {
         
 
         SchemaCompiler compiler = createCompiler(type);
@@ -753,17 +820,34 @@ public class SourceGenerator {
         return JAXBUtils.createSchemaCompilerWithDefaultAllocator(typeClassNames);
     }
     
-    private void addSchemas(List<Element> schemaElements, SchemaCompiler compiler) {
+    private void addSchemas(List<SchemaInfo> schemas, SchemaCompiler compiler) {
         
-        for (int i = 0; i < schemaElements.size(); i++) {
-            String key = Integer.toString(i);
-            //For JAXB 2.1.8
+        for (int i = 0; i < schemas.size(); i++) {
+            SchemaInfo schema = schemas.get(i);
+            
+            String key = schema.getSystemId();
+            if (key != null) {
+                // TODO: CXF code should have a better solution somewhere, we'll get back to it
+                // when addressing the issue of retrieving WADLs with included schemas  
+                if (key.startsWith("classpath:")) {
+                    String resource = key.substring(10);
+                    URL url = getClass().getResource(resource);
+                    if (url != null) {
+                        try {
+                            key = url.toURI().toString();
+                        } catch (Exception ex) {
+                            // won't happen
+                        }
+                    }
+                }
+            } else {
+                key = Integer.toString(i);
+            }
             InputSource is = new InputSource((InputStream)null);
             is.setSystemId(key);
             is.setPublicId(key);
             compiler.getOptions().addGrammar(is);
-    
-            compiler.parseSchema(key, schemaElements.get(i));
+            compiler.parseSchema(key, schema.getElement());
         }
     }
     
@@ -792,6 +876,14 @@ public class SourceGenerator {
         this.resourceName = name;
     }
     
+    public void setBaseWadlPath(String name) {
+        this.baseWadlPath = name;
+    }
+    
+    public void setBus(Bus bus) {
+        this.bus = bus;
+    }
+    
     public List<String> getGeneratedServiceClasses() {
         return generatedServiceClasses;    
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java Fri May 13 15:20:14 2011
@@ -28,6 +28,7 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -390,7 +391,7 @@ public final class ResourceUtils {
                 return null;
             }
         } else {
-            File f = new File(loc);
+            File f = new File(URI.create(loc).getRawPath());
             if (!f.exists()) {
                 LOG.warning("No file resource " + loc + " is available on local disk");
                 return null;

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java (original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java Fri May 13 15:20:14 2011
@@ -53,6 +53,7 @@ import org.xml.sax.InputSource;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.catalog.OASISCatalogManager;
+import org.apache.cxf.catalog.OASISCatalogManagerHelper;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.CastUtils;
@@ -367,22 +368,12 @@ public class WSDLGetInterceptor extends 
     }
 
     static String resolveWithCatalogs(OASISCatalogManager catalogs, String start, String base) {
-        if (catalogs == null) {
-            return null;
-        }
-        String resolvedSchemaLocation = null;
         try {
-            resolvedSchemaLocation = catalogs.resolveSystem(start);
-            if (resolvedSchemaLocation == null) {
-                resolvedSchemaLocation = catalogs.resolveURI(start);
-            }
-            if (resolvedSchemaLocation == null) {
-                resolvedSchemaLocation = catalogs.resolvePublic(start, base);
-            }
+            return new OASISCatalogManagerHelper().resolve(catalogs, start, base);
         } catch (Exception ex) {
             //ignore
         }
-        return resolvedSchemaLocation;
+        return null;
     }
     
     protected void updateDefinition(Bus bus,

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=1102788&r1=1102787&r2=1102788&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 Fri May 13 15:20:14 2011
@@ -45,6 +45,7 @@ import org.xml.sax.InputSource;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.catalog.OASISCatalogManager;
+import org.apache.cxf.catalog.OASISCatalogManagerHelper;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
@@ -78,13 +79,8 @@ public class WSDL11Validator extends Abs
         try {
             OASISCatalogManager catalogResolver = OASISCatalogManager.getCatalogManager(this.getBus());
 
-            String nw = catalogResolver.resolveSystem(wsdl);
-            if (nw == null) {
-                nw = catalogResolver.resolveURI(wsdl);
-            }
-            if (nw == null) {
-                nw = catalogResolver.resolvePublic(wsdl, null);
-            }
+            String nw = new OASISCatalogManagerHelper().resolve(catalogResolver, 
+                                                                wsdl, null);
             if (nw == null) {
                 nw = wsdl;
             }

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/WadlToolConstants.java Fri May 13 15:20:14 2011
@@ -33,13 +33,19 @@ public final class WadlToolConstants {
     public static final String CFG_INTERFACE = ToolConstants.CFG_INTERFACE;
     public static final String CFG_SERVER = ToolConstants.CFG_SERVER;
     public static final String CFG_TYPES = ToolConstants.CFG_TYPES;
-    
     public static final String CFG_PACKAGENAME = ToolConstants.CFG_PACKAGENAME;
     public static final String CFG_RESOURCENAME = "resourcename";
-    
+    public static final String CFG_CATALOG = ToolConstants.CFG_CATALOG;
     public static final String CFG_WADLURL = "wadl";
     
+    //public static final String CFG_NO_TYPES = ToolConstants.CFG_NO_TYPES;
+    //public static final String CFG_XJC_ARGS = ToolConstants.CFG_XJC_ARGS;
+    //public static final String CFG_BINDING = ToolConstants.CFG_BINDING;
         
+    //public static final String CFG_CMD_ARG = ToolConstants.CFG_CMD_ARG;
+    //public static final String CFG_INSTALL_DIR = ToolConstants.CFG_INSTALL_DIR;
+    //public static final String CFG_PLATFORM_VERSION = ToolConstants.CFG_PLATFORM_VERSION;
+    
     private WadlToolConstants() {
         //utility class
     }

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java Fri May 13 15:20:14 2011
@@ -82,9 +82,12 @@ public class JAXRSContainer extends Abst
 
     private void processWadl() {
         File outDir = new File((String)context.get(WadlToolConstants.CFG_OUTPUTDIR));
-        String wadl = readWadl();
-
+        String wadlURL = getAbsoluteWadlURL();
+        
+        String wadl = readWadl(wadlURL);
+        
         SourceGenerator sg = new SourceGenerator();
+        sg.setBus(getBus());
         boolean isInterface = context.optionSet(WadlToolConstants.CFG_INTERFACE);
         boolean isServer = context.optionSet(WadlToolConstants.CFG_SERVER);
         if (isServer) {
@@ -93,6 +96,12 @@ public class JAXRSContainer extends Abst
         }
         sg.setPackageName((String)context.get(WadlToolConstants.CFG_PACKAGENAME));
         sg.setResourceName((String)context.get(WadlToolConstants.CFG_RESOURCENAME));
+
+        // find the base path
+        int lastSep = wadlURL.lastIndexOf("/");
+        if (lastSep != -1) {
+            sg.setBaseWadlPath(wadlURL.substring(0, lastSep + 1));
+        }
         
         // generate
         String codeType = context.optionSet(WadlToolConstants.CFG_TYPES)
@@ -124,15 +133,17 @@ public class JAXRSContainer extends Abst
 
     }
     
-    protected String readWadl() {
-        String wadlURL = (String)context.get(WadlToolConstants.CFG_WADLURL);
-        wadlURL = URIParserUtil.getAbsoluteURI(wadlURL);
-        
+    protected String readWadl(String wadlURI) {
         try {
-            URL url = new URL(wadlURL);
+            URL url = new URL(wadlURI);
             return IOUtils.toString(url.openStream());
         } catch (IOException e) {
             throw new ToolException(e);
         }
-    }     
+    }
+    
+    protected String getAbsoluteWadlURL() {
+        String wadlURL = (String)context.get(WadlToolConstants.CFG_WADLURL);
+        return URIParserUtil.getAbsoluteURI(wadlURL);
+    }
 }

Modified: cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java Fri May 13 15:20:14 2011
@@ -47,8 +47,57 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyFiles("java", false, "org.apache.cxf.jaxrs.model.wadl");
-            verifyFiles("class", false, "org.apache.cxf.jaxrs.model.wadl");
+            verifyFiles("java", true, false, "org.apache.cxf.jaxrs.model.wadl");
+            verifyFiles("class", true, false, "org.apache.cxf.jaxrs.model.wadl");
+            
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+    
+    @Test    
+    public void testCodeGenWithImportedSchema() {
+        try {
+            JAXRSContainer container = new JAXRSContainer(null);
+
+            ToolContext context = new ToolContext();
+            context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+            context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstoreImport.xml"));
+            context.put(WadlToolConstants.CFG_COMPILE, "true");
+
+            container.setContext(context);
+            container.execute();
+
+            assertNotNull(output.list());
+            
+            verifyFiles("java", false, false, "org.apache.cxf.jaxrs.model.wadl");
+            verifyFiles("class", false, false, "org.apache.cxf.jaxrs.model.wadl");
+            
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+    
+    @Test    
+    public void testCodeGenWithImportedSchemaAndCatalog() {
+        try {
+            JAXRSContainer container = new JAXRSContainer(null);
+
+            ToolContext context = new ToolContext();
+            context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+            context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstoreImportCatalog.xml"));
+            context.put(WadlToolConstants.CFG_CATALOG, getLocation("/wadl/jax-rs-catalog.xml"));
+            context.put(WadlToolConstants.CFG_COMPILE, "true");
+
+            container.setContext(context);
+            container.execute();
+
+            assertNotNull(output.list());
+            
+            verifyFiles("java", false, false, "org.apache.cxf.jaxrs.model.wadl");
+            verifyFiles("class", false, false, "org.apache.cxf.jaxrs.model.wadl");
             
         } catch (Exception e) {
             e.printStackTrace();
@@ -65,16 +114,20 @@ public class JAXRSContainerTest extends 
             context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
             context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/singleResource.xml"));
             context.put(WadlToolConstants.CFG_RESOURCENAME, "CustomResource");
+            context.put(WadlToolConstants.CFG_COMPILE, "true");
             
             container.setContext(context);
             container.execute();
 
             assertNotNull(output.list());
             
-            List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "java" + "$");
-            assertEquals(1, files.size());
-            assertTrue(checkContains(files, "application.CustomResource.java"));
-            
+            List<File> javaFiles = FileUtils.getFilesRecurse(output, ".+\\." + "java" + "$");
+            assertEquals(1, javaFiles.size());
+            assertTrue(checkContains(javaFiles, "application.CustomResource.java"));
+            
+            List<File> classFiles = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
+            assertEquals(1, classFiles.size());
+            assertTrue(checkContains(classFiles, "application.CustomResource.class"));
         } catch (Exception e) {
             e.printStackTrace();
             fail();
@@ -97,8 +150,8 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyFiles("java", false, "custom.books");
-            verifyFiles("class", false, "custom.books");
+            verifyFiles("java", true, false, "custom.books");
+            verifyFiles("class", true, false, "custom.books");
             
         } catch (Exception e) {
             e.printStackTrace();
@@ -122,8 +175,8 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyFiles("java", false, "org.apache.cxf.jaxrs.model.wadl");
-            verifyFiles("class", false, "org.apache.cxf.jaxrs.model.wadl");
+            verifyFiles("java", true, false, "org.apache.cxf.jaxrs.model.wadl");
+            verifyFiles("class", true, false, "org.apache.cxf.jaxrs.model.wadl");
         } catch (Exception e) {
             fail();
             e.printStackTrace();
@@ -147,8 +200,8 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyFiles("java", true, "org.apache.cxf.jaxrs.model.wadl");
-            verifyFiles("class", true, "org.apache.cxf.jaxrs.model.wadl");
+            verifyFiles("java", true, true, "org.apache.cxf.jaxrs.model.wadl");
+            verifyFiles("class", true, true, "org.apache.cxf.jaxrs.model.wadl");
         } catch (Exception e) {
             fail();
             e.printStackTrace();
@@ -178,15 +231,23 @@ public class JAXRSContainerTest extends 
         }
     }
     
-    private void verifyFiles(String ext, boolean interfacesAndImpl, String resourcePackage) {
+    private void verifyFiles(String ext, boolean subresourceExpected, boolean interfacesAndImpl, 
+                             String resourcePackage) {
         List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + ext + "$");
-        assertEquals(interfacesAndImpl ? 9 : 7, files.size());
+        int size = interfacesAndImpl ? 9 : 7;
+        if (!subresourceExpected) {
+            size--;
+        }
+        assertEquals(size, files.size());
         doVerifyTypes(files, ext);
-        
-        assertTrue(checkContains(files, resourcePackage + ".FormInterface." + ext));
+        if (subresourceExpected) {
+            assertTrue(checkContains(files, resourcePackage + ".FormInterface." + ext));
+        }
         assertTrue(checkContains(files, resourcePackage + ".BookStore." + ext));
         if (interfacesAndImpl) {
-            assertTrue(checkContains(files, resourcePackage + ".FormInterfaceImpl." + ext));
+            if (subresourceExpected) {
+                assertTrue(checkContains(files, resourcePackage + ".FormInterfaceImpl." + ext));
+            }
             assertTrue(checkContains(files, resourcePackage + ".BookStoreImpl." + ext));
         }
     }

Modified: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml Fri May 13 15:20:14 2011
@@ -1,3 +1,22 @@
+<?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.
+-->
 <application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:prefix1="http://superbooks">
 
  <grammars>

Added: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImport.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImport.xml?rev=1102788&view=auto
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImport.xml (added)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImport.xml Fri May 13 15:20:14 2011
@@ -0,0 +1,40 @@
+<?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.
+-->
+<application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:prefix1="http://superbooks">
+
+ <grammars>
+    <include href="schemas/book.xsd"/>
+ </grammars>
+ <resources base="http://localhost:8080/baz">
+   <resource path="/bookstore" id="{org.apache.cxf.jaxrs.model.wadl}BookStore">
+    
+    <resource path="/books/{bookid}">
+     <param name="bookid" style="template" type="xs:int"/>
+     
+     <method name="POST" id="addBook">
+      <request>
+       <representation mediaType="application/xml" element="prefix1:thebook2"/>
+      </request>
+     </method>
+    </resource>
+   </resource>
+</resources>
+
+</application>

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImport.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImport.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImport.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImportCatalog.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImportCatalog.xml?rev=1102788&view=auto
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImportCatalog.xml (added)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImportCatalog.xml Fri May 13 15:20:14 2011
@@ -0,0 +1,40 @@
+<?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.
+-->
+<application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:prefix1="http://superbooks">
+
+ <grammars>
+    <include href="http://schemas/books/book.xsd"/>
+ </grammars>
+ <resources base="http://localhost:8080/baz">
+   <resource path="/bookstore" id="{org.apache.cxf.jaxrs.model.wadl}BookStore">
+    
+    <resource path="/books/{bookid}">
+     <param name="bookid" style="template" type="xs:int"/>
+     
+     <method name="POST" id="addBook">
+      <request>
+       <representation mediaType="application/xml" element="prefix1:thebook2"/>
+      </request>
+     </method>
+    </resource>
+   </resource>
+</resources>
+
+</application>

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImportCatalog.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImportCatalog.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstoreImportCatalog.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/jax-rs-catalog.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/jax-rs-catalog.xml?rev=1102788&view=auto
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/jax-rs-catalog.xml (added)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/jax-rs-catalog.xml Fri May 13 15:20:14 2011
@@ -0,0 +1,22 @@
+<?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.
+-->
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
+    <rewriteSystem systemIdStartString="http://schemas/books" rewritePrefix="classpath:/wadl/schemas"/>
+</catalog>

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/jax-rs-catalog.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/jax-rs-catalog.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/jax-rs-catalog.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/book.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/book.xsd?rev=1102788&view=auto
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/book.xsd (added)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/book.xsd Fri May 13 15:20:14 2011
@@ -0,0 +1,37 @@
+<?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.
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+  xmlns:tns="http://superbooks" attributeFormDefault="unqualified" elementFormDefault="unqualified" 
+  targetNamespace="http://superbooks">
+    <xs:include schemaLocation="chapter.xsd"/>
+    <xs:element name="thebook" type="tns:book"/>
+    <xs:complexType name="book">
+        <xs:sequence>
+            <xs:element minOccurs="0" ref="tns:thechapter"/>
+            <xs:element name="id" type="xs:int"/>
+        </xs:sequence>
+    </xs:complexType>
+    <xs:complexType name="book2">
+        <xs:sequence>
+            <xs:element name="id" type="xs:int"/>
+            <xs:element minOccurs="0" name="name" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+ </xs:schema>
\ No newline at end of file

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/book.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/book.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/book.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/chapter.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/chapter.xsd?rev=1102788&view=auto
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/chapter.xsd (added)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/chapter.xsd Fri May 13 15:20:14 2011
@@ -0,0 +1,29 @@
+<?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.
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+  xmlns:tns="http://superbooks" attributeFormDefault="unqualified" elementFormDefault="unqualified" 
+  targetNamespace="http://superbooks">
+    <xs:element name="thechapter" type="tns:chapter"/>
+    <xs:complexType name="chapter">
+        <xs:sequence>
+            <xs:element name="id" type="xs:int"/>
+        </xs:sequence>
+    </xs:complexType>
+ </xs:schema>
\ No newline at end of file

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/chapter.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/chapter.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/schemas/chapter.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/singleResource.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/singleResource.xml?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/singleResource.xml (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/singleResource.xml Fri May 13 15:20:14 2011
@@ -1,3 +1,22 @@
+<?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.
+-->
 <application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:prefix1="http://superbooks">
 
  <resources base="http://localhost:8080/baz">
@@ -11,6 +30,16 @@
        </representation>
       </response>
     </method>
+    <resource path="/books">
+     <method name="GET">
+      <response>
+       <representation mediaType="text/plain">
+        <param name="result" style="plain" type="xs:string"/>
+       </representation>
+      </response>
+    </method>
+   </resource>
+    
    </resource>
  </resources>  
 </application>

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=1102788&r1=1102787&r2=1102788&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 Fri May 13 15:20:14 2011
@@ -92,6 +92,7 @@ import com.sun.tools.xjc.reader.xmlschem
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.catalog.OASISCatalogManager;
+import org.apache.cxf.catalog.OASISCatalogManagerHelper;
 import org.apache.cxf.common.WSDLConstants;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
@@ -1165,24 +1166,17 @@ public class JAXBDataBinding implements 
         }
     }
     private static String mapSchemaLocation(String target, String base, OASISCatalogManager catalog) {
-        if (catalog != null) {
-            try {
-                String resolvedLocation = catalog.resolveSystem(target);
-
-                if (resolvedLocation == null) {
-                    resolvedLocation = catalog.resolveURI(target);
-                }
-                if (resolvedLocation == null) {
-                    resolvedLocation = catalog.resolvePublic(target, base);
-                }
-                if (resolvedLocation != null) {
-                    return resolvedLocation;
-                }
-
-            } catch (Exception ex) {
-                //ignore
+        try {
+            String resolvedLocation = new OASISCatalogManagerHelper().resolve(catalog, 
+                                                                              target, base);
+            if (resolvedLocation != null) {
+                return resolvedLocation;
             }
+
+        } catch (Exception ex) {
+            //ignore
         }
+        
 
         try {
             URIResolver resolver = new URIResolver(base, target);

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java (original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java Fri May 13 15:20:14 2011
@@ -44,6 +44,7 @@ import org.xml.sax.InputSource;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.catalog.OASISCatalogManager;
+import org.apache.cxf.catalog.OASISCatalogManagerHelper;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
@@ -550,20 +551,14 @@ public final class CustomizationParser {
         }
         Bus bus = (Bus)env.get(Bus.class);
         OASISCatalogManager catalogResolver = OASISCatalogManager.getCatalogManager(bus);
-        if (catalogResolver == null) {
-            return null;
-        }
-        String resolvedLocation;
+        
         try {
-            resolvedLocation = catalogResolver.resolveSystem(url);
-            if (resolvedLocation == null) {
-                resolvedLocation = catalogResolver.resolveURI(url);
-            }
+            return new OASISCatalogManagerHelper().resolve(catalogResolver, 
+                                                           url, null);
         } catch (Exception e1) {
             Message msg = new Message("FAILED_RESOLVE_CATALOG", LOG, url);
             throw new ToolException(msg, e1);
         }
-        return resolvedLocation;
     }
 
     private InputSource convertToTmpInputSource(Element ele, String schemaLoc) throws Exception {

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java?rev=1102788&r1=1102787&r2=1102788&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java (original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/CustomizedWSDLLocator.java Fri May 13 15:20:14 2011
@@ -29,6 +29,7 @@ import org.w3c.dom.Element;
 import org.xml.sax.InputSource;
 
 import org.apache.cxf.catalog.OASISCatalogManager;
+import org.apache.cxf.catalog.OASISCatalogManagerHelper;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.resource.ExtendedURIResolver;
 
@@ -59,17 +60,8 @@ public class CustomizedWSDLLocator imple
 
     private InputSource resolve(final String target, final String base) {
         try {
-            String resolvedLocation = null;
-            if (catalogResolver != null) {
-                resolvedLocation  = catalogResolver.resolveSystem(target);
-                
-                if (resolvedLocation == null) {
-                    resolvedLocation = catalogResolver.resolveURI(target);
-                }
-                if (resolvedLocation == null) {
-                    resolvedLocation = catalogResolver.resolvePublic(target, base);
-                }                
-            }
+            String resolvedLocation = 
+                new OASISCatalogManagerHelper().resolve(catalogResolver, target, base);
             if (resolvedLocation == null) {
                 return this.resolver.resolve(target, base);
             } else {



Mime
View raw message