[jboss-svn-commits] JBL Code SVN: r7454 - labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 7 17:19:03 EST 2006
Author: b_georges
Date: 2006-11-07 17:19:00 -0500 (Tue, 07 Nov 2006)
New Revision: 7454
Added:
labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/JschFtpImpl.java
Removed:
labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/SFtpClientUtil.java
Log:
Refactoring work. In progress
Copied: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/JschFtpImpl.java (from rev 7450, labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/SFtpClientUtil.java)
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/SFtpClientUtil.java 2006-11-07 20:10:11 UTC (rev 7450)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/JschFtpImpl.java 2006-11-07 22:19:00 UTC (rev 7454)
@@ -0,0 +1,225 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.internal.soa.esb.util;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.PipedInputStream;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.util.RemoteFileSystem;
+
+import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.ChannelSftp;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Session;
+import com.jcraft.jsch.SftpException;
+
+/**
+ * Secure FTP transfers
+ * <p>
+ * Description: Implements a simple set of FTP functionality Parameters to
+ * establish the Secure FTP connection are provided at construction time and
+ * cannot change during the lifetime of the object <br/>Hides low level details.
+ * Current implementation is based on the "jcraft" library Note that this class
+ * is for my workspace only and is not supposed to superseed the FtpClientUtil
+ * Instead the good stuff will be taken out of this one and integrated with the
+ * FtpClientUtil
+ * </p>
+ *
+ * @author: $Author$
+ * @version: $Rev:$
+ */
+ at SuppressWarnings(
+{ "unused" })
+public class JschFtpImpl extends JSch implements RemoteFileSystem
+{
+ private static Logger log = Logger
+ .getLogger(JschFtpImpl.class.getName());
+
+ private String host = null;
+
+ private String user = null;
+
+ private Session session = null;
+
+ private ChannelSftp sftpChannel = null;
+
+ private boolean isConnected = false;
+
+ private String privateKeyFileName = null;
+
+ /**
+ *
+ * Constructor
+ *
+ * @param host
+ * @param user
+ * @param password
+ */
+ public JschFtpImpl(String host, String user, String password)
+ {
+ this.host = host;
+ this.user = user;
+ }
+
+ /**
+ * Gets a file from the SFTP-Server as Stream (currentdir is ~home).
+ *
+ * @param directory
+ * The files directory
+ * @param fileName
+ * The filename
+ * @return
+ */
+ public InputStream getFileAsSteam(String directory, String fileName)
+ {
+ if (isConnected)
+ {
+ try
+ {
+ this.sftpChannel.cd(directory);
+ PipedInputStream fileStream = (PipedInputStream) this.sftpChannel
+ .get(fileName);
+ return fileStream;
+ } catch (SftpException e)
+ {
+ log.error("Unable to get: " + fileName + " Message: " + e);
+ }
+ } else
+ {
+ log.warn("You must call connect() before you can get a file! ");
+ }
+ return null;
+ }
+
+ /**
+ * Connects to the SFTP-Server
+ */
+ public void connect()
+ {
+ try
+ {
+ this.session = this.getSession(this.user, this.host, 22);
+ this.session.connect();
+ Channel channel = session.openChannel("sftp");
+ channel.connect();
+ this.sftpChannel = (ChannelSftp) channel;
+ isConnected = this.session.isConnected();
+ } catch (JSchException e)
+ {
+ log.error("Unable to connect to " + host + " Message= " + e);
+ }
+ }
+
+ /**
+ * Disconnects from the server.
+ */
+ public void disconnect()
+ {
+ if (this.session != null)
+ {
+ this.session.disconnect();
+ }
+ }
+
+ /**
+ * @return Returns the privateKeyFileName.
+ */
+ public String getPrivateKeyFileName()
+ {
+ return privateKeyFileName;
+ }
+
+ /**
+ * @param privateKeyFileName
+ * The privateKeyFileName to set.
+ */
+ public void setPrivateKeyFileName(String privateKeyFileName)
+ {
+ this.privateKeyFileName = privateKeyFileName;
+ }
+
+ public void deleteRemoteFile(String p_sFile) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void downloadFile(String p_sFile, String p_sFinalName)
+ throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String[] getFileListFromRemoteDir(String p_sSuffix) throws Exception
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getRemoteDir()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void quit()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void remoteDelete(File p_oFile) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void remoteRename(File p_oFrom, File p_oTo) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void renameInRemoteDir(String p_sFrom, String p_sTo)
+ throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setRemoteDir(String p_sDir) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void uploadFile(File p_oFile, String p_sRemoteName) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+}
\ No newline at end of file
Deleted: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/SFtpClientUtil.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/SFtpClientUtil.java 2006-11-07 22:18:34 UTC (rev 7453)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/SFtpClientUtil.java 2006-11-07 22:19:00 UTC (rev 7454)
@@ -1,225 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.internal.soa.esb.util;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.PipedInputStream;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.util.RemoteFileSystem;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.ChannelSftp;
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Session;
-import com.jcraft.jsch.SftpException;
-
-/**
- * Secure FTP transfers
- * <p>
- * Description: Implements a simple set of FTP functionality Parameters to
- * establish the Secure FTP connection are provided at construction time and
- * cannot change during the lifetime of the object <br/>Hides low level details.
- * Current implementation is based on the "jcraft" library Note that this class
- * is for my workspace only and is not supposed to superseed the FtpClientUtil
- * Instead the good stuff will be taken out of this one and integrated with the
- * FtpClientUtil
- * </p>
- *
- * @author: $Author$
- * @version: $Rev:$
- */
- at SuppressWarnings(
-{ "unused" })
-public class SFtpClientUtil extends JSch implements RemoteFileSystem
-{
- private static Logger log = Logger
- .getLogger(SFtpClientUtil.class.getName());
-
- private String host = null;
-
- private String user = null;
-
- private Session session = null;
-
- private ChannelSftp sftpChannel = null;
-
- private boolean isConnected = false;
-
- private String privateKeyFileName = null;
-
- /**
- *
- * Constructor
- *
- * @param host
- * @param user
- * @param password
- */
- public SFtpClientUtil(String host, String user, String password)
- {
- this.host = host;
- this.user = user;
- }
-
- /**
- * Gets a file from the SFTP-Server as Stream (currentdir is ~home).
- *
- * @param directory
- * The files directory
- * @param fileName
- * The filename
- * @return
- */
- public InputStream getFileAsSteam(String directory, String fileName)
- {
- if (isConnected)
- {
- try
- {
- this.sftpChannel.cd(directory);
- PipedInputStream fileStream = (PipedInputStream) this.sftpChannel
- .get(fileName);
- return fileStream;
- } catch (SftpException e)
- {
- log.error("Unable to get: " + fileName + " Message: " + e);
- }
- } else
- {
- log.warn("You must call connect() before you can get a file! ");
- }
- return null;
- }
-
- /**
- * Connects to the SFTP-Server
- */
- public void connect()
- {
- try
- {
- this.session = this.getSession(this.user, this.host, 22);
- this.session.connect();
- Channel channel = session.openChannel("sftp");
- channel.connect();
- this.sftpChannel = (ChannelSftp) channel;
- isConnected = this.session.isConnected();
- } catch (JSchException e)
- {
- log.error("Unable to connect to " + host + " Message= " + e);
- }
- }
-
- /**
- * Disconnects from the server.
- */
- public void disconnect()
- {
- if (this.session != null)
- {
- this.session.disconnect();
- }
- }
-
- /**
- * @return Returns the privateKeyFileName.
- */
- public String getPrivateKeyFileName()
- {
- return privateKeyFileName;
- }
-
- /**
- * @param privateKeyFileName
- * The privateKeyFileName to set.
- */
- public void setPrivateKeyFileName(String privateKeyFileName)
- {
- this.privateKeyFileName = privateKeyFileName;
- }
-
- public void deleteRemoteFile(String p_sFile) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- public void downloadFile(String p_sFile, String p_sFinalName)
- throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- public String[] getFileListFromRemoteDir(String p_sSuffix) throws Exception
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getRemoteDir()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void quit()
- {
- // TODO Auto-generated method stub
-
- }
-
- public void remoteDelete(File p_oFile) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- public void remoteRename(File p_oFrom, File p_oTo) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- public void renameInRemoteDir(String p_sFrom, String p_sTo)
- throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- public void setRemoteDir(String p_sDir) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- public void uploadFile(File p_oFile, String p_sRemoteName) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list