Commit bf1cdea7 authored by afreyssin's avatar afreyssin
Browse files

Minor changes.

parent f6a9fb53
......@@ -159,13 +159,22 @@ public class FtpQueueImpl extends QueueImpl {
}
public ClientMessages preProcess(AgentId from, ClientMessages not) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"--- " + this + " preProcess : not.getMessages = " + not.getMessages().size());
for (Iterator msgs = not.getMessages().iterator(); msgs.hasNext();) {
Message msg = (Message) msgs.next();
if (isFtpMsg(msg)) {
doProcessFtp(not,msg);
not.getMessages().remove(msg);
doProcessFtp(not, msg);
msgs.remove();
}
}
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"--- " + this + " preProcess : not.getMessages = " + not.getMessages().size());
if (not.getMessages().size() > 0) {
return not;
}
......@@ -198,6 +207,10 @@ public class FtpQueueImpl extends QueueImpl {
FtpMessage ftpMsg = new FtpMessage(msg);
transferTable.put(ftpMsg.getIdentifier(),ftpMsg);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "--- " + this + " doProcessFtp: launch FtpThread (" + transferTable.size() + ')');
FtpThread t = new FtpThread(transfer,
(FtpMessage) ftpMsg.clone(),
getId(),
......@@ -211,7 +224,7 @@ public class FtpQueueImpl extends QueueImpl {
} else {
DMQManager dmqManager = new DMQManager(not.getDMQId(), dmqId, getId());
nbMsgsSentToDMQSinceCreation++;
dmqManager.addDeadMessage(msg, MessageErrorConstants.NOT_WRITEABLE);
dmqManager.addDeadMessage(msg, MessageErrorConstants.UNEXPECTED_ERROR);
dmqManager.sendToDMQ();
}
}
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2008 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2010 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -150,34 +150,14 @@ public class FtpThread extends Thread {
crc);
file = file.replace('\\','/');
if (!file.startsWith("/"))
file = "/" + file;
if (!file.startsWith("/")) file = "/" + file;
URI uri = new URI("file",null,file,null,null);
URI uri = new URI("file", null, file, null, null);
uri = uri.normalize();
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "--- doFtp : uri = " + uri);
// StringBuffer sb = new StringBuffer();
// sb.append(protocol + "://");
// sb.append(user);
// sb.append(":");
// sb.append("****");//pass);
// sb.append("@");
// sb.append(InetAddress.getLocalHost().getHostName());
// if (port > -1) {
// sb.append(":");
// sb.append(port);
// }
// sb.append("/");
// if (path != null)
// sb.append(path + "/");
// sb.append(fileName);
// sb.append(";type=");
// sb.append(type);
FtpMessage clone = (FtpMessage) msg.clone();
clone.clearProperties();
for (Enumeration e = msg.getPropertyNames(); e.hasMoreElements(); ) {
......@@ -191,6 +171,9 @@ public class FtpThread extends Thread {
clone.getSharedMessage()));
} catch (Exception exc) {
if (logger.isLoggable(BasicLevel.ERROR))
logger.log(BasicLevel.ERROR, "--- doFtp", exc);
DMQManager dmqManager = new DMQManager(dmqId, destId);
dmqManager.addDeadMessage(msg.getSharedMessage(), MessageErrorConstants.UNEXPECTED_ERROR);
dmqManager.sendToDMQ();
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2007 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2010 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Nicolas Tachker (ScalAgent)
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package com.scalagent.joram.mom.dest.ftp;
......@@ -30,8 +30,7 @@ import net.sf.jftp.net.ConnectionHandler;
import net.sf.jftp.net.ConnectionListener;
import net.sf.jftp.net.FtpConnection;
public class TransferImplJftp
implements TransferItf, ConnectionListener {
public class TransferImplJftp implements TransferItf, ConnectionListener {
private boolean established = false;
......@@ -40,10 +39,8 @@ public class TransferImplJftp
private ConnectionHandler handler = new ConnectionHandler();
public String getFile(String protocol,
String host,
int port,
String user,
String pass,
String host, int port,
String user, String pass,
String remotePath,
String localPath,
String remoteFileName,
......@@ -100,7 +97,6 @@ public class TransferImplJftp
return file.getAbsolutePath();
}
//------ needed by ConnectionListener interface ------
// called if the remote directory has changed
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2007 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2010 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Nicolas Tachker (ScalAgent)
* Initial developer(s): ScalAgent Distributed Technologies
* Contributor(s):
*/
package com.scalagent.joram.mom.dest.ftp;
......@@ -29,14 +29,11 @@ import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
public class TransferImplRef
implements TransferItf {
public class TransferImplRef implements TransferItf {
public String getFile(String protocol,
String host,
int port,
String user,
String pass,
String host, int port,
String user, String pass,
String remotePath,
String localPath,
String remoteFileName,
......@@ -46,32 +43,25 @@ public class TransferImplRef
StringBuffer sb = new StringBuffer();
sb.append("ftp://");
sb.append(user);
sb.append(":");
sb.append(pass);
sb.append("@");
sb.append(host);
sb.append("ftp://").append(user).append(':').append(pass).append('@').append(host);
if (port > -1) {
sb.append(":");
sb.append(port);
sb.append(":").append(port);
}
sb.append('/');
if (remotePath != null) {
sb.append(remotePath).append('/');
}
sb.append("/");
if (remotePath != null)
sb.append(remotePath + "/");
sb.append(remoteFileName);
sb.append(";type=");
sb.append(type);
sb.append(";type=").append(type);
URL url = new URL(sb.toString());
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream();
File file = new File(localPath,localFileName);
File file = new File(localPath, localFileName);
BufferedOutputStream bos = new BufferedOutputStream(
new FileOutputStream(file));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
int c = is.read();
while (c != -1) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment