Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x cc21a31dc -> efb679f85


CAMEL-8359, fixed LinkedInConsumer to set 'fields' parameter to null 
automatically


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

Branch: refs/heads/camel-2.14.x
Commit: efb679f859de62f98c18d9f8626aa7ea2405f830
Parents: cc21a31
Author: Dhiraj Bokde <dhira...@yahoo.com>
Authored: Sun Feb 15 17:56:11 2015 -0800
Committer: Dhiraj Bokde <dhira...@yahoo.com>
Committed: Sun Feb 15 18:00:03 2015 -0800

----------------------------------------------------------------------
 .../component/linkedin/LinkedInConsumer.java     | 19 +++++++++++++++++++
 .../component/linkedin/LinkedInEndpoint.java     |  3 ++-
 .../linkedin/PeopleResourceIntegrationTest.java  |  4 ++++
 3 files changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/efb679f8/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInConsumer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInConsumer.java
 
b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInConsumer.java
index bb1e029..9c885cf 100644
--- 
a/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInConsumer.java
+++ 
b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInConsumer.java
@@ -16,7 +16,9 @@
  */
 package org.apache.camel.component.linkedin;
 
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response;
 
@@ -26,6 +28,7 @@ import 
org.apache.camel.component.linkedin.api.LinkedInException;
 import org.apache.camel.component.linkedin.api.model.Error;
 import org.apache.camel.component.linkedin.internal.LinkedInApiName;
 import org.apache.camel.util.component.AbstractApiConsumer;
+import org.apache.camel.util.component.ApiMethod;
 
 /**
  * The LinkedIn consumer.
@@ -37,6 +40,22 @@ public class LinkedInConsumer extends 
AbstractApiConsumer<LinkedInApiName, Linke
     }
 
     @Override
+    public void interceptPropertyNames(Set<String> propertyNames) {
+        // do we need to add fields option
+        if (!propertyNames.contains(LinkedInEndpoint.FIELDS_OPTION)) {
+            final List<ApiMethod> candidates = endpoint.getCandidates();
+
+            for (ApiMethod method : candidates) {
+                if 
(!method.getArgNames().contains(LinkedInEndpoint.FIELDS_OPTION)) {
+                    return;
+                }
+            }
+            // all candidates use fields option, so there is no ambiguity
+            propertyNames.add(LinkedInEndpoint.FIELDS_OPTION);
+        }
+    }
+
+    @Override
     protected Object doInvokeMethod(Map<String, Object> args) {
         try {
             return super.doInvokeMethod(args);

http://git-wip-us.apache.org/repos/asf/camel/blob/efb679f8/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInEndpoint.java
 
b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInEndpoint.java
index 12f8ade..381fb2a 100644
--- 
a/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInEndpoint.java
+++ 
b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInEndpoint.java
@@ -47,8 +47,9 @@ import org.apache.cxf.jaxrs.client.WebClient;
 @UriEndpoint(scheme = "linkedin", consumerClass = LinkedInConsumer.class, 
consumerPrefix = "consumer")
 public class LinkedInEndpoint extends AbstractApiEndpoint<LinkedInApiName, 
LinkedInConfiguration> {
 
+    protected static final String FIELDS_OPTION = "fields";
     private static final String DEFAULT_FIELDS_SELECTOR = "";
-    private static final String FIELDS_OPTION = "fields";
+
     // OAuth request filter
     private LinkedInOAuthRequestFilter requestFilter;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/efb679f8/components/camel-linkedin/camel-linkedin-component/src/test/java/org/apache/camel/component/linkedin/PeopleResourceIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-linkedin/camel-linkedin-component/src/test/java/org/apache/camel/component/linkedin/PeopleResourceIntegrationTest.java
 
b/components/camel-linkedin/camel-linkedin-component/src/test/java/org/apache/camel/component/linkedin/PeopleResourceIntegrationTest.java
index d99fc06..95c5991 100644
--- 
a/components/camel-linkedin/camel-linkedin-component/src/test/java/org/apache/camel/component/linkedin/PeopleResourceIntegrationTest.java
+++ 
b/components/camel-linkedin/camel-linkedin-component/src/test/java/org/apache/camel/component/linkedin/PeopleResourceIntegrationTest.java
@@ -543,6 +543,10 @@ public class PeopleResourceIntegrationTest extends 
AbstractLinkedInTestSupport {
                 from("direct://GETCONNECTIONS")
                     .to("linkedin://" + PATH_PREFIX + "/getConnections");
 
+                // test consumer route for getConnections
+                from("linkedin://" + PATH_PREFIX + "/getConnections")
+                    .to("mock://GETCONNECTIONS");
+
                 // test route for getConnectionsById
                 from("direct://GETCONNECTIONSBYID")
                     .to("linkedin://" + PATH_PREFIX + "/getConnectionsById");

Reply via email to