camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r772071 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
Date Wed, 06 May 2009 06:45:15 GMT
Author: ningjiang
Date: Wed May  6 06:45:14 2009
New Revision: 772071

URL: http://svn.apache.org/viewvc?rev=772071&view=rev
Log:
CAMEL-1585 fixed the issue of GenericFileProducer.createFileName produces OS normalized file
name, that doesn't work with SFTP

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java?rev=772071&r1=772070&r2=772071&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileProducer.java
Wed May  6 06:45:14 2009
@@ -36,12 +36,21 @@
     protected final transient Log log = LogFactory.getLog(getClass());
     protected final GenericFileEndpoint<T> endpoint;
     protected final GenericFileOperations<T> operations;
-
+    
     protected GenericFileProducer(GenericFileEndpoint<T> endpoint, GenericFileOperations<T>
operations) {
         super(endpoint);
         this.endpoint = endpoint;
         this.operations = operations;
     }
+    
+    protected String getFileSeparator() {
+        return File.separator;
+    }
+    
+   
+    protected String normalizePath(String name) {        
+        return FileUtil.normalizePath(name);
+    }
 
     @SuppressWarnings("unchecked")
     public void process(Exchange exchange) throws Exception {
@@ -116,7 +125,7 @@
         try {
             // build directory if auto create is enabled
             if (endpoint.isAutoCreate()) {
-                int lastPathIndex = fileName.lastIndexOf(File.separator);
+                int lastPathIndex = fileName.lastIndexOf(getFileSeparator());
                 if (lastPathIndex != -1) {
                     String directory = fileName.substring(0, lastPathIndex);
                     // skip trailing /
@@ -173,7 +182,7 @@
 
         // flattern name
         if (name != null && endpoint.isFlattern()) {
-            int pos = name.lastIndexOf(File.separator);
+            int pos = name.lastIndexOf(getFileSeparator());
             if (pos == -1) {
                 pos = name.lastIndexOf('/');
             }
@@ -188,7 +197,7 @@
         // If the path isn't empty, we need to add a trailing / if it isn't already there
         String baseDir = "";
         if (endpointPath.length() > 0) {
-            baseDir = endpointPath + (endpointPath.endsWith(File.separator) ? "" : File.separator);
+            baseDir = endpointPath + (endpointPath.endsWith(getFileSeparator()) ? "" : getFileSeparator());
         }
         if (name != null) {
             answer = baseDir + name;
@@ -198,16 +207,16 @@
         }
 
         // must normalize path to cater for Windows and other OS
-        answer = FileUtil.normalizePath(answer);
+        answer = normalizePath(answer);
 
         return answer;
     }
 
     protected String createTempFileName(String fileName) {
         // must normalize path to cater for Windows and other OS
-        fileName = FileUtil.normalizePath(fileName);
+        fileName = normalizePath(fileName);
 
-        int path = fileName.lastIndexOf(File.separator);
+        int path = fileName.lastIndexOf(getFileSeparator());
         if (path == -1) {
             // no path
             return endpoint.getTempPrefix() + fileName;

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java?rev=772071&r1=772070&r2=772071&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
Wed May  6 06:45:14 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.file.remote;
 
+import java.io.File;
 import java.io.IOException;
 
 import org.apache.camel.Exchange;
@@ -31,10 +32,20 @@
 public class RemoteFileProducer<T> extends GenericFileProducer<T> {
 
     private boolean loggedIn;
-
+    
     protected RemoteFileProducer(RemoteFileEndpoint<T> endpoint, RemoteFileOperations<T>
operations) {
         super(endpoint, operations);
     }
+    
+    @Override
+    protected String getFileSeparator() {
+        return "/";
+    }
+    
+    @Override
+    protected String normalizePath(String name) {        
+        return name;
+    }
 
     @SuppressWarnings("unchecked")
     public void process(Exchange exchange) throws Exception {



Mime
View raw message