[jboss-svn-commits] JBL Code SVN: r8097 - labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Dec 6 08:39:58 EST 2006
Author: b_georges
Date: 2006-12-06 08:39:55 -0500 (Wed, 06 Dec 2006)
New Revision: 8097
Added:
labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/FtpGatewayListener.java
labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/GatewayException.java
Log:
Added Gateway classes
Added: labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/FtpGatewayListener.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/FtpGatewayListener.java 2006-12-06 13:34:57 UTC (rev 8096)
+++ labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/FtpGatewayListener.java 2006-12-06 13:39:55 UTC (rev 8097)
@@ -0,0 +1,161 @@
+/*
+ * 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.listeners.gateway;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.util.FtpClientUtil;
+import org.jboss.soa.esb.util.Util;
+
+public class FtpGatewayListener extends FileGatewayListener
+{
+ protected FtpGatewayListener() {}
+ public FtpGatewayListener(GatewayListenerController commandListener, ConfigTree config)
+ throws Exception
+ {
+ super(commandListener,config);
+ }
+
+ protected void checkMyParms() throws Exception
+ {
+ super.checkMyParms();
+
+
+ FtpClientUtil ftpClient = new FtpClientUtil(_config,false);
+ ftpClient.quit();
+
+ // Copy FTP parameters to be passed to the action class (inside the WorkingFile class)
+ // This is a kludge - we have to get back to this (ES)
+ String[] sa = new String[]
+ {FtpClientUtil.PARMS_FTP_SERVER
+ ,FtpClientUtil.PARMS_USER
+ ,FtpClientUtil.PARMS_PASSWD
+ ,FtpClientUtil.PARMS_PASSIVE
+ ,FtpClientUtil.PARMS_PORT
+ };
+ for (String sProp : sa)
+ {
+ String sVal = _config.getAttribute(sProp);
+ if (!Util.isNullString(sVal))
+ _ftpArguments.put(sProp,sVal);
+ } }
+
+ @Override
+ protected void seeIfOkToWorkOnDir (File p_oDir) throws GatewayException
+ {
+ // Bruno: is there any way that the remote directory exists, that we can
+ // read it, and that that we can write on it ?
+ // please see the AnewFileGatewayListener class to see what the method does there
+ } //________________________________
+
+ @Override
+ boolean deleteFile(File file) throws GatewayException
+ {
+ // Bruno: please check this and the rest of the methods.
+ // I just copied the RemoteDirectoryPoller, but I know you have been working on this
+ // so what I copied here could be stale
+ FtpClientUtil ftpClient=null;
+ try
+ {
+ ftpClient = new FtpClientUtil(_config,true);
+ ftpClient.deleteRemoteFile(file.toString());
+ return true;
+ }
+ catch (Exception e) { throw new GatewayException(e); }
+ finally
+ {
+ if (null!=ftpClient)
+ ftpClient.quit();
+ }
+ }
+
+
+ @Override
+ byte[] getFileContents(File file) throws GatewayException
+ {
+ FtpClientUtil ftpClient=null;
+ try
+ {
+ File temp = File.createTempFile("FTPdown",".tmp");
+ temp.delete();
+ ftpClient = new FtpClientUtil(_config,true);
+ ftpClient.downloadFile(file.toString(), temp.toString());
+ return getFileContents(temp);
+ }
+ catch (Exception e) { throw new GatewayException(e); }
+ finally
+ {
+ if (null!=ftpClient)
+ ftpClient.quit();
+ }
+ }
+
+
+ @Override
+ File[] getFileList(String suffix) throws GatewayException
+ {
+ FtpClientUtil ftpClient = null;
+ try
+ {
+ ftpClient = new FtpClientUtil(_config,true);
+ ftpClient.setRemoteDir(FtpClientUtil.fileToFtpString(_inputDirectory));
+ String[] sa = ftpClient.getFileListFromRemoteDir(_inputSuffix);
+ File[] oaRet = new File[(null==sa)?0:sa.length];
+ int i1 = 0;
+ if (null!=sa)
+ for (String sCurr : sa)
+ oaRet[i1++] = new File(sCurr);
+ return oaRet;
+ }
+ catch (Exception e) { throw new GatewayException(e); }
+ finally
+ {
+ if (null!=ftpClient)
+ ftpClient.quit();
+ }
+ }
+
+
+ @Override
+ boolean renameFile(File from, File to) throws GatewayException
+ {
+ FtpClientUtil ftpClient=null;
+ try
+ {
+ ftpClient = new FtpClientUtil(_config,true);
+ ftpClient.renameInRemoteDir(from.toString(), to.toString());
+ return true;
+ }
+ catch (Exception e) { throw new GatewayException(e); }
+ finally
+ {
+ if (null!=ftpClient)
+ ftpClient.quit();
+ }
+ }
+
+ protected Map<String,String> _ftpArguments = new HashMap<String, String>();
+}
Property changes on: labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/FtpGatewayListener.java
___________________________________________________________________
Name: svn:executable
+ *
Added: labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/GatewayException.java
===================================================================
--- labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/GatewayException.java 2006-12-06 13:34:57 UTC (rev 8096)
+++ labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/GatewayException.java 2006-12-06 13:39:55 UTC (rev 8097)
@@ -0,0 +1,54 @@
+/*
+ * 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.listeners.gateway;
+
+import org.jboss.soa.esb.BaseException;
+
+/**
+ * Dispatch Exception.
+ * @author b_georges
+ * @since Version 4.0
+ */
+public class GatewayException extends BaseException {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct an exception instance.
+ * @param message Exception message.
+ */
+ public GatewayException(String message) { super(message); }
+
+ /**
+ * Construct an exception instance.
+ * @param message Exception message.
+ * @param cause Exception cause.
+ */
+ public GatewayException(String message, Throwable cause) { super(message, cause); }
+
+ /**
+ * Construct an exception instance.
+ * @param cause Exception cause.
+ */
+ public GatewayException(Throwable cause) { super(cause); }
+}
Property changes on: labs/jbossesb/workspace/b_georges/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/GatewayException.java
___________________________________________________________________
Name: svn:executable
+ *
More information about the jboss-svn-commits
mailing list