camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r738386 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/component/file/ components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/
Date Wed, 28 Jan 2009 07:30:03 GMT
Author: davsclaus
Date: Wed Jan 28 07:30:02 2009
New Revision: 738386

URL: http://svn.apache.org/viewvc?rev=738386&view=rev
Log:
CAMEL-1241: A little cleanup in the camel-ftp component.

Removed:
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExclusiveReadLockStrategy.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileMessage.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileMessage.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileComponent.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileOperations.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileOperations.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileComponent.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileEndpoint.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileOperations.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
Wed Jan 28 07:30:02 2009
@@ -47,7 +47,7 @@
     protected final transient Log log = LogFactory.getLog(getClass());
 
     protected GenericFileProcessStrategy processStrategy;
-    protected GenericFileOperations operations;
+    protected GenericFileOperations<T> operations;
     protected GenericFileConfiguration configuration;
 
     // TODO: Consider remove setNames
@@ -404,11 +404,11 @@
         this.autoCreate = autoCreate;
     }
 
-    public GenericFileOperations getOperations() {
+    public GenericFileOperations<T> getOperations() {
         return operations;
     }
 
-    public void setOperations(GenericFileOperations operations) {
+    public void setOperations(GenericFileOperations<T> operations) {
         this.operations = operations;
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
Wed Jan 28 07:30:02 2009
@@ -28,8 +28,6 @@
 
     private GenericFile<T> genericFile;
 
-    // TODO: Consider removing some of he constructors
-
     public GenericFileExchange(CamelContext context) {
         super(context);
     }
@@ -92,7 +90,7 @@
     }
 
     public Exchange newInstance() {
-        return new GenericFileExchange(this, genericFile);
+        return new GenericFileExchange<T>(this, genericFile);
     }
 
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileMessage.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileMessage.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileMessage.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileMessage.java
Wed Jan 28 07:30:02 2009
@@ -22,12 +22,12 @@
  * Remote file message
  */
 public class GenericFileMessage<T> extends DefaultMessage {
-    private GenericFile genericFile;
+    private GenericFile<T> genericFile;
 
     public GenericFileMessage() {
     }
 
-    public GenericFileMessage(GenericFile genericFile) {
+    public GenericFileMessage(GenericFile<T> genericFile) {
         this.genericFile = genericFile;
     }
 
@@ -45,7 +45,7 @@
         return genericFile;
     }
 
-    public void setRemoteFile(GenericFile genericFile) {
+    public void setRemoteFile(GenericFile<T> genericFile) {
         this.genericFile = genericFile;
     }
 

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
Wed Jan 28 07:30:02 2009
@@ -28,7 +28,7 @@
  */
 public class FtpConsumer extends RemoteFileConsumer<FTPFile> {
 
-    public FtpConsumer(RemoteFileEndpoint endpoint, Processor processor, RemoteFileOperations
fileOperations) {
+    public FtpConsumer(RemoteFileEndpoint<FTPFile> endpoint, Processor processor, RemoteFileOperations<FTPFile>
fileOperations) {
         super(endpoint, processor, fileOperations);
     }
 

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileComponent.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileComponent.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileComponent.java
Wed Jan 28 07:30:02 2009
@@ -54,5 +54,9 @@
         return new FtpRemoteFileEndpoint(uri, this, operations, config);
     }
 
+    protected void afterPropertiesSet(GenericFileEndpoint<FTPFile> endpoint) throws
Exception {
+        // noop
+    }
+
 }
 

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileOperations.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileOperations.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpRemoteFileOperations.java
Wed Jan 28 07:30:02 2009
@@ -22,6 +22,7 @@
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Arrays;
 
 import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.component.file.GenericFileExchange;
@@ -143,9 +144,7 @@
                     }
                     success = client.makeDirectory(directory);
                     if (!success) {
-                        // we are here if the server side doesn't create
-                        // intermediate folders
-                        // so create the folder one by one
+                        // we are here if the server side doesn't create intermediate folders
so create the folder one by one
                         buildDirectoryChunks(directory);
                     }
                 }
@@ -195,22 +194,20 @@
         }
     }
 
