[jboss-svn-commits] JBL Code SVN: r8256 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Dec 12 10:47:10 EST 2006
Author: b_georges
Date: 2006-12-12 10:47:08 -0500 (Tue, 12 Dec 2006)
New Revision: 8256
Modified:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/FtpGatewayListener.java
Log:
This FTP Gateway listener is required before implemeting the Secure FTP transport adapter: http://jira.jboss.com/jira/browse/JBESB-127
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/FtpGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/FtpGatewayListener.java 2006-12-12 15:40:42 UTC (rev 8255)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/FtpGatewayListener.java 2006-12-12 15:47:08 UTC (rev 8256)
@@ -34,10 +34,9 @@
public class FtpGatewayListener extends FileGatewayListener
{
- // protected FtpGatewayListener()
- // {
- // super();
- // }
+ protected FtpGatewayListener()
+ {
+ }
public FtpGatewayListener(GatewayListenerController commandListener,
ConfigTree config) throws Exception
@@ -48,10 +47,9 @@
protected void checkMyParms() throws Exception
{
super.checkMyParms();
- RemoteFileSystem rfs = RemoteFileSystemFactory.getRemoteFileSystem(_config, true);
+ RemoteFileSystem rfs = RemoteFileSystemFactory.getRemoteFileSystem(
+ _config, true);
rfs.quit();
- FtpClientUtil ftpClient = new FtpClientUtil(_config, false);
- ftpClient.quit();
// Copy FTP parameters to be passed to the action class (inside the
// WorkingFile class)
@@ -72,65 +70,64 @@
@Override
protected void seeIfOkToWorkOnDir(File p_oDir) throws GatewayException
{
- // Bruno: is there any way that the remote directory exists, that we can
- // read it, and that that we can write on it ?
- // please see the FileGatewayListener class to see what the method
- // does there
- } // ________________________________
+ // TODO: Implement. Very expensive though.
+ // It is possible to check for existence and permission by connecting,
+ // cd to target, put dummy file, ls to see list it, rm to clean it
+ // p_oDir exists
+ // p_oDir writable
+ // p_oDir readable
+ }
+
// @Override
- boolean deleteFile(File file) throws GatewayException
+ public boolean deleteFile(File file) throws GatewayException
{
- // Bruno: please check this and the rest of the methods.
- // I just copied the RemoteDirectoryPoller, but I know you have been
- // working on this so what I copied here could be stale
- FtpClientUtil ftpClient = null;
+ RemoteFileSystem rfs = null;
try
{
- ftpClient = new FtpClientUtil(_config, true);
- ftpClient.deleteRemoteFile(file.toString());
+ rfs = RemoteFileSystemFactory.getRemoteFileSystem(_config, true);
+ rfs.deleteRemoteFile(file.toString());
return true;
} catch (Exception e)
{
throw new GatewayException(e);
} finally
{
- if (null != ftpClient)
- ftpClient.quit();
+ if (null != rfs)
+ rfs.quit();
}
}
// @Override
byte[] getFileContents(File file) throws GatewayException
{
- FtpClientUtil ftpClient = null;
+ RemoteFileSystem rfs = null;
try
{
+ rfs = RemoteFileSystemFactory.getRemoteFileSystem(_config, true);
File temp = File.createTempFile("FTPdown", ".tmp");
temp.delete();
- ftpClient = new FtpClientUtil(_config, true);
- ftpClient.downloadFile(file.toString(), temp.toString());
+ rfs.downloadFile(file.toString(), temp.toString());
return getFileContents(temp);
} catch (Exception e)
{
throw new GatewayException(e);
} finally
{
- if (null != ftpClient)
- ftpClient.quit();
+ if (null != rfs)
+ rfs.quit();
}
}
// @Override
File[] getFileList(String suffix) throws GatewayException
{
- FtpClientUtil ftpClient = null;
+ RemoteFileSystem rfs = null;
try
{
- ftpClient = new FtpClientUtil(_config, true);
- ftpClient.setRemoteDir(FtpClientUtil
- .fileToFtpString(_inputDirectory));
- String[] sa = ftpClient.getFileListFromRemoteDir(_inputSuffix);
+ rfs = RemoteFileSystemFactory.getRemoteFileSystem(_config, true);
+ rfs.setRemoteDir(FtpClientUtil.fileToFtpString(_inputDirectory));
+ String[] sa = rfs.getFileListFromRemoteDir(_inputSuffix);
File[] oaRet = new File[(null == sa) ? 0 : sa.length];
int i1 = 0;
if (null != sa)
@@ -142,27 +139,27 @@
throw new GatewayException(e);
} finally
{
- if (null != ftpClient)
- ftpClient.quit();
+ if (null != rfs)
+ rfs.quit();
}
}
// @Override
boolean renameFile(File from, File to) throws GatewayException
{
- FtpClientUtil ftpClient = null;
+ RemoteFileSystem rfs = null;
try
{
- ftpClient = new FtpClientUtil(_config, true);
- ftpClient.renameInRemoteDir(from.toString(), to.toString());
+ rfs = RemoteFileSystemFactory.getRemoteFileSystem(_config, true);
+ rfs.renameInRemoteDir(from.toString(), to.toString());
return true;
} catch (Exception e)
{
throw new GatewayException(e);
} finally
{
- if (null != ftpClient)
- ftpClient.quit();
+ if (null != rfs)
+ rfs.quit();
}
}
More information about the jboss-svn-commits
mailing list