camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r953939 - in /camel/trunk/components/camel-jetty/src: main/java/org/apache/camel/component/jetty/JettyHttpComponent.java test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
Date Sat, 12 Jun 2010 05:40:41 GMT
Author: ningjiang
Date: Sat Jun 12 05:40:41 2010
New Revision: 953939

URL: http://svn.apache.org/viewvc?rev=953939&view=rev
Log:
CAMEL-2806 Fixed the camel-jetty MultiPartForm temp directory issue

Modified:
    camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java

Modified: camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java?rev=953939&r1=953938&r2=953939&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
(original)
+++ camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
Sat Jun 12 05:40:41 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.jetty;
 
+import java.io.File;
 import java.net.URI;
 import java.util.HashMap;
 import java.util.List;
@@ -35,6 +36,7 @@ import org.apache.camel.spi.ManagementAg
 import org.apache.camel.spi.ManagementStrategy;
 import org.apache.camel.util.CastUtils;
 import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -473,8 +475,13 @@ public class JettyHttpComponent extends 
         CamelContext camelContext = this.getCamelContext();
         FilterHolder filterHolder = new FilterHolder();
         filterHolder.setInitParameter("deleteFiles", "true");
-        if (camelContext.getProperties().get(TMP_DIR) != null) {
-            context.setAttribute("javax.servlet.context.tempdir", camelContext.getProperties().get(TMP_DIR));
+        if (ObjectHelper.isNotEmpty(camelContext.getProperties().get(TMP_DIR))) {
+            File file =  new File(camelContext.getProperties().get(TMP_DIR));           

+            if (!file.isDirectory()) {
+                throw new RuntimeCamelException("The temp file directory of camel-jetty is
not exists, please recheck it with directory name :"
+                                                + camelContext.getProperties().get(TMP_DIR));
+            }
+            context.setAttribute("javax.servlet.context.tempdir", file);
         }
         filterHolder.setFilter(new MultiPartFilter());
         //add the default MultiPartFilter filter for it

Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java?rev=953939&r1=953938&r2=953939&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
(original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/MultiPartFormTest.java
Sat Jun 12 05:40:41 2010
@@ -63,6 +63,10 @@ public class MultiPartFormTest extends C
         return new RouteBuilder() {
             public void configure() throws Exception {
                 // START SNIPPET: e1
+                // Set the jetty temp directory which store the file 
+                // camel-jetty will clean up the file after it handled the request.
+                getContext().getProperties().put("CamelJettyTempDir", "target");
+                
                 from("jetty://http://localhost:9080/test").process(new Processor() {
 
                     public void process(Exchange exchange) throws Exception {



Mime
View raw message