-    public List listFiles() throws GenericFileOperationFailedException {
+    public List<FTPFile> listFiles() throws GenericFileOperationFailedException {
         return listFiles(".");
     }
 
-    public List listFiles(String path) throws GenericFileOperationFailedException {
+    public List<FTPFile> listFiles(String path) throws GenericFileOperationFailedException
{
         // use current directory if path not given
         if (ObjectHelper.isEmpty(path)) {
             path = ".";
         }
 
         try {
-            final List list = new ArrayList();
+            final List<FTPFile> list = new ArrayList<FTPFile>();
             FTPFile[] files = client.listFiles(path);
-            for (FTPFile file : files) {
-                list.add(file);
-            }
+            list.addAll(Arrays.asList(files));
             return list;
         } catch (IOException e) {
             throw new RemoteFileOperationFailedException(client.getReplyCode(), client.getReplyString(),
e.getMessage(), e);

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFile.java
Wed Jan 28 07:30:02 2009
@@ -20,8 +20,10 @@
 
 /**
  * Represents a remote file of some sort of backing object
+ *
+ * @param <T> the type of file that these remote endpoints provide
  */
-public class RemoteFile<F> extends GenericFile<F> implements Cloneable {
+public class RemoteFile<T> extends GenericFile<T> implements Cloneable {
 
     private String hostname;
 
@@ -33,8 +35,8 @@
         this.hostname = hostname;
     }
 
-    public RemoteFile<F> copyFrom(RemoteFile<F> source) {
-        RemoteFile<F> result = (RemoteFile<F>) source.clone();
+    public RemoteFile<T> copyFrom(RemoteFile<T> source) {
+        RemoteFile<T> result = (RemoteFile<T>) source.clone();
         result.setAbsoluteFileName(source.getAbsoluteFileName());
         result.setRelativeFileName(source.getRelativeFileName());
         result.setFileName(source.getFileName());

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java
Wed Jan 28 07:30:02 2009
@@ -18,7 +18,6 @@
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.component.file.GenericFileComponent;
-import org.apache.camel.component.file.GenericFileEndpoint;
 
 /**
  * Base class for remote file components. Polling and consuming files from
@@ -36,9 +35,4 @@
         super(context);
     }
 
-    @Override
-    protected void afterPropertiesSet(GenericFileEndpoint<T> endpoint) throws Exception
{
-        // noop
-    }
-
 }

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
Wed Jan 28 07:30:02 2009
@@ -21,8 +21,6 @@
 import org.apache.camel.Processor;
 import org.apache.camel.component.file.GenericFileConsumer;
 import org.apache.camel.component.file.GenericFileOperationFailedException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * Base class for remote file consumers.

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
Wed Jan 28 07:30:02 2009
@@ -23,16 +23,12 @@
 import org.apache.camel.component.file.GenericFileProducer;
 import org.apache.camel.processor.idempotent.MemoryIdempotentRepository;
 import org.apache.camel.util.ObjectHelper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * Remote file endpoint.
  */
 public abstract class RemoteFileEndpoint<T> extends GenericFileEndpoint<T> {
 
-    protected final transient Log log = LogFactory.getLog(getClass());
-
     public RemoteFileEndpoint() {
         // no args constructor for spring bean endpoint configuration
     }
@@ -50,8 +46,8 @@
     }
 
     @Override
-    public GenericFileExchange createExchange(GenericFile<T> file) {
-        return new RemoteFileExchange(this, getExchangePattern(), (RemoteFile<T>) file);
+    public GenericFileExchange<T> createExchange(GenericFile<T> file) {
+        return new RemoteFileExchange<T>(this, getExchangePattern(), (RemoteFile<T>)
file);
     }
 
     @Override
@@ -60,11 +56,11 @@
     }
 
     @Override
-    public RemoteFileConsumer createConsumer(Processor processor) throws Exception {
+    public RemoteFileConsumer<T> createConsumer(Processor processor) throws Exception
{
         String protocol = ((RemoteFileConfiguration) getConfiguration()).getProtocol();
         ObjectHelper.notEmpty(protocol, "protocol");
 
-        RemoteFileConsumer consumer = buildConsumer(processor, (RemoteFileOperations<T>)
operations);
+        RemoteFileConsumer<T> consumer = buildConsumer(processor, (RemoteFileOperations<T>)
operations);
 
         if (isDelete() && (getMoveNamePrefix() != null || getMoveNamePostfix() !=
null || getExpression() != null)) {
             throw new IllegalArgumentException("You cannot set delete=true and a moveNamePrefix,
moveNamePostfix or expression option");
@@ -92,7 +88,7 @@
      * @param operations the operations
      * @return the created consumer
      */
-    protected abstract RemoteFileConsumer buildConsumer(Processor processor, RemoteFileOperations<T>
operations);
+    protected abstract RemoteFileConsumer<T> buildConsumer(Processor processor, RemoteFileOperations<T>
operations);
 
     /**
      * Returns human readable server information for logging purpose

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java
Wed Jan 28 07:30:02 2009
@@ -58,7 +58,7 @@
     protected void populateHeaders(GenericFile<T> remoteFile) {
         super.populateHeaders(remoteFile);
         if (remoteFile != null) {
-            getIn().setHeader("file.remote.host", ((RemoteFile<T>) remoteFile).getHostname());
+            getIn().setHeader("CamelFileHost", ((RemoteFile<T>) remoteFile).getHostname());
         }
     }
 

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileOperations.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileOperations.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileOperations.java
Wed Jan 28 07:30:02 2009
@@ -30,8 +30,7 @@
      *
      * @param configuration configuraiton
      * @return true if connected
-     * @throws GenericFileOperationFailedException
-     *          can be thrown
+     * @throws GenericFileOperationFailedException can be thrown
      */
     boolean connect(RemoteFileConfiguration configuration) throws GenericFileOperationFailedException;
 
@@ -39,16 +38,14 @@
      * Returns whether we are connected to the remote server or not
      *
      * @return true if connected, false if not
-     * @throws GenericFileOperationFailedException
-     *          can be thrown
+     * @throws GenericFileOperationFailedException can be thrown
      */
     boolean isConnected() throws GenericFileOperationFailedException;
 
     /**
      * Discconects from the remote server
      *
-     * @throws GenericFileOperationFailedException
-     *          can be thrown
+     * @throws GenericFileOperationFailedException can be thrown
      */
     void disconnect() throws GenericFileOperationFailedException;
 

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=738386&r1=738385&r2=738386&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 Jan 28 07:30:02 2009
@@ -28,11 +28,11 @@
  * Remote file producer. Handles connecting and disconnecting if we are not.
  * Generic type F is the remote system implementation of a file.
  */
-public class RemoteFileProducer<F> extends GenericFileProducer<F> {
+public class RemoteFileProducer<T> extends GenericFileProducer<T> {
 
     private boolean loggedIn;
 
-    protected RemoteFileProducer(RemoteFileEndpoint<F> endpoint, RemoteFileOperations<F>
operations) {
+    protected RemoteFileProducer(RemoteFileEndpoint<T> endpoint, RemoteFileOperations<T>
operations) {
         super(endpoint, operations);
     }
 
@@ -45,7 +45,7 @@
     /**
      * The file could not be written. We need to disconnect from the remote server.
      */
-    protected void handleFailedWrite(GenericFileExchange exchange, Exception exception) throws
Exception {
+    protected void handleFailedWrite(GenericFileExchange<T> exchange, Exception exception)
throws Exception {
         loggedIn = false;
         if (isStopping() || isStopped()) {
             // if we are stopping then ignore any exception during a poll

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
Wed Jan 28 07:30:02 2009
@@ -28,7 +28,7 @@
  */
 public class SftpConsumer extends RemoteFileConsumer<ChannelSftp.LsEntry> {
 
-    public SftpConsumer(RemoteFileEndpoint endpoint, Processor processor, RemoteFileOperations
operations) {
+    public SftpConsumer(RemoteFileEndpoint<ChannelSftp.LsEntry> endpoint, Processor
processor, RemoteFileOperations<ChannelSftp.LsEntry> operations) {
         super(endpoint, processor, operations);
     }
 
@@ -81,7 +81,7 @@
         List<ChannelSftp.LsEntry> list = operations.listFiles(fileName);
         ChannelSftp.LsEntry file = list.get(0);
         if (file != null) {
-            RemoteFile remoteFile = asRemoteFile(directory, file);
+            RemoteFile<ChannelSftp.LsEntry> remoteFile = asRemoteFile(directory, file);
             if (isValidFile(remoteFile, false)) {
                 // matched file so add
                 fileList.add(remoteFile);

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileComponent.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileComponent.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileComponent.java
Wed Jan 28 07:30:02 2009
@@ -38,7 +38,6 @@
 
     @Override
     protected GenericFileEndpoint<ChannelSftp.LsEntry> buildFileEndpoint(String uri,
String remaining, Map parameters) throws Exception {
-
         // get the uri part before the options as they can be non URI valid such
         // as the expression using $ chars
         if (uri.indexOf("?") != -1) {
@@ -52,5 +51,10 @@
         SftpRemoteFileOperations operations = new SftpRemoteFileOperations();
         return new SftpRemoteFileEndpoint(uri, this, operations, config);
     }
+
+    protected void afterPropertiesSet(GenericFileEndpoint<ChannelSftp.LsEntry> endpoint)
throws Exception {
+        // noop
+    }
+
 }
 

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileEndpoint.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileEndpoint.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileEndpoint.java
Wed Jan 28 07:30:02 2009
@@ -31,7 +31,7 @@
     }
 
     @Override
-    protected RemoteFileConsumer buildConsumer(Processor processor, RemoteFileOperations
operations) {
+    protected RemoteFileConsumer<ChannelSftp.LsEntry> buildConsumer(Processor processor,
RemoteFileOperations<ChannelSftp.LsEntry> operations) {
         return new SftpConsumer(this, processor, operations);
     }
 

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileOperations.java?rev=738386&r1=738385&r2=738386&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileOperations.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpRemoteFileOperations.java
Wed Jan 28 07:30:02 2009
@@ -34,15 +34,17 @@
 import org.apache.camel.component.file.GenericFileExchange;
 import org.apache.camel.component.file.GenericFileOperationFailedException;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.ExchangeHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import static org.apache.camel.util.ObjectHelper.isNotEmpty;
+import org.apache.camel.InvalidPayloadException;
 
 /**
  * SFTP remote file operations
  */
 public class SftpRemoteFileOperations implements RemoteFileOperations<ChannelSftp.LsEntry>
{
-    private static final Log LOG = LogFactory.getLog(SftpRemoteFileOperations.class);
+    private static final transient Log LOG = LogFactory.getLog(SftpRemoteFileOperations.class);
     private ChannelSftp channel;
     private Session session;
 
@@ -237,21 +239,21 @@
         }
     }
 
-    public List listFiles() throws GenericFileOperationFailedException {
+    public List<ChannelSftp.LsEntry> listFiles() throws GenericFileOperationFailedException
{
         return listFiles(".");
     }
 
-    public List listFiles(String path) throws GenericFileOperationFailedException {
+    public List<ChannelSftp.LsEntry> listFiles(String path) throws GenericFileOperationFailedException
{
         if (ObjectHelper.isEmpty(path)) {
             // list current dirctory if file path is not given
             path = ".";
         }
 
         try {
-            final List list = new ArrayList();
+            final List<ChannelSftp.LsEntry> list = new ArrayList<ChannelSftp.LsEntry>();
             Vector files = channel.ls(path);
             for (Object file : files) {
-                list.add(file);
+                list.add((ChannelSftp.LsEntry)file);
             }
             return list;
         } catch (SftpException e) {
@@ -273,10 +275,13 @@
 
     public boolean storeFile(String name, GenericFileExchange<ChannelSftp.LsEntry>
exchange) throws GenericFileOperationFailedException {
         try {
-            channel.put((InputStream) exchange.getIn().getBody(InputStream.class), name);
+            InputStream in = ExchangeHelper.getMandatoryInBody(exchange, InputStream.class);
+            channel.put(in, name);
             return true;
         } catch (SftpException e) {
             throw new RemoteFileOperationFailedException("Could not write the file [" + name
+ "]", e);
+        } catch (InvalidPayloadException e) {
+            throw new RemoteFileOperationFailedException("Could not write the file [" + name
+ "]", e);
         }
     }
 



Mime
View raw message