Author: buildbot
Date: Sun Dec 21 15:18:09 2014
New Revision: 933558

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/cache/main.pageCache
    websites/production/camel/content/rest-dsl.html

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/camel/content/rest-dsl.html
==============================================================================
--- websites/production/camel/content/rest-dsl.html (original)
+++ websites/production/camel/content/rest-dsl.html Sun Dec 21 15:18:09 2014
@@ -274,7 +274,15 @@ public class UserPojo {
         exchange.getIn().setHeader(Exchange.HTTP_RESPONSE_CODE, 400);
     }
 }]]></script>
-</div></div><p>In the UserErrorService bean we build our custom error message, 
and set the HTTP error code to 400. This is important, as that tells rest-dsl 
that this is a custom error message, and the message should not use the output 
pojo binding (eg would otherwise bind to CountryPojo).</p><h3 
id="RestDSL-IntegrationaCamelcomponentwithRestDSL">Integration a Camel 
component with Rest DSL</h3><p>Any Apache Camel component can integrate with 
the Rest DSL if they can be used as a REST service (eg as a REST consumer in 
Camel lingo). To integrate with the Rest DSL, then the component should 
implement the&#160;<code>org.apache.camel.spi.RestConsumerFactory</code>. The 
Rest DSL will then invoke the&#160;<code>createConsumer</code> method when it 
setup the Camel routes from the defined DSL. The component should then 
implement logic to create a Camel consumer that exposes the REST services based 
on the given parameters, such as path, verb, and other options. For example see 
the source code
  for camel-restlet, camel-spark-rest.</p><h3 id="RestDSL-SwaggerAPI">Swagger 
API</h3><p>The Rest DSL supports <a shape="rect" 
href="swagger.html">Swagger</a>&#160;by the&#160;<code>camel-swagger</code> 
module. See more details at &#160;<a shape="rect" 
href="swagger.html">Swagger</a>&#160;and 
the&#160;<code>camel-example-servlet-rest-tomcat</code> example from the Apache 
Camel distribution.</p><h3 id="RestDSL-SeeAlso">See Also</h3><ul><li><a 
shape="rect" href="dsl.html">DSL</a></li><li><a shape="rect" 
href="rest.html">Rest</a></li><li><a shape="rect" 
href="swagger.html">Swagger</a></li><li><a shape="rect" 
href="spark-rest.html">Spark-rest</a></li><li><a shape="rect" 
href="how-do-i-import-rests-from-other-xml-files.html">How do I import rests 
from other XML files</a></li></ul></div>
+</div></div><p>In the UserErrorService bean we build our custom error message, 
and set the HTTP error code to 400. This is important, as that tells rest-dsl 
that this is a custom error message, and the message should not use the output 
pojo binding (eg would otherwise bind to CountryPojo).</p><h3 
id="RestDSL-CatchingJsonParserExceptionandreturningacustomerrormessage">Catching
 JsonParserException and returning a custom error 
message</h3><p>From&#160;<strong>Camel 2.14.1</strong> onwards you return a 
custom message as-is (see previous section). So we can leverage this with Camel 
error handler to catch JsonParserException, handle that exception and build our 
custom response message. For example to return a HTTP error code 400 with a 
hardcoded message, we can do as shown below:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[onException(JsonParseException.class)
+    .handled(true)
+    .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400))
+    .setHeader(Exchange.HTTP_CONTENT_TYPE, constant(&quot;text/plain&quot;))
+    .setBody().constant(&quot;Invalid json data&quot;);
+
+]]></script>
+</div></div><p>&#160;</p><h3 
id="RestDSL-IntegrationaCamelcomponentwithRestDSL">Integration a Camel 
component with Rest DSL</h3><p>Any Apache Camel component can integrate with 
the Rest DSL if they can be used as a REST service (eg as a REST consumer in 
Camel lingo). To integrate with the Rest DSL, then the component should 
implement the&#160;<code>org.apache.camel.spi.RestConsumerFactory</code>. The 
Rest DSL will then invoke the&#160;<code>createConsumer</code> method when it 
setup the Camel routes from the defined DSL. The component should then 
implement logic to create a Camel consumer that exposes the REST services based 
on the given parameters, such as path, verb, and other options. For example see 
the source code for camel-restlet, camel-spark-rest.</p><h3 
id="RestDSL-SwaggerAPI">Swagger API</h3><p>The Rest DSL supports <a 
shape="rect" href="swagger.html">Swagger</a>&#160;by 
the&#160;<code>camel-swagger</code> module. See more details at &#160;<a 
shape="rect" href="swagger.htm
 l">Swagger</a>&#160;and 
the&#160;<code>camel-example-servlet-rest-tomcat</code> example from the Apache 
Camel distribution.</p><h3 id="RestDSL-SeeAlso">See Also</h3><ul><li><a 
shape="rect" href="dsl.html">DSL</a></li><li><a shape="rect" 
href="rest.html">Rest</a></li><li><a shape="rect" 
href="swagger.html">Swagger</a></li><li><a shape="rect" 
href="spark-rest.html">Spark-rest</a></li><li><a shape="rect" 
href="how-do-i-import-rests-from-other-xml-files.html">How do I import rests 
from other XML files</a></li></ul></div>
         </td>
         <td valign="top">
           <div class="navigation">


Reply via email to