camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject [3/3] camel git commit: CAMEL-8216 - support all properties in Google API components
Date Wed, 07 Jan 2015 18:49:29 GMT
CAMEL-8216 - support all properties in Google API components

Conflicts:
	components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarConsumer.java
	components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/GoogleCalendarProducer.java
	components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailConsumer.java
	components/camel-google-mail/src/main/java/org/apache/camel/component/google/mail/GoogleMailProducer.java


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

Branch: refs/heads/camel-2.14.x
Commit: bfd3797ebab3dd8ec30456ef9872347c8ec11c0e
Parents: 10b3aae
Author: Jonathan Anstey <janstey@gmail.com>
Authored: Wed Jan 7 15:16:52 2015 -0330
Committer: Jonathan Anstey <janstey@gmail.com>
Committed: Wed Jan 7 15:18:27 2015 -0330

----------------------------------------------------------------------
 .../google/drive/GoogleDriveConsumer.java        | 19 ++++++++-----------
 .../google/drive/GoogleDriveProducer.java        | 17 +++++++----------
 2 files changed, 15 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bfd3797e/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveConsumer.java
b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveConsumer.java
index e08e9b2..70a040d 100644
--- a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveConsumer.java
+++ b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveConsumer.java
@@ -18,11 +18,13 @@ package org.apache.camel.component.google.drive;
 
 import java.io.IOException;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
 
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.TypeConverter;
 import org.apache.camel.component.google.drive.internal.GoogleDriveApiName;
 import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.component.AbstractApiConsumer;
@@ -44,19 +46,14 @@ public class GoogleDriveConsumer extends AbstractApiConsumer<GoogleDriveApiName,
     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");
-            setProperty(properties, request, "fields");
+            TypeConverter typeConverter = getEndpoint().getCamelContext().getTypeConverter();
+            for (Entry<String, Object> p : properties.entrySet()) {
+                IntrospectionSupport.setProperty(typeConverter, request, p.getKey(), p.getValue());
+            }
             return request.execute();
         } 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/bfd3797e/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveProducer.java
b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveProducer.java
index 9762f0c..ffa873c 100644
--- a/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveProducer.java
+++ b/components/camel-google-drive/src/main/java/org/apache/camel/component/google/drive/GoogleDriveProducer.java
@@ -18,10 +18,12 @@ package org.apache.camel.component.google.drive;
 
 import java.io.IOException;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.TypeConverter;
 import org.apache.camel.component.google.drive.internal.GoogleDriveApiName;
 import org.apache.camel.component.google.drive.internal.GoogleDriveConstants;
 import org.apache.camel.component.google.drive.internal.GoogleDrivePropertiesHelper;
@@ -42,23 +44,18 @@ public class GoogleDriveProducer extends AbstractApiProducer<GoogleDriveApiName,
     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");
-            setProperty(properties, request, "fields");
+            TypeConverter typeConverter = getEndpoint().getCamelContext().getTypeConverter();
+            for (Entry<String, Object> p : properties.entrySet()) {
+                IntrospectionSupport.setProperty(typeConverter, request, p.getKey(), p.getValue());
+            }
             return request.execute();
         } catch (Exception e) {
             throw new RuntimeCamelException(e);
         }
     }
-    
+
     protected String getThreadProfileName() {
         return GoogleDriveConstants.THREAD_PROFILE_NAME;
     }
     
-    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