fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vorbur...@apache.org
Subject [fineract] branch develop updated: FINERACT-964
Date Tue, 19 May 2020 22:56:30 GMT
This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new dc3af0c  FINERACT-964
dc3af0c is described below

commit dc3af0c8673a096ed4e49b3800fe8460bfa5998c
Author: xurror <kaze.nasser@outlook.com>
AuthorDate: Sat May 16 10:05:11 2020 +0100

    FINERACT-964
    
    bump json-path from 0.9.1 to 2.4.0
---
 fineract-provider/build.gradle                     |  2 +-
 .../fineract/batch/service/ResolutionHelper.java   | 29 +++++++++++-----------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle
index a59c852..5689df0 100644
--- a/fineract-provider/build.gradle
+++ b/fineract-provider/build.gradle
@@ -99,7 +99,7 @@ dependencyManagement {
         dependency 'com.amazonaws:aws-java-sdk-s3:1.11.779'
         dependency 'net.sf.ehcache:ehcache:+'
         dependency 'com.github.spullara.mustache.java:compiler:0.8.12'
-        dependency 'com.jayway.jsonpath:json-path:0.9.1'
+        dependency 'com.jayway.jsonpath:json-path:2.4.0'
         dependency 'org.apache.tika:tika-core:1.24.1'
         dependency 'org.apache.httpcomponents:httpclient:+'
         dependency 'io.swagger:swagger-jersey-jaxrs:1.6.1'
diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java
b/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java
index 13e41d7..0ed763b 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/batch/service/ResolutionHelper.java
@@ -21,7 +21,8 @@ package org.apache.fineract.batch.service;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
-import com.jayway.jsonpath.JsonModel;
+import com.jayway.jsonpath.JsonPath;
+import com.jayway.jsonpath.ReadContext;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map.Entry;
@@ -134,7 +135,7 @@ public class ResolutionHelper {
         // Create a duplicate request
         final BatchRequest br = request;
 
-        final JsonModel responseJsonModel = JsonModel.model(parentResponse.getBody());
+        final ReadContext responseCtx = JsonPath.parse(parentResponse.getBody());
 
         // Gets the body from current Request as a JsonObject
         final JsonObject jsonRequestBody = this.fromJsonHelper.parse(request.getBody()).getAsJsonObject();
@@ -145,7 +146,7 @@ public class ResolutionHelper {
         // parameter
         for (Entry<String, JsonElement> element : jsonRequestBody.entrySet()) {
             final String key = element.getKey();
-            final JsonElement value = resolveDependentVariables(element, responseJsonModel);
+            final JsonElement value = resolveDependentVariables(element, responseCtx);
             jsonResultBody.add(key, value);
         }
 
@@ -167,7 +168,7 @@ public class ResolutionHelper {
 
             for (String parameter : parameters) {
                 if (parameter.contains("$.")) {
-                    final String resParamValue = responseJsonModel.get(parameter).toString();
+                    final String resParamValue = responseCtx.read(parameter).toString();
                     relativeUrl = relativeUrl.replace(parameter, resParamValue);
                     br.setRelativeUrl(relativeUrl+queryParams);
                 }
@@ -177,53 +178,53 @@ public class ResolutionHelper {
         return br;
     }
 
-    private JsonElement resolveDependentVariables(final Entry<String, JsonElement>
entryElement, final JsonModel responseJsonModel) {
+    private JsonElement resolveDependentVariables(final Entry<String, JsonElement>
entryElement, final ReadContext responseCtx) {
         JsonElement value = null;
 
         final JsonElement element = entryElement.getValue();
 
         if (element.isJsonObject()) {
             final JsonObject jsObject = element.getAsJsonObject();
-            value = processJsonObject(jsObject, responseJsonModel);
+            value = processJsonObject(jsObject, responseCtx);
         } else if (element.isJsonArray()) {
             final JsonArray jsElementArray = element.getAsJsonArray();
-            value = processJsonArray(jsElementArray, responseJsonModel);
+            value = processJsonArray(jsElementArray, responseCtx);
         } else {
-            value = resolveDependentVariable(element, responseJsonModel);
+            value = resolveDependentVariable(element, responseCtx);
         }
         return value;
     }
 
-    private JsonElement processJsonObject(final JsonObject jsObject, final JsonModel responseJsonModel)
{
+    private JsonElement processJsonObject(final JsonObject jsObject, final ReadContext responseCtx)
{
         JsonObject valueObj = new JsonObject();
         for (Entry<String, JsonElement> element : jsObject.entrySet()) {
             final String key = element.getKey();
-            final JsonElement value = resolveDependentVariable(element.getValue(), responseJsonModel);
+            final JsonElement value = resolveDependentVariable(element.getValue(), responseCtx);
             valueObj.add(key, value);
         }
         return valueObj;
     }
 
-    private JsonArray processJsonArray(final JsonArray elementArray, final JsonModel responseJsonModel)
{
+    private JsonArray processJsonArray(final JsonArray elementArray, final ReadContext responseCtx)
{
 
         JsonArray valueArr = new JsonArray();
 
         for (JsonElement element : elementArray) {
             if (element.isJsonObject()) {
                 final JsonObject jsObject = element.getAsJsonObject();
-                valueArr.add(processJsonObject(jsObject, responseJsonModel));
+                valueArr.add(processJsonObject(jsObject, responseCtx));
             }
         }
 
         return valueArr;
     }
 
-    private JsonElement resolveDependentVariable(final JsonElement element, final JsonModel
responseJsonModel) {
+    private JsonElement resolveDependentVariable(final JsonElement element, final ReadContext
responseCtx) {
         JsonElement value = element;
         String paramVal = element.getAsString();
         if (paramVal.contains("$.")) {
             // Get the value of the parameter from parent response
-            final String resParamValue = responseJsonModel.get(paramVal).toString();
+            final String resParamValue = responseCtx.read(paramVal).toString();
             value = this.fromJsonHelper.parse(resParamValue);
         }
         return value;


Mime
View raw message