servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r398685 - in /incubator/servicemix/trunk/servicemix-common/src: main/java/org/apache/servicemix/common/tools/wsdl/ test/java/org/apache/servicemix/common/tools/wsdl/
Date Mon, 01 May 2006 20:49:15 GMT
Author: gnodet
Date: Mon May  1 13:48:46 2006
New Revision: 398685

URL: http://svn.apache.org/viewcvs?rev=398685&view=rev
Log:
SM-419: WSDL for WS-Notification component are not available
Make sure that jar uri are resolved property.

Modified:
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/SchemaCollection.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattener.java
    incubator/servicemix/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattenerTest.java

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/SchemaCollection.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/SchemaCollection.java?rev=398685&r1=398684&r2=398685&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/SchemaCollection.java
(original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/SchemaCollection.java
Mon May  1 13:48:46 2006
@@ -25,6 +25,8 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -38,6 +40,8 @@
  */
 public class SchemaCollection {
 
+    private static Log log = LogFactory.getLog(SchemaCollection.class);
+    
     private Map schemas;
     private URI baseUri;
     
@@ -46,6 +50,9 @@
     }
     
     public SchemaCollection(URI baseUri) {
+        if (log.isDebugEnabled()) {
+            log.debug("Initializing schema collection with baseUri: " + baseUri);
+        }
         this.baseUri = baseUri;
         this.schemas = new HashMap();
     }
@@ -64,14 +71,23 @@
     }
     
     public void read(String location, URI baseUri) throws Exception {
+        if (log.isDebugEnabled()) {
+            log.debug("Reading schema at '" + location + "' with baseUri '" + baseUri + "'");
+        }
         if (baseUri == null) {
             baseUri = this.baseUri;
         }
         URI loc;
         if (baseUri != null) {
-            loc = baseUri.resolve(location);
+            loc = resolve(baseUri, location);
+            if (!loc.isAbsolute()) {
+                throw new IllegalArgumentException("Unable to resolve '" + loc.toString()
+ "' relative to '" + baseUri + "'");
+            }
         } else {
             loc = new URI(location);
+            if (!loc.isAbsolute()) {
+                throw new IllegalArgumentException("Location '" + loc.toString() + "' is
not absolute and no baseUri specified");
+            }
         }
         InputSource inputSource = new InputSource();
         inputSource.setByteStream(loc.toURL().openStream());
@@ -113,6 +129,16 @@
             schema.addImport(namespace);
             schema.getRoot().removeChild(ce);
         }
+    }
+    
+    protected static URI resolve(URI base, String location) {
+        if ("jar".equals(base.getScheme())) {
+            String str = base.toString();
+            String[] parts = str.split("!");
+            parts[1] = URI.create(parts[1]).resolve(location).toString();
+            return URI.create(parts[0] + "!" + parts[1]);
+        }
+        return base.resolve(location);
     }
 
 }

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattener.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattener.java?rev=398685&r1=398684&r2=398685&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattener.java
(original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattener.java
Mon May  1 13:48:46 2006
@@ -24,10 +24,15 @@
 import javax.wsdl.factory.WSDLFactory;
 import javax.xml.namespace.QName;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import com.ibm.wsdl.extensions.schema.SchemaImpl;
 
 public class WSDLFlattener {
 
+    private static Log log = LogFactory.getLog(WSDLFlattener.class);
+    
     private Definition definition;
     private SchemaCollection schemas;
     private Map flattened;

Modified: incubator/servicemix/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattenerTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattenerTest.java?rev=398685&r1=398684&r2=398685&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattenerTest.java
(original)
+++ incubator/servicemix/trunk/servicemix-common/src/test/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattenerTest.java
Mon May  1 13:48:46 2006
@@ -2,6 +2,7 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.net.URI;
 import java.net.URL;
 
 import javax.wsdl.Definition;
@@ -12,10 +13,10 @@
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import org.w3c.dom.Document;
-
 import junit.framework.TestCase;
 
+import org.w3c.dom.Document;
+
 public class WSDLFlattenerTest extends TestCase {
 
     public void test() throws Exception {
@@ -42,6 +43,14 @@
         assertEquals(1, newFlat.getPortTypes().size());
         PortType portType = (PortType) newFlat.getPortTypes().values().iterator().next();
         assertNotNull(portType);
+    }
+    
+    public void testResolve() throws Exception {
+        URI base = URI.create("jar:file:/C:/java/servicemix/servicemix-assembly/target/incubator-servicemix-3.0-SNAPSHOT/bin/incubator-servicemix-3.0-SNAPSHOT/bin/../lib/optional/servicemix-wsn2005-3.0-SNAPSHOT.jar!/org/apache/servicemix/wsn/wsn.wsdl");
+        String loc = "b-2.xsd";
+        URI rel = SchemaCollection.resolve(base, loc);
+        assertEquals("jar:file:/C:/java/servicemix/servicemix-assembly/target/incubator-servicemix-3.0-SNAPSHOT/bin/incubator-servicemix-3.0-SNAPSHOT/bin/../lib/optional/servicemix-wsn2005-3.0-SNAPSHOT.jar!/org/apache/servicemix/wsn/b-2.xsd",
rel.toString());
+        System.out.println(rel);
     }
     
 }



Mime
View raw message