geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r696894 - /geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/EndpointInfoBuilder.java
Date Fri, 19 Sep 2008 01:37:07 GMT
Author: gawor
Date: Thu Sep 18 18:37:07 2008
New Revision: 696894

URL: http://svn.apache.org/viewvc?rev=696894&view=rev
Log:
handle external wsdl/xsd imports in service-ref wsdl (GERONIMO-4311)

Modified:
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/EndpointInfoBuilder.java

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/EndpointInfoBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/EndpointInfoBuilder.java?rev=696894&r1=696893&r2=696894&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/EndpointInfoBuilder.java
(original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/EndpointInfoBuilder.java
Thu Sep 18 18:37:07 2008
@@ -362,19 +362,8 @@
         }
 
         public InputSource getBaseInputSource() {
-            InputStream wsdlInputStream;
-            ZipEntry entry = moduleFile.getEntry(wsdlURI.toString());
-            if (entry == null) {
-                throw new RuntimeException(
-                        "WSDL file does not exist in the module " + wsdlURI.toString());
-            }
-            try {
-                wsdlInputStream = moduleFile.getInputStream(entry);
-                streams.add(wsdlInputStream);
-            } catch (Exception e) {
-                throw new RuntimeException(
-                        "Could not open stream to wsdl file", e);
-            }
+            InputStream wsdlInputStream = getModuleFile(wsdlURI);
+            streams.add(wsdlInputStream);
             return new InputSource(wsdlInputStream);
         }
 
@@ -385,20 +374,19 @@
         public InputSource getImportInputSource(String parentLocation,
                                                 String relativeLocation) {
             URI parentURI = URI.create(parentLocation);
-            latestImportURI = parentURI.resolve(relativeLocation);
+            URI relativeURI = URI.create(relativeLocation);
             InputStream importInputStream;
-            ZipEntry entry = moduleFile.getEntry(latestImportURI.toString());
-            if (entry == null) {
-                throw new RuntimeException(
-                        "File does not exist in the module " + latestImportURI.toString());
-            }
-            try {                
-                importInputStream = moduleFile.getInputStream(entry);
-                streams.add(importInputStream);
-            } catch (Exception e) {
-                throw new RuntimeException(
-                        "Could not open stream to import file", e);
+            if (relativeURI.isAbsolute()) {
+                latestImportURI = relativeURI;
+                importInputStream = getExternalFile(latestImportURI);
+            } else if (parentURI.isAbsolute()) {
+                latestImportURI = parentURI.resolve(relativeLocation);
+                importInputStream = getExternalFile(latestImportURI);
+            } else {
+                latestImportURI = parentURI.resolve(relativeLocation);
+                importInputStream = getModuleFile(latestImportURI);
             }
+            streams.add(importInputStream);
             InputSource inputSource = new InputSource(importInputStream);
             inputSource.setSystemId(getLatestImportURI());
             return inputSource;
@@ -408,6 +396,29 @@
             return latestImportURI.toString();
         }
 
+        private InputStream getExternalFile(URI file) {
+            try {
+                return file.toURL().openStream();
+            } catch (Exception e) {
+                throw new RuntimeException(
+                        "Failed to import external file: " + latestImportURI, e);
+            }
+        }
+        
+        private InputStream getModuleFile(URI file) {
+            ZipEntry entry = moduleFile.getEntry(file.toString());
+            if (entry == null) {
+                throw new RuntimeException(
+                    "File does not exist in the module: " + file);
+            }
+            try {                
+                return moduleFile.getInputStream(entry);
+            } catch (Exception e) {
+                throw new RuntimeException(
+                    "Could not open stream to import file", e);
+            }
+        }
+        
         public void close() {
             for (InputStream inputStream : this.streams) {
                 try {



Mime
View raw message