camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r790289 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/component/file/ camel-core/src/test/java/org/apache/camel/component/file/ components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/
Date Wed, 01 Jul 2009 17:40:01 GMT
Author: hadrian
Date: Wed Jul  1 17:40:01 2009
New Revision: 790289

URL: http://svn.apache.org/viewvc?rev=790289&view=rev
Log:
CAMEL-1078.  More cleanup around the file exchange.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMultipleDirectoriesTest.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java?rev=790289&r1=790288&r2=790289&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
Wed Jul  1 17:40:01 2009
@@ -130,12 +130,12 @@
         return null;
     }
 
-    public boolean retrieveFile(String name, GenericFileExchange<File> exchange) throws
GenericFileOperationFailedException {
+    public boolean retrieveFile(String name, Exchange exchange) throws GenericFileOperationFailedException
{
         // noop as we use type converters to read the body content for java.io.File
         return true;
     }
 
-    public boolean storeFile(String fileName, GenericFileExchange<File> exchange) throws
GenericFileOperationFailedException {
+    public boolean storeFile(String fileName, Exchange exchange) throws GenericFileOperationFailedException
{
         ObjectHelper.notNull(endpoint, "endpoint");
 
         File file = new File(fileName);
@@ -157,7 +157,6 @@
         // 1. write file to file
         // 2. rename a file from a local work path
         // 3. write stream to file
-
         try {
 
             // is the body file based
@@ -267,5 +266,4 @@
         }
         return out;
     }
-
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java?rev=790289&r1=790288&r2=790289&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileOperations.java
Wed Jul  1 17:40:01 2009
@@ -18,6 +18,8 @@
 
 import java.util.List;
 
+import org.apache.camel.Exchange;
+
 public interface GenericFileOperations<T> {
 
     /**
@@ -65,7 +67,7 @@
      * @return true if file has been retrieved, false if not
      * @throws GenericFileOperationFailedException can be thrown
      */
-    boolean retrieveFile(String name, GenericFileExchange<T> exchange) throws GenericFileOperationFailedException;
+    boolean retrieveFile(String name, Exchange exchange) throws GenericFileOperationFailedException;
 
     /**
      * Stores the content as a new remote file (upload)
@@ -75,7 +77,7 @@
      * @return true if the file was stored, false if not
      * @throws GenericFileOperationFailedException can be thrown
      */
-    boolean storeFile(String name, GenericFileExchange<T> exchange) throws GenericFileOperationFailedException;
+    boolean storeFile(String name, Exchange exchange) throws GenericFileOperationFailedException;
 
     /**
      * Gets the current remote directory
@@ -109,5 +111,4 @@
      * @throws GenericFileOperationFailedException can be thrown
      */
     List<T> listFiles(String path) throws GenericFileOperationFailedException;
-
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMultipleDirectoriesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMultipleDirectoriesTest.java?rev=790289&r1=790288&r2=790289&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMultipleDirectoriesTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumeMultipleDirectoriesTest.java
Wed Jul  1 17:40:01 2009
@@ -45,18 +45,21 @@
 
         assertMockEndpointsSatisfied();
 
-        GenericFileExchange<File> exchange = (GenericFileExchange<File>) mock.getExchanges().get(0);
-        File file = exchange.getGenericFile().getFile();
+        Exchange exchange =  mock.getExchanges().get(0);
+        GenericFile<File> gf = (GenericFile<File>) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE);
+        File file = gf.getFile();
         assertDirectoryEquals("target/multidir/bye.txt", file.getPath());
         assertEquals("bye.txt", file.getName());
 
-        exchange = (GenericFileExchange<File>) mock.getExchanges().get(1);
-        file = exchange.getGenericFile().getFile();
+        exchange =  mock.getExchanges().get(1);
+        gf = (GenericFile<File>) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE);
+        file = gf.getFile();
         assertDirectoryEquals("target/multidir/sub/hello.txt", file.getPath());
         assertEquals("hello.txt", file.getName());
 
-        exchange = (GenericFileExchange<File>) mock.getExchanges().get(2);
-        file = exchange.getGenericFile().getFile();
+        exchange =  mock.getExchanges().get(2);
+        gf = (GenericFile<File>) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE);
+        file = gf.getFile();
         assertDirectoryEquals("target/multidir/sub/sub2/godday.txt", file.getPath());
         assertEquals("godday.txt", file.getName());
     }

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java?rev=790289&r1=790288&r2=790289&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
Wed Jul  1 17:40:01 2009
@@ -30,7 +30,6 @@
 import org.apache.camel.component.file.FileComponent;
 import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.component.file.GenericFileEndpoint;
-import org.apache.camel.component.file.GenericFileExchange;
 import org.apache.camel.component.file.GenericFileExist;
 import org.apache.camel.component.file.GenericFileOperationFailedException;
 import org.apache.camel.util.FileUtil;
