Author: mriou
Date: Tue Oct  3 10:00:30 2006
New Revision: 452572

URL: http://svn.apache.org/viewvc?view=rev&rev=452572
Log:
Encoding spaces in file paths when used as URIs (can you feel that windows 
smell?)

Modified:
    
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
    
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
    
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
    
incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/StaticCheckTCase.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DocumentEntityResolver.java
    
incubator/ode/trunk/tools/src/main/java/org/apache/ode/tools/bpelc/BpelCompileCommand.java
    
incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/fs/FileUtils.java
    
incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java

Modified: 
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java?view=diff&rev=452572&r1=452571&r2=452572
==============================================================================
--- 
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
 (original)
+++ 
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
 Tue Oct  3 10:00:30 2006
@@ -37,6 +37,7 @@
 import org.apache.ode.utils.stl.CollectionsX;
 import org.apache.ode.utils.stl.MemberOfFunction;
 import org.apache.ode.utils.stl.UnaryFunction;
+import org.apache.ode.utils.fs.FileUtils;
 
 import javax.wsdl.Definition;
 import javax.wsdl.Message;
@@ -1319,7 +1320,7 @@
     public OXslSheet compileXslt(String docStrUri) throws CompilationException 
{
         URI docUri;
         try {
-            docUri = new URI(docStrUri);
+            docUri = new URI(FileUtils.encodePath(docStrUri));
         } catch (URISyntaxException e) {
             throw new 
CompilationException(__cmsgs.errInvalidDocXsltUri(docStrUri));
         }

Modified: 
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java?view=diff&rev=452572&r1=452571&r2=452572
==============================================================================
--- 
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
 (original)
+++ 
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WSDLRegistry.java
 Tue Oct  3 10:00:30 2006
@@ -26,6 +26,7 @@
 import org.apache.ode.utils.xsd.SchemaModelImpl;
 import org.apache.ode.utils.xsd.XSUtils;
 import org.apache.ode.utils.xsd.XsdException;
+import org.apache.ode.utils.fs.FileUtils;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
 
 import java.net.URI;
@@ -190,7 +191,7 @@
                     Map<URI, byte[]> capture = null;
                     URI docuri;
                     try {
-                        docuri = new URI(def.getDocumentBaseURI());
+                        docuri = new 
URI(FileUtils.encodePath(def.getDocumentBaseURI()));
                     } catch (URISyntaxException e) {
                         // This is really quite unexpected..
                         __log.fatal("Internal Error: WSDL Base URI is 
invalid.",e);

Modified: 
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java?view=diff&rev=452572&r1=452571&r2=452572
==============================================================================
--- 
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
 (original)
+++ 
incubator/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/WsdlFinderXMLEntityResolver.java
 Tue Oct  3 10:00:30 2006
@@ -24,6 +24,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ode.utils.fs.FileUtils;
 
 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
 import com.sun.org.apache.xerces.internal.xni.XNIException;
@@ -62,7 +63,7 @@
             if (resourceIdentifier.getExpandedSystemId() == null)
                 location = new URI(resourceIdentifier.getNamespace());
             else
-                location = new URI(resourceIdentifier.getExpandedSystemId());
+                location = new 
URI(FileUtils.encodePath(resourceIdentifier.getExpandedSystemId()));
         } catch (URISyntaxException e) {
             __log.debug("resolveEntity: URI syntax error", e);
             throw new IOException(e.getMessage());

Modified: 
incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/StaticCheckTCase.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/StaticCheckTCase.java?view=diff&rev=452572&r1=452571&r2=452572
==============================================================================
--- 
incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/StaticCheckTCase.java
 (original)
+++ 
incubator/ode/trunk/bpel-compiler/src/test/java/org/apache/ode/bpel/compiler/StaticCheckTCase.java
 Tue Oct  3 10:00:30 2006
@@ -23,6 +23,7 @@
 import org.apache.ode.bpel.capi.CompilationException;
 import org.apache.ode.bpel.capi.CompilationMessage;
 import org.apache.ode.bpel.capi.CompileListener;
+import org.apache.ode.utils.fs.FileUtils;
 import org.xml.sax.InputSource;
 
 import javax.wsdl.WSDLException;

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DocumentEntityResolver.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DocumentEntityResolver.java?view=diff&rev=452572&r1=452571&r2=452572
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DocumentEntityResolver.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/deploy/DocumentEntityResolver.java
 Tue Oct  3 10:00:30 2006
@@ -29,6 +29,8 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 
+import org.apache.ode.utils.fs.FileUtils;
+
 /**
  * Resolves references inide the deployment unit.
  */
@@ -45,7 +47,7 @@
         String resourceName = resourceIdentifier.getLiteralSystemId();
         String base;
         try {
-            base = new 
URI(resourceIdentifier.getBaseSystemId()).toURL().getFile();
+            base = new 
URI(FileUtils.encodePath(resourceIdentifier.getBaseSystemId())).toURL().getFile();
         } catch (URISyntaxException e) {
             throw new RuntimeException("Base system id incorrect, parser 
error", e);
         }

Modified: 
incubator/ode/trunk/tools/src/main/java/org/apache/ode/tools/bpelc/BpelCompileCommand.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/tools/src/main/java/org/apache/ode/tools/bpelc/BpelCompileCommand.java?view=diff&rev=452572&r1=452571&r2=452572
==============================================================================
--- 
incubator/ode/trunk/tools/src/main/java/org/apache/ode/tools/bpelc/BpelCompileCommand.java
 (original)
+++ 
incubator/ode/trunk/tools/src/main/java/org/apache/ode/tools/bpelc/BpelCompileCommand.java
 Tue Oct  3 10:00:30 2006
@@ -27,6 +27,7 @@
 import org.apache.ode.tools.CommandContext;
 import org.apache.ode.tools.ExecutionException;
 import org.apache.ode.utils.SystemUtils;
+import org.apache.ode.utils.fs.FileUtils;
 import org.apache.ode.utils.msg.MessageBundle;
 
 import java.io.File;
@@ -95,7 +96,7 @@
 
     if (_wsdlUri != null) {
       try {
-        u = new URI(_wsdlUri);
+        u = new URI(FileUtils.encodePath(_wsdlUri));
       }
       catch (URISyntaxException use) {
         throw new ExecutionException(__msgs.msgInvalidWsdlUrl(_wsdlUri));

Modified: 
incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/fs/FileUtils.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/fs/FileUtils.java?view=diff&rev=452572&r1=452571&r2=452572
==============================================================================
--- 
incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/fs/FileUtils.java 
(original)
+++ 
incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/fs/FileUtils.java 
Tue Oct  3 10:00:30 2006
@@ -31,107 +31,111 @@
  */
 public class FileUtils {
 
-  private static final Log __log = LogFactory.getLog(FileUtils.class);
+    private static final Log __log = LogFactory.getLog(FileUtils.class);
 
-  /**
-   * Delete a file/directory, recursively.
-   * 
-   * @param file
-   *          file/directory to delete
-   * @return <code>true</code> if successful
-   */
-  public static boolean deepDelete(File file) {
-    if (file.exists()) {
-      if (__log.isDebugEnabled()) {
-        __log.debug("deleting: " + file.getAbsolutePath());
-      }
-      if (file.delete()) {
-        return true;
-      }
-
-      if (file.isDirectory()) {
-        boolean success = true;
-        File[] files = file.listFiles();
-        for (int i = 0; i < files.length; ++i) {
-          success &= deepDelete(files[i]);
-        }
-        return success ? file.delete() : false;
-      }
-      else {
-        __log.error("Unable to deepDelete file " + file.getAbsolutePath()
-            + "; this may be caused by a descriptor leak and should be 
reported.");
-        return false;
-      }
-    }
-    else {
-      // file seems to be gone already?! anyway nothing to do for us.
-      return true;
+    /**
+     * Delete a file/directory, recursively.
+     *
+     * @param file
+     *          file/directory to delete
+     * @return <code>true</code> if successful
+     */
+    public static boolean deepDelete(File file) {
+        if (file.exists()) {
+            if (__log.isDebugEnabled()) {
+                __log.debug("deleting: " + file.getAbsolutePath());
+            }
+            if (file.delete()) {
+                return true;
+            }
+
+            if (file.isDirectory()) {
+                boolean success = true;
+                File[] files = file.listFiles();
+                for (int i = 0; i < files.length; ++i) {
+                    success &= deepDelete(files[i]);
+                }
+                return success ? file.delete() : false;
+            }
+            else {
+                __log.error("Unable to deepDelete file " + 
file.getAbsolutePath()
+                        + "; this may be caused by a descriptor leak and 
should be reported.");
+                return false;
+            }
+        }
+        else {
+            // file seems to be gone already?! anyway nothing to do for us.
+            return true;
+        }
     }
-  }
 
-  /**
-   * Recursively collect all Files in the given directory and all its
-   * subdirectories.
-   * 
-   * @param rootDirectory
-   *          the top level directory used for the search
-   * @return a List of found Files
-   */
-  public static List<File> directoryEntriesInPath(File rootDirectory) {
-    return FileUtils.directoryEntriesInPath(rootDirectory, null);
-  }
-
-  /**
-   * Recursively collect all Files in the given directory and all its
-   * subdirectories, applying the given FileFilter.
-   * 
-   * @param rootDirectory
-   *          the top level directory used for the search
-   * @param filter
-   *          a FileFilter used for accepting/rejecting individual entries
-   * @return a List of found Files
-   */
-  public static List<File> directoryEntriesInPath(File rootDirectory, 
FileFilter filter) {
-    if (rootDirectory == null) {
-      throw new IllegalArgumentException("File must not be null!");
-    }
+    /**
+     * Recursively collect all Files in the given directory and all its
+     * subdirectories.
+     *
+     * @param rootDirectory
+     *          the top level directory used for the search
+     * @return a List of found Files
+     */
+    public static List<File> directoryEntriesInPath(File rootDirectory) {
+        return FileUtils.directoryEntriesInPath(rootDirectory, null);
+    }
+
+    /**
+     * Recursively collect all Files in the given directory and all its
+     * subdirectories, applying the given FileFilter.
+     *
+     * @param rootDirectory
+     *          the top level directory used for the search
+     * @param filter
+     *          a FileFilter used for accepting/rejecting individual entries
+     * @return a List of found Files
+     */
+    public static List<File> directoryEntriesInPath(File rootDirectory, 
FileFilter filter) {
+        if (rootDirectory == null) {
+            throw new IllegalArgumentException("File must not be null!");
+        }
 
-    if (!rootDirectory.exists()) {
-      throw new IllegalArgumentException("File does not exist!");
-    }
+        if (!rootDirectory.exists()) {
+            throw new IllegalArgumentException("File does not exist!");
+        }
 
-    ArrayList<File> collectedFiles = new ArrayList<File>(32);
+        ArrayList<File> collectedFiles = new ArrayList<File>(32);
 
-    if (rootDirectory.isFile()) {
-      if ((filter == null) || ((filter != null) && 
(filter.accept(rootDirectory)))) {
-        collectedFiles.add(rootDirectory);
-      }
-      return collectedFiles;
-    }
+        if (rootDirectory.isFile()) {
+            if ((filter == null) || ((filter != null) && 
(filter.accept(rootDirectory)))) {
+                collectedFiles.add(rootDirectory);
+            }
+            return collectedFiles;
+        }
 
-    FileUtils.directoryEntriesInPath(collectedFiles, rootDirectory, filter);
-    return collectedFiles;
-  }
-
-  private static void directoryEntriesInPath(List<File> collectedFiles, File 
parentDir, FileFilter filter) {
-    if ((filter == null) || ((filter != null) && (filter.accept(parentDir)))) {
-      collectedFiles.add(parentDir);
+        FileUtils.directoryEntriesInPath(collectedFiles, rootDirectory, 
filter);
+        return collectedFiles;
     }
 
-    File[] files = parentDir.listFiles();
-    if (files != null) {
-      for (int numFiles = files.length, i = 0; i < numFiles; i++) {
-        File currentFile = files[i];
-
-        if ((filter == null) || ((filter != null) && 
(filter.accept(currentFile)))) {
-          collectedFiles.add(currentFile);
+    private static void directoryEntriesInPath(List<File> collectedFiles, File 
parentDir, FileFilter filter) {
+        if ((filter == null) || ((filter != null) && 
(filter.accept(parentDir)))) {
+            collectedFiles.add(parentDir);
         }
 
-        if (currentFile.isDirectory()) {
-          FileUtils.directoryEntriesInPath(collectedFiles, currentFile, 
filter);
+        File[] files = parentDir.listFiles();
+        if (files != null) {
+            for (int numFiles = files.length, i = 0; i < numFiles; i++) {
+                File currentFile = files[i];
+
+                if ((filter == null) || ((filter != null) && 
(filter.accept(currentFile)))) {
+                    collectedFiles.add(currentFile);
+                }
+
+                if (currentFile.isDirectory()) {
+                    FileUtils.directoryEntriesInPath(collectedFiles, 
currentFile, filter);
+                }
+            }
         }
-      }
     }
-  }
+
+    public static String encodePath(String path) {
+        return path.replaceAll(" ", "%20");
+    }
 
 }

Modified: 
incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java?view=diff&rev=452572&r1=452571&r2=452572
==============================================================================
--- 
incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java
 (original)
+++ 
incubator/ode/trunk/utils/src/main/java/org/apache/ode/utils/xsd/CapturingXMLEntityResolver.java
 Tue Oct  3 10:00:30 2006
@@ -19,6 +19,7 @@
 package org.apache.ode.utils.xsd;
 
 import org.apache.ode.utils.StreamUtils;
+import org.apache.ode.utils.fs.FileUtils;
 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
 import com.sun.org.apache.xerces.internal.xni.XNIException;
 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
@@ -86,8 +87,8 @@
 
     try {
       URI systemId = new URI(
-          resourceIdentifier.getExpandedSystemId() == null ? resourceIdentifier
-              .getNamespace() : resourceIdentifier.getExpandedSystemId());
+          FileUtils.encodePath(resourceIdentifier.getExpandedSystemId() == 
null ? resourceIdentifier
+              .getNamespace() : resourceIdentifier.getExpandedSystemId()));
 
       _capture.put(systemId, data);
     } catch (URISyntaxException use) {


Reply via email to