camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/4] camel git commit: Previous code was over writing result values after each call to addToResult call
Date Sun, 01 May 2016 05:46:37 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.17.x fc0812153 -> 2f8592754
  refs/heads/master 88bed23b0 -> 50d029ae2


Previous code was over writing result values after each call to addToResult call


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

Branch: refs/heads/camel-2.17.x
Commit: ad79efc05b7ce733713d949ae8e869e9d1f85c1c
Parents: fc08121
Author: wkim <wkim@qualcomm.com>
Authored: Fri Apr 29 02:41:58 2016 -0700
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun May 1 07:39:30 2016 +0200

----------------------------------------------------------------------
 .../component/aws/ddb/AbstractDdbCommand.java    |  6 ++++++
 .../component/aws/ddb/BatchGetItemsCommand.java  |  7 +++++--
 .../component/aws/ddb/DeleteTableCommand.java    | 19 ++++++++++++-------
 .../camel/component/aws/ddb/QueryCommand.java    | 13 ++++++++-----
 .../camel/component/aws/ddb/ScanCommand.java     | 13 ++++++++-----
 5 files changed, 39 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ad79efc0/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/AbstractDdbCommand.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/AbstractDdbCommand.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/AbstractDdbCommand.java
index 12b06ee..6ea5bd7 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/AbstractDdbCommand.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/AbstractDdbCommand.java
@@ -71,6 +71,12 @@ public abstract class AbstractDdbCommand {
         msg.setHeader(DdbConstants.ATTRIBUTES, attributes);
     }
     
