camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1073657 - in /camel/trunk: components/camel-restlet/ components/camel-restlet/src/main/java/org/apache/camel/component/restlet/ components/camel-restlet/src/test/java/org/apache/camel/component/restlet/ parent/ platforms/karaf/features/src...
Date Wed, 23 Feb 2011 09:37:30 GMT
Author: davsclaus
Date: Wed Feb 23 09:37:30 2011
New Revision: 1073657

URL: http://svn.apache.org/viewvc?rev=1073657&view=rev
Log:
CAMEL-3701: camel-restlet upgraded to reslet 2.0.5. Thanks to Michael Shorter for patch.

Modified:
    camel/trunk/components/camel-restlet/pom.xml
    camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
    camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
    camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletBinding.java
    camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
    camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConsumer.java
    camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
    camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
    camel/trunk/parent/pom.xml
    camel/trunk/platforms/karaf/features/src/main/resources/features.xml

Modified: camel/trunk/components/camel-restlet/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/pom.xml?rev=1073657&r1=1073656&r2=1073657&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/pom.xml (original)
+++ camel/trunk/components/camel-restlet/pom.xml Wed Feb 23 09:37:30 2011
@@ -53,13 +53,9 @@
     </dependency>
 
     <dependency>
-      <groupId>org.restlet</groupId>
+      <groupId>org.restlet.jse</groupId>
       <artifactId>org.restlet</artifactId>
-    </dependency>
-    <!-- restlet engine is needed at runtime -->
-    <dependency>
-      <groupId>com.noelios.restlet</groupId>
-      <artifactId>com.noelios.restlet</artifactId>      
+      <version>${restlet-version}</version>
     </dependency>
 
     <!-- test artifacts -->

Modified: camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java?rev=1073657&r1=1073656&r2=1073657&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
(original)
+++ camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
Wed Feb 23 09:37:30 2011
@@ -16,33 +16,35 @@
  */
 package org.apache.camel.component.restlet;
 
+import java.io.File;
+import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Map;
-
 import javax.xml.transform.dom.DOMSource;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
+import org.apache.camel.component.file.GenericFile;
 import org.apache.camel.converter.jaxp.StringSource;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
+import org.restlet.Request;
+import org.restlet.Response;
 import org.restlet.data.ChallengeResponse;
 import org.restlet.data.ChallengeScheme;
 import org.restlet.data.CharacterSet;
 import org.restlet.data.Form;
 import org.restlet.data.MediaType;
 import org.restlet.data.Method;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
 import org.restlet.data.Status;
+import org.restlet.representation.FileRepresentation;
+import org.restlet.representation.InputRepresentation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Default Restlet binding implementation
- *
- * @version 
  */
 public class DefaultRestletBinding implements RestletBinding, HeaderFilterStrategyAware {
     private static final Logger LOG = LoggerFactory.getLogger(DefaultRestletBinding.class);
@@ -213,11 +215,29 @@ public class DefaultRestletBinding imple
             }
         }
 
-        String text = out.getBody(String.class);
+        // set response body according to the message body
+        Object body = out.getBody();
+        if (body instanceof GenericFile) {
+            // grab body from generic file holder
+            GenericFile gf = (GenericFile) body;
+            body = gf.getBody();
+        }
+
+        if (body == null) {
+            // empty response
+            response.setEntity("", MediaType.TEXT_PLAIN);
+        } else if (body instanceof InputStream) {
+            response.setEntity(new InputRepresentation(out.getBody(InputStream.class), mediaType));
+        } else if (body instanceof File) {
+            response.setEntity(new FileRepresentation(out.getBody(File.class), mediaType));
+        } else if (body != null) {
+            // fallback and use string
+            String text = out.getBody(String.class);
+            response.setEntity(text, mediaType);
+        }
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Populate Restlet response from exchange body: " + text);
+            LOG.debug("Populate Restlet response from exchange body: " + body);
         }
