[jboss-svn-commits] JBL Code SVN: r8269 - labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Dec 12 14:27:09 EST 2006
Author: estebanschifman
Date: 2006-12-12 14:27:06 -0500 (Tue, 12 Dec 2006)
New Revision: 8269
Modified:
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
Log:
Fix FileCourier bugs: in deliver(Message) to remote filesystems
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java 2006-12-12 18:42:12 UTC (rev 8268)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java 2006-12-12 19:27:06 UTC (rev 8269)
@@ -24,7 +24,6 @@
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
@@ -33,8 +32,8 @@
import javax.xml.parsers.ParserConfigurationException;
import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.couriers.helpers.FileHandler;
import org.jboss.internal.soa.esb.couriers.helpers.FileHandlerFactory;
-import org.jboss.internal.soa.esb.couriers.helpers.FileHandler;
import org.jboss.internal.soa.esb.couriers.helpers.LocalFileHandler;
import org.jboss.soa.esb.addressing.eprs.FileEpr;
import org.jboss.soa.esb.couriers.CourierException;
@@ -138,31 +137,48 @@
if (null==handler)
throw new CourierException("Can't find appropriate file handler for "+_url.toString());
- File dir = new File(_url.getFile());
- try
- {
- File tmpFile = CourierUtil.messageToLocalFile(dir, message);
+ File tmpFile = null;
- Method upload = null;
- try { upload = handler.getClass().getMethod("uploadFile",new Class[] {File.class}); }
- catch (NoSuchMethodException e) { /* OK- we just won't call it */ }
- if (null!=upload)
+ if (handler instanceof LocalFileHandler)
+ try
{
- try { upload.invoke(handler, new Object[] {tmpFile}); }
- catch (InvocationTargetException e) {throw new CourierException(e);}
- catch (IllegalAccessException e) {throw new CourierException(e);}
- finally { tmpFile.delete(); }
+ File dir = new File(_url.getFile());
+ tmpFile = CourierUtil.messageToLocalFile(dir, message);
+
+ String name = message.getHeader().getCall().getMessageID().toString();
+ name += _outputSuffix;
+ handler.renameFile(tmpFile, new File(dir,name));
+
+ return true;
}
+ catch (IOException e) { throw new CourierException(e);}
+ catch (ParserConfigurationException e){ throw new CourierException(e);}
+ catch (URISyntaxException e) { throw new CourierException(e);}
+ try
+ {
+ Method upload = handler.getClass().getMethod("uploadFile",new Class[] {File.class});
+
+ File dir = new File(System.getProperty("io.temp.dir",DEFAULT_TMP));
+ tmpFile = CourierUtil.messageToLocalFile(dir, message);
String name = message.getHeader().getCall().getMessageID().toString();
name += _outputSuffix;
- handler.renameFile(tmpFile, new File(dir,name));
+
+ File messageFile = new File(dir,name);
+ tmpFile.renameTo(messageFile);
+ tmpFile = messageFile;
+ upload.invoke(handler, new Object[] {messageFile});
return true;
}
- catch (IOException e) { throw new CourierException(e);}
- catch (ParserConfigurationException e){ throw new CourierException(e);}
- catch (URISyntaxException e) { throw new CourierException(e);}
+ catch (Exception e) {throw new CourierException(e);}
+ finally
+ {
+ if (null!=tmpFile)
+ tmpFile.delete();
+ }
+
+
} //________________________________
@@ -276,6 +292,9 @@
return new File(dir,input.getName()+sfx);
} //________________________________
+ protected static final String DEFAULT_TMP
+ = (System.getProperty("os.name").toLowerCase().contains("window")) ? "/temp" : "/tmp";
+
protected String _outputSuffix;
protected URL _url;
protected boolean _receiverOnly;
More information about the jboss-svn-commits
mailing list