+    protected void addToResults(Map<String, Object> map) {
+        Message msg = getMessageForResponse(exchange);
+        for(Map.Entry<String,Object> en : map.entrySet()){
+            msg.setHeader(en.getKey(), en.getValue());
+        }
+    }
     protected void addToResult(String headerKey, Object value) {
         Message msg = getMessageForResponse(exchange);
         msg.setHeader(headerKey, value);

http://git-wip-us.apache.org/repos/asf/camel/blob/ad79efc0/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/BatchGetItemsCommand.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/BatchGetItemsCommand.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/BatchGetItemsCommand.java
index 74b340a..8e3cf36 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/BatchGetItemsCommand.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/BatchGetItemsCommand.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.aws.ddb;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
@@ -35,8 +36,10 @@ public class BatchGetItemsCommand extends AbstractDdbCommand {
         BatchGetItemResult result = ddbClient.batchGetItem(
                 new BatchGetItemRequest().withRequestItems(determineBatchItems()));
 
-        addToResult(DdbConstants.BATCH_RESPONSE, result.getResponses());
-        addToResult(DdbConstants.UNPROCESSED_KEYS, result.getUnprocessedKeys());
+        Map tmp = new HashMap<>();
+        tmp.put(DdbConstants.BATCH_RESPONSE, result.getResponses());
+        tmp.put(DdbConstants.UNPROCESSED_KEYS, result.getUnprocessedKeys());
+        addToResults(tmp);        
     }
 
     @SuppressWarnings("unchecked")

http://git-wip-us.apache.org/repos/asf/camel/blob/ad79efc0/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DeleteTableCommand.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DeleteTableCommand.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DeleteTableCommand.java
index 5bb1181..a2d5faa 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DeleteTableCommand.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/DeleteTableCommand.java
@@ -22,6 +22,9 @@ import com.amazonaws.services.dynamodbv2.model.TableDescription;
 
 import org.apache.camel.Exchange;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public class DeleteTableCommand extends AbstractDdbCommand {
     public DeleteTableCommand(AmazonDynamoDB ddbClient, DdbConfiguration configuration,
                               Exchange exchange) {
@@ -33,12 +36,14 @@ public class DeleteTableCommand extends AbstractDdbCommand {
         TableDescription tableDescription = ddbClient
                 .deleteTable(new DeleteTableRequest(determineTableName())).getTableDescription();
 
-        addToResult(DdbConstants.PROVISIONED_THROUGHPUT, tableDescription.getProvisionedThroughput());
-        addToResult(DdbConstants.CREATION_DATE, tableDescription.getCreationDateTime());
-        addToResult(DdbConstants.ITEM_COUNT, tableDescription.getItemCount());
-        addToResult(DdbConstants.KEY_SCHEMA, tableDescription.getKeySchema());
-        addToResult(DdbConstants.TABLE_NAME, tableDescription.getTableName());
-        addToResult(DdbConstants.TABLE_SIZE, tableDescription.getTableSizeBytes());
-        addToResult(DdbConstants.TABLE_STATUS, tableDescription.getTableStatus());
+        Map tmp = new HashMap<>();
+        tmp.put(DdbConstants.PROVISIONED_THROUGHPUT, tableDescription.getProvisionedThroughput());
+        tmp.put(DdbConstants.CREATION_DATE, tableDescription.getCreationDateTime());
+        tmp.put(DdbConstants.ITEM_COUNT, tableDescription.getItemCount());
+        tmp.put(DdbConstants.KEY_SCHEMA, tableDescription.getKeySchema());
+        tmp.put(DdbConstants.TABLE_NAME, tableDescription.getTableName());
+        tmp.put(DdbConstants.TABLE_SIZE, tableDescription.getTableSizeBytes());
+        tmp.put(DdbConstants.TABLE_STATUS, tableDescription.getTableStatus());
+        addToResults(tmp);
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ad79efc0/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/QueryCommand.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/QueryCommand.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/QueryCommand.java
index 0204abb..5651dac 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/QueryCommand.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/QueryCommand.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.aws.ddb;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
@@ -41,11 +42,13 @@ public class QueryCommand extends AbstractDdbCommand {
                 .withExclusiveStartKey(determineStartKey())
                 .withLimit(determineLimit())
                 .withScanIndexForward(determineScanIndexForward()));
-
-        addToResult(DdbConstants.ITEMS, result.getItems());
-        addToResult(DdbConstants.LAST_EVALUATED_KEY, result.getLastEvaluatedKey());
-        addToResult(DdbConstants.CONSUMED_CAPACITY, result.getConsumedCapacity());
-        addToResult(DdbConstants.COUNT, result.getCount());
+        
+        Map tmp = new HashMap<>();
+        tmp.put(DdbConstants.ITEMS, result.getItems());
+        tmp.put(DdbConstants.LAST_EVALUATED_KEY, result.getLastEvaluatedKey());
+        tmp.put(DdbConstants.CONSUMED_CAPACITY, result.getConsumedCapacity());
+        tmp.put(DdbConstants.COUNT, result.getCount());
+        addToResults(tmp);
     }
 
     private  Map<String, AttributeValue> determineStartKey() {

http://git-wip-us.apache.org/repos/asf/camel/blob/ad79efc0/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/ScanCommand.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/ScanCommand.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/ScanCommand.java
index e33e635..cafc60e 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/ScanCommand.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/ScanCommand.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.aws.ddb;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
@@ -36,11 +37,13 @@ public class ScanCommand extends AbstractDdbCommand {
                 .withTableName(determineTableName())
                 .withScanFilter(determineScanFilter()));
 
-        addToResult(DdbConstants.ITEMS, result.getItems());
-        addToResult(DdbConstants.LAST_EVALUATED_KEY, result.getLastEvaluatedKey());
-        addToResult(DdbConstants.CONSUMED_CAPACITY, result.getConsumedCapacity());
-        addToResult(DdbConstants.COUNT, result.getCount());
-        addToResult(DdbConstants.SCANNED_COUNT, result.getScannedCount());
+        Map tmp = new HashMap<>();
+        tmp.put(DdbConstants.ITEMS, result.getItems());
+        tmp.put(DdbConstants.LAST_EVALUATED_KEY, result.getLastEvaluatedKey());
+        tmp.put(DdbConstants.CONSUMED_CAPACITY, result.getConsumedCapacity());
+        tmp.put(DdbConstants.COUNT, result.getCount());
+        tmp.put(DdbConstants.SCANNED_COUNT, result.getScannedCount());
+        addToResults(tmp);
     }
 
     @SuppressWarnings("unchecked")


Mime
View raw message