[jboss-svn-commits] JBL Code SVN: r19805 - in labs/jbossesb/branches/JBESB_4_2_1_GA_FP1: product/etc/schemas/xml and 22 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu May 1 09:49:09 EDT 2008


Author: kevin.conner at jboss.com
Date: 2008-05-01 09:49:08 -0400 (Thu, 01 May 2008)
New Revision: 19805

Added:
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/ext/commons-net-2.0.0-652071.jar
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/ext/jsch-0.1.38.jar
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFtpsReplyToEpr.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpImpl.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpsImpl.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPSEpr.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/FtpImplUnitTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/FTPSUnitTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/SFTPUnitTest.java
Removed:
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/ext/edtftpj-1.5.4.jar
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/ext/jsch-0.1.jar
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/EdtFtpImplUnitTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/qa/lib/ext/edtftpj-pro.jar
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/qa/lib/ext/license.jar
Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/build-distr.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/etc/schemas/xml/jbossesb-1.0.1.xsd
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/install/Deployment.txt
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/Licenses.txt
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFileReplyToEpr.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFtpReplyToEpr.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultSftpReplyToEpr.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/FtpFileHandler.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/LocalFileHandler.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/message/filter/MetaDataFilter.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/SecureFtpImpl.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/EPR.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/SFTPEpr.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/util/DefaultReplyTo.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapper.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/FtpClientUtil.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystem.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/CourierIntegrationTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/tests/DefaultFileReplyToEprUnitTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/tests/DefaultFtpReplyToEprIntegrationTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/FTPUnitTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/HTTPUnitTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
Log:
Update to URI and introduce FTPS/SFTP: JBESB-1598

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/build-distr.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/build-distr.xml	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/build-distr.xml	2008-05-01 13:49:08 UTC (rev 19805)
@@ -105,7 +105,7 @@
             <fileset dir="${lib.ext.dir}"
                      includes="opencsv-*.jar,ognl-*.jar,groovy-*.jar,commons-lang-2.1.jar,stringtemplate-3.0.jar,antlr-2.7.6.jar"/>
             <!-- ftp -->
-            <fileset dir="${lib.ext.dir}" includes="edtftpj-*.jar,commons-io*.jar"/>
+            <fileset dir="${lib.ext.dir}" includes="commons-net-*.jar,commons-io*.jar jsch-0.1.38.jar"/>
             <!-- XStream jars - including woodstox for the StaxDriver -->
             <fileset dir="${lib.ext.dir}" includes="xstream-*.jar,wstx-lgpl-*.jar"/>
             <!-- JBossCache jars - including jgroups -->

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/etc/schemas/xml/jbossesb-1.0.1.xsd
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/etc/schemas/xml/jbossesb-1.0.1.xsd	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/etc/schemas/xml/jbossesb-1.0.1.xsd	2008-05-01 13:49:08 UTC (rev 19805)
@@ -1109,6 +1109,15 @@
 					</xsd:documentation>
 				</xsd:annotation>
 			</xsd:attribute>
+			<xsd:attribute name="certificate-name" type="xsd:string"
+				use="optional">
+				<xsd:annotation>
+					<xsd:documentation xml:lang="en">
+						The common name of a certificate, which can be needed
+						for secure protocols (sftp and ftps).
+					</xsd:documentation>
+				</xsd:annotation>
+			</xsd:attribute>
 			<xsd:attribute default="false" name="read-only"
 				type="xsd:boolean" use="optional">
 				<xsd:annotation>

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/install/Deployment.txt
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/install/Deployment.txt	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/install/Deployment.txt	2008-05-01 13:49:08 UTC (rev 19805)
@@ -23,7 +23,6 @@
 |                                  	|                              |
 | cglib                            	| 2.0-RC2 (full)               | http://cglib.sourceforge.net/
 | XStream                          	| 1.1.3                        | http://xstream.codehaus.org/
-| edtftpj                          	| 1.5.2                        | http://www.enterprisedt.com/products/edtftpj/download.html
 |                                  	|                              |
 | milyn-commons                    	| 0.9                          | http://milyn.codehaus.org/downloads
 | milyn-smooks-core                	| 0.9                          | http://milyn.codehaus.org/downloads

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/Licenses.txt
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/Licenses.txt	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/Licenses.txt	2008-05-01 13:49:08 UTC (rev 19805)
@@ -24,7 +24,7 @@
  * (C) 2005-2006,
  */
  
-Apache Jakarta Commons Collections, Commons Logging, jUDDI, Scout, JAXR-API, DBCP, Pooling:
+Apache Jakarta Commons Collections, Commons Logging, Commons Net, jUDDI, Scout, JAXR-API, DBCP, Pooling:
 
 Apache License
                            Version 2.0, January 2004
@@ -231,11 +231,6 @@
    
    
    
