You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/05/29 08:54:23 UTC

[camel] branch master updated (9f2e14d -> 0ccc2d6)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 9f2e14d  Upgrade Swagger Parser to version 1.0.36
     new ea12f9c  CAMEL-12544 - Camel-Couchdb: Add a get method to have a complete CRUD support
     new 454fe3f  CAMEL-12544 - Fixed CS
     new 0ccc2d6  CAMEL-12544 - Update docs

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/docs/couchdb-component.adoc            |  4 ++--
 .../component/couchdb/CouchDbClientWrapper.java     |  4 ++++
 .../camel/component/couchdb/CouchDbOperations.java  |  9 ++++-----
 .../camel/component/couchdb/CouchDbProducer.java    | 21 ++++++++++++++++++++-
 .../component/couchdb/CouchDbProducerTest.java      | 16 ++++++++++++++++
 5 files changed, 46 insertions(+), 8 deletions(-)
 copy camel-core/src/test/java/org/apache/camel/component/bean/issues/ClassB.java => components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbOperations.java (89%)

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

[camel] 01/03: CAMEL-12544 - Camel-Couchdb: Add a get method to have a complete CRUD support

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ea12f9ca7e984006c572dbb2c28fb010e75340f9
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue May 29 10:49:42 2018 +0200

    CAMEL-12544 - Camel-Couchdb: Add a get method to have a complete CRUD support
---
 .../component/couchdb/CouchDbClientWrapper.java    |  4 ++++
 .../camel/component/couchdb/CouchDbOperations.java | 22 ++++++++++++++++++++++
 .../camel/component/couchdb/CouchDbProducer.java   | 21 ++++++++++++++++++++-
 .../component/couchdb/CouchDbProducerTest.java     | 16 ++++++++++++++++
 4 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java
