[jboss-svn-commits] JBL Code SVN: r26872 - labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jun 8 06:35:50 EDT 2009
Author: kevin.conner at jboss.com
Date: 2009-06-08 06:35:49 -0400 (Mon, 08 Jun 2009)
New Revision: 26872
Modified:
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/SecureFtpImpl.java
Log:
Remove cd invocation from file not found behaviour, added some debug logging: JBESB-2466
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/SecureFtpImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/SecureFtpImpl.java 2009-06-08 10:24:39 UTC (rev 26871)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/SecureFtpImpl.java 2009-06-08 10:35:49 UTC (rev 26872)
@@ -168,7 +168,7 @@
}
catch (final URISyntaxException urise)
{
- _logger.warn(urise) ;
+ throw new RemoteFileSystemException(urise);
}
m_sPassphrase = p_oP.getPassphrase() ;
@@ -200,6 +200,7 @@
if (bConnect)
{
+ _logger.debug("Connecting to SFTP server") ;
try
{
if (m_iPort > 0)
@@ -359,6 +360,11 @@
*/
public void deleteRemoteFile(String p_sFile) throws RemoteFileSystemException
{
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("deleteRemoteFile(" + p_sFile + "), remote dir " + getRemoteDir()) ;
+ }
+
try
{
m_oSftpChannel.cd(getRemoteDir()) ;
@@ -379,9 +385,14 @@
*/
public void remoteDelete(File p_oFile) throws RemoteFileSystemException
{
+ final String remoteFile = FtpUtils.fileToFtpString(p_oFile) ;
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("remoteDelete(" + remoteFile + ")") ;
+ }
try
{
- m_oSftpChannel.rm(FtpUtils.fileToFtpString(p_oFile));
+ m_oSftpChannel.rm(remoteFile);
}
catch (SftpException ex)
{
@@ -398,40 +409,52 @@
*/
public String[] getFileListFromRemoteDir(String p_sSuffix) throws RemoteFileSystemException
{
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("getFileListFromRemoteDir(" + p_sSuffix + "), remote dir " + getRemoteDir()) ;
+ }
try
{
m_oSftpChannel.cd(getRemoteDir()) ;
- String sSuffix = (null == p_sSuffix) ? "*" : "*" + p_sSuffix;
- List<String> lFileList = new ArrayList<String>();
- Vector vFileList = m_oSftpChannel.ls(sSuffix);
-
- if (vFileList != null)
- {
- for (int i = 0; i < vFileList.size(); i++)
- {
- Object obj = vFileList.elementAt(i);
-
- if (obj instanceof LsEntry)
- {
- SftpATTRS oSftAttr = ((LsEntry) obj).getAttrs();
- if (!oSftAttr.isDir())
- {
- lFileList.add(((LsEntry) obj).getFilename());
- }
- }
- }
- }
-
- return (String[]) lFileList.toArray(new String[lFileList.size()]);
}
catch (SftpException ex)
{
+ throw new RemoteFileSystemException(ex);
+ }
+ String sSuffix = (null == p_sSuffix) ? "*" : "*" + p_sSuffix;
+ final Vector vFileList ;
+ try
+ {
+ vFileList = m_oSftpChannel.ls(sSuffix);
+ }
+ catch (SftpException ex)
+ {
if (ex.id == ChannelSftp.SSH_FX_NO_SUCH_FILE)
{
return null ;
}
throw new RemoteFileSystemException(ex);
}
+
+ List<String> lFileList = new ArrayList<String>();
+ if (vFileList != null)
+ {
+ for (int i = 0; i < vFileList.size(); i++)
+ {
+ Object obj = vFileList.elementAt(i);
+
+ if (obj instanceof LsEntry)
+ {
+ SftpATTRS oSftAttr = ((LsEntry) obj).getAttrs();
+ if (!oSftAttr.isDir())
+ {
+ lFileList.add(((LsEntry) obj).getFilename());
+ }
+ }
+ }
+ }
+
+ return (String[]) lFileList.toArray(new String[lFileList.size()]);
}
/*
@@ -459,6 +482,10 @@
public void renameInRemoteDir(String p_sFrom, String p_sTo)
throws RemoteFileSystemException
{
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("renameInRemoteDir(" + p_sFrom + ", " + p_sTo + "), remote dir " + getRemoteDir()) ;
+ }
try
{
m_oSftpChannel.cd(getRemoteDir()) ;
@@ -482,11 +509,16 @@
*/
public void remoteRename(File p_oFrom, File p_oTo) throws RemoteFileSystemException
{
+ final String from = FtpUtils.fileToFtpString(p_oFrom) ;
+ final String to = FtpUtils.fileToFtpString(p_oTo) ;
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("remoteRename(" + from + ", " + to + "), remote dir " + getRemoteDir()) ;
+ }
try
{
m_oSftpChannel.cd(getRemoteDir()) ;
- m_oSftpChannel.rename(FtpUtils.fileToFtpString(p_oFrom), FtpUtils
- .fileToFtpString(p_oTo));
+ m_oSftpChannel.rename(from, to);
}
catch (SftpException se)
{
@@ -507,6 +539,10 @@
*/
public void uploadFile(File p_oFile, String p_sRemoteName) throws RemoteFileSystemException
{
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("uploadFile(" + p_oFile + ", " + p_sRemoteName + "), remote dir " + getRemoteDir()) ;
+ }
try
{
m_oSftpChannel.cd(getRemoteDir()) ;
@@ -555,6 +591,10 @@
*/
public void downloadFile(String p_sFile, String p_sFinalName) throws IOException, RemoteFileSystemException
{
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("downloadFile(" + p_sFile + ", " + p_sFinalName + "), remote dir " + getRemoteDir()) ;
+ }
try
{
final File to = new File(p_sFinalName) ;
@@ -612,6 +652,7 @@
*/
public void quit()
{
+ _logger.debug("quitting") ;
m_oSftpChannel.disconnect() ;
session.disconnect() ;
}
More information about the jboss-svn-commits
mailing list