-   Enterprise Distributed Technologies edtftpj.jar
-   
-   edtFTPj is Open Source, licensed under the LGPL, the GNU Lesser General 
-   Public License.   http://www.gnu.org/licenses/lgpl.html
-   
 --- jsch-0.1.jar
 JSch 0.0.* was released under the GNU LGPL license.  Later, we have switched 
 over to a BSD-style license. 

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/ext/commons-net-2.0.0-652071.jar
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/ext/commons-net-2.0.0-652071.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/ext/edtftpj-1.5.4.jar
===================================================================
(Binary files differ)

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/ext/jsch-0.1.38.jar
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/ext/jsch-0.1.38.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/lib/ext/jsch-0.1.jar
===================================================================
(Binary files differ)

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFileReplyToEpr.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFileReplyToEpr.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFileReplyToEpr.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -32,7 +32,7 @@
 	public DefaultFileReplyToEpr (FileEpr epr)
 		throws URISyntaxException, MalformedURLException
 	{
-		super(epr.getURL());
+		super(epr.getURI());
 		String suffix = uniqueFileSuffix(epr);
 		setInputSuffix(suffix);
 		setPostSuffix(suffix);

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFtpReplyToEpr.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFtpReplyToEpr.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFtpReplyToEpr.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -31,7 +31,7 @@
 	public DefaultFtpReplyToEpr(FTPEpr epr)
 		throws URISyntaxException, MalformedURLException
 	{
-		super(epr.getURL());
+		super(epr.getURI());
 		String suffix = DefaultFileReplyToEpr.uniqueFileSuffix(epr);
 		setInputSuffix(suffix);
 		setPostSuffix(suffix);

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFtpsReplyToEpr.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFtpsReplyToEpr.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFtpsReplyToEpr.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ */
+
+package org.jboss.internal.soa.esb.addressing.eprs;
+
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+
+import org.jboss.soa.esb.addressing.eprs.FTPSEpr;
+
+public class DefaultFtpsReplyToEpr extends FTPSEpr 
+{
+	
+	public DefaultFtpsReplyToEpr(FTPSEpr epr)
+		throws URISyntaxException, MalformedURLException
+	{
+		super(epr.getURI());
+		String suffix = DefaultFileReplyToEpr.uniqueFileSuffix(epr);
+		setInputSuffix(suffix);
+		setPostSuffix(suffix);
+		setPostDelete(true);
+		
+		setPassive(epr.getPassive());
+		setCertificateURI(epr.getCertificateURI());
+	}
+
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultFtpsReplyToEpr.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultSftpReplyToEpr.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultSftpReplyToEpr.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/eprs/DefaultSftpReplyToEpr.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -31,14 +31,14 @@
 	public DefaultSftpReplyToEpr(SFTPEpr epr)
 		throws URISyntaxException, MalformedURLException
 	{
-		super(epr.getURL());
+		super(epr.getURI());
 		String suffix = DefaultFileReplyToEpr.uniqueFileSuffix(epr);
 		setInputSuffix(suffix);
 		setPostSuffix(suffix);
 		setPostDelete(true);
 		
 		setPassive(epr.getPassive());
-		setCertificateURL(epr.getCertificateURL());
+		setCertificateURI(epr.getCertificateURI());
 	}
 
 }

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -161,6 +161,8 @@
 			eprType = InVMEpr.type().toString();
 		else if (epr instanceof EmailEpr)
 			eprType = EmailEpr.type().toString();
+		else if (epr instanceof FTPSEpr)
+			eprType = FTPSEpr.type().toString();
 		else if (epr instanceof SFTPEpr)
 			eprType = SFTPEpr.type().toString();
 		else if (epr instanceof HTTPEpr)
@@ -201,6 +203,8 @@
 				return new InVMEpr(epr);
 			else if (eprType.equals(EmailEpr.type().toString()))
 				return new EmailEpr(epr);
+			else if (eprType.equals(FTPSEpr.type().toString()))
+				return new FTPSEpr(epr);
 			else if (eprType.equals(SFTPEpr.type().toString()))
 				return new SFTPEpr(epr);
 			else if (eprType.equals(HTTPEpr.type().toString()))

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -26,10 +26,8 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.lang.reflect.Method;
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 import java.util.UUID;
 
 import javax.xml.parsers.ParserConfigurationException;
@@ -121,13 +119,13 @@
 		// Certain things can only be checked in local filesystem
 		try
 		{
-			_url = _epr.getURL();
+			_uri = _epr.getURI();
 			FileHandler handler = FileHandlerFactory.getInstance()
 					.getFileHandler(_epr);
 			if (handler instanceof LocalFileHandler)
 			{
 				_localFhandler = (LocalFileHandler) handler;
-				File file = new File(_url.getFile());
+				File file = new File(_uri);
 				if ((!_receiverOnly) && (!file.isDirectory()))
 					throw new CourierException(
 							"File for deliverAsync EPR must be a directory (file name will be MessageID)");
@@ -148,10 +146,6 @@
 				return;
 			}
 		}
-		catch (MalformedURLException e)
-		{
-			throw new MalformedEPRException(e);
-		}
 		catch (URISyntaxException e)
 		{
 			throw new MalformedEPRException(e);
@@ -182,7 +176,7 @@
 		if (null == handler)
 			throw new CourierServiceBindException(
 					"Can't find appropriate file handler for "
-							+ _url.toString());
+							+ _uri.toASCIIString());
 
 		Call call = message.getHeader().getCall();
 		if (null==call)
@@ -203,7 +197,7 @@
 		{
 			try
 			{
-				File dir = new File(_url.getFile());
+				File dir = new File(_uri);
 				String name = message.getHeader().getCall().getMessageID()
 						.toString();
 				name += _inputSuffix;
@@ -544,7 +538,7 @@
 
 	protected String _inputSuffix;
 
-	protected URL _url;
+	protected URI _uri;
 
 	protected boolean _receiverOnly;
 

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/FtpFileHandler.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/FtpFileHandler.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/FtpFileHandler.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -24,9 +24,8 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.addressing.eprs.FTPEpr;
@@ -41,34 +40,26 @@
 
 public class FtpFileHandler implements FileHandler
 {
-	private FtpFileHandler()
-	{
-	}
-
 	FtpFileHandler(FTPEpr epr) throws CourierException
 	{
 		_epr = epr;
 
-		URL url = null;
+		final URI uri ;
 		try
 		{
-			url = _epr.getURL();
+			uri = _epr.getURI();
 		}
-		catch (MalformedURLException e)
-		{
-			throw new CourierException(e);
-		}
 		catch (URISyntaxException e)
 		{
 			throw new CourierException(e);
 		}
 
-		_server = url.getHost();
+		_server = uri.getHost();
 
 		String[] sa = null;
 		
-		if (url.getUserInfo() != null)
-			sa = url.getUserInfo().split(":");
+		if (uri.getUserInfo() != null)
+			sa = uri.getUserInfo().split(":");
 		
 		if (sa == null)
 			sa = new String[]
@@ -76,15 +67,13 @@
 		_user = (sa.length < 1) ? "" : sa[0];
 		_passwd = (sa.length < 2) ? "" : sa[1];
 
-		_remoteDir = url.getFile();
+		_remoteDir = uri.getPath();
 		
 		final String tmpdir = System.getProperty("java.io.tmpdir") ;
 		if ((_remoteDir == null) || (_remoteDir.equals("")))
 			_remoteDir = ModulePropertyManager.getPropertyManager(ModulePropertyManager.TRANSPORTS_MODULE).getProperty(Environment.FTP_REMOTEDIR, tmpdir);
 
-		_port = url.getPort();
-		if (_port < 0)
-			_port = url.getDefaultPort();
+		_port = uri.getPort();
 
 		_localDir = ModulePropertyManager.getPropertyManager(ModulePropertyManager.TRANSPORTS_MODULE).getProperty(Environment.FTP_LOCALDIR, tmpdir);
 

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/LocalFileHandler.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/LocalFileHandler.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/couriers/helpers/LocalFileHandler.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -27,7 +27,6 @@
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 
 import org.apache.log4j.Logger;
@@ -86,7 +85,7 @@
 	{
 		try
 		{
-			File dir = new File(_epr.getURL().getFile());
+			File dir = new File(_epr.getURI());
 			if (!dir.isDirectory())
 				throw new CourierException(
 						"Can't get file list if URL is not a directory");
@@ -98,10 +97,6 @@
 		{
 			throw new CourierException(e);
 		}
-		catch (MalformedURLException e)
-		{
-			throw new CourierException(e);
-		}
 		catch (Exception e)
 		{
 			throw new CourierException(e);

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/message/filter/MetaDataFilter.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/message/filter/MetaDataFilter.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/message/filter/MetaDataFilter.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -23,7 +23,6 @@
 package org.jboss.internal.soa.esb.message.filter;
 
 import java.io.File;
-import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.util.Calendar;
 import java.util.Map;
@@ -90,16 +89,12 @@
 		{
 		    type = Environment.Transports.File;
 
-		    name = ((FileEpr) destination).getURL()
+		    name = destination.getURI()
 			    + File.separator
 			    + msg.getHeader().getCall().getMessageID()
 				    .toString()
 			    + ((FileEpr) destination).getInputSuffix();
 		}
-		catch (MalformedURLException ex)
-		{
-		    throw new CourierException(ex);
-		}
 		catch (URISyntaxException ex)
 		{
 		    throw new CourierException(ex);

Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -1,642 +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.IOException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.eprs.FTPEpr;
-import org.jboss.soa.esb.addressing.eprs.FileEpr;
-import org.jboss.soa.esb.common.Environment;
-import org.jboss.soa.esb.common.ModulePropertyManager;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.helpers.KeyValuePair;
-import org.jboss.soa.esb.util.FileUtil;
-import org.jboss.soa.esb.util.FtpClientUtil;
-import org.jboss.soa.esb.util.RemoteFileSystem;
-import org.jboss.soa.esb.util.RemoteFileSystemException;
-
-import com.enterprisedt.net.ftp.FTPClient;
-import com.enterprisedt.net.ftp.FTPConnectMode;
-import com.enterprisedt.net.ftp.FTPException;
-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 Logger _logger = Logger.getLogger(EdtFtpImpl.class);
-
-	private static final String TMP_SUFFIX = ".rosettaPart";
-
-	private boolean m_bPassive;
-
-	private int m_iPort;
-	private int _timeout = 0;
-
-	private FTPClient m_oConn = new FTPClient();
-
-	private FTPEpr m_oEpr;
-
-	private ConfigTree m_oParms;
-
-	private FTPTransferType m_oXferType;
-
-	private String m_sFtpServer, m_sUser, m_sPasswd;
-
-	private String m_sRemoteDir, m_sLocalDir;
-
-	/**
-	 * Checks validity and completeness of parameters, and keeps the info
-	 * internally for subsequent FTP requests
-	 * 
-	 * @param p_oP
-	 *            ConfigTree
-	 * @throws ConfigurationException :
-	 *             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 ConfigurationException, RemoteFileSystemException
-	{
-		m_oParms = p_oP;
-		initialize(p_bConnect);
-	}
-
-	public EdtFtpImpl (FTPEpr p_oP, boolean p_bConnect)
-			throws ConfigurationException, RemoteFileSystemException
-	{
-		m_oEpr = p_oP;
-
-		URL url = null;
-		try
-		{
-			url = m_oEpr.getURL();
-		}
-		catch (MalformedURLException e)
-		{
-			throw new ConfigurationException(e);
-		}
-		catch (URISyntaxException e)
-		{
-			throw new ConfigurationException(e);
-		}
-
-		m_sFtpServer = url.getHost();
-
-		String[] sa = null;
-
-		if (url.getUserInfo() != null) sa = url.getUserInfo().split(":");
-
-		if (sa == null) sa = new String[] { "", "" };
-
-		m_sUser = (sa.length < 1) ? "" : sa[0];
-		m_sPasswd = (sa.length < 2) ? "" : sa[1];
-
-		m_sRemoteDir = url.getFile();
-
-		final String tmpdir = System.getProperty("java.io.tmpdir");
-		if ((m_sRemoteDir == null) || (m_sRemoteDir.equals("")))
-			m_sRemoteDir = ModulePropertyManager.getPropertyManager(
-					ModulePropertyManager.TRANSPORTS_MODULE).getProperty(
-					Environment.FTP_REMOTEDIR, tmpdir);
-
-		m_iPort = url.getPort();
-		if (m_iPort < 0) m_iPort = url.getDefaultPort();
-
-		m_sLocalDir = ModulePropertyManager.getPropertyManager(
-				ModulePropertyManager.TRANSPORTS_MODULE).getProperty(
-				Environment.FTP_LOCALDIR, tmpdir);
-
-        File oLocalDir = new File(m_sLocalDir);
-        if(!oLocalDir.exists()) {
-            throw new ConfigurationException("Local FTP directory '" + oLocalDir.getAbsolutePath()
-                    + "' doesn't exist.  Check your JBossESB config '"
-                    + ModulePropertyManager.TRANSPORTS_MODULE + ":" + Environment.FTP_LOCALDIR + "'");
-        }
-
-        m_bPassive = false;
-
-		try
-		{
-			m_bPassive = m_oEpr.getPassive();
-		}
-		catch (URISyntaxException e)
-		{
-			_logger.warn(e);
-		}
-
-		String timeout = ModulePropertyManager.getPropertyManager(ModulePropertyManager.TRANSPORTS_MODULE).getProperty(Environment.FTP_SOCKET_TIMEOUT, null);
-		
-		if (timeout != null)
-		{
-			try
-			{
-				_timeout = Integer.parseInt(timeout);
-			}
-			catch (NumberFormatException ex)
-			{
-				throw new ConfigurationException("Invalid timeout specified.", ex);
-			}
-		}
-		else
-			_timeout = 0;
-
-		// TODO there is still a bit of space for improvements here.
-		configTreeFromEpr();
-
-		initialize(p_bConnect);
-	}
-
-	public EdtFtpImpl (List<KeyValuePair> p_oAttribs, boolean p_bConnect)
-			throws ConfigurationException, RemoteFileSystemException
-	{
-		m_oParms = new ConfigTree("fromProps");
-		for (KeyValuePair oCurr : p_oAttribs)
-			m_oParms.setAttribute(oCurr.getKey(), oCurr.getValue());
-		initialize(p_bConnect);
-	}
-
-	private void checkParms () throws ConfigurationException
-	{
-		String att = m_oParms.getAttribute(FileEpr.URL_TAG);
-		URL url = null;
-		
-		try
-		{
-			if (att != null)
-				url = new URL(att);
-		}
-		catch (MalformedURLException ex)
-		{
-			throw new ConfigurationException(ex);
-		}
-		
-		m_sFtpServer = (null != url) ? url.getHost() : m_oParms
-				.getAttribute(PARMS_FTP_SERVER);
-		if (null == m_sFtpServer)
-			throw new ConfigurationException("No FTP server specified");
-
-		String[] sa = (null == url) ? null : url.getUserInfo().split(":");
-		m_sUser = (null != sa) ? sa[0] : m_oParms.getAttribute(PARMS_USER);
-		if (null == m_sUser)
-			throw new ConfigurationException("No username specified for FTP");
-
-		m_sPasswd = (null != sa) ? sa[1] : m_oParms.getAttribute(PARMS_PASSWD);
-		if (null == m_sPasswd)
-			throw new ConfigurationException("No password specified for FTP");
-
-		m_sRemoteDir = (null != url) ? url.getFile() : 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 != url) ? url.getPort() : (null == sAux) ? 21 : Integer
-				.parseInt(sAux);
-		
-		try
-		{
-			if (m_iPort < 0)
-				m_iPort = new URL("ftp://").getDefaultPort();
-		}
-		catch (MalformedURLException ex)
-		{
-			throw new ConfigurationException(ex);
-		}
-
-		// Dec-2006 (b_georges): it has been decided to set the Type to binary.
-		m_oXferType = FTPTransferType.BINARY;
-
-		m_bPassive = false;
-		sAux = m_oParms.getAttribute(PARMS_PASSIVE);
-		m_bPassive = (null != sAux) && Boolean.parseBoolean(sAux);
-
-		return;
-	}
-
-	private void configTreeFromEpr () throws RemoteFileSystemException
-	{
-		m_oParms = new ConfigTree("fromEpr");
-		try
-		{
-			m_oParms.setAttribute(RemoteFileSystem.PARMS_FTP_SERVER,
-					m_sFtpServer);
-			m_oParms.setAttribute(RemoteFileSystem.PARMS_USER, m_sUser);
-			m_oParms.setAttribute(RemoteFileSystem.PARMS_PASSWD, m_sPasswd);
-			m_oParms.setAttribute(RemoteFileSystem.PARMS_REMOTE_DIR,
-					m_sRemoteDir);
-			m_oParms.setAttribute(RemoteFileSystem.PARMS_PORT, Integer
-					.toString(m_iPort));
-			m_oParms
-					.setAttribute(RemoteFileSystem.PARMS_LOCAL_DIR, m_sLocalDir);
-			m_oParms.setAttribute(RemoteFileSystem.PARMS_ASCII, Boolean
-					.toString(false));
-			m_oParms.setAttribute(RemoteFileSystem.PARMS_PASSIVE, Boolean
-					.toString(m_bPassive));
-		}
-		catch (Exception e)
-		{
-			throw new RemoteFileSystemException(e);
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.jboss.soa.esb.util.RemoteFileSystem#deleteRemoteFile(java.lang.String)
-	 */
-	public void deleteRemoteFile (String p_sFile) throws RemoteFileSystemException
-	{
-		try
-		{
-			m_oConn.delete(getRemoteDir() + "/" + new File(p_sFile).getName());
-		}
-		catch (Exception ex)
-		{
-			/*
-			 * It seems as though we have a race condition whereby one thread
-			 * tries to remove a file when another renames it!
-			 */
-			
-			throw new RemoteFileSystemException(ex);
-		}
-	}
-
-	/*
-	 * (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 IOException, RemoteFileSystemException
-	{
-		File oLocalDir = new File(m_sLocalDir);
-
-        File oLclFile = File.createTempFile("Rosetta_", TMP_SUFFIX, oLocalDir);
-
-		try
-		{
-			oLclFile.delete();
-		}
-		catch (Exception e)
-		{
-		}
-
-		try
-		{
-			m_oConn.get(FtpUtils.fileToFtpString(oLclFile), p_sFile);
-		}
-		catch (FTPException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
-
-                final File to = new File(p_sFinalName) ;
-		final File oNew = (to.isAbsolute() ? to : new File(oLocalDir, p_sFinalName)) ;
-		
-		if (oNew.exists()) 
-			oNew.delete();
-		
-		FileUtil.renameTo(oLclFile, oNew);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.jboss.soa.esb.util.RemoteFileSystem#getFileListFromRemoteDir(java.lang.String)
-	 */
-	public String[] getFileListFromRemoteDir (String p_sSuffix)
-			throws RemoteFileSystemException, IOException
-	{
-		String sSuffix = (null == p_sSuffix) ? "*" : "*" + p_sSuffix;
-
-		try
-		{
-			return m_oConn.dir(sSuffix);
-		}
-		catch (FTPException ex)
-		{
-			String msg = ex.getMessage();
-			int rc = ex.getReplyCode();
-			if (rc == 550) // means File Not Found - see JBESB-303
-			{
-				_logger
-						.debug("No matching file or directory. Server returns: [" + rc + "] " + msg);
-				return null;
-			}
-			else
-			{
-				// TODO Test with different FTP Servers
-				String sMess = this.getClass().getSimpleName() + " can't list " + sSuffix + " due to: [" + rc + "] " + msg;
-				throw new RemoteFileSystemException(sMess);
-			}
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.jboss.soa.esb.util.RemoteFileSystem#getRemoteDir()
-	 */
-	public String getRemoteDir ()
-	{
-		return m_sRemoteDir;
-	}
-
-	private void initialize (boolean bConnect) throws ConfigurationException,
-			RemoteFileSystemException
-	{
-		checkParms();
-		if (bConnect)
-		{
-			try
-			{
-				m_oConn.setRemoteHost(m_sFtpServer);
-			}
-			catch (UnknownHostException ex)
-			{
-				_logger.error("Unknown host for FTP.", ex);
-
-				throw new ConfigurationException(ex);
-			}
-			catch (IOException ex)
-			{
-				_logger.error("Caught IOException", ex);
-				
-				throw new RemoteFileSystemException(ex);
-			}
-			catch (FTPException ex)
-			{
-				_logger.error("Caught FTPException.", ex);
-
-				throw new RemoteFileSystemException(ex);
-			}
-
-			try
-			{
-				m_oConn.setRemotePort(m_iPort);
-
-				m_oConn.connect();
-				for (int i1 = 0; i1 < 10 && !m_oConn.connected(); i1++)
-				{
-					try
-					{
-						Thread.sleep(200); // TODO arbitrary MAGIC number!
-					}
-					catch (InterruptedException ex)
-					{
-					}
-				}
-
-				// Configurable?
-				if (!m_oConn.connected())
-					throw new RemoteFileSystemException(
-							"Can't connect to FTP server");
-				m_oConn.user(m_sUser);
-				m_oConn.password(m_sPasswd);
-				
-				/*
-				 * It's ok to set the passive/active mode here as this is for
-				 * the data connection. The previous call to connect() was for
-				 * the command connection and is not affected by this setting.
-				 * 
-				 * http://www.slacksite.com/other/ftp.html
-				 */
-				
-				m_oConn.setConnectMode((m_bPassive) ? FTPConnectMode.PASV : FTPConnectMode.ACTIVE);
-				
-				m_oConn.setType(m_oXferType);
-				
-				if (_timeout > 0)
-				{
-					try
-					{ 
-						m_oConn.setTimeout(_timeout); 
-					}
-					catch (IOException e)
-					{ 
-						throw new RemoteFileSystemException("Failed while setting timeout=" + _timeout, e); 
-					}
-				}
-			}
-			catch (IOException ex)
-			{
-				throw new RemoteFileSystemException(ex);
-			}
-			catch (FTPException ex)
-			{
-				_logger.error("Caught FTPException.", ex);
-
-				throw new RemoteFileSystemException(ex);
-			}
-		}
-	}
-
-	/*
-	 * (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#remoteDelete(java.io.File)
-	 */
-	public void remoteDelete (File p_oFile) throws RemoteFileSystemException
-	{
-		try
-		{
-			m_oConn.delete(getRemoteDir() + "/" + p_oFile.getName());
-		}
-		catch (IOException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
-		catch (FTPException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
-	}
-
-	/*
-	 * (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 RemoteFileSystemException
-	{
-		try
-		{
-			m_oConn.rename(FtpClientUtil.fileToFtpString(p_oFrom), FtpUtils
-					.fileToFtpString(p_oTo));
-		}
-		catch (FTPException ex)
-		{
-			if (ex.getReplyCode() == 550) // EdtFtp error code meaning File
-			// Not Found
-			{
-				_logger
-						.debug("EdtFtpImpl tried to rename file that had moved.");
-
-				throw new RemoteFileSystemException("File not found.");
-			}
-			else
-			{
-				_logger.error("Caught FTPException.", ex);
-
-				throw new RemoteFileSystemException(ex);
-			}
-		}
-		catch (Exception e)
-		{
-			e.printStackTrace();
-
-			String sMess = this.getClass().getSimpleName() + " can't rename in remote directory <" + e
-					.getMessage() + ">";
-			throw new RemoteFileSystemException(sMess);
-		}
-	}
-
-	/*
-	 * (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 RemoteFileSystemException
-	{
-		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 RemoteFileSystemException(sMess);
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.jboss.soa.esb.util.RemoteFileSystem#setRemoteDir(java.lang.String)
-	 */
-	public void setRemoteDir (String p_sDir) throws RemoteFileSystemException
-	{
-		if (p_sDir == null)
-			throw new IllegalArgumentException();
-		
-		try
-		{
-			m_oConn.chdir(p_sDir);
-			m_sRemoteDir = p_sDir;
-		}
-		catch (IOException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
-		catch (FTPException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
-	}
-
-	/*
-	 * (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 RemoteFileSystemException
-	{
-		String sRemoteOK = getRemoteDir() + "/" + p_sRemoteName;
-		String sRemoteTmp = sRemoteOK + TMP_SUFFIX;
-
-		try
-		{
-			m_oConn.put(FtpUtils.fileToFtpString(p_oFile), sRemoteTmp);
-			m_oConn.rename(sRemoteTmp, sRemoteOK);
-		}
-		catch (IOException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
-		catch (FTPException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
-	}
-
-}

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpImpl.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpImpl.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -0,0 +1,635 @@
+/*
+ * 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.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import org.apache.commons.net.ftp.FTP;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.ModulePropertyManager;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.util.FileUtil;
+import org.jboss.soa.esb.util.FtpClientUtil;
+import org.jboss.soa.esb.util.RemoteFileSystem;
+import org.jboss.soa.esb.util.RemoteFileSystemException;
+
+
+/**
+ * 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.
+ * </p>
+ */
+
+public class FtpImpl implements RemoteFileSystem
+{
+	private static final Logger _logger = Logger.getLogger(FtpImpl.class);
+
+	private static final String TMP_SUFFIX = ".rosettaPart";
+
+	private boolean m_bPassive;
+
+	private int m_iPort;
+	private int _timeout = 0;
+
+	protected FTPClient m_oConn ;
+
+	private FTPEpr m_oEpr;
+
+	protected ConfigTree m_oParms;
+
+	private String m_sFtpServer, m_sUser, m_sPasswd;
+
+	private String m_sRemoteDir, m_sLocalDir;
+
+	/**
+	 * Checks validity and completeness of parameters, and keeps the info
+	 * internally for subsequent FTP requests
+	 * 
+	 * @param p_oP
+	 *            ConfigTree
+	 * @throws ConfigurationException :
+	 *             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 FtpImpl (ConfigTree p_oP, boolean p_bConnect)
+			throws ConfigurationException, RemoteFileSystemException
+	{
+		m_oParms = p_oP;
+		initialize(p_bConnect);
+	}
+
+	public FtpImpl (FTPEpr p_oP, boolean p_bConnect)
+			throws ConfigurationException, RemoteFileSystemException
+	{
+		this(p_oP) ;
+		// TODO there is still a bit of space for improvements here.
+		configTreeFromEpr() ;
+		
+		initialize(p_bConnect) ;
+	}
+
+	public FtpImpl (FTPEpr p_oP)
+			throws ConfigurationException
+	{
+		m_oEpr = p_oP;
+
+		final URI uri;
+		try
+		{
+			uri = m_oEpr.getURI();
+		}
+		catch (URISyntaxException e)
+		{
+			throw new ConfigurationException(e);
+		}
+
+		m_sFtpServer = uri.getHost();
+
+                String[] sa = null;
+
+                if (uri.getUserInfo() != null)
+                        sa = uri.getUserInfo().split(":");
+
+                final int saLen = (sa == null ? 0 : sa.length) ;
+                switch(saLen)
+                {
+                case 2:
+                    m_sPasswd = sa[1] ;
+                case 1:
+                    m_sUser = sa[0] ;
+                }
+
+		m_sRemoteDir = uri.getPath();
+
+		final String tmpdir = System.getProperty("java.io.tmpdir");
+		if ((m_sRemoteDir == null) || (m_sRemoteDir.equals("")))
+			m_sRemoteDir = ModulePropertyManager.getPropertyManager(
+					ModulePropertyManager.TRANSPORTS_MODULE).getProperty(
+					Environment.FTP_REMOTEDIR, tmpdir);
+
+		m_iPort = uri.getPort();
+
+		m_sLocalDir = ModulePropertyManager.getPropertyManager(
+				ModulePropertyManager.TRANSPORTS_MODULE).getProperty(
+				Environment.FTP_LOCALDIR, tmpdir);
+
+        File oLocalDir = new File(m_sLocalDir);
+        if(!oLocalDir.exists()) {
+            throw new ConfigurationException("Local FTP directory '" + oLocalDir.getAbsolutePath()
+                    + "' doesn't exist.  Check your JBossESB config '"
+                    + ModulePropertyManager.TRANSPORTS_MODULE + ":" + Environment.FTP_LOCALDIR + "'");
+        }
+
+        m_bPassive = false;
+
+		try
+		{
+			m_bPassive = m_oEpr.getPassive();
+		}
+		catch (URISyntaxException e)
+		{
+			_logger.warn(e);
+		}
+
+		String timeout = ModulePropertyManager.getPropertyManager(ModulePropertyManager.TRANSPORTS_MODULE).getProperty(Environment.FTP_SOCKET_TIMEOUT, null);
+		
+		if (timeout != null)
+		{
+			try
+			{
+				_timeout = Integer.parseInt(timeout);
+			}
+			catch (NumberFormatException ex)
+			{
+				throw new ConfigurationException("Invalid timeout specified.", ex);
+			}
+		}
+		else
+			_timeout = 0;
+	}
+
+	public FtpImpl (List<KeyValuePair> p_oAttribs, boolean p_bConnect)
+			throws ConfigurationException, RemoteFileSystemException
+	{
+		m_oParms = new ConfigTree("fromProps");
+		for (KeyValuePair oCurr : p_oAttribs)
+			m_oParms.setAttribute(oCurr.getKey(), oCurr.getValue());
+		initialize(p_bConnect);
+	}
+
+	protected void checkParms () throws ConfigurationException
+	{
+		String att = m_oParms.getAttribute(FileEpr.URL_TAG);
+		URI uri = null;
+		
+		try
+		{
+			if (att != null)
+				uri = new URI(att);
+		}
+		catch (URISyntaxException ex)
+		{
+			throw new ConfigurationException(ex);
+		}
+		
+		m_sFtpServer = (null != uri) ? uri.getHost() : m_oParms
+				.getAttribute(PARMS_FTP_SERVER);
+		if (null == m_sFtpServer)
+			throw new ConfigurationException("No FTP server specified");
+
+		String[] sa = (null == uri) ? null : uri.getUserInfo().split(":");
+		m_sUser = (null != sa) ? sa[0] : m_oParms.getAttribute(PARMS_USER);
+		if (null == m_sUser)
+			throw new ConfigurationException("No username specified for FTP");
+
+		m_sPasswd = (null != sa) ? sa[1] : m_oParms.getAttribute(PARMS_PASSWD);
+
+		m_sRemoteDir = (null != uri) ? uri.getPath() : 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 != uri) ? uri.getPort() : (null == sAux) ? 21 : Integer
+				.parseInt(sAux);
+		
+		m_bPassive = false;
+		sAux = m_oParms.getAttribute(PARMS_PASSIVE);
+		m_bPassive = (null != sAux) && Boolean.parseBoolean(sAux);
+
+		return;
+	}
+
+	protected void configTreeFromEpr () throws RemoteFileSystemException
+	{
+		m_oParms = new ConfigTree("fromEpr");
+		try
+		{
+			m_oParms.setAttribute(RemoteFileSystem.PARMS_FTP_SERVER,
+					m_sFtpServer);
+			m_oParms.setAttribute(RemoteFileSystem.PARMS_USER, m_sUser);
+			if (m_sPasswd != null)
+			    m_oParms.setAttribute(RemoteFileSystem.PARMS_PASSWD, m_sPasswd);
+			m_oParms.setAttribute(RemoteFileSystem.PARMS_REMOTE_DIR,
+					m_sRemoteDir);
+			if (m_iPort > 0)
+			{
+			    m_oParms.setAttribute(RemoteFileSystem.PARMS_PORT, Integer
+					.toString(m_iPort));
+			}
+			m_oParms
+					.setAttribute(RemoteFileSystem.PARMS_LOCAL_DIR, m_sLocalDir);
+			m_oParms.setAttribute(RemoteFileSystem.PARMS_ASCII, Boolean
+					.toString(false));
+			m_oParms.setAttribute(RemoteFileSystem.PARMS_PASSIVE, Boolean
+					.toString(m_bPassive));
+		}
+		catch (Exception e)
+		{
+			throw new RemoteFileSystemException(e);
+		}
+	}
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see org.jboss.soa.esb.util.RemoteFileSystem#deleteRemoteFile(java.lang.String)
+         */
+        public void deleteRemoteFile (String p_sFile) throws RemoteFileSystemException
+        {
+            try
+            {
+                changeRemoteDirectory() ;
+                if (!m_oConn.deleteFile(p_sFile))
+                {
+                    throw new RemoteFileSystemException("Failed to delete remote file: " + m_oConn.getReplyString());
+                }
+            }
+            catch (final IOException ioe)
+            {
+                throw new RemoteFileSystemException(ioe);
+            }
+        }
+
+        /*
+         * (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 IOException, RemoteFileSystemException
+        {
+                try
+                {
+                    final File to = new File(p_sFinalName) ;
+                    final File oLocalDir = new File(m_sLocalDir);
+                    final File oNew = (to.isAbsolute() ? to : new File(oLocalDir, p_sFinalName)) ;
+                    if (oNew.exists()) 
+                        oNew.delete();
+                    
+                    final File toTmp = new File(p_sFinalName + TMP_SUFFIX) ;
+                    final File oNewTmp = (toTmp.isAbsolute() ? toTmp : new File(oLocalDir, p_sFinalName + TMP_SUFFIX)) ;
+                    if (oNewTmp.exists()) 
+                        oNewTmp.delete();
+                    
+                    changeRemoteDirectory() ;
+                    final InputStream is = m_oConn.retrieveFileStream(p_sFile) ;
+                    if (is == null)
+                    {
+                        throw new RemoteFileSystemException("Could not download file: " + m_oConn.getReplyString());
+                    }
+                    
+                    try
+                    {
+                        final FileOutputStream fos = new FileOutputStream(oNewTmp) ;
+                        try
+                        {
+                            copyStream(is, fos) ;
+                        }
+                        finally
+                        {
+                            fos.close() ;
+                        }
+                    }
+                    finally
+                    {
+                        is.close() ;
+                    }
+                    if (!m_oConn.completePendingCommand())
+                    {
+                        oNewTmp.delete() ;
+                        throw new RemoteFileSystemException("Failed to download contents: " + m_oConn.getReplyString()) ;
+                    }
+                    FileUtil.renameTo(oNewTmp, oNew) ;
+                }
+                catch (final IOException ioe)
+                {
+                    throw new RemoteFileSystemException(ioe) ;
+                }
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see org.jboss.soa.esb.util.RemoteFileSystem#getFileListFromRemoteDir(java.lang.String)
+         */
+        public String[] getFileListFromRemoteDir (String p_sSuffix)
+                        throws RemoteFileSystemException, IOException
+        {
+                String sSuffix = (null == p_sSuffix) ? "*" : "*" + p_sSuffix;
+
+                try
+                {
+                    changeRemoteDirectory() ;
+                    return m_oConn.listNames(sSuffix) ;
+                }
+                catch (final IOException ioe)
+                {
+                    throw new RemoteFileSystemException(ioe) ;
+                }
+        }
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.soa.esb.util.RemoteFileSystem#getRemoteDir()
+	 */
+	public String getRemoteDir ()
+	{
+		return m_sRemoteDir;
+	}
+
+        protected void initialize (boolean bConnect)
+            throws ConfigurationException, RemoteFileSystemException
+        {
+            checkParms();
+            m_oConn = instantiateClient() ;
+            
+            if (bConnect)
+            {
+                try
+                {
+                    connect() ;
+                    
+                    if (!m_oConn.isConnected())
+                        throw new RemoteFileSystemException(
+                                        "Can't connect to FTP server");
+                    
+                    if (!m_oConn.login(m_sUser, m_sPasswd))
+                    {
+                        m_oConn.logout() ;
+                        throw new RemoteFileSystemException("Remote login failed: " + m_oConn.getReplyString());
+                    }
+                    m_oConn.setFileType(FTP.BINARY_FILE_TYPE) ;
+                    if (m_bPassive)
+                    {
+                        m_oConn.enterLocalPassiveMode() ;
+                    }
+                    if (_timeout > 0)
+                    {
+                        m_oConn.setDataTimeout(_timeout);
+                    }
+                }
+                catch (final IOException ioe)
+                {
+                    if (m_oConn.isConnected())
+                    {
+                        try
+                        {
+                            m_oConn.disconnect() ;
+                        }
+                        catch (final IOException ioe2) {} // ignore
+                    }
+                    throw new RemoteFileSystemException(ioe); 
+                }
+            }
+        }
+
+        protected FTPClient instantiateClient()
+            throws RemoteFileSystemException
+        {
+                return new FTPClient() ;
+        }
+        
+        protected void connect()
+                throws IOException
+        {
+            if (m_iPort > 0)
+            {
+                m_oConn.connect(m_sFtpServer, m_iPort) ;
+            }
+            else
+            {
+                m_oConn.connect(m_sFtpServer) ;
+            }
+        }
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.soa.esb.util.RemoteFileSystem#quit()
+	 */
+	public void quit ()
+	{
+		if (null != m_oConn)
+		{
+			try
+			{
+				m_oConn.quit();
+				m_oConn.disconnect() ;
+			}
+			catch (Exception e)
+			{
+			}
+		}
+	}
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see org.jboss.soa.esb.util.RemoteFileSystem#remoteDelete(java.io.File)
+         */
+        public void remoteDelete (File p_oFile) throws RemoteFileSystemException
+        {
+                try
+                {
+                    changeRemoteDirectory() ;
+                    if (!m_oConn.deleteFile(p_oFile.getName()))
+                    {
+                        throw new RemoteFileSystemException("Failed to delete remote file: " + m_oConn.getReplyString());
+                    }
+                }
+                catch (final IOException ioe)
+                {
+                    throw new RemoteFileSystemException(ioe);
+                }
+        }
+
+        /*
+         * (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 RemoteFileSystemException
+        {
+                try
+                {
+                        changeRemoteDirectory();
+                        if (!m_oConn.rename(FtpClientUtil.fileToFtpString(p_oFrom),
+                                FtpUtils.fileToFtpString(p_oTo)))
+                        {
+                            throw new RemoteFileSystemException("Failed to rename file: " + m_oConn.getReplyString());
+                        }
+                }
+                catch (final IOException ioe)
+                {
+                    throw new RemoteFileSystemException(ioe);
+                }
+        }
+
+        /*
+         * (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 RemoteFileSystemException
+        {
+            try
+            {
+                changeRemoteDirectory() ;
+                if (!m_oConn.rename(p_sFrom, p_sTo))
+                {
+                    throw new RemoteFileSystemException("Failed to rename file: " + m_oConn.getReplyString());
+                }
+            }
+            catch (final IOException ioe)
+            {
+                throw new RemoteFileSystemException(ioe);
+            }
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see org.jboss.soa.esb.util.RemoteFileSystem#setRemoteDir(java.lang.String)
+         */
+        public void setRemoteDir (String p_sDir) throws RemoteFileSystemException
+        {
+                if (p_sDir == null)
+                        throw new IllegalArgumentException();
+                
+                m_sRemoteDir = p_sDir;
+        }
+
+        /*
+         * (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 RemoteFileSystemException
+        {
+            try
+            {
+                changeRemoteDirectory() ;
+                
+                final String sRemoteTmp = p_sRemoteName + TMP_SUFFIX;
+                
+                final OutputStream os = m_oConn.storeFileStream(sRemoteTmp) ;
+                try
+                {
+                    final FileInputStream fis = new FileInputStream(p_oFile) ;
+                    try
+                    {
+                        copyStream(fis, os) ;
+                    }
+                    finally
+                    {
+                        fis.close() ;
+                    }
+                }
+                finally
+                {
+                    os.flush() ;
+                    os.close() ;
+                }
+                if (!m_oConn.completePendingCommand())
+                {
+                    throw new RemoteFileSystemException("Failed to upload contents: " + m_oConn.getReplyString()) ;
+                }
+                if (!m_oConn.rename(sRemoteTmp, p_sRemoteName))
+                {
+                    throw new RemoteFileSystemException("Failed to rename file: " + m_oConn.getReplyString());
+                }
+            }
+            catch (final IOException ioe)
+            {
+                throw new RemoteFileSystemException(ioe);
+            }
+        }
+        
+        private void changeRemoteDirectory()
+            throws IOException, RemoteFileSystemException
+        {
+            final String remoteDir = getRemoteDir() ;
+            if ((remoteDir != null) && (remoteDir.length() > 0))
+            {
+                if (!m_oConn.changeWorkingDirectory(remoteDir))
+                {
+                    throw new RemoteFileSystemException("Failed to change to remote directory: " + m_oConn.getReplyString());
+                }
+            }
+        }
+        
+        private void copyStream(final InputStream is, final OutputStream os)
+            throws IOException
+        {
+            final BufferedInputStream bis = new BufferedInputStream(is) ;
+            final BufferedOutputStream bos = new BufferedOutputStream(os) ;
+            
+            final byte[] buffer = new byte[256] ;
+            while(true)
+            {
+                final int count = bis.read(buffer) ;
+                if (count <= 0)
+                {
+                    break ;
+                }
+                bos.write(buffer, 0, count) ;
+            }
+            bos.flush() ;
+        }
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpImpl.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpsImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpsImpl.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpsImpl.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -0,0 +1,315 @@
+/*
+ * 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.BufferedInputStream;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPSClient;
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.eprs.FTPSEpr;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.helpers.KeyValuePair;
+import org.jboss.soa.esb.util.RemoteFileSystemException;
+
+/**
+ * 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.
+ * </p>
+ */
+
+public class FtpsImpl extends FtpImpl
+{
+	private static final Logger _logger = Logger.getLogger(FtpsImpl.class);
+	
+	private URI m_oCertificate ;
+	private String m_oCertificateName ;
+
+	/**
+	 * Checks validity and completeness of parameters, and keeps the info
+	 * internally for subsequent FTP requests
+	 * 
+	 * @param p_oP
+	 *            ConfigTree
+	 * @throws ConfigurationException :
+	 *             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 FtpsImpl (ConfigTree p_oP, boolean p_bConnect)
+			throws ConfigurationException, RemoteFileSystemException
+	{
+		super(p_oP, p_bConnect) ;
+	}
+
+	public FtpsImpl (FTPSEpr p_oP, boolean p_bConnect)
+			throws ConfigurationException, RemoteFileSystemException
+	{
+		super(p_oP) ;
+
+		try
+		{
+			m_oCertificate = p_oP.getCertificateURI() ;
+		}
+		catch (final URISyntaxException urise)
+		{
+			_logger.warn(urise);
+		}
+		m_oCertificateName = p_oP.getCertificateName() ;
+		
+		// TODO there is still a bit of space for improvements here.
+		configTreeFromEpr();
+
+		initialize(p_bConnect);
+	}
+
+	public FtpsImpl (List<KeyValuePair> p_oAttribs, boolean p_bConnect)
+			throws ConfigurationException, RemoteFileSystemException
+	{
+		super(p_oAttribs, p_bConnect) ;
+	}
+
+	protected void configTreeFromEpr () throws RemoteFileSystemException
+	{
+		super.configTreeFromEpr() ;
+		try
+		{
+			if (m_oCertificate != null)
+			{
+				m_oParms.setAttribute(PARMS_CERTIFICATE, m_oCertificate.toString());
+			}
+			if (m_oCertificateName != null)
+			{
+				m_oParms.setAttribute(PARMS_CERTIFICATE_NAME, m_oCertificateName);
+			}
+		}
+		catch (Exception e)
+		{
+			throw new RemoteFileSystemException(e);
+		}
+	}
+	
+	protected void checkParms() throws ConfigurationException
+	{
+		super.checkParms();
+		
+		final String certificate = m_oParms.getAttribute(PARMS_CERTIFICATE) ;
+		
+		if (certificate != null)
+		{
+			try
+			{
+				m_oCertificate = new URI(certificate) ;
+			}
+			catch (final URISyntaxException ex)
+			{
+				throw new ConfigurationException("Failed to create certificate URI", ex) ;
+			}
+		}
+		m_oCertificateName = m_oParms.getAttribute(PARMS_CERTIFICATE_NAME) ;
+	}
+        
+        protected FTPClient instantiateClient()
+            throws RemoteFileSystemException
+        {
+                final FTPSClient ftpsClient ;
+                try
+                {
+                    ftpsClient = new FTPSClient() ;
+                }
+                catch (final NoSuchAlgorithmException nsae)
+                {
+                    throw new RemoteFileSystemException(nsae) ;
+                }
+                
+                try
+                {
+                    ftpsClient.setTrustManager(new ESBTrustManager(m_oCertificate)) ;
+                }
+                catch (final Exception ex)
+                {
+                    throw new RemoteFileSystemException("Exception creating trust manager", ex) ;
+                }
+                return ftpsClient ;
+        }
+        
+        protected void connect()
+            throws IOException
+        {
+                super.connect() ;
+                final FTPSClient ftpsClient = (FTPSClient)m_oConn ;
+                
+                // force passive mode
+                ftpsClient.enterLocalPassiveMode() ;
+                
+                ftpsClient.execPBSZ(0) ;
+                ftpsClient.execPROT("P") ;
+        }
+        
+        /**
+         * Trust manager for handling the server certificate validation.
+         * @author kevin
+         */
+        private static final class ESBTrustManager implements X509TrustManager
+        {
+            /**
+             * Certificates being imported.
+             */
+            private final X509Certificate[] certificates ;
+            /**
+             * Start of certificate indicator.
+             */
+            private static final String BEGIN_CERTIFICATE = "-----BEGIN CERTIFICATE-----" ;
+            
+            /**
+             * Construct the trust manager with the specified certificate.
+             * 
+             * @param certificate  The certificate of the signer or null if signature not checked.
+             * @throws URISyntaxException
+             * @throws MalformedURLException
+             * @throws IOException
+             * @throws CertificateException
+             */
+            public ESBTrustManager(final URI certificate)
+                throws URISyntaxException, MalformedURLException, IOException, CertificateException
+            {
+                if (certificate != null)
+                {
+                    final InputStream is ;
+                    if (certificate.isAbsolute())
+                    {
+                        is = certificate.toURL().openStream() ;
+                    }
+                    else
+                    {
+                        final File file = new File(certificate) ;
+                        is = file.toURL().openStream() ;
+                    }
+                    final ArrayList<X509Certificate> certificates = new ArrayList<X509Certificate>() ;
+                    try
+                    {
+                        final CertificateFactory cf = CertificateFactory.getInstance("X.509");
+                        
+                        final BufferedInputStream bis = new BufferedInputStream(is) ;
+                        final DataInputStream dis = new DataInputStream(bis) ;
+                        
+                        if (bis.available() > 0)
+                        {
+                            // We have to skip any preamble to read the certificate
+                            do
+                            {
+                                bis.mark(BEGIN_CERTIFICATE.length() * 2) ;
+                                final String line = dis.readLine() ;
+                                if (BEGIN_CERTIFICATE.equals(line))
+                                {
+                                    bis.reset() ;
+                                    break ;
+                                }
+                            }
+                            while (bis.available() > 0) ;
+                            
+                            if (bis.available() > 0)
+                            {
+                                final X509Certificate cert = (X509Certificate)cf.generateCertificate(bis);
+                                certificates.add(cert) ;
+                            }
+                        }
+                        this.certificates = certificates.toArray(new X509Certificate[certificates.size()]) ;
+                    }
+                    finally
+                    {
+                        is.close() ;
+                    }
+                }
+                else
+                {
+                    this.certificates = null ;
+                }
+            }
+            
+            public void checkClientTrusted(X509Certificate[] chain, String authType)
+                    throws CertificateException
+            {
+            }
+            
+            public void checkServerTrusted(X509Certificate[] chain, String authType)
+                    throws CertificateException
+            {
+                final int numCerts = (chain == null ? 0 : chain.length) ;
+                for(int count = 0 ; count < numCerts ; count++)
+                {
+                    final X509Certificate cert = chain[count] ;
+                    cert.checkValidity() ;
+                    verify(cert) ;
+                }
+            }
+            
+            private void verify(final X509Certificate cert)
+                throws CertificateException
+            {
+                final int numCertificates = (certificates == null ? 0 : certificates.length) ;
+                if (numCertificates > 0)
+                {
+                    for(int count = 0 ; count < numCertificates ; count++)
+                    {
+                        try
+                        {
+                            cert.verify(certificates[count].getPublicKey()) ;
+                            return ;
+                        }
+                        catch (final Exception ex) {} // ignore and try next certificate
+                    }
+                    throw new CertificateException("Failed to verify certificate") ;
+                }
+            }
+            
+            public X509Certificate[] getAcceptedIssuers()
+            {
+                return certificates ;
+            }
+        }
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/FtpsImpl.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/SecureFtpImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/SecureFtpImpl.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/util/SecureFtpImpl.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -25,17 +25,23 @@
  */
 package org.jboss.internal.soa.esb.util;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
-import java.net.MalformedURLException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Vector;
 
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
 import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
 import org.jboss.soa.esb.common.Environment;
 import org.jboss.soa.esb.common.ModulePropertyManager;
@@ -61,7 +67,6 @@
  * http://www.jcraft.com/
  * 
  * @author b_georges
- * 
  */
 
 public class SecureFtpImpl implements RemoteFileSystem 
@@ -78,16 +83,8 @@
 
 	private Session session = null;
 
-	private Channel m_oChannel = null;
-
 	private ChannelSftp m_oSftpChannel = null;
 
-	// TODO Add support for certificate. Not for GA though.
-	private URL m_oCertificate = null;
-
-	@SuppressWarnings("unused")
-	private boolean m_bConnected, m_bPassive;
-
 	private int m_iPort;
 
 	private SFTPEpr m_oEpr;
@@ -125,72 +122,43 @@
 
 		m_oEpr = p_oP;
 
-		URL url = null;
+		final URI uri ;
 		try {
-			url = m_oEpr.getURL();
-		} catch (MalformedURLException e) {
-			throw new RemoteFileSystemException(e);
+			uri = m_oEpr.getURI();
 		} catch (URISyntaxException e) {
 			throw new RemoteFileSystemException(e);
 		}
 
-		m_sFtpServer = url.getHost();
+		m_sFtpServer = uri.getHost();
 
 		String[] sa = null;
 
-		if (url.getUserInfo() != null)
-			sa = url.getUserInfo().split(":");
+		if (uri.getUserInfo() != null)
+			sa = uri.getUserInfo().split(":");
 
-		if (sa == null)
-			sa = new String[] { "", "" };
+		final int saLen = (sa == null ? 0 : sa.length) ;
+		switch(saLen)
+		{
+		case 2:
+		    m_sPasswd = sa[1] ;
+		case 1:
+		    m_sUser = sa[0] ;
+		}
 
-		m_sUser = (sa.length < 1) ? "" : sa[0];
-		m_sPasswd = (sa.length < 2) ? "" : sa[1];
+		m_sRemoteDir = uri.getPath();
 
-		m_sRemoteDir = url.getFile();
-
 		final String tmpdir = System.getProperty("java.io.tmpdir");
 		if ((m_sRemoteDir == null) || (m_sRemoteDir.equals("")))
 			m_sRemoteDir = ModulePropertyManager.getPropertyManager(
 					ModulePropertyManager.TRANSPORTS_MODULE).getProperty(
 							Environment.FTP_REMOTEDIR, tmpdir);
 
-		m_iPort = url.getPort();
-		if (m_iPort < 0)
-			m_iPort = url.getDefaultPort();
+		m_iPort = uri.getPort();
 
 		m_sLocalDir = ModulePropertyManager.getPropertyManager(
 				ModulePropertyManager.TRANSPORTS_MODULE).getProperty(
 						Environment.FTP_LOCALDIR, tmpdir);
 
-		m_bPassive = false;
-
-		try
-		{
-			m_bPassive = m_oEpr.getPassive();
-		} catch (URISyntaxException e) 
-		{
-			_logger.warn(e);
-		}
-
-		try
-		{
-			m_oCertificate = m_oEpr.getCertificateURL();
-		} 
-		catch (MalformedURLException ex)
-		{
-			_logger.error(ex);
-			
-			throw new ConfigurationException(ex);
-		}
-		catch (URISyntaxException e) 
-		{
-			_logger.warn(e);
-			
-			throw new ConfigurationException(e);
-		}
-
-		// TODO there is still a bit of space for improvements here.
 		configTreeFromEpr();
 
 		initialize(p_bConnect);
@@ -221,62 +189,71 @@
 		{
 			try
 			{
-				session = m_oJSch.getSession(m_sUser, m_sFtpServer, m_iPort);
+				if (m_iPort > 0)
+				    session = m_oJSch.getSession(m_sUser, m_sFtpServer, m_iPort);
+				else
+				    session = m_oJSch.getSession(m_sUser, m_sFtpServer);
 	
-				UserInfo ui = new SecureFtpUserInfo(m_sPasswd);
-				session.setUserInfo(ui);
-	
+				if (m_sPasswd != null)
+				{
+				    final UserInfo ui = new SecureFtpUserInfo(m_sPasswd);
+				    session.setUserInfo(ui);
+				}
+				
+				session.setConfig("StrictHostKeyChecking", "no") ;
+				session.setConfig("PreferredAuthentications", "password") ;
+
 				session.connect();
 	
-				m_oChannel = session.openChannel(SECURE_CHANNEL);
+				final Channel channel  = session.openChannel(SECURE_CHANNEL);
+				channel.connect();
 	
-				m_oChannel.connect();
+				m_oSftpChannel = (ChannelSftp) channel;
 	
-				m_oSftpChannel = (ChannelSftp) m_oChannel;
-	
-				for (int i1 = 0; i1 < 10 && !session.isConnected(); i1++)
-				{
-					try
-					{
-						Thread.sleep(200);  // TODO magic number
-					}
-					catch (InterruptedException ex)
-					{
-						// try again?
-					}
-				}
-				
 				if (!session.isConnected())
 					throw new RemoteFileSystemException("Can't connect to FTP server");
-	
-				m_bConnected = this.session.isConnected();
 			}
 			catch (JSchException ex)
 			{
-				_logger.error("Caught Secure FTP Exception.", ex);
+				if ((session != null) && session.isConnected())
+				{
+				    session.disconnect() ;
+				}
+				_logger.error("Caught Secure FTP Exception.");
+				_logger.debug("Caught Secure FTP Exception.", ex);
 				
 				throw new RemoteFileSystemException(ex);
 			}
 		}
-		// TODO set connection Mode [PASSIVE|ACTIVE]using m_bPassive ?
-
 	}
 
 	private void checkParms() throws ConfigurationException 
 	{
-		m_sFtpServer = m_oParms.getAttribute(PARMS_FTP_SERVER);
+            String att = m_oParms.getAttribute(FileEpr.URL_TAG);
+            URI uri = null;
+            
+            try
+            {
+                    if (att != null)
+                            uri = new URI(att);
+            }
+            catch (URISyntaxException ex)
+            {
+                    throw new ConfigurationException(ex);
+            }
+            
+		m_sFtpServer = (null != uri) ? uri.getHost() : m_oParms.getAttribute(PARMS_FTP_SERVER);
 		if (null == m_sFtpServer)
 			throw new ConfigurationException("No SFTP server specified");
 
-		m_sUser = m_oParms.getAttribute(PARMS_USER);
+                String[] sa = (null == uri) ? null : uri.getUserInfo().split(":");
+		m_sUser = (null != sa) ? sa[0] : m_oParms.getAttribute(PARMS_USER);
 		if (null == m_sUser)
 			throw new ConfigurationException("No username specified for SFTP");
 
-		m_sPasswd = m_oParms.getAttribute(PARMS_PASSWD);
-		if (null == m_sPasswd)
-			throw new ConfigurationException("No password specified for SFTP");
+		m_sPasswd = (null != sa) ? sa[1] : m_oParms.getAttribute(PARMS_PASSWD);
 
-		m_sRemoteDir = m_oParms.getAttribute(PARMS_REMOTE_DIR);
+		m_sRemoteDir = (null != uri) ? uri.getPath() : m_oParms.getAttribute(PARMS_REMOTE_DIR);
 		if (null == m_sRemoteDir)
 			m_sRemoteDir = "";
 
@@ -288,30 +265,12 @@
 		
 		try
 		{
-			m_iPort = (null == sAux) ? 22 : Integer.parseInt(sAux);
+			m_iPort = (null != uri) ? uri.getPort() : (null == sAux) ? 22 : Integer.parseInt(sAux);
 		}
 		catch (Exception ex)
 		{
 			throw new ConfigurationException(ex);
 		}
-
-		m_bPassive = false;
-		sAux = m_oParms.getAttribute(PARMS_PASSIVE);
-		m_bPassive = (null != sAux) && Boolean.parseBoolean(sAux);
-
-		final String certificate = m_oParms.getAttribute(PARMS_CERTIFICATE) ;
-		
-		if (certificate != null)
-		{
-			try
-			{
-				m_oCertificate = new URL(certificate);
-			}
-			catch (MalformedURLException ex)
-			{
-				throw new ConfigurationException(ex);
-			}
-		}
 	}
 
 	/*
@@ -325,7 +284,8 @@
 	{
 		try
 		{
-			m_oSftpChannel.rm(getRemoteDir() + "/" + new File(p_sFile).getName());
+			m_oSftpChannel.cd(getRemoteDir()) ;
+			m_oSftpChannel.rm(p_sFile);
 		}
 		catch (SftpException ex)
 		{
@@ -363,6 +323,7 @@
 	{
 		try
 		{
+			m_oSftpChannel.cd(getRemoteDir()) ;
 			String sSuffix = (null == p_sSuffix) ? "*" : "*" + p_sSuffix;
 			List<String> lFileList = new ArrayList<String>();
 			Vector vFileList = m_oSftpChannel.ls(sSuffix);
@@ -388,6 +349,10 @@
 		}
 		catch (SftpException ex)
 		{
+			if (ex.id == ChannelSftp.SSH_FX_NO_SUCH_FILE)
+			{
+			    return null ;
+			}
 			throw new RemoteFileSystemException(ex);
 		}
 	}
@@ -401,14 +366,7 @@
 	 */
 	public void setRemoteDir(String p_sDir) throws RemoteFileSystemException 
 	{
-		try
-		{
-			m_oSftpChannel.cd(p_sDir);
-		}
-		catch (SftpException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
+		m_sRemoteDir = p_sDir ;
 	}
 
 	/*
@@ -422,23 +380,16 @@
 	 *      java.lang.String)
 	 */
 	public void renameInRemoteDir(String p_sFrom, String p_sTo)
-	throws RemoteFileSystemException 
+	    throws RemoteFileSystemException 
 	{
-
-		String sRmtFrom = new File(p_sFrom).getName();
-		String sRmtTo = new File(p_sTo).getName();
-
 		try 
 		{
-			m_oSftpChannel.rename(getRemoteDir() + "/" + sRmtFrom,
-					getRemoteDir() + "/" + sRmtTo);
+			m_oSftpChannel.cd(getRemoteDir()) ;
+			m_oSftpChannel.rename(p_sFrom, p_sTo) ;
 		} 
-		catch (Exception e) 
+		catch (SftpException se) 
 		{
-			String sMess = this.getClass().getSimpleName()
-			+ " can't rename in remote directory <" + e.getMessage()
-			+ ">";
-			throw new RemoteFileSystemException(sMess);
+			throw new RemoteFileSystemException("Faile to rename file", se) ;
 		}
 	}
 
@@ -456,85 +407,117 @@
 	{
 		try 
 		{
+			m_oSftpChannel.cd(getRemoteDir()) ;
 			m_oSftpChannel.rename(FtpUtils.fileToFtpString(p_oFrom), FtpUtils
 					.fileToFtpString(p_oTo));
 		} 
-		catch (Exception e) 
+		catch (SftpException se) 
 		{
-			String sMess = this.getClass().getSimpleName()
-			+ " can't rename in remote directory <" + e.getMessage()
-			+ ">";
-			throw new RemoteFileSystemException(sMess);
+			throw new RemoteFileSystemException("Faile to rename file", se) ;
 		}
 	}
 
-	/*
-	 * Upload the local File p_ofile to p_sRemoteName
-	 * 
-	 * @param p_oFile The local file name we want to upload
-	 * 
-	 * @param p_sRemoteName The remote file name [can be the same as p_oFile of
-	 * course]
-	 * 
-	 * @see org.jboss.soa.esb.util.RemoteFileSystem#uploadFile(java.io.File,
-	 *      java.lang.String)
-	 */
-	public void uploadFile(File p_oFile, String p_sRemoteName) throws RemoteFileSystemException 
-	{
-		try
-		{
-			String sRemoteOK = getRemoteDir() + "/" + p_sRemoteName;
-			String sRemoteTmp = sRemoteOK + TMP_SUFFIX;
-			m_oSftpChannel.put(FtpUtils.fileToFtpString(p_oFile), sRemoteTmp);
-			m_oSftpChannel.rename(sRemoteTmp, sRemoteOK);
-		}
-		catch (SftpException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
-	}
+        /*
+         * Upload the local File p_ofile to p_sRemoteName
+         * 
+         * @param p_oFile The local file name we want to upload
+         * 
+         * @param p_sRemoteName The remote file name [can be the same as p_oFile of
+         * course]
+         * 
+         * @see org.jboss.soa.esb.util.RemoteFileSystem#uploadFile(java.io.File,
+         *      java.lang.String)
+         */
+        public void uploadFile(File p_oFile, String p_sRemoteName) throws RemoteFileSystemException 
+        {
+            try
+            {
+                    m_oSftpChannel.cd(getRemoteDir()) ;
+                    
+                    final String sRemoteTmp = p_sRemoteName + TMP_SUFFIX;
+                    
+                    final OutputStream os = m_oSftpChannel.put(sRemoteTmp) ;
+                    try
+                    {
+                        final FileInputStream fis = new FileInputStream(p_oFile) ;
+                        try
+                        {
+                            copyStream(fis, os) ;
+                        }
+                        finally
+                        {
+                            fis.close() ;
+                        }
+                    }
+                    finally
+                    {
+                        os.flush() ;
+                        os.close() ;
+                    }
+                    m_oSftpChannel.rename(sRemoteTmp, p_sRemoteName);
+            }
+            catch (final IOException ioe)
+            {
+                throw new RemoteFileSystemException(ioe) ;
+            }
+            catch (SftpException ex)
+            {
+                    throw new RemoteFileSystemException(ex);
+            }
+    }
 
-	/*
-	 * Download the remote File p_sFile to p_sFile.
-	 * 
-	 * @param p_sFile The remote file name we want to download
-	 * 
-	 * @param p_sFinalName The local file name
-	 * 
-	 * @see org.jboss.soa.esb.util.RemoteFileSystem#downloadFile(java.lang.String,
-	 *      java.lang.String)
-	 */
-	public void downloadFile(String p_sFile, String p_sFinalName) throws IOException, RemoteFileSystemException 
-	{
-		File oLocalDir = new File(m_sLocalDir);
-		File oLclFile = File.createTempFile("Rosetta_", TMP_SUFFIX, oLocalDir);
+        /*
+         * Download the remote File p_sFile to p_sFile.
+         * 
+         * @param p_sFile The remote file name we want to download
+         * 
+         * @param p_sFinalName The local file name
+         * 
+         * @see org.jboss.soa.esb.util.RemoteFileSystem#downloadFile(java.lang.String,
+         *      java.lang.String)
+         */
+        public void downloadFile(String p_sFile, String p_sFinalName) throws IOException, RemoteFileSystemException 
+        {
+            try
+            {
+                final File to = new File(p_sFinalName) ;
+                final File oLocalDir = new File(m_sLocalDir);
+                final File oNew = (to.isAbsolute() ? to : new File(oLocalDir, p_sFinalName)) ;
+                if (oNew.exists()) 
+                    oNew.delete();
+                
+                final File toTmp = new File(p_sFinalName + TMP_SUFFIX) ;
+                final File oNewTmp = (toTmp.isAbsolute() ? toTmp : new File(oLocalDir, p_sFinalName + TMP_SUFFIX)) ;
+                if (oNewTmp.exists()) 
+                    oNewTmp.delete();
+                
+                m_oSftpChannel.cd(getRemoteDir()) ;
+                final InputStream is = m_oSftpChannel.get(p_sFile) ;
+                
+                try
+                {
+                    final FileOutputStream fos = new FileOutputStream(oNewTmp) ;
+                    try
+                    {
+                        copyStream(is, fos) ;
+                    }
+                    finally
+                    {
+                        fos.close() ;
+                    }
+                }
+                finally
+                {
+                    is.close() ;
+                }
+                FileUtil.renameTo(oNewTmp, oNew) ;
+            }
+            catch (SftpException ex)
+            {
+                    throw new RemoteFileSystemException(ex);
+            }
+        }
 
-		try 
-		{
-			oLclFile.delete();
-		} 
-		catch (Exception e) 
-		{
-			_logger.warn("Could not delete file: "+oLclFile, e);
-		}
-		// TODO check if we have to set the Transfer Type with JSch impl =>
-		// m_oXferType
-		
-		try
-		{
-			m_oSftpChannel.get(p_sFile, FtpUtils.fileToFtpString(oLclFile));
-	
-			File oNew = new File(oLocalDir, p_sFinalName);
-			if (oNew.exists())
-				oNew.delete();
-			FileUtil.renameTo(oLclFile, oNew);
-		}
-		catch (Exception ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
-	}
-
 	/*
 	 * Returns the current remote directory
 	 * 
@@ -552,7 +535,8 @@
 	 */
 	public void quit() 
 	{
-		m_oSftpChannel.quit();
+		m_oSftpChannel.disconnect() ;
+		session.disconnect() ;
 	}
 
 	private void configTreeFromEpr() throws ConfigurationException 
@@ -563,20 +547,16 @@
 			m_oParms.setAttribute(RemoteFileSystem.PARMS_FTP_SERVER,
 					m_sFtpServer);
 			m_oParms.setAttribute(RemoteFileSystem.PARMS_USER, m_sUser);
-			m_oParms.setAttribute(RemoteFileSystem.PARMS_PASSWD, m_sPasswd);
+			if (m_sPasswd != null)
+			    m_oParms.setAttribute(RemoteFileSystem.PARMS_PASSWD, m_sPasswd);
 			m_oParms.setAttribute(RemoteFileSystem.PARMS_REMOTE_DIR,
 					m_sRemoteDir);
-			m_oParms.setAttribute(RemoteFileSystem.PARMS_PORT, Integer
+			if (m_iPort > 0)
+			    m_oParms.setAttribute(RemoteFileSystem.PARMS_PORT, Integer
 					.toString(m_iPort));
 			m_oParms.setAttribute(RemoteFileSystem.PARMS_LOCAL_DIR, m_sLocalDir);
 			m_oParms.setAttribute(RemoteFileSystem.PARMS_ASCII, Boolean
 					.toString(false));
-			m_oParms.setAttribute(RemoteFileSystem.PARMS_PASSIVE, Boolean
-					.toString(m_bPassive));
-			if (m_oCertificate != null)
-			{
-				m_oParms.setAttribute(RemoteFileSystem.PARMS_CERTIFICATE, m_oCertificate.toString());
-			}
 		} 
 		catch (Exception e) 
 		{
@@ -584,4 +564,23 @@
 		}
 	}
 
+        
+        private void copyStream(final InputStream is, final OutputStream os)
+            throws IOException
+        {
+            final BufferedInputStream bis = new BufferedInputStream(is) ;
+            final BufferedOutputStream bos = new BufferedOutputStream(os) ;
+            
+            final byte[] buffer = new byte[256] ;
+            while(true)
+            {
+                final int count = bis.read(buffer) ;
+                if (count <= 0)
+                {
+                    break ;
+                }
+                bos.write(buffer, 0, count) ;
+            }
+            bos.flush() ;
+        }
 }

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/EPR.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/EPR.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/EPR.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -27,6 +27,7 @@
  */
 
 import java.net.URI;
+import java.net.URISyntaxException;
 
 /**
  * The Endpoint Reference class. All services (and clients) can be represented by
@@ -97,6 +98,29 @@
 	{
 		_addr = uri;
 	}
+
+        /**
+         * Set the URI for this endpoint.
+         * 
+         * @param uri the address.
+         */
+        
+        public void setURI(URI uri)
+        {
+                setAddr(new PortReference(uri.toASCIIString()));
+        }
+        
+        /**
+         * Get the URI address.
+         * 
+         * @return the address.
+         * @throws URISyntaxException thrown if the address is invalid.
+         */
+        
+        public URI getURI() throws URISyntaxException
+        {
+                return new URI(getAddr().getAddress());
+        }
 	
 	/**
 	 * Get the EPR address.

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPEpr.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -113,12 +113,28 @@
 			}
 		}
 	}
-			
+	
+	/**
+	 * Construct the FTP EPR with the specified URL.
+	 * @param url
+	 * @throws URISyntaxException
+	 * @deprecated
+	 */
 	public FTPEpr (URL url) throws URISyntaxException
 	{
-		super(new URI(url.toString()));
+		this(url.toURI());
 	}
-	
+
+       /**
+         * Construct the FTP EPR with the specified URI.
+         * @param uri
+         * @throws URISyntaxException
+         */
+        public FTPEpr (URI uri)
+        {
+                super(uri);
+        }
+
 	public FTPEpr (String url) throws URISyntaxException
 	{
 		super(new URI(url));
@@ -128,6 +144,7 @@
 	 * Set the URL for this endpoint.
 	 * 
 	 * @param url the address.
+	 * @deprecated
 	 */
 	
 	public final void setURL (URL url)
@@ -140,6 +157,7 @@
 	 * 
 	 * @return the address.
 	 * @throws URISyntaxException thrown if the address is invalid.
+	 * @deprecated
 	 */
 	
 	public final URL getURL () throws MalformedURLException, URISyntaxException

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPSEpr.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPSEpr.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPSEpr.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -0,0 +1,237 @@
+package org.jboss.soa.esb.addressing.eprs;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author mark.little at jboss.com
+ */
+
+/**
+ * This class represents the endpoint reference for services.
+ */
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * A helper class for using FTPS style EPRs.
+ * 
+ * @author marklittle
+ */
+public class FTPSEpr extends FTPEpr
+{
+	public static final String CERTIFICATE_TAG = "certificate";
+	public static final String CERTIFICATE_NAME_TAG = "certificateName";
+
+	public FTPSEpr(EPR epr)
+	{
+		super(epr);
+		
+		if (epr instanceof FTPSEpr)
+		{
+		    certificateSet = ((FTPSEpr) epr).certificateSet;
+		    certificateNameSet = ((FTPSEpr) epr).certificateNameSet;
+		}
+	}
+	
+	public FTPSEpr (EPR epr, Element header)
+	{
+		super(epr, header);
+		
+		NodeList nl = header.getChildNodes();
+
+		for (int i = 0; i < nl.getLength(); i++)
+		{
+			String prefix = nl.item(i).getPrefix();
+			String tag = nl.item(i).getLocalName();
+			
+			try
+			{
+				if ((prefix != null) && (prefix.equals(XMLUtil.JBOSSESB_PREFIX)))
+				{
+					if ((tag != null) && (tag.equals(CERTIFICATE_TAG)))
+					{
+						getAddr().addExtension(CERTIFICATE_TAG, nl.item(i).getTextContent());
+						certificateSet = true;
+					}
+					else if ((tag != null) && (tag.equals(CERTIFICATE_NAME_TAG)))
+					{
+						setCertificateName(nl.item(i).getTextContent());
+					}
+				}
+			}
+			catch (Exception ex)
+			{
+				ex.printStackTrace();
+			}
+		}
+	}
+
+	public FTPSEpr(URI uri) throws URISyntaxException
+	{
+		super(uri);
+	}
+	
+	public FTPSEpr(URI uri, URI cert, final String name) throws URISyntaxException
+	{
+		super(uri);
+		
+		if (cert != null)
+		{
+			setCertificateURI(cert);
+		}
+		if (name != null)
+		{
+			setCertificateName(name);
+		}
+	}
+
+	public FTPSEpr(URI uri, String cert, final String name) throws URISyntaxException
+	{
+		super(uri);	
+
+		if (cert != null)
+		{
+			setCertificateURI(new URI(cert));
+		}
+		if (name != null)
+		{
+			setCertificateName(name);
+		}
+	}
+
+	public FTPSEpr(String uri, String cert, final String name) throws URISyntaxException
+	{
+		super(uri);	
+
+		if(cert != null)
+		{
+			setCertificateURI(new URI(cert));
+		}
+		if (name != null)
+		{
+			setCertificateName(name);
+		}
+	}
+
+	/**
+	 * Set the Certificate URI for this endpoint.
+	 * 
+	 * @param cert
+	 *            the address.
+	 * @throws URISyntaxException
+	 *             thrown if this EPR is malformed.
+	 */
+
+	public final void setCertificateURI(URI cert) throws URISyntaxException
+	{
+		if (cert == null)
+			throw new IllegalArgumentException();
+
+		if (certificateSet)
+			throw new IllegalStateException("Certificate URI already set.");
+
+		getAddr().addExtension(CERTIFICATE_TAG, cert.toASCIIString());
+		certificateSet = true;
+	}
+
+	/**
+	 * @return the certificate URI for this EPR.
+	 * @throws URISyntaxException
+	 *             thrown if this EPR is malformed.
+	 */
+
+	public final URI getCertificateURI () throws URISyntaxException
+	{
+		String cert = getAddr().getExtensionValue(CERTIFICATE_TAG);
+
+		if (cert != null)
+			return new URI(cert);
+		else
+			return null;
+	}
+
+	/**
+	 * Set the Certificate Name for this endpoint.
+	 * 
+	 * @param name
+	 *            the certificate name.
+	 */
+
+	public final void setCertificateName(final String name)
+	{
+		if (name == null)
+			throw new IllegalArgumentException();
+
+		if (certificateNameSet)
+			throw new IllegalStateException("Certificate Name already set.");
+
+		getAddr().addExtension(CERTIFICATE_NAME_TAG, name);
+		certificateNameSet = true;
+	}
+
+	/**
+	 * @return the certificate Name for this EPR.
+	 * @throws URISyntaxException
+	 *             thrown if this EPR is malformed.
+	 */
+
+	public final String getCertificateName()
+	{
+		return getAddr().getExtensionValue(CERTIFICATE_NAME_TAG);
+	}
+
+	public EPR copy ()
+	{
+	    return new FTPSEpr(this);
+	}
+	
+	public String toString ()
+	{
+		return "FTPSEpr [ "+super.getAddr().extendedToString()+" ]";
+	}
+	
+	public static URI type ()
+	{
+		return _type;
+	}
+
+	private boolean certificateSet = false;
+	private boolean certificateNameSet ;
+
+	private static URI _type;
+
+	static
+	{
+		try
+		{
+			_type = new URI("urn:jboss/esb/epr/type/ftps");
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+
+			throw new ExceptionInInitializerError(ex.toString());
+		}
+	}
+}
\ No newline at end of file


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FTPSEpr.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -159,9 +159,15 @@
 		}
 	}
 
+	/**
+	 * Construct the File EPR with the specified URL.
+	 * @param url
+	 * @throws URISyntaxException
+	 * @deprecated
+	 */
 	public FileEpr (URL url) throws URISyntaxException
 	{
-		super(new URI(url.toString()));
+		this(url.toURI());
 	}
 	
 	public FileEpr (String url) throws URISyntaxException
@@ -173,6 +179,7 @@
 	 * Set the URL for this endpoint.
 	 * 
 	 * @param url the address.
+	 * @deprecated
 	 */
 	
 	public void setURL (URL url)
@@ -185,6 +192,7 @@
 	 * 
 	 * @return the address.
 	 * @throws URISyntaxException thrown if the address is invalid.
+	 * @deprecated
 	 */
 	
 	public URL getURL () throws MalformedURLException, URISyntaxException
@@ -442,7 +450,7 @@
 	    return _type;
 	}
 	
-	protected FileEpr (URI uri)
+	public FileEpr (URI uri)
 	{
 		super(uri);
 	}

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/HTTPEpr.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -54,12 +54,27 @@
 	{
 		super(epr);
 	}
-	
+	/**
+	 * Construct the HTTP EPR using the specified URL.
+	 * @param url
+	 * @throws URISyntaxException
+	 * @deprecated
+	 */
 	public HTTPEpr (URL url) throws URISyntaxException
 	{
-		super(new URI(url.toString()));
+		this(url.toURI());
 	}
-	
+
+       /**
+         * Construct the HTTP EPR using the specified URI.
+         * @param uri
+         * @throws URISyntaxException
+         */
+        public HTTPEpr (URI uri)
+        {
+                super(uri);
+        }
+
 	public HTTPEpr (String url) throws URISyntaxException
 	{
 		super(new URI(url));
@@ -69,6 +84,7 @@
 	 * Set the URL for this endpoint.
 	 * 
 	 * @param url the address.
+	 * @deprecated
 	 */
 	
 	public final void setURL (URL url)
@@ -81,6 +97,7 @@
 	 * 
 	 * @return the address.
 	 * @throws URISyntaxException thrown if the address is invalid.
+	 * @deprecated
 	 */
 	
 	public final URL getURL () throws MalformedURLException, URISyntaxException

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/SFTPEpr.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/SFTPEpr.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/SFTPEpr.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -25,10 +25,8 @@
  * This class represents the endpoint reference for services.
  */
 
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 
 import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.addressing.XMLUtil;
@@ -36,12 +34,9 @@
 import org.w3c.dom.NodeList;
 
 /**
- * A helper class for using FTP style EPRs. Simply create instances of this
- * class instead of the base EPR. Since URLs can use FTP, we try to leverage
- * that as much as possible.
+ * A helper class for using SFTP style EPRs.
  * 
  * @author marklittle
- * 
  */
 public class SFTPEpr extends FTPEpr
 {
@@ -84,59 +79,68 @@
 		}
 	}
 
-	public SFTPEpr(URL url) throws URISyntaxException
-	{
-		super(url);
-	}
+       /**
+         * Construct the SFTP EPR with the specified URI.
+         * @param uri
+         * @throws URISyntaxException
+         */
+        public SFTPEpr(URI uri)
+        {
+                super(uri);
+        }
 
-	public SFTPEpr(URL url, URL cert) throws URISyntaxException
-	{
-		super(url);
-		
-		setCertificateURL(cert);
-	}
+        /**
+         * Construct the SFTP EPR with the specified URI and certificate.
+         * @param uri
+         * @param cert
+         * @throws URISyntaxException
+         */
+        public SFTPEpr(URI uri, URI cert) throws URISyntaxException
+        {
+                super(uri) ;
+                
+                setCertificateURI(cert);
+        }
 
-	public SFTPEpr(String url, String cert) throws URISyntaxException, MalformedURLException
+	public SFTPEpr(String url, String cert) throws URISyntaxException
 	{
 		super(url);	
 
-		setCertificateURL(new URL(cert));
+		setCertificateURI(new URI(cert));
 	}
 
 	/**
-	 * Set the Certificate URL for this endpoint.
+	 * Set the Certificate URI for this endpoint.
 	 * 
 	 * @param cert
 	 *            the address.
 	 * @throws URISyntaxException
 	 *             thrown if this EPR is malformed.
 	 */
-
-	public final void setCertificateURL(URL cert) throws URISyntaxException
+	public final void setCertificateURI(URI cert) throws URISyntaxException
 	{
 		if (cert == null)
 			throw new IllegalArgumentException();
 
 		if (certificateSet)
-			throw new IllegalStateException("Certificate URL already set.");
+			throw new IllegalStateException("Certificate URI already set.");
 
-		getAddr().addExtension(CERTIFICATE_TAG, cert.toString());
+		getAddr().addExtension(CERTIFICATE_TAG, cert.toASCIIString());
 		certificateSet = true;
 	}
 
 	/**
-	 * @return the certificate URL for this EPR.
+	 * @return the certificate URI for this EPR.
 	 * @throws URISyntaxException
 	 *             thrown if this EPR is malformed.
 	 */
 
-	public final URL getCertificateURL () throws URISyntaxException,
-			MalformedURLException
+	public final URI getCertificateURI () throws URISyntaxException
 	{
 		String cert = getAddr().getExtensionValue(CERTIFICATE_TAG);
 
 		if (cert != null)
-			return new URL(cert);
+			return new URI(cert);
 		else
 			return null;
 	}

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/util/DefaultReplyTo.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/util/DefaultReplyTo.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/addressing/util/DefaultReplyTo.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -62,6 +62,8 @@
 	    if (toEpr instanceof JMSEpr)
 		return new DefaultJmsReplyToEpr((JMSEpr) toEpr);
 	    // Check for SFTPEpr first, as it extends FTPEpr
+	    if (toEpr instanceof FTPSEpr)
+		return new DefaultFtpsReplyToEpr((FTPSEpr) toEpr);
 	    if (toEpr instanceof SFTPEpr)
 		return new DefaultSftpReplyToEpr((SFTPEpr) toEpr);
 	    // Check for FTPEpr first, as it extends FileEpr

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -23,9 +23,7 @@
 package org.jboss.soa.esb.listeners;
 
 import java.io.File;
-import java.net.MalformedURLException;
 import java.net.URISyntaxException;
-import java.net.URL;
 import java.net.URI;
 import java.util.Properties;
 import java.util.Set;
@@ -90,6 +88,10 @@
 				return fileEprFromElement(tree);
 			if ("ftp".equals(protocol))
 				return fileEprFromElement(tree);
+			if ("ftps".equals(protocol))
+				return fileEprFromElement(tree);
+			if ("sftp".equals(protocol))
+				return fileEprFromElement(tree);
 			if ("jdbc".equals(protocol))
 				return jdbcEprFromElement(tree);
 		}
@@ -188,22 +190,45 @@
 		try
 		{
             String urlString = tree.getRequiredAttribute(ListenerTagNames.URL_TAG);
-			URL url = new URL(urlString);
-			String protocol = url.getProtocol();
+			URI uri = new URI(urlString);
+			String scheme = uri.getScheme();
 	
-			if ("file".equals(protocol))
+                        final FileEpr epr ;
+			if ("file".equals(scheme))
 			{
-				if (!new File(url.getFile()).isDirectory())
+				if (!new File(uri).isDirectory())
 					throw new ConfigurationException("Attribute "
 							+ ListenerTagNames.URL_TAG
 							+ " must reference a directory");
+				epr = new FileEpr(uri) ;
 			}
-	
-			FileEpr epr = ("file".equals(protocol)) ? new FileEpr(url) : ("ftp"
-					.equals(protocol)) ? new FTPEpr(url) : null;
-			if (null == epr)
+			else if ("ftp".equals(scheme))
+			{
+			    epr = new FTPEpr(uri) ;
+			}
+			else if ("ftps".equals(scheme))
+			{
+			    String cert = tree.getAttribute(FTPSEpr.CERTIFICATE_TAG);
+			    String name = tree.getAttribute(FTPSEpr.CERTIFICATE_NAME_TAG);
+			    epr = new FTPSEpr(uri, cert, name);
+			}
+			else if ("sftp".equals(scheme))
+			{
+			    String cert = tree.getAttribute(SFTPEpr.CERTIFICATE_TAG);
+			    if(cert == null)
+			    {
+			        epr = new SFTPEpr(uri);
+			    }
+			    else
+			    {
+			        epr = new SFTPEpr(uri,new URI(cert));
+			    }
+			}
+			else
+			{
 				throw new ConfigurationException("Unsupported file protocol : "
-						+ protocol);
+						+ scheme);
+			}
 	
 			String inputSuffix = tree.getAttribute(FileEpr.INPUT_SUFFIX_TAG);
 	
@@ -229,7 +254,7 @@
 			}
 			if (null == errorDir)
 			{
-				errorDir = url.getFile();
+				errorDir = uri.getPath();
 				warnDefault(FileEpr.ERROR_DIR_TAG, errorDir);
 			}
 			if (null == errorSuffix)
@@ -260,7 +285,7 @@
 			}
 			if (null == postDir)
 			{
-				postDir = url.getFile();
+				postDir = uri.getPath();
 				warnDefault(FileEpr.POST_DIR_TAG, postDir);
 			}
 			if (null == postSuffix)
@@ -284,10 +309,6 @@
 		{
 			throw new ConfigurationException(ex);
 		}
-		catch (MalformedURLException ex)
-		{
-			throw new ConfigurationException(ex);
-		}
 	} // ________________________________
 
 	public static JDBCEpr jdbcEprFromElement(ConfigTree tree) throws ConfigurationException

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapper.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/FtpListenerMapper.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -22,12 +22,14 @@
 
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.addressing.eprs.FTPSEpr;
 import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
 import org.jboss.soa.esb.dom.YADOMUtil;
 import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.FtpBusDocument.FtpBus;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.FtpListenerDocument.FtpListener;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.FtpMessageFilterDocument.FtpMessageFilter;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.FtpMessageFilterDocument.FtpMessageFilter.Protocol;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.FtpProviderDocument.FtpProvider;
 import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
 import org.jboss.soa.esb.listeners.gateway.ReadOnlyRemoteGatewayListener;
@@ -112,7 +114,7 @@
 	{
 		String inputDir = messageFilter.getDirectory();
 		if ( ! inputDir.startsWith( FTP_SEPARATOR ) )
-			inputDir += FTP_SEPARATOR + inputDir;
+			inputDir = FTP_SEPARATOR + inputDir;
 		
 		toElement.setAttribute(ListenerTagNames.URL_TAG, messageFilter.getProtocol() + "://" + messageFilter.getUsername() + ":" 
 				+ messageFilter.getPassword() + "@" + provider.getHostname() + inputDir );
@@ -129,8 +131,12 @@
 			toElement.setAttribute(FTPEpr.ERROR_SUFFIX_TAG, messageFilter.getErrorSuffix());
 		}
 		toElement.setAttribute(FTPEpr.PASSIVE_TAG, String.valueOf(messageFilter.getPassive()));
-		if ("sftp".equals(messageFilter.getProtocol()) || "ftps".equals(messageFilter.getProtocol())) {
+		if (Protocol.SFTP.equals(messageFilter.getProtocol())) {
 			toElement.setAttribute(SFTPEpr.CERTIFICATE_TAG, messageFilter.getCertificateUrl());
 		}
+		if (Protocol.FTPS.equals(messageFilter.getProtocol())) {
+			toElement.setAttribute(FTPSEpr.CERTIFICATE_TAG, messageFilter.getCertificateUrl());
+			toElement.setAttribute(FTPSEpr.CERTIFICATE_NAME_TAG, messageFilter.getCertificateName());
+		}
 	}
 }

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -25,9 +25,8 @@
 import java.io.File;
 import java.io.FileFilter;
 import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
 import java.net.URI;
-import java.net.URL;
+import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -366,13 +365,13 @@
     }
 
     private static String getInputDir(ConfigTree config) throws ConfigurationException {
-        String url = config.getAttribute(ListenerTagNames.URL_TAG);
+        String uri = config.getAttribute(ListenerTagNames.URL_TAG);
 
-        if(url != null) {
+        if(uri != null) {
             try {
-                return new URL(url).getFile();
-            } catch (MalformedURLException e) {
-                throw new ConfigurationException("Invalid '" + ListenerTagNames.URL_TAG + "' value '" + url + "'.  Must be a valid URI.");
+                return new URI(uri).getPath();
+            } catch (URISyntaxException e) {
+                throw new ConfigurationException("Invalid '" + ListenerTagNames.URL_TAG + "' value '" + uri + "'.  Must be a valid URI.");
             }
         }
 

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/FtpClientUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/FtpClientUtil.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/FtpClientUtil.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -21,29 +21,29 @@
  */
 package org.jboss.soa.esb.util;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.List;
 
+import org.apache.commons.net.ftp.FTP;
+import org.apache.commons.net.ftp.FTPClient;
+import org.jboss.internal.soa.esb.util.FtpUtils;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.helpers.KeyValuePair;
 
-import com.enterprisedt.net.ftp.FTPClient;
-import com.enterprisedt.net.ftp.FTPConnectMode;
-import com.enterprisedt.net.ftp.FTPException;
-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>
  */
 
@@ -70,7 +70,7 @@
 	public enum XFER_TYPE
 	{
 		ascii, binary
-	};
+	}
 
 	private ConfigTree m_oParms;
 
@@ -82,15 +82,15 @@
 
 	private boolean m_bPassive;
 
+        private FTPClient m_oConn = new FTPClient();
+
+        private boolean m_bAsciiTransferType ; 
+
 	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
@@ -133,38 +133,42 @@
 		{
 			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++)
+				if (m_iPort > 0)
 				{
-					try
-					{
-						// TODO magic number
-						Thread.sleep(200);
-					}
-					catch (InterruptedException ex)
-					{
-					}
+				    m_oConn.connect(m_sFtpServer, m_iPort) ;
 				}
+				else
+				{
+				    m_oConn.connect(m_sFtpServer) ;
+				}
+
 				
-				if (!m_oConn.connected())
+				if (!m_oConn.isConnected())
 					throw new RemoteFileSystemException("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);
+				if (!m_oConn.login(m_sUser, m_sPasswd))
+				{
+				    m_oConn.logout() ;
+				    throw new RemoteFileSystemException("Remote login failed: " + m_oConn.getReplyString());
+				}
+				m_oConn.setFileType(m_bAsciiTransferType ? FTP.ASCII_FILE_TYPE : FTP.BINARY_FILE_TYPE) ;
+				if (m_bPassive)
+				{
+					m_oConn.enterLocalPassiveMode() ;
+				}
 			}
 		}
-		catch (RemoteFileSystemException ex)
+		catch (IOException ioe)
 		{
-			throw ex;
+			if (m_oConn.isConnected())
+			{
+			    try
+			    {
+			        m_oConn.disconnect() ;
+			    }
+			    catch (final IOException ioe2) {} // ignore
+			}
+			throw new RemoteFileSystemException(ioe);
 		}
-		catch (Exception ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
 	} // __________________________________
 
 	/**
@@ -176,6 +180,7 @@
 		if (null != m_oConn) try
 		{
 			m_oConn.quit();
+			m_oConn.disconnect();
 		}
 		catch (Exception e)
 		{
@@ -197,12 +202,12 @@
 	{
 		try
 		{
-			m_oConn.delete(getRemoteDir() + "/" + new File(p_sFile).getName());
+			changeRemoteDirectory() ;
+			if (!m_oConn.deleteFile(p_sFile))
+			{
+			    throw new RemoteFileSystemException("Failed to delete remote file: " + m_oConn.getReplyString());
+			}
 		}
-		catch (FTPException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
 		catch (IOException ex)
 		{
 			throw new RemoteFileSystemException(ex);
@@ -213,12 +218,12 @@
 	{
 		try
 		{
-			m_oConn.delete(fileToFtpString(p_oFile));
+			changeRemoteDirectory() ;
+			if (!m_oConn.deleteFile(p_oFile.getName()))
+			{
+			    throw new RemoteFileSystemException("Failed to delete remote file: " + m_oConn.getReplyString());
+			}
 		}
-		catch (FTPException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
 		catch (IOException ex)
 		{
 			throw new RemoteFileSystemException(ex);
@@ -242,12 +247,9 @@
 		
 		try
 		{
-			return m_oConn.dir(sSuffix);
+			changeRemoteDirectory() ;
+			return m_oConn.listNames(sSuffix);
 		}
-		catch (FTPException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
 		catch (IOException ex)
 		{
 			throw new RemoteFileSystemException(ex);
@@ -265,18 +267,7 @@
 	 */
 	public void setRemoteDir (String p_sDir) throws RemoteFileSystemException
 	{
-		try
-		{
-			m_oConn.chdir(p_sDir);
-		}
-		catch (FTPException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
-		catch (IOException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
+		m_sRemoteDir = p_sDir ;
 	} // _________________________________
 
 	/**
@@ -296,19 +287,17 @@
 	public void renameInRemoteDir (String p_sFrom, String p_sTo)
 			throws RemoteFileSystemException
 	{
-		String sRmtFrom = new File(p_sFrom).getName();
-		String sRmtTo = new File(p_sTo).getName();
-
 		try
 		{
-			m_oConn.rename(getRemoteDir() + "/" + sRmtFrom,
-					getRemoteDir() + "/" + sRmtTo);
+			changeRemoteDirectory() ;
+			if (!m_oConn.rename(p_sFrom, p_sTo))
+			{
+			    throw new RemoteFileSystemException("Failed to rename file: " + m_oConn.getReplyString());
+			}
 		}
-		catch (Exception e)
+		catch (final IOException ioe)
 		{
-			String sMess = this.getClass().getSimpleName() + " can't rename in remote directory <" + e
-					.getMessage() + ">";
-			throw new RemoteFileSystemException(sMess);
+			throw new RemoteFileSystemException(ioe);
 		}
 	} // _________________________________
 
@@ -316,13 +305,15 @@
 	{
 		try
 		{
-			m_oConn.rename(fileToFtpString(p_oFrom), fileToFtpString(p_oTo));
+			if (!m_oConn.rename(FtpClientUtil.fileToFtpString(p_oFrom),
+			        FtpUtils.fileToFtpString(p_oTo)))
+			{
+			    throw new RemoteFileSystemException("Failed to rename file: " + m_oConn.getReplyString());
+			}
 		}
-		catch (Exception e)
+		catch (IOException ioe)
 		{
-			String sMess = this.getClass().getSimpleName() + " can't rename in remote directory <" + e
-					.getMessage() + ">";
-			throw new RemoteFileSystemException(sMess);
+			throw new RemoteFileSystemException(ioe);
 		}
 	} // _________________________________
 
@@ -343,19 +334,38 @@
 	public void uploadFile (File p_oFile, String p_sRemoteName)
 			throws RemoteFileSystemException
 	{
-		String sRemoteOK = getRemoteDir() + "/" + p_sRemoteName;
-		String sRemoteTmp = sRemoteOK + TMP_SUFFIX;
-		
 		try
 		{
-			m_oConn.setType(m_oXferType);
-			m_oConn.put(fileToFtpString(p_oFile), sRemoteTmp);
-			m_oConn.rename(sRemoteTmp, sRemoteOK);
+			changeRemoteDirectory() ;
+			final String sRemoteTmp = p_sRemoteName + TMP_SUFFIX ;
+			
+			final OutputStream os = m_oConn.storeFileStream(sRemoteTmp) ;
+			try
+			{
+			    final FileInputStream fis = new FileInputStream(p_oFile) ;
+			    try
+			    {
+			        copyStream(fis, os) ;
+			    }
+			    finally
+			    {
+			        fis.close() ;
+			    }
+			}
+			finally
+			{
+			    os.flush() ;
+			    os.close() ;
+			}
+			if (!m_oConn.completePendingCommand())
+			{
+			    throw new RemoteFileSystemException("Failed to upload contents: " + m_oConn.getReplyString()) ;
+			}
+			if (!m_oConn.rename(sRemoteTmp, p_sRemoteName))
+			{
+			    throw new RemoteFileSystemException("Failed to rename file: " + m_oConn.getReplyString());
+			}
 		}
-		catch (FTPException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
 		catch (IOException ex)
 		{
 			throw new RemoteFileSystemException(ex);
@@ -383,46 +393,53 @@
 	{
 		try
 		{
-			File oLocalDir = new File(m_sLocalDir);
-			File oLclFile = File.createTempFile("Rosetta_", TMP_SUFFIX, oLocalDir);
-	
+			final File to = new File(p_sFinalName) ;
+			final File oLocalDir = new File(m_sLocalDir);
+			final File oNew = (to.isAbsolute() ? to : new File(oLocalDir, p_sFinalName)) ;
+			if (oNew.exists())
+			    oNew.delete();
+			
+			final File toTmp = new File(p_sFinalName + TMP_SUFFIX) ;
+			final File oNewTmp = (toTmp.isAbsolute() ? toTmp : new File(oLocalDir, p_sFinalName + TMP_SUFFIX)) ;
+			if (oNewTmp.exists())
+			    oNewTmp.delete();
+			
+			changeRemoteDirectory() ;
+			final InputStream is = m_oConn.retrieveFileStream(p_sFile) ;
+			if (is == null)
+			{
+			    throw new RemoteFileSystemException("Could not download file: " + m_oConn.getReplyString());
+			}
+			
 			try
 			{
-				oLclFile.delete();
+			    final FileOutputStream fos = new FileOutputStream(oNewTmp) ;
+			    try
+			    {
+			        copyStream(is, fos) ;
+			    }
+			    finally
+			    {
+			        fos.close() ;
+			    }
 			}
-			catch (Exception e)
+			finally
 			{
+			    is.close() ;
 			}
-			
-			m_oConn.setType(m_oXferType);
-			m_oConn.get(fileToFtpString(oLclFile), p_sFile);
-	
-			File oNew = new File(oLocalDir, p_sFinalName);
-			
-			if (oNew.exists()) 
-				oNew.delete();
-			
-			FileUtil.renameTo(oLclFile, oNew);
+			if (!m_oConn.completePendingCommand())
+			{
+			    oNewTmp.delete() ;
+			    throw new RemoteFileSystemException("Failed to download contents: " + m_oConn.getReplyString()) ;
+			}
+			FileUtil.renameTo(oNewTmp, oNew);
 		}
-		catch (FTPException ex)
-		{
-			throw new RemoteFileSystemException(ex);
-		}
 		catch (IOException ex)
 		{
 			throw new RemoteFileSystemException(ex);
 		}
 	} // _________________________________
 
-	// 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 ConfigurationException
 	{
 		m_sFtpServer = m_oParms.getAttribute(PARMS_FTP_SERVER);
@@ -454,7 +471,7 @@
 		if (null != sAux) 
 			bAscii = Boolean.parseBoolean(sAux);
 		
-		setXferType((bAscii) ? XFER_TYPE.ascii : XFER_TYPE.binary);
+		m_bAsciiTransferType = bAscii;
 
 		m_bPassive = false;
 		sAux = m_oParms.getAttribute(PARMS_PASSIVE);
@@ -465,5 +482,36 @@
 	{
 		return (null == p_oF) ? null : p_oF.toString().replace("\\", "/");
 	} // ________________________________
-
+        
+        private void changeRemoteDirectory()
+            throws IOException, RemoteFileSystemException
+        {
+            final String remoteDir = getRemoteDir() ;
+            if ((remoteDir != null) && (remoteDir.length() > 0))
+            {
+                if (!m_oConn.changeWorkingDirectory(remoteDir))
+                {
+                    throw new RemoteFileSystemException("Failed to change to remote directory: " + m_oConn.getReplyString());
+                }
+            }
+        }
+        
+        private void copyStream(final InputStream is, final OutputStream os)
+            throws IOException
+        {
+            final BufferedInputStream bis = new BufferedInputStream(is) ;
+            final BufferedOutputStream bos = new BufferedOutputStream(os) ;
+            
+            final byte[] buffer = new byte[256] ;
+            while(true)
+            {
+                final int count = bis.read(buffer) ;
+                if (count <= 0)
+                {
+                    break ;
+                }
+                bos.write(buffer, 0, count) ;
+            }
+            bos.flush() ;
+        }
 } // ____________________________________________________________________________

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystem.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystem.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystem.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -54,6 +54,8 @@
 
 	public static final String PARMS_CERTIFICATE = "certificate";
 
+	public static final String PARMS_CERTIFICATE_NAME = "certificateName";
+
 	public String getRemoteDir ();
 
 	/**

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -22,13 +22,14 @@
 
 package org.jboss.soa.esb.util;
 
-import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 
-import org.jboss.internal.soa.esb.util.EdtFtpImpl;
+import org.jboss.internal.soa.esb.util.FtpImpl;
+import org.jboss.internal.soa.esb.util.FtpsImpl;
 import org.jboss.internal.soa.esb.util.SecureFtpImpl;
 import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.addressing.eprs.FTPSEpr;
 import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
 
 public class RemoteFileSystemFactory
@@ -53,18 +54,18 @@
 	public static RemoteFileSystem getRemoteFileSystem(FTPEpr p_oEpr,
 			boolean p_bConnect) throws RemoteFileSystemException
 	{
-		URL url = null;
+		URI uri = null;
 		try
 		{
-			url = p_oEpr.getURL();
-			if (url.getProtocol().equals(RemoteFileSystem.FTP_PROTOCOL))
-				return new EdtFtpImpl((FTPEpr) p_oEpr, p_bConnect);
-			else if (url.getProtocol().equals(RemoteFileSystem.SFTP_PROTOCOL))
+			uri = p_oEpr.getURI();
+			final String scheme = uri.getScheme();
+			if (RemoteFileSystem.FTP_PROTOCOL.equals(scheme))
+				return new FtpImpl((FTPEpr) p_oEpr, p_bConnect);
+			else if (RemoteFileSystem.FTPS_PROTOCOL.equals(scheme))
+				return new FtpsImpl((FTPSEpr) p_oEpr, p_bConnect);
+			else if (RemoteFileSystem.SFTP_PROTOCOL.equals(scheme))
 				return new SecureFtpImpl((SFTPEpr) p_oEpr, p_bConnect);
 
-		} catch (MalformedURLException e)
-		{
-			throw new RemoteFileSystemException(e);
 		} catch (URISyntaxException e)
 		{
 			throw new RemoteFileSystemException(e);

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/CourierIntegrationTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/CourierIntegrationTest.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/CourierIntegrationTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -24,7 +24,6 @@
 
 import java.io.File;
 import java.net.URI;
-import java.net.URL;
 import java.util.UUID;
 
 import org.jboss.soa.esb.addressing.Call;
@@ -35,7 +34,6 @@
 import org.jboss.soa.esb.couriers.CourierFactory;
 import org.jboss.soa.esb.couriers.TwoWayCourier;
 import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.body.content.BytesBody;
 import org.jboss.soa.esb.message.format.MessageFactory;
 
 /**
@@ -43,6 +41,7 @@
  * 
  * @since Version 4.0
  * 
+ * TODO Extend this to include FTPS/SFTP
  */
 
 public class CourierIntegrationTest extends BaseTest
@@ -84,14 +83,14 @@
 			pickup("ftp://"+getFtpUser()+"@"+getFtpHostname()+"/"+getFtpDir());
 	}
 	
-	private final FileEpr getEpr(String sUrl) throws Exception
+	private final FileEpr getEpr(String sUri) throws Exception
 	{
-		String protocol = new URL(sUrl).getProtocol();
+		final String scheme = new URI(sUri).getScheme();
 
-		if ("ftp".equals(protocol))
-			return new FTPEpr(sUrl);
-		if ("file".equals(protocol))
-			return new FileEpr(sUrl);
+		if ("ftp".equals(scheme))
+			return new FTPEpr(sUri);
+		if ("file".equals(scheme))
+			return new FileEpr(sUri);
 
 		throw new IllegalArgumentException("Not a recognised protocol!");
 	}

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/FileCourierUnitTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -43,7 +43,6 @@
 import org.jboss.soa.esb.couriers.FaultMessageException;
 import org.jboss.soa.esb.couriers.TwoWayCourier;
 import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.body.content.BytesBody;
 import org.jboss.soa.esb.message.format.MessageFactory;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -115,7 +114,7 @@
 		String contents = "This is the text that travels in the Message body";
 
 		// toEpr for files must be a directory
-		FileEpr toEpr = new FileEpr(_tmpDir.toURL());
+		FileEpr toEpr = new FileEpr(_tmpDir.toURI());
 		toEpr.setInputSuffix(TEST_SUFFIX);
 		
 		Message msg = MessageFactory.getInstance().getMessage();
@@ -135,7 +134,7 @@
 		Assert.assertTrue(theFile.exists());
 		_logger.info("Message file "+theFile.toString()+" successfully created");
 				
-		FileEpr fromEpr = new FileEpr(toEpr.getURL());
+		FileEpr fromEpr = new FileEpr(toEpr.getURI());
 		fromEpr.setInputSuffix(TEST_SUFFIX);
 		fromEpr.setPostSuffix(DONE_SUFFIX);
 		
@@ -162,7 +161,7 @@
 	public void testFaultMessage () throws Exception 
     {
 		// toEpr for files must be a directory
-		FileEpr toEpr = new FileEpr(_tmpDir.toURL());
+		FileEpr toEpr = new FileEpr(_tmpDir.toURI());
 		toEpr.setInputSuffix(TEST_SUFFIX);
 		
 		Message msg = MessageFactory.getInstance().getMessage();
@@ -184,7 +183,7 @@
 		Assert.assertTrue(theFile.exists());
 		_logger.info("Message file "+theFile.toString()+" successfully created");
 				
-		FileEpr fromEpr = new FileEpr(toEpr.getURL());
+		FileEpr fromEpr = new FileEpr(toEpr.getURI());
 		fromEpr.setInputSuffix(TEST_SUFFIX);
 		fromEpr.setPostSuffix(DONE_SUFFIX);
 		
@@ -216,7 +215,7 @@
 		String contents = "This is the text that travels in the Message body";
 
 		// toEpr for files must be a directory
-		FileEpr toEpr = new FileEpr(_tmpDir.toURL());
+		FileEpr toEpr = new FileEpr(_tmpDir.toURI());
 		toEpr.setInputSuffix(TEST_SUFFIX);
 		
 		Message msg = MessageFactory.getInstance().getMessage();
@@ -232,7 +231,7 @@
 		Assert.assertTrue(theFile.exists());
 		_logger.info("Message file "+theFile.toString()+" successfully created");
 				
-		FileEpr fromEpr = new FileEpr(toEpr.getURL());
+		FileEpr fromEpr = new FileEpr(toEpr.getURI());
 		fromEpr.setInputSuffix(TEST_SUFFIX);
 		fromEpr.setPostSuffix(DONE_SUFFIX);
 		
@@ -257,7 +256,7 @@
 		String contents = "This is the text that travels in the Message body";
 
 		// toEpr for files must be a directory
-		FileEpr toEpr = new FileEpr(_tmpDir.toURL());
+		FileEpr toEpr = new FileEpr(_tmpDir.toURI());
 		toEpr.setInputSuffix(TEST_SUFFIX);
 		
 		Message msg = MessageFactory.getInstance().getMessage();
@@ -274,7 +273,7 @@
 		Assert.assertTrue(theFile.exists());
 		_logger.info("Message file "+theFile.toString()+" successfully created");
 				
-		FileEpr fromEpr = new FileEpr(toEpr.getURL());
+		FileEpr fromEpr = new FileEpr(toEpr.getURI());
 		fromEpr.setInputSuffix(TEST_SUFFIX);
 		// setting postdelete to true will delete input Message files, if they were picked up
 		fromEpr.setPostDelete(true);
@@ -318,7 +317,7 @@
 		Assert.assertTrue(theFile.exists());
 		_logger.info("Invalid Message file "+theFile.toString()+" successfully created");
 				
-		FileEpr fromEpr = new FileEpr(_tmpDir.toURL()) ;
+		FileEpr fromEpr = new FileEpr(_tmpDir.toURI()) ;
 		fromEpr.setInputSuffix(TEST_SUFFIX);
 		fromEpr.setPostSuffix(DONE_SUFFIX);
 		fromEpr.setErrorSuffix(ERROR_SUFFIX);
@@ -347,7 +346,7 @@
 		Assert.assertTrue(theFile.exists());
 		_logger.info("Invalid Message file "+theFile.toString()+" successfully created");
 				
-		FileEpr fromEpr = new FileEpr(_tmpDir.toURL());
+		FileEpr fromEpr = new FileEpr(_tmpDir.toURI());
 		fromEpr.setInputSuffix(TEST_SUFFIX);
 		fromEpr.setPostSuffix(DONE_SUFFIX);
 		fromEpr.setErrorSuffix(ERROR_SUFFIX);

Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/EdtFtpImplUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/EdtFtpImplUnitTest.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/EdtFtpImplUnitTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -1,336 +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 static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.util.embedded.EmbeddableException;
-import org.jboss.internal.soa.esb.util.embedded.ftp.FtpTestUtil;
-import org.jboss.internal.soa.esb.util.embedded.ftp.NoConfigFileFtpServer;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.eprs.FTPEpr;
-import org.jboss.soa.esb.addressing.eprs.FileEpr;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.util.RemoteFileSystem;
-import org.jboss.soa.esb.util.RemoteFileSystemException;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Unit test for EdtFtpImpl that uses an embedded ftp server
- * 
- * @author Daniel Bevenius
- * 
- */
-public class EdtFtpImplUnitTest 
-{
-	private static Logger log = Logger.getLogger( EdtFtpImplUnitTest.class );
-	
-	/* EmbeddedFtp Server */
-	private static NoConfigFileFtpServer ftpServer;
-
-	/* Instance of class under test */
-	private static EdtFtpImpl edtFtpImpl;
-	
-	private static String remoteInputDirName;
-	private static String remoteUploadDirName;
-	private static final String INPUT_SUFFIX = ".txt";
-	private static final String RENAMED_SUFFIX = ".renamed";
-	
-	/* Content for created test files */
-	private static final String TEST_FILE_CONTENT = EdtFtpImplUnitTest.class .getName() + " junit ftp test";
-	private File testFile;
-	private File renamedFile;
-
-	@BeforeClass
-	public static void classSetup() throws EmbeddableException, ConfigurationException, RemoteFileSystemException, MalformedURLException, URISyntaxException
-	{
-		ftpServer = new NoConfigFileFtpServer();
-		ftpServer.setPort( 2221 );
-		ftpServer.start();
-
-		remoteInputDirName = "/" + ftpServer.getLocalInputDir().getName();
-		remoteUploadDirName = "/" + ftpServer.getLocalUploadDir().getName();
-		edtFtpImpl = new EdtFtpImpl( createConfigTree(), true );
-	}
-
-	@AfterClass
-	public static void classTearDown() throws EmbeddableException
-	{
-		try
-		{
-			ftpServer.stop();
-		} 
-		catch (Exception e)
-		{
-			log.warn( e.getMessage() );
-		}
-		
-		if  ( !FtpTestUtil.deleteDir( ftpServer.getFtpServerDir() ) )
-		{
-			log.warn( "Could not delete " +  ftpServer.getFtpServerDir() ) ;
-		}
-	}
-
-	@Before
-	public void setUp()
-	{
-		testFile = FtpTestUtil.createTestFile( ftpServer.getLocalInputDir(), getClass().getName() + INPUT_SUFFIX, TEST_FILE_CONTENT );
-	}
-	
-	@After
-	public void tearDown()
-	{
-		FtpTestUtil.deleteFile( testFile );
-		FtpTestUtil.deleteFile( renamedFile );
-	}
-	
-	@Test
-	public void construtor_FTPEpr() 
-	{
-		try
-		{
-			new EdtFtpImpl( createFTPEpr(), true );
-		}
-		catch ( Exception e )
-		{
-			fail ( e.getMessage() );
-		}
-	}
-	
-	@Test
-	public void getRemoteDir() throws RemoteFileSystemException
-	{
-		String oldRemoteDir =  remoteInputDirName;
-		try
-		{
-			edtFtpImpl.setRemoteDir( remoteUploadDirName );
-			assertEquals( "The remote dir was not changed.", remoteUploadDirName, edtFtpImpl.getRemoteDir() );
-		} 
-		finally
-		{
-			try { edtFtpImpl.setRemoteDir( oldRemoteDir ); } catch (Exception e) { fail( e.getMessage() ); }
-		}
-	}
-
-	@Test
-	public void setRemoteDir() throws RemoteFileSystemException
-	{
-		String oldRemoteDir = remoteInputDirName;
-		try
-		{
-			edtFtpImpl.setRemoteDir( remoteUploadDirName );
-
-			String actualRemoteDir = edtFtpImpl.getRemoteDir();
-			assertFalse( "The setRemoteDir method did not change the directory!", oldRemoteDir.equals( actualRemoteDir ) );
-		} 
-		finally
-		{
-			try { edtFtpImpl.setRemoteDir( oldRemoteDir ); } catch (Exception e) { fail( e.getMessage() ); }
-		}
-	}
-
-	@Test
-	public void getFileListFromRemoteDir() throws RemoteFileSystemException, IOException
-	{
-		String[] fileListFromRemoteDir = edtFtpImpl .getFileListFromRemoteDir( INPUT_SUFFIX );
-		assertNotNull( fileListFromRemoteDir );
-		List<String> fileList = Arrays.asList( fileListFromRemoteDir );
-		assertTrue( "The test file was not included in the List! ", fileList.contains( testFile.getName() ) );
-	}
-
-	@Test
-	public void deleteRemoteFile() throws RemoteFileSystemException
-	{
-		edtFtpImpl.deleteRemoteFile( testFile.getName() );
-		assertFalse( "File was not deleted", testFile.exists() );
-	}
-
-	@Test
-	public void remoteDelete() throws RemoteFileSystemException
-	{
-		edtFtpImpl.remoteDelete( testFile );
-		assertFalse( testFile.exists() );
-	}
-
-	@Test
-	public void renameInRemoteDir() throws RemoteFileSystemException
-	{
-		File from = testFile;
-		String toFileName = from.getName() + RENAMED_SUFFIX;
-			
-		edtFtpImpl.renameInRemoteDir( from.getName(), toFileName );
-
-		renamedFile = new File( ftpServer.getLocalInputDir(), toFileName );
-		assertFalse( "The file was not removed from the filesystem", from .exists() );
-		assertTrue( "The named file does not exist", renamedFile.exists() );
-	}
-
-	@Test
-	public void remoteRename_To_Different_RemoteDir() throws RemoteFileSystemException
-	{
-		File from = createAbsoluteFromFile();
-		File to = createAbsoluteToFileUploadDir();
-
-		edtFtpImpl.remoteRename( from, to );
-
-		renamedFile = new File( ftpServer.getLocalUploadDir(), to.getName() );
-		assertFalse( "The file was not removed from the filesystem", from .exists() );
-		assertTrue( renamedFile + " was not found in dir " + ftpServer.getLocalUploadDir(), renamedFile.exists() );
-	}
-	
-	@Test
-	public void remoteRename_To_Same_RemoteDir() throws RemoteFileSystemException
-	{
-		File from =  createAbsoluteFromFile();
-		File to = createAbsoluteToFile();
-			
-		edtFtpImpl.remoteRename( from, to );
-
-		renamedFile = new File( ftpServer.getLocalInputDir(), testFile.getName() + RENAMED_SUFFIX );
-		assertFalse( testFile.exists() );
-		assertTrue( renamedFile.exists() );
-	}
-	
-	@Test
-	public void downloadFile() throws RemoteFileSystemException, IOException
-	{
-		File localFile = null;
-		File localDownloadedlFile = null;
-		String testFileName = "downloadFileTestFile.txt";
-		try
-		{
-			localFile = FtpTestUtil.createTestFile( ftpServer .getLocalInputDir(), testFileName, TEST_FILE_CONTENT );
-			String remoteFileName = "/input/" + localFile.getName();
-			String downloadFileName = testFileName + ".downloaded";
-
-			edtFtpImpl.downloadFile( remoteFileName, downloadFileName );
-
-			localDownloadedlFile = new File( ftpServer.getRootDir(), downloadFileName );
-			assertTrue( "The remote file should not have been removed.", localFile.exists() );
-			assertTrue( "File was not downloaded ", localDownloadedlFile .exists() );
-		} 
-		finally
-		{
-			FtpTestUtil.deleteFile( localDownloadedlFile );
-			FtpTestUtil.deleteFile( localFile );
-		}
-	}
-
-	@Test
-	public void uploadFile() throws RemoteFileSystemException
-	{
-		File localFile = null;
-		File remoteFile = null;
-		String testFileName = "uploadFileTestFile.txt";
-		try
-		{
-			localFile = FtpTestUtil.createTestFile(  ftpServer.getLocalInputDir(),  testFileName, TEST_FILE_CONTENT );
-			
-			String renameTo = testFileName + RENAMED_SUFFIX;
-			edtFtpImpl.uploadFile( localFile, renameTo );
-			remoteFile = new File ( ftpServer.getLocalInputDir(), renameTo );
-			
-			assertTrue( "The file was not uploaded succesfully." , remoteFile.exists() );
-		} 
-		finally
-		{
-			FtpTestUtil.deleteFile( remoteFile );
-			FtpTestUtil.deleteFile( localFile );
-		}
-	}
-
-	private static ConfigTree createConfigTree()
-	{
-		ConfigTree configTree = new ConfigTree( "junitEdtFtpImplTest" );
-		try
-		{
-			configTree.setAttribute( FileEpr.URL_TAG, ftpServer.getURL().toString() ) ;
-		}
-		catch ( MalformedURLException e )
-		{
-			log.error(  e  );
-			fail ( e.getMessage() );
-		}
-		configTree.setAttribute( RemoteFileSystem.PARMS_FTP_SERVER, ftpServer .getHost() );
-		configTree.setAttribute( RemoteFileSystem.PARMS_USER, ftpServer .getUserName() );
-		configTree.setAttribute( RemoteFileSystem.PARMS_PASSWD, ftpServer .getPassword() );
-		configTree.setAttribute( RemoteFileSystem.PARMS_REMOTE_DIR, remoteInputDirName );
-		configTree.setAttribute( RemoteFileSystem.PARMS_PORT, Integer .toString( ftpServer.getPort() ) );
-		configTree.setAttribute( RemoteFileSystem.PARMS_LOCAL_DIR, ftpServer .getRootDir() );
-		configTree.setAttribute( RemoteFileSystem.PARMS_ASCII, Boolean .toString( false ) );
-		configTree.setAttribute( RemoteFileSystem.PARMS_PASSIVE, Boolean .toString( false ) );
-		return configTree;
-	}
-	
-	private static FTPEpr createFTPEpr() throws MalformedURLException, URISyntaxException
-	{
-		FTPEpr epr = new FTPEpr ( new EPR() );
-		epr.setURL( ftpServer.getURL() );
-		epr.setUserName( ftpServer.getUserName() );
-		epr.setErrorDirectory( ftpServer.getErrorDirName() );
-		epr.setInputSuffix( INPUT_SUFFIX );
-		epr.setPassword( ftpServer.getPassword() );
-		epr.setPostDirectory( ftpServer.getUploadDirName() );
-		epr.setWorkSuffix( ".work" );
-		return epr;
-	}
-	
-	private File createAbsoluteFromFile()
-	{
-		return new File ( remoteInputDirName + "/" + testFile.getName() );
-	}
-	
-	private File createAbsoluteToFile()
-	{
-		return new File ( remoteInputDirName + "/" + testFile.getName() + RENAMED_SUFFIX );
-	}
-	
-	private File createAbsoluteToFileUploadDir()
-	{
-		return new File ( remoteUploadDirName + "/" +  testFile.getName() + RENAMED_SUFFIX );
-	}
-
-	public static junit.framework.Test suite()
-	{
-		return new JUnit4TestAdapter( EdtFtpImplUnitTest.class);
-	}
-	
-}

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/FtpImplUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/FtpImplUnitTest.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/FtpImplUnitTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -0,0 +1,336 @@
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.util.embedded.EmbeddableException;
+import org.jboss.internal.soa.esb.util.embedded.ftp.FtpTestUtil;
+import org.jboss.internal.soa.esb.util.embedded.ftp.NoConfigFileFtpServer;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.addressing.eprs.FileEpr;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.util.RemoteFileSystem;
+import org.jboss.soa.esb.util.RemoteFileSystemException;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Unit test for FtpImpl that uses an embedded ftp server
+ * 
+ * @author Daniel Bevenius
+ * 
+ */
+public class FtpImplUnitTest 
+{
+	private static Logger log = Logger.getLogger( FtpImplUnitTest.class );
+	
+	/* EmbeddedFtp Server */
+	private static NoConfigFileFtpServer ftpServer;
+
+	/* Instance of class under test */
+	private static FtpImpl ftpImpl;
+	
+	private static String remoteInputDirName;
+	private static String remoteUploadDirName;
+	private static final String INPUT_SUFFIX = ".txt";
+	private static final String RENAMED_SUFFIX = ".renamed";
+	
+	/* Content for created test files */
+	private static final String TEST_FILE_CONTENT = FtpImplUnitTest.class .getName() + " junit ftp test";
+	private File testFile;
+	private File renamedFile;
+
+	@BeforeClass
+	public static void classSetup() throws EmbeddableException, ConfigurationException, RemoteFileSystemException, MalformedURLException, URISyntaxException
+	{
+		ftpServer = new NoConfigFileFtpServer();
+		ftpServer.setPort( 2221 );
+		ftpServer.start();
+
+		remoteInputDirName = "/" + ftpServer.getLocalInputDir().getName();
+		remoteUploadDirName = "/" + ftpServer.getLocalUploadDir().getName();
+		ftpImpl = new FtpImpl( createConfigTree(), true );
+	}
+
+	@AfterClass
+	public static void classTearDown() throws EmbeddableException
+	{
+		try
+		{
+			ftpServer.stop();
+		} 
+		catch (Exception e)
+		{
+			log.warn( e.getMessage() );
+		}
+		
+		if  ( !FtpTestUtil.deleteDir( ftpServer.getFtpServerDir() ) )
+		{
+			log.warn( "Could not delete " +  ftpServer.getFtpServerDir() ) ;
+		}
+	}
+
+	@Before
+	public void setUp()
+	{
+		testFile = FtpTestUtil.createTestFile( ftpServer.getLocalInputDir(), getClass().getName() + INPUT_SUFFIX, TEST_FILE_CONTENT );
+	}
+	
+	@After
+	public void tearDown()
+	{
+		FtpTestUtil.deleteFile( testFile );
+		FtpTestUtil.deleteFile( renamedFile );
+	}
+	
+	@Test
+	public void construtor_FTPEpr() 
+	{
+		try
+		{
+			new FtpImpl( createFTPEpr(), true );
+		}
+		catch ( Exception e )
+		{
+			fail ( e.getMessage() );
+		}
+	}
+	
+	@Test
+	public void getRemoteDir() throws RemoteFileSystemException
+	{
+		String oldRemoteDir =  remoteInputDirName;
+		try
+		{
+			ftpImpl.setRemoteDir( remoteUploadDirName );
+			assertEquals( "The remote dir was not changed.", remoteUploadDirName, ftpImpl.getRemoteDir() );
+		} 
+		finally
+		{
+			try { ftpImpl.setRemoteDir( oldRemoteDir ); } catch (Exception e) { fail( e.getMessage() ); }
+		}
+	}
+
+	@Test
+	public void setRemoteDir() throws RemoteFileSystemException
+	{
+		String oldRemoteDir = remoteInputDirName;
+		try
+		{
+			ftpImpl.setRemoteDir( remoteUploadDirName );
+
+			String actualRemoteDir = ftpImpl.getRemoteDir();
+			assertFalse( "The setRemoteDir method did not change the directory!", oldRemoteDir.equals( actualRemoteDir ) );
+		} 
+		finally
+		{
+			try { ftpImpl.setRemoteDir( oldRemoteDir ); } catch (Exception e) { fail( e.getMessage() ); }
+		}
+	}
+
+	@Test
+	public void getFileListFromRemoteDir() throws RemoteFileSystemException, IOException
+	{
+		String[] fileListFromRemoteDir = ftpImpl .getFileListFromRemoteDir( INPUT_SUFFIX );
+		assertNotNull( fileListFromRemoteDir );
+		List<String> fileList = Arrays.asList( fileListFromRemoteDir );
+		assertTrue( "The test file was not included in the List! ", fileList.contains( testFile.getName() ) );
+	}
+
+	@Test
+	public void deleteRemoteFile() throws RemoteFileSystemException
+	{
+		ftpImpl.deleteRemoteFile( testFile.getName() );
+		assertFalse( "File was not deleted", testFile.exists() );
+	}
+
+	@Test
+	public void remoteDelete() throws RemoteFileSystemException
+	{
+		ftpImpl.remoteDelete( testFile );
+		assertFalse( testFile.exists() );
+	}
+
+	@Test
+	public void renameInRemoteDir() throws RemoteFileSystemException
+	{
+		File from = testFile;
+		String toFileName = from.getName() + RENAMED_SUFFIX;
+			
+		ftpImpl.renameInRemoteDir( from.getName(), toFileName );
+
+		renamedFile = new File( ftpServer.getLocalInputDir(), toFileName );
+		assertFalse( "The file was not removed from the filesystem", from .exists() );
+		assertTrue( "The named file does not exist", renamedFile.exists() );
+	}
+
+	@Test
+	public void remoteRename_To_Different_RemoteDir() throws RemoteFileSystemException
+	{
+		File from = createAbsoluteFromFile();
+		File to = createAbsoluteToFileUploadDir();
+
+		ftpImpl.remoteRename( from, to );
+
+		renamedFile = new File( ftpServer.getLocalUploadDir(), to.getName() );
+		assertFalse( "The file was not removed from the filesystem", from .exists() );
+		assertTrue( renamedFile + " was not found in dir " + ftpServer.getLocalUploadDir(), renamedFile.exists() );
+	}
+	
+	@Test
+	public void remoteRename_To_Same_RemoteDir() throws RemoteFileSystemException
+	{
+		File from =  createAbsoluteFromFile();
+		File to = createAbsoluteToFile();
+			
+		ftpImpl.remoteRename( from, to );
+
+		renamedFile = new File( ftpServer.getLocalInputDir(), testFile.getName() + RENAMED_SUFFIX );
+		assertFalse( testFile.exists() );
+		assertTrue( renamedFile.exists() );
+	}
+	
+	@Test
+	public void downloadFile() throws RemoteFileSystemException, IOException
+	{
+		File localFile = null;
+		File localDownloadedlFile = null;
+		String testFileName = "downloadFileTestFile.txt";
+		try
+		{
+			localFile = FtpTestUtil.createTestFile( ftpServer .getLocalInputDir(), testFileName, TEST_FILE_CONTENT );
+			String remoteFileName = "/input/" + localFile.getName();
+			String downloadFileName = testFileName + ".downloaded";
+
+			ftpImpl.downloadFile( remoteFileName, downloadFileName );
+
+			localDownloadedlFile = new File( ftpServer.getRootDir(), downloadFileName );
+			assertTrue( "The remote file should not have been removed.", localFile.exists() );
+			assertTrue( "File was not downloaded ", localDownloadedlFile .exists() );
+		} 
+		finally
+		{
+			FtpTestUtil.deleteFile( localDownloadedlFile );
+			FtpTestUtil.deleteFile( localFile );
+		}
+	}
+
+	@Test
+	public void uploadFile() throws RemoteFileSystemException
+	{
+		File localFile = null;
+		File remoteFile = null;
+		String testFileName = "uploadFileTestFile.txt";
+		try
+		{
+			localFile = FtpTestUtil.createTestFile(  ftpServer.getLocalInputDir(),  testFileName, TEST_FILE_CONTENT );
+			
+			String renameTo = testFileName + RENAMED_SUFFIX;
+			ftpImpl.uploadFile( localFile, renameTo );
+			remoteFile = new File ( ftpServer.getLocalInputDir(), renameTo );
+			
+			assertTrue( "The file was not uploaded succesfully." , remoteFile.exists() );
+		} 
+		finally
+		{
+			FtpTestUtil.deleteFile( remoteFile );
+			FtpTestUtil.deleteFile( localFile );
+		}
+	}
+
+	private static ConfigTree createConfigTree()
+	{
+		ConfigTree configTree = new ConfigTree( "junitFtpImplTest" );
+		try
+		{
+			configTree.setAttribute( FileEpr.URL_TAG, ftpServer.getURL().toString() ) ;
+		}
+		catch ( MalformedURLException e )
+		{
+			log.error(  e  );
+			fail ( e.getMessage() );
+		}
+		configTree.setAttribute( RemoteFileSystem.PARMS_FTP_SERVER, ftpServer .getHost() );
+		configTree.setAttribute( RemoteFileSystem.PARMS_USER, ftpServer .getUserName() );
+		configTree.setAttribute( RemoteFileSystem.PARMS_PASSWD, ftpServer .getPassword() );
+		configTree.setAttribute( RemoteFileSystem.PARMS_REMOTE_DIR, remoteInputDirName );
+		configTree.setAttribute( RemoteFileSystem.PARMS_PORT, Integer .toString( ftpServer.getPort() ) );
+		configTree.setAttribute( RemoteFileSystem.PARMS_LOCAL_DIR, ftpServer .getRootDir() );
+		configTree.setAttribute( RemoteFileSystem.PARMS_ASCII, Boolean .toString( false ) );
+		configTree.setAttribute( RemoteFileSystem.PARMS_PASSIVE, Boolean .toString( false ) );
+		return configTree;
+	}
+	
+	private static FTPEpr createFTPEpr() throws MalformedURLException, URISyntaxException
+	{
+		FTPEpr epr = new FTPEpr ( new EPR() );
+		epr.setURI( ftpServer.getURL().toURI() );
+		epr.setUserName( ftpServer.getUserName() );
+		epr.setErrorDirectory( ftpServer.getErrorDirName() );
+		epr.setInputSuffix( INPUT_SUFFIX );
+		epr.setPassword( ftpServer.getPassword() );
+		epr.setPostDirectory( ftpServer.getUploadDirName() );
+		epr.setWorkSuffix( ".work" );
+		return epr;
+	}
+	
+	private File createAbsoluteFromFile()
+	{
+		return new File ( remoteInputDirName + "/" + testFile.getName() );
+	}
+	
+	private File createAbsoluteToFile()
+	{
+		return new File ( remoteInputDirName + "/" + testFile.getName() + RENAMED_SUFFIX );
+	}
+	
+	private File createAbsoluteToFileUploadDir()
+	{
+		return new File ( remoteUploadDirName + "/" +  testFile.getName() + RENAMED_SUFFIX );
+	}
+
+	public static junit.framework.Test suite()
+	{
+		return new JUnit4TestAdapter( FtpImplUnitTest.class);
+	}
+	
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/FtpImplUnitTest.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/tests/DefaultFileReplyToEprUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/tests/DefaultFileReplyToEprUnitTest.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/tests/DefaultFileReplyToEprUnitTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -105,7 +105,7 @@
         	CourierUtil.deliverMessage(outgoingMsg);
 
         	// Mock a service that picks up the original message and replies
-        	FileEpr serviceEpr = new FileEpr(toEpr.getURL());
+        	FileEpr serviceEpr = new FileEpr(toEpr.getURI());
         	serviceEpr.setInputSuffix(initialSuffix);
         	serviceEpr.setPostDelete(true);
         	PickUpOnlyCourier listener = CourierFactory.getPickupCourier(serviceEpr);

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/tests/DefaultFtpReplyToEprIntegrationTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/tests/DefaultFtpReplyToEprIntegrationTest.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/eprs/tests/DefaultFtpReplyToEprIntegrationTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -31,7 +31,6 @@
 import org.jboss.soa.esb.couriers.CourierFactory;
 import org.jboss.soa.esb.couriers.CourierUtil;
 import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.body.content.BytesBody;
 import org.jboss.soa.esb.message.format.MessageFactory;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -106,7 +105,7 @@
         	CourierUtil.deliverMessage(outgoingMsg);
 
         	// Mock a service that picks up the original message and replies
-        	FTPEpr serviceEpr = new FTPEpr(toEpr.getURL());
+        	FTPEpr serviceEpr = new FTPEpr(toEpr.getURI());
         	serviceEpr.setInputSuffix(initialSuffix);
         	serviceEpr.setPostDelete(true);
         	PickUpOnlyCourier listener = CourierFactory.getPickupCourier(serviceEpr);

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/FTPSUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/FTPSUnitTest.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/FTPSUnitTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -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.addressing.helpers.tests;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.addressing.eprs.FTPSEpr;
+
+/**
+ * Unit tests for the EPR class.
+ * 
+ * @author Mark Little
+ */
+
+public class FTPSUnitTest extends TestCase
+{
+
+	public void testConstructor ()
+	{
+		try
+		{
+			new FTPSEpr(new URI("ftps://foo.com"));
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGet ()
+	{
+		try
+		{
+			FTPSEpr ftp = new FTPSEpr(new URI("ftps://foo.com"));
+			
+			assertEquals(ftp.getURI().toString(), "ftps://foo.com");
+			assertEquals(ftp.getURI().getHost(), "foo.com");
+			assertEquals(ftp.getURI().getScheme(), "ftps");
+			
+			ftp.setPassword("foobar");
+			assertEquals(ftp.getPassword(), "foobar");
+			
+			ftp.setUserName("barfoo");
+			assertEquals(ftp.getUserName(), "barfoo");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/FTPSUnitTest.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/FTPUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/FTPUnitTest.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/FTPUnitTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -53,9 +53,9 @@
 		{
 			FTPEpr ftp = new FTPEpr("ftp://foo.com");
 			
-			assertEquals(ftp.getURL().toString(), "ftp://foo.com");
-			assertEquals(ftp.getURL().getHost(), "foo.com");
-			assertEquals(ftp.getURL().getProtocol(), "ftp");
+			assertEquals(ftp.getURI().toString(), "ftp://foo.com");
+			assertEquals(ftp.getURI().getHost(), "foo.com");
+			assertEquals(ftp.getURI().getScheme(), "ftp");
 			
 			ftp.setPassword("foobar");
 			assertEquals(ftp.getPassword(), "foobar");

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/HTTPUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/HTTPUnitTest.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/HTTPUnitTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -22,6 +22,7 @@
 
 package org.jboss.soa.esb.addressing.helpers.tests;
 
+import java.net.URI;
 import java.net.URL;
 
 import junit.framework.TestCase;
@@ -63,6 +64,11 @@
 			epr.setURL(new URL(url2));
 			
 			assertEquals(epr.getURL().toString(), url2);
+                        
+                        String uri = "http://foo.com";
+                        epr.setURI(new URI(uri));
+                        
+                        assertEquals(epr.getURI().toString(), uri);
 		}
 		catch (Exception ex)
 		{

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/SFTPUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/SFTPUnitTest.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/SFTPUnitTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -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.addressing.helpers.tests;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
+
+/**
+ * Unit tests for the EPR class.
+ * 
+ * @author Mark Little
+ */
+
+public class SFTPUnitTest extends TestCase
+{
+
+	public void testConstructor ()
+	{
+		try
+		{
+			new SFTPEpr(new URI("sftp://foo.com"));
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+	
+	public void testSetGet ()
+	{
+		try
+		{
+			SFTPEpr ftp = new SFTPEpr(new URI("sftp://foo.com"));
+			
+			assertEquals(ftp.getURI().toString(), "sftp://foo.com");
+			assertEquals(ftp.getURI().getHost(), "foo.com");
+			assertEquals(ftp.getURI().getScheme(), "sftp");
+			
+			ftp.setPassword("foobar");
+			assertEquals(ftp.getPassword(), "foobar");
+			
+			ftp.setUserName("barfoo");
+			assertEquals(ftp.getUserName(), "barfoo");
+		}
+		catch (Exception ex)
+		{
+			fail(ex.toString());
+		}
+	}
+
+}


Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/SFTPUnitTest.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -26,7 +26,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.net.URL;
+import java.net.URI;
 
 import junit.framework.TestCase;
 
@@ -36,6 +36,7 @@
 import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.addressing.eprs.EmailEpr;
 import org.jboss.soa.esb.addressing.eprs.FTPEpr;
+import org.jboss.soa.esb.addressing.eprs.FTPSEpr;
 import org.jboss.soa.esb.addressing.eprs.FileEpr;
 import org.jboss.soa.esb.addressing.eprs.HTTPEpr;
 import org.jboss.soa.esb.addressing.eprs.JDBCEpr;
@@ -469,7 +470,7 @@
 
 			assertEquals(theEpr instanceof HTTPEpr, true);
 			
-			assertEquals(((HTTPEpr) theEpr).getURL().toString(), "http://www.foo.bar");
+			assertEquals(theEpr.getURI().toString(), "http://www.foo.bar");
 		}
 		catch (Exception ex)
 		{
@@ -523,7 +524,7 @@
 
 		try
 		{
-			FTPEpr epr = new FTPEpr("http://www.foo.bar");
+			FTPEpr epr = new FTPEpr("ftp://www.foo.bar");
 			
 			epr.setPassive(true);
 			
@@ -555,6 +556,80 @@
 			fail(ex.toString());
 		}
 	}
+        
+        public void testFtpsEPRType ()
+        {
+                Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+
+                try
+                {
+                        FTPSEpr epr = new FTPSEpr(new URI("ftps://www.foo.bar"));
+                        
+                        epr.setPassive(true);
+                        
+                        msg.getHeader().getCall().setTo(epr);
+                        
+                        ByteArrayOutputStream s = new ByteArrayOutputStream();
+                        ObjectOutputStream o = new ObjectOutputStream(s);
+        
+                        o.writeObject(msg);
+                        o.close();
+                
+                        ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+                        ObjectInputStream io = new ObjectInputStream(is);
+
+                        MessageImpl nImpl = (MessageImpl) io.readObject();
+                        
+                        o.close();
+                        
+                        EPR theEpr = nImpl.getHeader().getCall().getTo();
+
+                        assertEquals(theEpr instanceof FTPSEpr, true);
+                }
+                catch (Exception ex)
+                {
+                        log.error(ex);
+                        
+                        fail(ex.toString());
+                }
+        }
+        
+        public void testSftpEPRType ()
+        {
+                Message msg = MessageFactory.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+
+                try
+                {
+                        SFTPEpr epr = new SFTPEpr(new URI("sftp://www.foo.bar"));
+                        
+                        epr.setPassive(true);
+                        
+                        msg.getHeader().getCall().setTo(epr);
+                        
+                        ByteArrayOutputStream s = new ByteArrayOutputStream();
+                        ObjectOutputStream o = new ObjectOutputStream(s);
+        
+                        o.writeObject(msg);
+                        o.close();
+                
+                        ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+                        ObjectInputStream io = new ObjectInputStream(is);
+
+                        MessageImpl nImpl = (MessageImpl) io.readObject();
+                        
+                        o.close();
+                        
+                        EPR theEpr = nImpl.getHeader().getCall().getTo();
+
+                        assertEquals(theEpr instanceof SFTPEpr, true);
+                }
+                catch (Exception ex)
+                {
+                        log.error(ex);
+                        
+                        fail(ex.toString());
+                }
+        }
 	
 	public void testJdbcEPRType ()
 	{
@@ -638,9 +713,9 @@
 
 		try
 		{
-			SFTPEpr epr = new SFTPEpr(new URL("http://www.foo.bar"), new URL("http://www.bar.foo"));
+			SFTPEpr epr = new SFTPEpr(new URI("http://www.foo.bar"), new URI("http://www.bar.foo"));
 
-			assertEquals(epr.getCertificateURL().toString(), "http://www.bar.foo");
+			assertEquals(epr.getCertificateURI().toString(), "http://www.bar.foo");
 			
 			msg.getHeader().getCall().setTo(epr);
 			
@@ -661,7 +736,7 @@
 
 			assertEquals(theEpr instanceof SFTPEpr, true);
 			
-			assertEquals(((SFTPEpr) theEpr).getCertificateURL().toString(), "http://www.bar.foo");
+			assertEquals(((SFTPEpr) theEpr).getCertificateURI().toString(), "http://www.bar.foo");
 		}
 		catch (Exception ex)
 		{

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java	2008-05-01 13:34:52 UTC (rev 19804)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java	2008-05-01 13:49:08 UTC (rev 19805)
@@ -34,7 +34,7 @@
 import org.jboss.soa.esb.message.format.MessageType;
 import org.jboss.soa.esb.util.Util;
 
-import java.net.URL;
+import java.net.URI;
 
 /**
  * Unit tests for the Class class.
@@ -387,7 +387,7 @@
 			
 			assertEquals(theEpr instanceof HTTPEpr, true);
 			
-			assertEquals(((HTTPEpr) theEpr).getURL().toString(), "http://www.foo.bar");
+			assertEquals(theEpr.getURI().toString(), "http://www.foo.bar");
 		}
 		catch (Exception ex)
 		{			
@@ -428,7 +428,7 @@
 
 		try
 		{
-			FTPEpr epr = new FTPEpr("http://www.foo.bar");
+			FTPEpr epr = new FTPEpr("ftp://www.foo.bar");
 			
 			epr.setPassive(true);
 			
@@ -450,6 +450,60 @@
 			fail(ex.toString());
 		}
 	}
+        
+        public void testFtpsEPRType ()
+        {
+                Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+                try
+                {
+                        FTPSEpr epr = new FTPSEpr(new URI("ftps://www.foo.bar"));
+                        
+                        epr.setPassive(true);
+                        
+                        msg.getHeader().getCall().setTo(epr);
+                        
+                        final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+                        log.debug("Document is "+xmlRepresentation);
+                        
+                        final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+                        
+                        EPR theEpr = nImpl.getHeader().getCall().getTo();
+                        
+                        assertEquals(theEpr instanceof FTPSEpr, true);
+                }
+                catch (Exception ex)
+                {                       
+                        fail(ex.toString());
+                }
+        }
+        
+        public void testSftpEPRType ()
+        {
+                Message msg = MessageFactory.getInstance().getMessage(MessageType.JBOSS_XML);
+
+                try
+                {
+                        SFTPEpr epr = new SFTPEpr(new URI("sftp://www.foo.bar"));
+                        
+                        epr.setPassive(true);
+                        
+                        msg.getHeader().getCall().setTo(epr);
+                        
+                        final String xmlRepresentation = msgToXML((MessageImpl)msg) ;
+                        log.debug("Document is "+xmlRepresentation);
+                        
+                        final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
+                        
+                        EPR theEpr = nImpl.getHeader().getCall().getTo();
+                        
+                        assertEquals(theEpr instanceof SFTPEpr, true);
+                }
+                catch (Exception ex)
+                {                       
+                        fail(ex.toString());
+                }
+        }
 	
 	public void testJdbcEPRType ()
 	{
@@ -513,9 +567,9 @@
 
 		try
 		{
-			SFTPEpr epr = new SFTPEpr(new URL("http://www.foo.bar"), new URL("http://www.bar.foo"));
+			SFTPEpr epr = new SFTPEpr(new URI("http://www.foo.bar"), new URI("http://www.bar.foo"));
 
-			assertEquals(epr.getCertificateURL().toString(), "http://www.bar.foo");
+			assertEquals(epr.getCertificateURI().toString(), "http://www.bar.foo");
 			
 			msg.getHeader().getCall().setTo(epr);
 			
@@ -528,7 +582,7 @@
 			
 			assertEquals(theEpr instanceof SFTPEpr, true);
 			
-			assertEquals(((SFTPEpr) theEpr).getCertificateURL().toString(), "http://www.bar.foo");
+			assertEquals(((SFTPEpr)theEpr).getCertificateURI().toString(), "http://www.bar.foo");
 		}
 		catch (Exception ex)
 		{			

Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/qa/lib/ext/edtftpj-pro.jar
===================================================================
(Binary files differ)

Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/qa/lib/ext/license.jar
===================================================================
(Binary files differ)




More information about the jboss-svn-commits mailing list