index 6dc492e..6919f18 100644
--- a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java
+++ b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java
@@ -48,6 +48,10 @@ public class CouchDbClientWrapper {
     public Changes changes() {
         return client.changes();
     }
+    
+    public Object get(String id) {
+    	return client.find(id);
+    }
 
     public CouchDbContext context() {
         return client.context();
diff --git a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbOperations.java b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbOperations.java
new file mode 100644
index 0000000..788c9ba
--- /dev/null
+++ b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbOperations.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.couchdb;
+
+public enum CouchDbOperations {
+	DELETE,
+	GET
+}
diff --git a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbProducer.java b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbProducer.java
index d5d5f95..0d3cbb9 100644
--- a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbProducer.java
+++ b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbProducer.java
@@ -51,7 +51,7 @@ public class CouchDbProducer extends DefaultProducer {
             exchange.getIn().setHeader(CouchDbConstants.HEADER_DOC_REV, save.getRev());
             exchange.getIn().setHeader(CouchDbConstants.HEADER_DOC_ID, save.getId());
         } else {
-            if (operation.equalsIgnoreCase("DELETE")) {
+            if (operation.equalsIgnoreCase(CouchDbOperations.DELETE.toString())) {
                 Response delete = deleteJsonElement(json);
                 if (delete == null) {
                     throw new CouchDbException("Could not delete document [unknown reason]", exchange);
@@ -63,6 +63,19 @@ public class CouchDbProducer extends DefaultProducer {
                 exchange.getIn().setHeader(CouchDbConstants.HEADER_DOC_REV, delete.getRev());
                 exchange.getIn().setHeader(CouchDbConstants.HEADER_DOC_ID, delete.getId());
             }
+            if (operation.equalsIgnoreCase(CouchDbOperations.GET.toString())) {
+                String docId = exchange.getIn().getHeader(CouchDbConstants.HEADER_DOC_ID, String.class);
+                if (docId == null) {
+                    throw new CouchDbException("Could not get document, document id is missing", exchange);
+                }
+                Object response = getElement(docId);
+
+                if (log.isTraceEnabled()) {
+                    log.trace("Document retrieved [_id={}]", docId);
+                }
+                
+                exchange.getIn().setBody(response);
+            }
         }
     }
 
@@ -106,4 +119,10 @@ public class CouchDbProducer extends DefaultProducer {
         }
         return delete;
     }
+    
+    private Object getElement(String id) {
+        Object response;
+        response = couchClient.get(id);
+        return response;
+    }   
 }
diff --git a/components/camel-couchdb/src/test/java/org/apache/camel/component/couchdb/CouchDbProducerTest.java b/components/camel-couchdb/src/test/java/org/apache/camel/component/couchdb/CouchDbProducerTest.java
index 5fceae2..46f49aa 100644
--- a/components/camel-couchdb/src/test/java/org/apache/camel/component/couchdb/CouchDbProducerTest.java
+++ b/components/camel-couchdb/src/test/java/org/apache/camel/component/couchdb/CouchDbProducerTest.java
@@ -114,6 +114,22 @@ public class CouchDbProducerTest {
         verify(msg).setHeader(CouchDbConstants.HEADER_DOC_ID, id);
         verify(msg).setHeader(CouchDbConstants.HEADER_DOC_REV, rev);
     }
+    
+    @Test
+    public void testGetResponse() throws Exception {
+        String id = UUID.randomUUID().toString();
+
+        JsonObject doc = new JsonObject();
+        doc.addProperty("_id", id);
+
+        when(msg.getHeader(CouchDbConstants.HEADER_METHOD, String.class)).thenReturn("GET");
+        when(msg.getHeader(CouchDbConstants.HEADER_DOC_ID, String.class)).thenReturn(id);
+        when(msg.getMandatoryBody()).thenReturn(doc);
+        when(client.get(id)).thenReturn(response);
+
+        producer.process(exchange);
+        verify(msg).getHeader(CouchDbConstants.HEADER_DOC_ID, String.class);
+    }
 
     @Test
     public void testStringBodyIsConvertedToJsonTree() throws Exception {

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

[camel] 02/03: CAMEL-12544 - Fixed CS

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 454fe3fe181e9e4dc901bb8137f8ff4146275c92
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue May 29 10:51:26 2018 +0200

    CAMEL-12544 - Fixed CS
---
 .../java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java | 2 +-
 .../java/org/apache/camel/component/couchdb/CouchDbOperations.java    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java
index 6919f18..ee83a78 100644
--- a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java
+++ b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbClientWrapper.java
@@ -50,7 +50,7 @@ public class CouchDbClientWrapper {
     }
     
     public Object get(String id) {
-    	return client.find(id);
+        return client.find(id);
     }
 
     public CouchDbContext context() {
diff --git a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbOperations.java b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbOperations.java
index 788c9ba..6092dba 100644
--- a/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbOperations.java
+++ b/components/camel-couchdb/src/main/java/org/apache/camel/component/couchdb/CouchDbOperations.java
@@ -17,6 +17,6 @@
 package org.apache.camel.component.couchdb;
 
 public enum CouchDbOperations {
-	DELETE,
-	GET
+    DELETE,
+    GET
 }

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

[camel] 03/03: CAMEL-12544 - Update docs

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0ccc2d6db67b8dc0edc104488374c553295d5a6f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue May 29 10:53:00 2018 +0200

    CAMEL-12544 - Update docs
---
 components/camel-couchdb/src/main/docs/couchdb-component.adoc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-couchdb/src/main/docs/couchdb-component.adoc b/components/camel-couchdb/src/main/docs/couchdb-component.adoc
index b0e5108..7bdffd0 100644
--- a/components/camel-couchdb/src/main/docs/couchdb-component.adoc
+++ b/components/camel-couchdb/src/main/docs/couchdb-component.adoc
@@ -10,8 +10,8 @@ has the following features:
 
 * As a consumer, monitors couch changesets for inserts, updates and
 deletes and publishes these as messages into camel routes.
-* As a producer, can save, update and from Camel 2.18 delete (by using CouchDbMethod with DELETE value) 
-documents into couch.
+* As a producer, can save, update, from Camel 2.18 delete (by using CouchDbMethod with DELETE value) 
+documents and from Camel 2.22 get document by id (by using CouchDbMethod with GET value) into couch.
 * Can support as many endpoints as required, eg for multiple databases
 across multiple instances.
 * Ability to have events trigger for only deletes, only inserts/updates

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.