[jboss-svn-commits] JBL Code SVN: r8584 - in labs/jbossesb/trunk/product: core/rosetta/src/org/jboss/internal/soa/esb/util core/rosetta/src/org/jboss/soa/esb/addressing/eprs core/rosetta/src/org/jboss/soa/esb/util samples/quickstarts/helloworld_file_action/src/quickstart/hw_file_action/test
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Dec 23 15:35:15 EST 2006
Author: estebanschifman
Date: 2006-12-23 15:35:05 -0500 (Sat, 23 Dec 2006)
New Revision: 8584
Modified:
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java
labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_action/src/quickstart/hw_file_action/test/CreateTestFile.java
Log:
Tune base classes for quickstart: FTP gateway
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java 2006-12-23 12:41:51 UTC (rev 8583)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/util/EdtFtpImpl.java 2006-12-23 20:35:05 UTC (rev 8584)
@@ -30,6 +30,7 @@
import org.apache.log4j.Logger;
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;
@@ -179,19 +180,25 @@
private void checkParms() throws Exception
{
- m_sFtpServer = m_oParms.getAttribute(PARMS_FTP_SERVER);
+ String att = m_oParms.getAttribute(FileEpr.URL_TAG);
+ URL url = (null==att) ? null : new URL(att);
+ m_sFtpServer = (null != url) ? url.getHost()
+ : m_oParms.getAttribute(PARMS_FTP_SERVER);
if (null == m_sFtpServer)
throw new Exception("No FTP server specified");
- m_sUser = m_oParms.getAttribute(PARMS_USER);
+ String[] sa = (null == url) ? null
+ : url.getAuthority().split(":");
+ m_sUser = (null!=sa) ? sa[0] :m_oParms.getAttribute(PARMS_USER);
if (null == m_sUser)
throw new Exception("No username specified for FTP");
- m_sPasswd = m_oParms.getAttribute(PARMS_PASSWD);
+ m_sPasswd = (null!=sa) ? sa[1] :m_oParms.getAttribute(PARMS_PASSWD);
if (null == m_sPasswd)
throw new Exception("No password specified for FTP");
- m_sRemoteDir = m_oParms.getAttribute(PARMS_REMOTE_DIR);
+ m_sRemoteDir = (null != url) ? url.getFile()
+ : m_oParms.getAttribute(PARMS_REMOTE_DIR);
if (null == m_sRemoteDir)
m_sRemoteDir = "";
@@ -200,7 +207,10 @@
m_sLocalDir = ".";
String sAux = m_oParms.getAttribute(PARMS_PORT);
- m_iPort = (null == sAux) ? 21 : Integer.parseInt(sAux);
+ m_iPort = (null != url) ? url.getPort()
+ : (null == sAux) ? 21 : Integer.parseInt(sAux);
+ if (m_iPort < 0)
+ m_iPort = new URL("ftp://").getDefaultPort();
// Dec-2006 (b_georges): it has been decided to set the Type to binary.
m_oXferType = FTPTransferType.BINARY;
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java 2006-12-23 12:41:51 UTC (rev 8583)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/addressing/eprs/FileEpr.java 2006-12-23 20:35:05 UTC (rev 8584)
@@ -52,6 +52,7 @@
public static final String ERROR_DIR_TAG = "errorDir";
public static final String ERROR_SUFFIX_TAG = "errorSuffix";
public static final String ERROR_DEL_TAG = "errorDelete";
+ public static final String URL_TAG = "URL";
public FileEpr (EPR epr)
{
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java 2006-12-23 12:41:51 UTC (rev 8583)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/util/RemoteFileSystemFactory.java 2006-12-23 20:35:05 UTC (rev 8584)
@@ -22,12 +22,9 @@
package org.jboss.soa.esb.util;
-import java.io.FileNotFoundException;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
-import java.net.UnknownHostException;
import org.jboss.internal.soa.esb.util.EdtFtpImpl;
import org.jboss.internal.soa.esb.util.SecureFtpImpl;
@@ -35,7 +32,6 @@
import org.jboss.soa.esb.addressing.eprs.FileEpr;
import org.jboss.soa.esb.addressing.eprs.SFTPEpr;
import org.jboss.soa.esb.helpers.ConfigTree;
-import org.xml.sax.SAXException;
public class RemoteFileSystemFactory
{
@@ -91,38 +87,24 @@
public static RemoteFileSystem getRemoteFileSystem(ConfigTree p_oP,
boolean p_bConnect) throws RemoteFileSystemException
{
- final String protocol = p_oP.getAttribute(RemoteFileSystem.PARMS_PROTOCOL) ;
+ String att = p_oP.getAttribute(FileEpr.URL_TAG);
+ URL url = null;
+ try { url = (null==att) ? null : new URL(att); }
+ catch (MalformedURLException e) { /* OK just leave it null */}
+
+ final String protocol = (null!=url) ? url.getProtocol()
+ : p_oP.getAttribute(RemoteFileSystem.PARMS_PROTOCOL) ;
try
{
if (RemoteFileSystem.FTP_PROTOCOL.equals(protocol))
return new EdtFtpImpl(p_oP, p_bConnect);
else if (RemoteFileSystem.SFTP_PROTOCOL.equals(protocol))
return new SecureFtpImpl(p_oP, p_bConnect);
- } catch (UnknownHostException ex)
+ }
+ catch (Exception ex)
{
throw new RemoteFileSystemException(ex);
- } catch (URISyntaxException e)
- {
- throw new RemoteFileSystemException(e);
- } catch (FileNotFoundException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SAXException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
-
- } catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
throw new RemoteFileSystemException("Unknown protocol: " + protocol);
}
-
}
Modified: labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_action/src/quickstart/hw_file_action/test/CreateTestFile.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_action/src/quickstart/hw_file_action/test/CreateTestFile.java 2006-12-23 12:41:51 UTC (rev 8583)
+++ labs/jbossesb/trunk/product/samples/quickstarts/helloworld_file_action/src/quickstart/hw_file_action/test/CreateTestFile.java 2006-12-23 20:35:05 UTC (rev 8584)
@@ -1,8 +1,7 @@
package quickstart.hw_file_action.test;
-import java.io.File;
-import java.io.IOException;
import java.io.BufferedWriter;
+import java.io.File;
import java.io.FileWriter;
public class CreateTestFile {
More information about the jboss-svn-commits
mailing list