You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ba...@apache.org on 2007/04/11 17:43:05 UTC

svn commit: r527531 - /webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/URIResolverImpl.java

Author: barrettj
Date: Wed Apr 11 08:43:05 2007
New Revision: 527531

URL: http://svn.apache.org/viewvc?view=rev&rev=527531
Log:
AXIS2-2506
Fix contributed by Dustin Amrhein.  Set systemId to the resolved location.

Modified:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/URIResolverImpl.java

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/URIResolverImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/URIResolverImpl.java?view=diff&rev=527531&r1=527530&r2=527531
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/URIResolverImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/URIResolverImpl.java Wed Apr 11 08:43:05 2007
@@ -20,6 +20,8 @@
 
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.ws.commons.schema.resolver.URIResolver;
 import org.xml.sax.InputSource;
 
@@ -39,6 +41,8 @@
     private final String FILE_PROTOCOL = "file";
 
     private ClassLoader classLoader;
+    
+    private static final Log log = LogFactory.getLog(URIResolverImpl.class);
 
     public URIResolverImpl() {
     }
@@ -52,32 +56,56 @@
 
         InputStream is = null;
         URI pathURI = null;
+        String pathURIStr = null;
+        if(log.isDebugEnabled()) {
+            log.debug("Import location: " + schemaLocation + " parent document: " + 
+                    baseUri);
+        }
         if (baseUri != null) {
             try {
                 // if the location is an absolute path, build a URL directly
                 // from it
 
                 if (isAbsolute(schemaLocation)) {
+                    if(log.isDebugEnabled()) {
+                        log.debug("Retrieving input stream for absolute schema location: "
+                                + schemaLocation);
+                    }
                     is = getInputStreamForURI(schemaLocation);
                 }
 
-                // Try baseURI + relavtive schema path combo
                 else {
                     pathURI = new URI(baseUri);
-                    String pathURIStr = schemaLocation;
+                    pathURIStr = schemaLocation;
                     // If this is absolute we need to resolve the path without the 
                     // scheme information
                     if (pathURI.isAbsolute()) {
+                        if(log.isDebugEnabled()) {
+                            log.debug("Parent document is at absolute location: " + 
+                                    pathURI.toString());
+                        }
                         URL url = new URL(baseUri);
                         if (url != null) {
                             URI tempURI = new URI(url.getPath());
                             URI resolvedURI = tempURI.resolve(schemaLocation);
                             // Add back the scheme to the resolved path
                             pathURIStr = constructPath(url, resolvedURI);
+                            if(log.isDebugEnabled()) {
+                                log.debug("Resolved this path to imported document: " + 
+                                        pathURIStr);
+                            }
                         }
                     } else {
+                        if(log.isDebugEnabled()) {
+                            log.debug("Parent document is at relative location: " + 
+                                    pathURI.toString());
+                        }
                         pathURI = pathURI.resolve(schemaLocation);
                         pathURIStr = pathURI.toString();
+                        if(log.isDebugEnabled()) {
+                            log.debug("Resolved this path to imported document: " + 
+                                    pathURIStr);
+                        }
                     }
                     // If path is absolute, build URL directly from it
                     if (isAbsolute(pathURIStr)) {
@@ -98,11 +126,24 @@
 
             }
         }
+        if(is == null) {
+            if(log.isDebugEnabled()) {
+                log.debug("XSD input stream is null after resolving import for: " + 
+                        schemaLocation + " from parent document: " + baseUri);
+            }
+        }
+        else {
+            if(log.isDebugEnabled()) {
+                log.debug("XSD input stream is not null after resolving import for: " + 
+                        schemaLocation + " from parent document: " + baseUri);
+            }
+        }
+
         InputSource returnInputSource = new InputSource(is);
         // We need to set the systemId.  XmlSchema will use this value to maintain a collection of
         // imported XSDs that have been read.  If this value is null, then circular XSDs will 
         // cause infinite recursive reads.
-        returnInputSource.setSystemId(schemaLocation);
+        returnInputSource.setSystemId(pathURIStr != null ? pathURIStr : schemaLocation);
         return returnInputSource;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org