Return-Path: Delivered-To: apmail-camel-commits-archive@www.apache.org Received: (qmail 52856 invoked from network); 1 Jul 2009 17:40:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Jul 2009 17:40:19 -0000 Received: (qmail 45199 invoked by uid 500); 1 Jul 2009 17:40:29 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 45160 invoked by uid 500); 1 Jul 2009 17:40:29 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 45148 invoked by uid 99); 1 Jul 2009 17:40:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jul 2009 17:40:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jul 2009 17:40:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B4B5B238888E; Wed, 1 Jul 2009 17:40:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@camel.apache.org From: hadrian@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090701174001.B4B5B238888E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 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 { /** @@ -65,7 +67,7 @@ * @return true if file has been retrieved, false if not * @throws GenericFileOperationFailedException can be thrown */ - boolean retrieveFile(String name, GenericFileExchange 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 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 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 exchange = (GenericFileExchange) mock.getExchanges().get(0); - File file = exchange.getGenericFile().getFile(); + Exchange exchange = mock.getExchanges().get(0); + GenericFile gf = (GenericFile) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE); + File file = gf.getFile(); assertDirectoryEquals("target/multidir/bye.txt", file.getPath()); assertEquals("bye.txt", file.getName()); - exchange = (GenericFileExchange) mock.getExchanges().get(1); - file = exchange.getGenericFile().getFile(); + exchange = mock.getExchanges().get(1); + gf = (GenericFile) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE); + file = gf.getFile(); assertDirectoryEquals("target/multidir/sub/hello.txt", file.getPath()); assertEquals("hello.txt", file.getName()); - exchange = (GenericFileExchange) mock.getExchanges().get(2); - file = exchange.getGenericFile().getFile(); + exchange = mock.getExchanges().get(2); + gf = (GenericFile) 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 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 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 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 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 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 exchange) throws GenericFileOperationFailedException { + private boolean retrieveFileToStreamInBody(String name, Exchange exchange) throws GenericFileOperationFailedException { try { GenericFile target = (GenericFile) exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE); @@ -302,7 +301,7 @@ } } - private boolean retrieveFileToFileInLocalWorkDirectory(String name, GenericFileExchange 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 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) {