camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject camel git commit: CAMEL-8089 - Support paging and restricting results from google calendar
Date Wed, 03 Dec 2014 19:22:05 GMT
Repository: camel
Updated Branches:
  refs/heads/master 4ba970668 -> 74deb7036


CAMEL-8089 - Support paging and restricting results from google calendar


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

Branch: refs/heads/master
Commit: 74deb7036b6430c2dd4aae1115776c15d6c4bbdb
Parents: 4ba9706
Author: Jonathan Anstey <janstey@gmail.com>
Authored: Wed Dec 3 15:51:42 2014 -0330
Committer: Jonathan Anstey <janstey@gmail.com>
Committed: Wed Dec 3 15:51:49 2014 -0330

----------------------------------------------------------------------
 .../google/calendar/GoogleCalendarConsumer.java        | 13 +++++++++++--
 .../google/calendar/GoogleCalendarProducer.java        | 13 +++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/74deb703/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarConsumer.java
b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarConsumer.java
index bfaaca4..091f546 100644
--- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarConsumer.java
+++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarConsumer.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.google.calendar;
 
-import java.io.IOException;
 import java.util.Map;
 
 import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
@@ -24,6 +23,7 @@ import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.component.google.calendar.internal.GoogleCalendarApiName;
+import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.component.AbstractApiConsumer;
 
 /**
@@ -39,9 +39,18 @@ public class GoogleCalendarConsumer extends AbstractApiConsumer<GoogleCalendarAp
     protected Object doInvokeMethod(Map<String, Object> properties) throws RuntimeCamelException
{
         AbstractGoogleClientRequest request = (AbstractGoogleClientRequest) super.doInvokeMethod(properties);
         try {
+            setProperty(properties, request, "q");
+            setProperty(properties, request, "maxResults");
+            setProperty(properties, request, "pageToken");
             return request.execute();
-        } catch (IOException e) {
+        } catch (Exception e) {
             throw new RuntimeCamelException(e);
         }
     }    
+    
+    private void setProperty(Map<String, Object> properties, AbstractGoogleClientRequest
request, String key) throws Exception {
+        if (properties.containsKey(key)) {
+            IntrospectionSupport.setProperty(getEndpoint().getCamelContext().getTypeConverter(),
request, key, properties.get(key));
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/74deb703/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarProducer.java
b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarProducer.java
index c786bc1..a2e72a1 100644
--- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarProducer.java
+++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarProducer.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.google.calendar;
 
-import java.io.IOException;
 import java.util.Map;
 
 import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
@@ -24,6 +23,7 @@ import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.component.google.calendar.internal.GoogleCalendarApiName;
 import org.apache.camel.component.google.calendar.internal.GoogleCalendarPropertiesHelper;
+import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.component.AbstractApiProducer;
 import org.apache.camel.util.component.ApiMethod;
 
@@ -40,9 +40,18 @@ public class GoogleCalendarProducer extends AbstractApiProducer<GoogleCalendarAp
     protected Object doInvokeMethod(ApiMethod method, Map<String, Object> properties)
throws RuntimeCamelException {
         AbstractGoogleClientRequest request = (AbstractGoogleClientRequest) super.doInvokeMethod(method,
properties);
         try {
+            setProperty(properties, request, "q");
+            setProperty(properties, request, "maxResults");
+            setProperty(properties, request, "pageToken");
             return request.execute();
-        } catch (IOException e) {
+        } catch (Exception e) {
             throw new RuntimeCamelException(e);
         }
     }
+    
+    private void setProperty(Map<String, Object> properties, AbstractGoogleClientRequest
request, String key) throws Exception {
+        if (properties.containsKey(key)) {
+            IntrospectionSupport.setProperty(getEndpoint().getCamelContext().getTypeConverter(),
request, key, properties.get(key));
+        }
+    }
 }


Mime
View raw message