@@ -184,7 +183,7 @@
         }
     }
 
-    public boolean retrieveFile(String name, GenericFileExchange<FTPFile> exchange)
throws GenericFileOperationFailedException {
+    public boolean retrieveFile(String name, Exchange exchange) throws GenericFileOperationFailedException
{
         if (ObjectHelper.isNotEmpty(endpoint.getLocalWorkDirectory())) {
             // local work directory is configured so we should store file content as files
in this local directory
             return retrieveFileToFileInLocalWorkDirectory(name, exchange);
@@ -194,7 +193,7 @@
         }
     }
 
-    private boolean retrieveFileToStreamInBody(String name, GenericFileExchange<FTPFile>
exchange) throws GenericFileOperationFailedException {
+    private boolean retrieveFileToStreamInBody(String name, Exchange exchange) throws GenericFileOperationFailedException
{
         OutputStream os = null;
         try {
             os = new ByteArrayOutputStream();
@@ -209,7 +208,7 @@
         }
     }
 
-    private boolean retrieveFileToFileInLocalWorkDirectory(String name, GenericFileExchange<FTPFile>
exchange) throws GenericFileOperationFailedException {
+    private boolean retrieveFileToFileInLocalWorkDirectory(String name, Exchange exchange)
throws GenericFileOperationFailedException {
         File temp;        
         File local = new File(FileUtil.normalizePath(endpoint.getLocalWorkDirectory()));
         OutputStream os;
@@ -275,9 +274,9 @@
         return result;
     }
 
-    public boolean storeFile(String name, GenericFileExchange<FTPFile> exchange) throws
GenericFileOperationFailedException {
+    public boolean storeFile(String name, Exchange exchange) throws GenericFileOperationFailedException
{
 
-        // if an existing file already exsists what should we do?
+        // if an existing file already exists what should we do?
         if (endpoint.getFileExist() == GenericFileExist.Ignore || endpoint.getFileExist()
== GenericFileExist.Fail) {
             boolean existFile = existFile(name);
             if (existFile && endpoint.getFileExist() == GenericFileExist.Ignore)
{

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java?rev=790289&r1=790288&r2=790289&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpOperations.java
Wed Jul  1 17:40:01 2009
@@ -38,7 +38,6 @@
 import org.apache.camel.component.file.FileComponent;
 import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.component.file.GenericFileEndpoint;
-import org.apache.camel.component.file.GenericFileExchange;
 import org.apache.camel.component.file.GenericFileExist;
 import org.apache.camel.component.file.GenericFileOperationFailedException;
 import org.apache.camel.util.ExchangeHelper;
@@ -278,7 +277,7 @@
         }
     }
 
-    public boolean retrieveFile(String name, GenericFileExchange<ChannelSftp.LsEntry>
exchange) throws GenericFileOperationFailedException {
+    public boolean retrieveFile(String name, Exchange exchange) throws GenericFileOperationFailedException
{
         if (ObjectHelper.isNotEmpty(endpoint.getLocalWorkDirectory())) {
             // local work directory is configured so we should store file content as files
in this local directory
             return retrieveFileToFileInLocalWorkDirectory(name, exchange);
@@ -288,7 +287,7 @@
         }
     }
 
-    private boolean retrieveFileToStreamInBody(String name, GenericFileExchange<ChannelSftp.LsEntry>
exchange) throws GenericFileOperationFailedException {
+    private boolean retrieveFileToStreamInBody(String name, Exchange exchange) throws GenericFileOperationFailedException
{
         try {
             GenericFile<ChannelSftp.LsEntry> target = 
                 (GenericFile<ChannelSftp.LsEntry>) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE);
@@ -302,7 +301,7 @@
         }
     }
 
-    private boolean retrieveFileToFileInLocalWorkDirectory(String name, GenericFileExchange<ChannelSftp.LsEntry>
exchange) throws GenericFileOperationFailedException {
+    private boolean retrieveFileToFileInLocalWorkDirectory(String name, Exchange exchange)
throws GenericFileOperationFailedException {
         File temp;
         File local = new File(endpoint.getLocalWorkDirectory());
         OutputStream os;
@@ -363,8 +362,8 @@
         return true;
     }
 
-    public boolean storeFile(String name, GenericFileExchange<ChannelSftp.LsEntry>
exchange) throws GenericFileOperationFailedException {
-        // if an existing file already exsists what should we do?
+    public boolean storeFile(String name, Exchange exchange) throws GenericFileOperationFailedException
{
+        // if an existing file already exists what should we do?
         if (endpoint.getFileExist() == GenericFileExist.Ignore || endpoint.getFileExist()
== GenericFileExist.Fail) {
             boolean existFile = existFile(name);
             if (existFile && endpoint.getFileExist() == GenericFileExist.Ignore)
{



Mime
View raw message