-        response.setEntity(text, mediaType);
 
         if (exchange.getProperty(Exchange.CHARSET_NAME) != null) {
             CharacterSet cs = CharacterSet.valueOf(exchange.getProperty(Exchange.CHARSET_NAME,
String.class));

Modified: camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java?rev=1073657&r1=1073656&r2=1073657&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
(original)
+++ camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/MethodBasedRouter.java
Wed Feb 23 09:37:30 2011
@@ -20,10 +20,10 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import org.restlet.Request;
+import org.restlet.Response;
 import org.restlet.Restlet;
 import org.restlet.data.Method;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
 import org.restlet.data.Status;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

Modified: camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletBinding.java?rev=1073657&r1=1073656&r2=1073657&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletBinding.java
(original)
+++ camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletBinding.java
Wed Feb 23 09:37:30 2011
@@ -17,8 +17,8 @@
 package org.apache.camel.component.restlet;
 
 import org.apache.camel.Exchange;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
+import org.restlet.Request;
+import org.restlet.Response;
 
 /**
  * Interface for converting between Camel message and Restlet message.

Modified: camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java?rev=1073657&r1=1073656&r2=1073657&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
(original)
+++ camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletComponent.java
Wed Feb 23 09:37:30 2011
@@ -27,12 +27,13 @@ import org.apache.camel.impl.HeaderFilte
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.restlet.Component;
-import org.restlet.Guard;
 import org.restlet.Restlet;
 import org.restlet.Server;
 import org.restlet.data.ChallengeScheme;
 import org.restlet.data.Method;
 import org.restlet.data.Protocol;
+import org.restlet.security.ChallengeAuthenticator;
+import org.restlet.security.MapVerifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -188,11 +189,13 @@ public class RestletComponent extends He
         
         Map<String, String> realm = endpoint.getRestletRealm();
         if (realm != null && realm.size() > 0) {
-            Guard guard = new Guard(component.getContext().createChildContext(), 
+            ChallengeAuthenticator guard = new ChallengeAuthenticator(component.getContext().createChildContext(),
                     ChallengeScheme.HTTP_BASIC, "Camel-Restlet Endpoint Realm");
+            MapVerifier verifier = new MapVerifier();
             for (Map.Entry<String, String> entry : realm.entrySet()) {
-                guard.getSecrets().put(entry.getKey(), entry.getValue().toCharArray());
+                verifier.getLocalSecrets().put(entry.getKey(), entry.getValue().toCharArray());
             }
+            guard.setVerifier(verifier);
             guard.setNext(target);
             target = guard;
             if (LOG.isDebugEnabled()) {

Modified: camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConsumer.java?rev=1073657&r1=1073656&r2=1073657&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConsumer.java
(original)
+++ camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletConsumer.java
Wed Feb 23 09:37:30 2011
@@ -21,9 +21,9 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultConsumer;
+import org.restlet.Request;
+import org.restlet.Response;
 import org.restlet.Restlet;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java?rev=1073657&r1=1073656&r2=1073657&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
(original)
+++ camel/trunk/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
Wed Feb 23 09:37:30 2011
@@ -26,8 +26,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
 import org.restlet.Client;
 import org.restlet.Context;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
+import org.restlet.Request;
+import org.restlet.Response;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java?rev=1073657&r1=1073656&r2=1073657&view=diff
==============================================================================
--- camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
(original)
+++ camel/trunk/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
Wed Feb 23 09:37:30 2011
@@ -25,11 +25,11 @@ import org.apache.camel.builder.RouteBui
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 import org.restlet.Client;
+import org.restlet.Request;
+import org.restlet.Response;
 import org.restlet.data.MediaType;
 import org.restlet.data.Method;
 import org.restlet.data.Protocol;
-import org.restlet.data.Request;
-import org.restlet.data.Response;
 import org.restlet.data.Status;
 
 public class RestletRouteBuilderTest extends CamelTestSupport {

Modified: camel/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1073657&r1=1073656&r2=1073657&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Wed Feb 23 09:37:30 2011
@@ -118,7 +118,7 @@
     <qpid-version>0.5.0</qpid-version>
     <quartz-version>1.8.4</quartz-version>
     <quickfix-version>1.5.0</quickfix-version>
-    <restlet-version>1.1.10</restlet-version>
+    <restlet-version>2.0.5</restlet-version>
     <rome-version>1.0</rome-version>
     <saxon-version>9.1.0.8</saxon-version>
     <scala-version>2.8.1</scala-version>
@@ -1135,18 +1135,6 @@
         <version>${bouncycastle-version}</version>
       </dependency> 
       
-      <!-- optional restlet support -->
-      <dependency>
-        <groupId>org.restlet</groupId>
-        <artifactId>org.restlet</artifactId>
-        <version>${restlet-version}</version>
-      </dependency>
-      <dependency>
-        <groupId>com.noelios.restlet</groupId>
-        <artifactId>com.noelios.restlet</artifactId>
-        <version>${restlet-version}</version>
-      </dependency>
-
       <!-- optional jakarta http core support -->
       <dependency>
         <groupId>org.apache.httpcomponents</groupId>

Modified: camel/trunk/platforms/karaf/features/src/main/resources/features.xml
URL: http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/features/src/main/resources/features.xml?rev=1073657&r1=1073656&r2=1073657&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/features/src/main/resources/features.xml (original)
+++ camel/trunk/platforms/karaf/features/src/main/resources/features.xml Wed Feb 23 09:37:30
2011
@@ -521,8 +521,7 @@
   <feature name='camel-restlet' version='${pom.version}'>
     <feature version='${pom.version}'>camel-core</feature>
     <bundle>mvn:org.apache.camel/camel-restlet/${pom.version}</bundle>
-    <bundle>mvn:http://maven.restlet.org!org.restlet/org.restlet/${restlet-version}</bundle>
-    <bundle>mvn:http://maven.restlet.org!com.noelios.restlet/com.noelios.restlet/${restlet-version}</bundle>
+    <bundle>mvn:http://maven.restlet.org!org.restlet.jse/org.restlet/${restlet-version}</bundle>
   </feature>
   <feature name='camel-rmi' version='${pom.version}'>
     <feature version='${pom.version}'>camel-core</feature>



Mime
View raw message