tomj        02/05/09 11:38:23

  Modified:    java/src/org/apache/axis/wsdl/symbolTable SymbolTable.java
  Log:
  Once more fix the getURL function to correctly do imports.
  
  Convert backslashes to forward slashes for URL processing.
  The URL class does NOT treat them as the same for file URLs
  when constructed with new URL(context, spec).
  
  To verify, process a file (C:\foo\bar\baz.wsdl) that imports
  a simple filename (<import .. location="foo.wsdl"/>).
  Make sure your current directory is 'someplace else'
  
  Revision  Changes    Path
  1.3       +11 -6     
xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java
  
  Index: SymbolTable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SymbolTable.java  9 May 2002 15:25:21 -0000       1.2
  +++ SymbolTable.java  9 May 2002 18:38:22 -0000       1.3
  @@ -503,25 +503,30 @@
        * a file.
        */
       private static URL getURL(URL contextURL, String spec) throws IOException {
  +        // First, fix the slashes as windows filenames may have backslashes
  +        // in them, but the URL class wont do the right thing when we later
  +        // process this URL as the contextURL.
  +        String path = spec.replace('\\', '/');
  +        
           // See if we have a good URL.
           URL url = null;
           try {
  -            url = new URL(contextURL, spec);
  +            url = new URL(contextURL, path);
           }
           catch (MalformedURLException me)
           {
  +            // try treating is as a file pathname
               if (contextURL == null) {
  -                url = new URL("file", "", spec);
  +                url = new URL("file", "", path);
               } else {
                   // get the parent directory of the contextURL, and append
                   // the spec string to the end.
                   String contextFileName = contextURL.getFile();
                   String parentName = new File(contextFileName).getParent();
                   if (parentName != null) {
  -                    url = new URL(new URL("file", "", parentName + '/'), spec);
  -                }
  -                else {
  -                    throw new FileNotFoundException(url.toString());
  +                    url = new URL(new URL("file", "", parentName + '/'), path);
  +                } else {
  +                    url = new URL("file", "", path);
                   }
               }
           }
  
  
  


Reply via email to