[camel] branch master updated: Upgrade Elasticsearch Rest to version 6.4.2. It actually doesn't work in OSGi.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: Upgrade Elasticsearch Rest to version 6.4.2. It actually doesn't work in OSGi.

acosentino
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


The following commit(s) were added to refs/heads/master by this push:
     new 2a1fef6  Upgrade Elasticsearch Rest to version 6.4.2. It actually doesn't work in OSGi.
2a1fef6 is described below

commit 2a1fef66d7d1d9fb0953a5b6eb25ece435136a8f
Author: Andrea Cosentino <[hidden email]>
AuthorDate: Wed Nov 7 10:04:19 2018 +0100

    Upgrade Elasticsearch Rest to version 6.4.2. It actually doesn't work in OSGi.
---
 .../converter/ElasticsearchActionRequestConverter.java  |  5 +++--
 parent/pom.xml                                          |  8 ++++----
 .../karaf/features/src/main/resources/features.xml      |  1 +
 .../camel/itest/karaf/CamelElasticsearchRestTest.java   | 17 +++++++++++++++++
 4 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java
index aea664e..8764ac5 100644
--- a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java
+++ b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/converter/ElasticsearchActionRequestConverter.java
@@ -30,6 +30,7 @@ import org.elasticsearch.action.get.GetRequest;
 import org.elasticsearch.action.index.IndexRequest;
 import org.elasticsearch.action.search.SearchRequest;
 import org.elasticsearch.action.update.UpdateRequest;
+import org.elasticsearch.common.Strings;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentFactory;
 import org.elasticsearch.common.xcontent.XContentType;
@@ -59,7 +60,7 @@ public final class ElasticsearchActionRequestConverter {
         } else if (document instanceof Map) {
             updateRequest.doc((Map<String, Object>) document);
         } else if (document instanceof String) {
-            updateRequest.doc((String) document, XContentFactory.xContent((String) document));
+            updateRequest.doc(XContentFactory.xContent((String) document),(String) document);
         } else if (document instanceof XContentBuilder) {
             updateRequest.doc((XContentBuilder) document);
         } else {
@@ -170,7 +171,7 @@ public final class ElasticsearchActionRequestConverter {
             }
             try {
                 XContentBuilder contentBuilder = XContentFactory.contentBuilder(XContentType.JSON);
-                queryText = contentBuilder.map(mapQuery).string();
+                queryText = Strings.toString(contentBuilder.map(mapQuery));
             } catch (IOException e) {
                 LOG.error(e.getMessage());
             }
diff --git a/parent/pom.xml b/parent/pom.xml
index 4e1a916..d6e5c18 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -202,10 +202,10 @@
     <elasticsearch-sniffer-version>5.6.3</elasticsearch-sniffer-version>
     <elasticsearch-cluster-runner-version>2.4.0.0</elasticsearch-cluster-runner-version>
     <elasticsearch5-cluster-runner-version>5.6.3.0</elasticsearch5-cluster-runner-version>
-    <elasticsearch-rest-sniffer-version>6.1.1</elasticsearch-rest-sniffer-version>
-    <elasticsearch-rest-cluster-runner-version>6.1.1.0</elasticsearch-rest-cluster-runner-version>
-    <elasticsearch-rest-version>6.1.1</elasticsearch-rest-version>
-    <elasticsearch-rest-bundle-version>6.1.1_1</elasticsearch-rest-bundle-version>
+    <elasticsearch-rest-sniffer-version>6.4.2</elasticsearch-rest-sniffer-version>
+    <elasticsearch-rest-cluster-runner-version>6.4.2.0</elasticsearch-rest-cluster-runner-version>
+    <elasticsearch-rest-version>6.4.2</elasticsearch-rest-version>
+    <elasticsearch-rest-bundle-version>6.4.2_1</elasticsearch-rest-bundle-version>
     <elsql-version>1.3</elsql-version>
     <el-api-1.0-version>1.0.1</el-api-1.0-version>
     <embedmongo-version>2.1.1</embedmongo-version>
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index bd5c4bf..37c5862 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -614,6 +614,7 @@
     <bundle>mvn:org.apache.camel/camel-elasticsearch5/${project.version}</bundle>
   </feature>
   <feature name='camel-elasticsearch-rest' version='${project.version}' resolver='(obr)' start-level='50'>
+    <details>camel-elasticsearch-rest currently does not work in OSGi</details>
     <feature version='${project.version}'>camel-core</feature>
     <feature>http</feature>
     <bundle dependency='true'>mvn:com.fasterxml.jackson.core/jackson-core/${jackson2-version}</bundle>
diff --git a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelElasticsearchRestTest.java b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelElasticsearchRestTest.java
index 009fc5a..3821bab 100644
--- a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelElasticsearchRestTest.java
+++ b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelElasticsearchRestTest.java
@@ -18,12 +18,29 @@ package org.apache.camel.itest.karaf;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 
 @RunWith(PaxExam.class)
 public class CamelElasticsearchRestTest extends BaseKarafTest {
 
     public static final String COMPONENT = extractName(CamelElasticsearchRestTest.class);
+    
+    @Configuration
+    public static Option[] configure() {
+        Option[] baseOptions = BaseKarafTest.configure();
+        Option[] additionalOptions = CoreOptions.options(
+            CoreOptions.systemPackage("com.sun.jna.ptr,com.sun.jna.win32")
+        );
+
+        Option[] options = new Option[baseOptions.length + additionalOptions.length];
+        System.arraycopy(baseOptions, 0, options, 0, baseOptions.length);
+        System.arraycopy(additionalOptions, 0, options, baseOptions.length, additionalOptions.length);
+
+        return options;    
+    }
 
     @Test
     public void test() throws Exception {