[jboss-svn-commits] JBL Code SVN: r7426 - in labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss: internal/soa/esb/util soa/esb/util
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 7 11:41:05 EST 2006
Author: b_georges
Date: 2006-11-07 11:40:56 -0500 (Tue, 07 Nov 2006)
New Revision: 7426
Added:
labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java
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/soa/esb/util/RemoteFileSystem.java
labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemException.java
labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java
Log:
Started FTP refactoring
Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java 2006-11-07 15:01:58 UTC (rev 7425)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java 2006-11-07 16:40:56 UTC (rev 7426)
@@ -0,0 +1,266 @@
+/*
+* 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.util.List;
+
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.util.RemoteFileSystem;
+
+import com.enterprisedt.net.ftp.FTPClient;
+import com.enterprisedt.net.ftp.FTPConnectMode;
+import com.enterprisedt.net.ftp.FTPTransferType;
+
+/**
+ * Simplified FTP transfers
+ * <p>Description: Implements a simple set of FTP functionality
+ * Parameters to establish the 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
+ * "Entreprise Distributed Technology edtFTPj" library
+ * but this can be changed with no impact to existing code, just by changing
+ * this class without modifying the signature of it's public methods
+ * </p>
+ */
+
+public class EdtFtpImpl implements RemoteFileSystem
+{
+ private static final String TMP_SUFFIX = ".rosettaPart";
+
+ public enum XFER_TYPE
+ {ascii
+ ,binary
+ };
+
+ private ConfigTree m_oParms;
+ private String m_sFtpServer ,m_sUser ,m_sPasswd;
+ private String m_sRemoteDir ,m_sLocalDir;
+ private int m_iPort;
+ private boolean m_bPassive;
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.util.RemoteFileSystem#getRemoteDir()
+ */
+public String getRemoteDir() { return m_sRemoteDir; }
+
+ private FTPClient m_oConn = new FTPClient();
+ private FTPTransferType m_oXferType = FTPTransferType.BINARY;
+
+ /**
+ * Checks validity and completeness of parameters, and keeps the info internally
+ * for subsequent FTP requests
+ * @param p_oP ConfigTree
+ * @throws Exception : if parameters are invalid or incomplete
+ * <li>Parameters: (XML attributes at the root level) </li>
+ * <li> ftpServer = name or IP of FTP server </li>
+ * <li> ftpUser = login ID for server </li>
+ * <li> ftpPassword </li>
+ * <li> localDirURI = absolute path in the local filesystem </li>
+ * <li> remoteDirURI = remote path is relative to ftp user home in remote
+ * computer </li>
+ */
+
+ public EdtFtpImpl (ConfigTree p_oP, boolean p_bConnect) throws Exception
+ { m_oParms = p_oP;
+ initialize(p_bConnect);
+ } //_________________________________
+
+ public EdtFtpImpl (List<KeyValuePair> attribs, boolean connect) throws Exception
+ {
+ m_oParms = new ConfigTree("fromProps");
+ for (KeyValuePair oCurr : attribs)
+ m_oParms.setAttribute(oCurr.getKey(),oCurr.getValue());
+ initialize(connect);
+ } //__________________________________
+
+ private void initialize(boolean bConnect) throws Exception
+ {
+ checkParms();
+ if (bConnect)
+ {
+ m_oConn.setRemoteHost (m_sFtpServer);
+ m_oConn.setRemotePort(m_iPort);
+ m_oConn.connect();
+ for (int i1=0; i1<10 && ! m_oConn.connected(); i1++)
+ Thread.sleep(200);
+ if (! m_oConn.connected())
+ throw new Exception("Can't connect to FTP server");
+ m_oConn.user (m_sUser);
+ m_oConn.password (m_sPasswd);
+ m_oConn.setConnectMode ((m_bPassive) ? FTPConnectMode.PASV : FTPConnectMode.ACTIVE);
+ }
+ } //__________________________________
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.util.RemoteFileSystem#quit()
+ */
+ public void quit ()
+ { if (null != m_oConn)
+ try { m_oConn.quit(); }
+ catch (Exception e) {}
+ } //_________________________________
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.util.RemoteFileSystem#deleteRemoteFile(java.lang.String)
+ */
+ public void deleteRemoteFile (String p_sFile) throws Exception
+ { m_oConn.delete(getRemoteDir()+"/"+new File(p_sFile).getName());
+ } //_________________________________
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.util.RemoteFileSystem#remoteDelete(java.io.File)
+ */
+public void remoteDelete (File p_oFile) throws Exception
+ { m_oConn.delete(fileToFtpString(p_oFile));
+ } //_________________________________
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.util.RemoteFileSystem#getFileListFromRemoteDir(java.lang.String)
+ */
+ public String[] getFileListFromRemoteDir (String p_sSuffix) throws Exception
+ {
+ String sSuffix = (null==p_sSuffix)?"*":"*"+p_sSuffix;
+ return m_oConn.dir(sSuffix);
+ } //_________________________________
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.util.RemoteFileSystem#setRemoteDir(java.lang.String)
+ */
+ public void setRemoteDir (String p_sDir) throws Exception
+ {
+ m_oConn.chdir(p_sDir);
+ } //_________________________________
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.util.RemoteFileSystem#renameInRemoteDir(java.lang.String, java.lang.String)
+ */
+ public void renameInRemoteDir (String p_sFrom, String p_sTo) throws Exception
+ {
+ String sRmtFrom = new File(p_sFrom).getName();
+ String sRmtTo = new File(p_sTo).getName();
+
+ try { m_oConn.rename (getRemoteDir()+"/"+sRmtFrom,getRemoteDir()+"/"+sRmtTo); }
+ catch (Exception e)
+ { String sMess = this.getClass().getSimpleName()
+ +" can't rename in remote directory <"
+ +e.getMessage()+">"
+ ;
+ throw new Exception(sMess);
+ }
+ } //_________________________________
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.util.RemoteFileSystem#remoteRename(java.io.File, java.io.File)
+ */
+public void remoteRename(File p_oFrom, File p_oTo) throws Exception
+ {
+ try { m_oConn.rename (fileToFtpString(p_oFrom),fileToFtpString(p_oTo)); }
+ catch (Exception e)
+ { String sMess = this.getClass().getSimpleName()
+ +" can't rename in remote directory <"
+ +e.getMessage()+">"
+ ;
+ throw new Exception(sMess);
+ }
+ } //_________________________________
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.util.RemoteFileSystem#uploadFile(java.io.File, java.lang.String)
+ */
+ public void uploadFile (File p_oFile, String p_sRemoteName) throws Exception
+ {
+ String sRemoteOK = getRemoteDir() + "/" + p_sRemoteName;
+ String sRemoteTmp = sRemoteOK+TMP_SUFFIX;
+ m_oConn.setType(m_oXferType);
+ m_oConn.put(fileToFtpString(p_oFile),sRemoteTmp);
+ m_oConn.rename(sRemoteTmp,sRemoteOK);
+ } //_________________________________
+
+ /* (non-Javadoc)
+ * @see org.jboss.soa.esb.util.RemoteFileSystem#downloadFile(java.lang.String, java.lang.String)
+ */
+ public void downloadFile (String p_sFile, String p_sFinalName) throws Exception
+ {
+ File oLocalDir = new File(m_sLocalDir);
+ File oLclFile= File.createTempFile("Rosetta_",TMP_SUFFIX,oLocalDir);
+
+ try { oLclFile.delete(); }
+ catch (Exception e) {}
+ m_oConn.setType(m_oXferType);
+ m_oConn.get(fileToFtpString(oLclFile),p_sFile);
+
+ File oNew = new File(oLocalDir,p_sFinalName);
+ if (oNew.exists()) oNew.delete();
+ oLclFile.renameTo(oNew);
+ } //_________________________________
+
+ // Beware !!! The logic here seems wrong, but it works
+ // It appears that there's some kind of bug in the edtftpj.jar library
+ // The !XFER_TYPE.ascii.equals(p_oMode) should NOT be negated
+ // But it works when negated (newlines from Unix to DOS)
+ private void setXferType (XFER_TYPE p_oMode)
+ { m_oXferType = !XFER_TYPE.ascii.equals(p_oMode)
+ ? FTPTransferType.ASCII : FTPTransferType.BINARY;
+ } //_________________________________
+
+ private void checkParms() throws Exception
+ {
+ m_sFtpServer = m_oParms.getAttribute(PARMS_FTP_SERVER);
+ if (null==m_sFtpServer) throw new Exception ("No FTP server specified");
+
+ m_sUser = m_oParms.getAttribute(PARMS_USER);
+ if (null==m_sUser) throw new Exception ("No username specified for FTP");
+
+ m_sPasswd = m_oParms.getAttribute(PARMS_PASSWD);
+ if (null==m_sPasswd) throw new Exception ("No password specified for FTP");
+
+ m_sRemoteDir = m_oParms.getAttribute(PARMS_REMOTE_DIR);
+ if (null==m_sRemoteDir)
+ m_sRemoteDir = "";
+
+ m_sLocalDir = m_oParms.getAttribute(PARMS_LOCAL_DIR);
+ if (null==m_sLocalDir)
+ m_sLocalDir = ".";
+
+ String sAux = m_oParms.getAttribute(PARMS_PORT);
+ m_iPort = (null==sAux) ? 21 : Integer.parseInt(sAux);
+
+ boolean bAscii = false;
+ sAux = m_oParms.getAttribute(PARMS_ASCII);
+ if (null!=sAux)
+ bAscii = Boolean.parseBoolean(sAux);
+ setXferType((bAscii)?XFER_TYPE.ascii:XFER_TYPE.binary);
+
+ m_bPassive = false;
+ sAux = m_oParms.getAttribute(PARMS_PASSIVE);
+ m_bPassive = (null!=sAux) && Boolean.parseBoolean(sAux);
+
+ return;
+ } //__________________________________
+
+ public static String fileToFtpString(File p_oF)
+ {
+ return(null==p_oF) ? null
+ : p_oF.toString().replace("\\","/");
+ } //________________________________
+
+} //____________________________________________________________________________
Property changes on: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Added: 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 15:01:58 UTC (rev 7425)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/SFtpClientUtil.java 2006-11-07 16:40:56 UTC (rev 7426)
@@ -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 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
Property changes on: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/internal/soa/esb/util/SFtpClientUtil.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystem.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystem.java 2006-11-07 15:01:58 UTC (rev 7425)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystem.java 2006-11-07 16:40:56 UTC (rev 7426)
@@ -0,0 +1,120 @@
+/*
+* 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.soa.esb.util;
+
+import java.io.File;
+
+public interface RemoteFileSystem {
+
+ public static final String PARMS_FTP_SERVER = "ftpServer";
+
+ public static final String PARMS_USER = "ftpUser";
+
+ public static final String PARMS_PASSWD = "ftpPassword";
+
+ public static final String PARMS_PORT = "ftpPort";
+
+ public static final String PARMS_REMOTE_DIR = "ftpRemoteDir";
+
+ public static final String PARMS_LOCAL_DIR = "ftpLocalDir";
+
+ public static final String PARMS_ASCII = "ftpAscii";
+
+ public static final String PARMS_PASSIVE = "ftpPassive";
+
+ public String getRemoteDir();
+
+ /**
+ * Terminates ftp session and frees resources
+ * <li>Well behaved programs should make sure to call this method </li>
+ */
+ public void quit(); //_________________________________
+
+ /**
+ * Deletes specified file in remote directory
+ * @param p_sFile String : filename to delete. Method will attempt to delete
+ * file with rightmost node of argument within remote directory specified in 'remoteDirURI'
+ * @throws Exception : if ftp connection cannot be established, or file
+ * cannot be deleted in remote directory
+ */
+ public void deleteRemoteFile(String p_sFile) throws Exception; //_________________________________
+
+ public void remoteDelete(File p_oFile) throws Exception; //_________________________________
+
+ /**
+ * Gets the list of files in the remote directory that end with arg0
+ * @param p_sSuffix String : retrieve only files that end with that suffix - all files if null
+ * @throws Exception : if ftp connection cannot be established, or problems encountered
+ */
+ public String[] getFileListFromRemoteDir(String p_sSuffix) throws Exception; //_________________________________
+
+ /**
+ * Change remote directory
+ * @param p_sDir String : directory to set
+ * @throws Exception : if ftp connection cannot be established, or problems encountered
+ */
+ public void setRemoteDir(String p_sDir) throws Exception; //_________________________________
+
+ /**
+ * Renames specified file in remote directory to specified new name
+ * @param p_sFrom String : filename to rename
+ * @param p_sTo String : new filename
+ * @throws Exception : if ftp connection cannot be established, or file
+ * cannot be renamed to new name in remote directory
+ * <li>Method will attempt to rename file with rightmost node of argument
+ * within remote directory specified in 'remoteDirURI', to new name inside
+ * the SAME remote directory
+ */
+ public void renameInRemoteDir(String p_sFrom, String p_sTo)
+ throws Exception; //_________________________________
+
+ public void remoteRename(File p_oFrom, File p_oTo) throws Exception; //_________________________________
+
+ /**
+ * Uploads specified file from local directory (localDirURI) to remote
+ * directory (remoteDirURI)
+ * @param p_sFile String : filename to upload
+ * @throws Exception : if ftp connection cannot be established, or file
+ * cannot be uploaded
+ * <li> local file will be renamed during transfer ('.xferNotReady' appended
+ * to name)</li>
+ * <li> upon successful completion. the suffix '.xferDone' will be appended
+ * to the original filename </li>
+ */
+ public void uploadFile(File p_oFile, String p_sRemoteName) throws Exception; //_________________________________
+
+ /**
+ * Downloads specified file from remote directory (remoteDirURI) to local
+ * directory (localDirURI)
+ * @param p_sFile String : filename to download
+ * @throws Exception : if ftp connection cannot be established, or file
+ * cannot be downloaded
+ * <li> local file is assigned a temporary name during transfer </li>
+ * <li> upon successful completion, local temporary file will be renamed to
+ * name specified in argument, and suffix '.xferDone' will be appended
+ * to the original filename in the remote directory </li>
+ */
+ public void downloadFile(String p_sFile, String p_sFinalName)
+ throws Exception; //_________________________________
+
+}
\ No newline at end of file
Property changes on: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystem.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemException.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemException.java 2006-11-07 15:01:58 UTC (rev 7425)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemException.java 2006-11-07 16:40:56 UTC (rev 7426)
@@ -0,0 +1,55 @@
+/*
+ * 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.soa.esb.util;
+
+import org.jboss.soa.esb.BaseException;
+
+/**
+ * Dispatch Exception.
+ * @author b_georges
+ * @since Version 4.0
+ */
+public class RemoteFileSystemException extends BaseException
+{
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct an exception instance.
+ * @param message Exception message.
+ */
+ public RemoteFileSystemException(String message) { super(message); }
+
+ /**
+ * Construct an exception instance.
+ * @param message Exception message.
+ * @param cause Exception cause.
+ */
+ public RemoteFileSystemException(String message, Throwable cause) { super(message, cause); }
+
+ /**
+ * Construct an exception instance.
+ * @param cause Exception cause.
+ */
+ public RemoteFileSystemException(Throwable cause) { super(cause); }
+}
Property changes on: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemException.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java 2006-11-07 15:01:58 UTC (rev 7425)
+++ labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java 2006-11-07 16:40:56 UTC (rev 7426)
@@ -0,0 +1,74 @@
+/*
+ * 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.soa.esb.util;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URISyntaxException;
+
+import org.jboss.internal.soa.esb.util.EdtFtpImpl;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.xml.sax.SAXException;
+
+public class RemoteFileSystemFactory
+{
+
+ //
+ private static final RemoteFileSystemFactory _instance = new RemoteFileSystemFactory();
+
+ // private default constructor
+ private RemoteFileSystemFactory() {}
+
+ public static RemoteFileSystemFactory getInstance(Object obj)
+ {
+ return _instance;
+ }
+
+ public static RemoteFileSystem getRemoteFileSystem() throws RemoteFileSystemException
+ {
+ try
+ {
+ // TODO fix this to work with EPR
+ //if FTPEpr
+ ConfigTree cfgTree = ConfigTree.fromInputStream((InputStream)new FileInputStream("c:\test.txt"));
+ return new EdtFtpImpl(cfgTree,true);
+ }
+ catch (URISyntaxException e) { throw new RemoteFileSystemException(e); } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ throw new RemoteFileSystemException("Unknown protocol");
+ }
+
+}
Property changes on: labs/jbossesb/workspace/b_georges/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java
___________________________________________________________________
Name: svn:executable
+ *
More information about the jboss-svn-commits
mailing list