camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [02/10] camel git commit: formatting fixes
Date Fri, 20 May 2016 05:07:41 GMT
formatting fixes


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0b053791
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0b053791
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0b053791

Branch: refs/heads/master
Commit: 0b05379154a9dd2d28bf807a0b88dcf30e4792d2
Parents: 3254a9b
Author: jmandawg <jmandawg@hotmail.com>
Authored: Wed May 18 15:20:25 2016 -0400
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri May 20 06:56:26 2016 +0200

----------------------------------------------------------------------
 .../restlet/DefaultRestletBinding.java          | 85 ++++++++++----------
 .../restlet/RestletRouteBuilderTest.java        |  6 +-
 2 files changed, 44 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0b053791/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
index 8083de8..4ecbdef 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/DefaultRestletBinding.java
@@ -94,15 +94,15 @@ public class DefaultRestletBinding implements RestletBinding, HeaderFilterStrate
             if (!headerFilterStrategy.applyFilterToExternalHeaders(entry.getKey(), entry.getValue(),
exchange)) {
                 String key = entry.getKey();
                 Object value = entry.getValue();
-                if(HeaderConstants.ATTRIBUTE_HEADERS.equalsIgnoreCase(key)){
-                	 Series<Header> series = (Series<Header>) value;
-                     for(Header header: series){
-                    	 if (!headerFilterStrategy.applyFilterToExternalHeaders(header.getName(),
header.getValue(), exchange))
-                        	 inMessage.setHeader(header.getName(), header.getValue());
-                     }
-                }
-                else {
-                	inMessage.setHeader(key, value);
+                if (HeaderConstants.ATTRIBUTE_HEADERS.equalsIgnoreCase(key)) {
+                    Series<Header> series = (Series<Header>) value;
+                    for (Header header: series) {
+                        if (!headerFilterStrategy.applyFilterToExternalHeaders(header.getName(),
header.getValue(), exchange)) {
+                            inMessage.setHeader(header.getName(), header.getValue());
+                        }
+                    }
+                } else {
+                    inMessage.setHeader(key, value);
                 }
                 LOG.debug("Populate exchange from Restlet request header: {} value: {}",
key, value);
             }
@@ -171,38 +171,35 @@ public class DefaultRestletBinding implements RestletBinding, HeaderFilterStrate
         if ((Method.PUT == method || Method.POST == method) && MediaType.APPLICATION_WWW_FORM.equals(mediaType,
true)) {
             form = new Form();
             
-            if(exchange.getIn().getBody() instanceof Map) {
-            	//Body is key value pairs
-                try{
-                	Map pairs = exchange.getIn().getBody(Map.class);
-                	for(Object key: pairs.keySet()) {
-                		Object value = pairs.get(key);
-                		form.add(key.toString(), value != null ? value.toString() : null);
-                	}
-                }
-            	catch(Exception ex) {
+            if (exchange.getIn().getBody() instanceof Map) {
+                //Body is key value pairs
+                try {
+                    Map pairs = exchange.getIn().getBody(Map.class);
+                    for (Object key: pairs.keySet()) {
+                        Object value = pairs.get(key);
+                        form.add(key.toString(), value != null ? value.toString() : null);
+                    }
+                } catch (Exception ex) {
                     LOG.error("body for " + MediaType.APPLICATION_WWW_FORM + " must be Map<String,String>
or string format like name=bob&password=secRet", ex);
-                    
                 }
-            }
-            else {
-	            // use string based for forms
-	            String body = exchange.getIn().getBody(String.class);
-	            if (body != null) {
-	            	List<NameValuePair> pairs = URLEncodedUtils.parse(body, Charset.forName(IOHelper.getCharsetName(exchange,
true)));
-	                for(NameValuePair p : pairs) {
-	                	form.add(p.getName(), p.getValue());
-	                }
-	            }
+            } else {
+                // use string based for forms
+                String body = exchange.getIn().getBody(String.class);
+                if (body != null) {
+                    List<NameValuePair> pairs = URLEncodedUtils.parse(body, Charset.forName(IOHelper.getCharsetName(exchange,
true)));
+                    for (NameValuePair p : pairs) {
+                        form.add(p.getName(), p.getValue());
+                    }
+                }
             }
         }
 
         //Get outgoing custom http headers
         Series<Header> restletHeaders = (Series)request.getAttributes().get(HeaderConstants.ATTRIBUTE_HEADERS);
-    	if(restletHeaders == null){
-    		restletHeaders = new Series<>(Header.class);
-    		request.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, restletHeaders);
-    	}
+        if (restletHeaders == null) {
+            restletHeaders = new Series<>(Header.class);
+            request.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, restletHeaders);
+        }
 
         // login and password are filtered by header filter strategy
         String login = exchange.getIn().getHeader(RestletConstants.RESTLET_LOGIN, String.class);
@@ -228,23 +225,23 @@ public class DefaultRestletBinding implements RestletBinding, HeaderFilterStrate
                         if (value instanceof Collection) {
                             for (Object v : (Collection<?>) value) {
                                 form.add(key, v.toString());
-                                if(!headerFilterStrategy.applyFilterToCamelHeaders(key, value,
exchange)){
-                            		restletHeaders.set(key, value.toString());
-                            	}
+                                if (!headerFilterStrategy.applyFilterToCamelHeaders(key,
value, exchange)) {
+                                    restletHeaders.set(key, value.toString());
+                                }
                             }
                         } else {
-                        	//Add headers to headers and to body
+                            //Add headers to headers and to body
                             form.add(key, value.toString());
-                            if(!headerFilterStrategy.applyFilterToCamelHeaders(key, value,
exchange)){
-                        		restletHeaders.set(key, value.toString());
-                        	}
+                            if (!headerFilterStrategy.applyFilterToCamelHeaders(key, value,
exchange)) {
+                                restletHeaders.set(key, value.toString());
+                            }
                         }
                     }
                 } else {
                     // For non-form post put all the headers in custom headers
-                	if(!headerFilterStrategy.applyFilterToCamelHeaders(key, value, exchange)){
-                		restletHeaders.set(key, value.toString());
-                	}
+                    if (!headerFilterStrategy.applyFilterToCamelHeaders(key, value, exchange))
{
+                        restletHeaders.set(key, value.toString());
+                    }
                 }
                 LOG.debug("Populate Restlet request from exchange header: {} value: {}",
key, value);
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/0b053791/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
index 1c10dde..7509f68 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletRouteBuilderTest.java
@@ -95,7 +95,7 @@ public class RestletRouteBuilderTest extends RestletTestSupport {
 
     @Test
     public void testProducer() throws IOException {
-    	Map<String, Object> headers = new HashMap<String, Object>();
+        Map<String, Object> headers = new HashMap<String, Object>();
         headers.put(Exchange.CONTENT_TYPE, MediaType.APPLICATION_XML);
         
         String response = template.requestBodyAndHeaders("direct:start", "<order foo='1'/>",
headers, String.class);
@@ -163,7 +163,7 @@ public class RestletRouteBuilderTest extends RestletTestSupport {
     
     @Test
     public void testFormsProducer() throws IOException {
-    	Map<String, Object> headers = new HashMap<String, Object>();
+        Map<String, Object> headers = new HashMap<String, Object>();
         headers.put(Exchange.CONTENT_TYPE, MediaType.APPLICATION_WWW_FORM);
         
         String response = template.requestBodyAndHeaders("restlet:http://localhost:" + portNum
+ "/login?restletMethod=post", "user=jaymandawg&passwd=secret$%", headers, String.class);
@@ -172,7 +172,7 @@ public class RestletRouteBuilderTest extends RestletTestSupport {
     
     @Test
     public void testFormsProducerMapBody() throws IOException {
-    	Map<String, Object> headers = new HashMap<String, Object>();
+        Map<String, Object> headers = new HashMap<String, Object>();
         headers.put(Exchange.CONTENT_TYPE, MediaType.APPLICATION_WWW_FORM);
         Map<String, String> body = new HashMap<>();
         body.put("user", "jaymandawg");


Mime
View raw message