Repository: nifi
Updated Branches:
  refs/heads/master ff0005026 -> d2fd7e5e7


NIFI-5271 Moved JSON_VALIDATOR to its own maven module.

This closes #2765

Signed-off-by: zenfenan <[email protected]>


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

Branch: refs/heads/master
Commit: d2fd7e5e7dd5185adc737d9f3b1f225d4ed9ecb0
Parents: ff00050
Author: Mike Thomsen <[email protected]>
Authored: Wed Jun 6 07:29:01 2018 -0400
Committer: zenfenan <[email protected]>
Committed: Thu Jun 7 20:38:25 2018 +0530

----------------------------------------------------------------------
 nifi-commons/nifi-json-utils/pom.xml            |  39 +++++++
 .../nifi/processor/util/JsonValidator.java      |  49 +++++++++
 .../processor/TestStandardValidators.groovy     | 101 +++++++++++++++++++
 nifi-commons/nifi-utils/pom.xml                 |   5 -
 .../nifi/processor/util/StandardValidators.java |  40 ++------
 .../util/validator/TestStandardValidators.java  |  50 ++-------
 nifi-commons/pom.xml                            |   1 +
 .../pom.xml                                     |   6 ++
 .../ElasticSearchRestProcessor.java             |   3 +-
 .../nifi-gcp-bundle/nifi-gcp-processors/pom.xml |   6 ++
 .../factory/CredentialPropertyDescriptors.java  |   3 +-
 .../nifi-gcp-services-api/pom.xml               |   7 +-
 .../nifi-mongodb-processors/pom.xml             |   6 ++
 .../nifi/processors/mongodb/GetMongo.java       |   7 +-
 .../nifi/processors/mongodb/PutMongo.java       |   3 +-
 .../processors/mongodb/RunMongoAggregation.java |   6 +-
 16 files changed, 242 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-commons/nifi-json-utils/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-commons/nifi-json-utils/pom.xml 
b/nifi-commons/nifi-json-utils/pom.xml
new file mode 100644
index 0000000..7ebb79a
--- /dev/null
+++ b/nifi-commons/nifi-json-utils/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-commons</artifactId>
+        <version>1.7.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-json-utils</artifactId>
+    <version>1.7.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-api</artifactId>
+            <version>1.7.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.9.4</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-commons/nifi-json-utils/src/main/java/org/apache/nifi/processor/util/JsonValidator.java
----------------------------------------------------------------------
diff --git 
a/nifi-commons/nifi-json-utils/src/main/java/org/apache/nifi/processor/util/JsonValidator.java
 
b/nifi-commons/nifi-json-utils/src/main/java/org/apache/nifi/processor/util/JsonValidator.java
new file mode 100644
index 0000000..79c68d5
--- /dev/null
+++ 
b/nifi-commons/nifi-json-utils/src/main/java/org/apache/nifi/processor/util/JsonValidator.java
@@ -0,0 +1,49 @@
+/*
+ * 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.nifi.processor.util;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+
+import java.util.List;
+import java.util.Map;
+
+public class JsonValidator implements Validator {
+    public static final JsonValidator INSTANCE = new JsonValidator();
+
+    @Override
+    public ValidationResult validate(String subject, String input, 
ValidationContext context) {
+        ObjectMapper mapper = new ObjectMapper();
+        if (context.isExpressionLanguageSupported(subject) && 
context.isExpressionLanguagePresent(input)) {
+            return new 
ValidationResult.Builder().subject(subject).input(input).explanation("Expression
 Language Present").valid(true).build();
+        }
+
+        try {
+            Class clz = input.startsWith("[") ? List.class : Map.class;
+            mapper.readValue(input, clz);
+        } catch (Exception e) {
+            return new 
ValidationResult.Builder().subject(subject).input(input).valid(false)
+                    .explanation(subject + " is not a valid JSON 
representation due to " + e.getLocalizedMessage())
+                    .build();
+        }
+
+        return new 
ValidationResult.Builder().subject(subject).input(input).valid(true).build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-commons/nifi-json-utils/src/test/groovy/org/apache/nifi/processor/TestStandardValidators.groovy
----------------------------------------------------------------------
diff --git 
a/nifi-commons/nifi-json-utils/src/test/groovy/org/apache/nifi/processor/TestStandardValidators.groovy
 
b/nifi-commons/nifi-json-utils/src/test/groovy/org/apache/nifi/processor/TestStandardValidators.groovy
new file mode 100644
index 0000000..c820c03
--- /dev/null
+++ 
b/nifi-commons/nifi-json-utils/src/test/groovy/org/apache/nifi/processor/TestStandardValidators.groovy
@@ -0,0 +1,101 @@
+/*
+ * 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.nifi.processor
+
+import org.apache.nifi.components.ValidationContext
+import org.apache.nifi.components.ValidationResult
+import org.apache.nifi.components.Validator
+import org.apache.nifi.processor.util.JsonValidator
+import org.junit.Before
+import org.junit.Test
+
+import static org.junit.Assert.assertFalse
+import static org.junit.Assert.assertTrue
+import static org.mockito.Mockito.mock
+
+import static groovy.json.JsonOutput.*
+
+class TestStandardValidators {
+    final String DUMMY_JSON_PROPERTY = "JSONProperty"
+    Validator validator
+    ValidationContext context
+
+    @Before
+    void setup() {
+        validator = JsonValidator.INSTANCE
+        context = mock(ValidationContext.class)
+    }
+
+    @Test
+    void testFlat() {
+        def msg = prettyPrint(toJson([
+            Name: "Crockford, Douglas"
+        ]))
+        ValidationResult validationResult = 
validator.validate(DUMMY_JSON_PROPERTY, msg, context)
+        assertTrue(validationResult.isValid())
+    }
+
+    @Test
+    void testNested() {
+        def msg = prettyPrint(toJson([
+            Name: "Crockford, Douglas",
+            ContactInfo: [
+                Mobile: 987654321,
+                Email: "[email protected]"
+            ]
+        ]))
+        ValidationResult validationResult = 
validator.validate(DUMMY_JSON_PROPERTY, msg, context)
+        assertTrue(validationResult.isValid())
+    }
+
+    @Test
+    void testObjectWithArray() {
+        def msg = prettyPrint(toJson([
+            name: "Smith, John",
+            age: 30,
+            cars: [ "Ford", "BMW", "Fiat" ]
+        ]))
+        ValidationResult validationResult = 
validator.validate(DUMMY_JSON_PROPERTY, msg, context)
+        assertTrue(validationResult.isValid())
+    }
+
+    @Test
+    void testJSONArray() {
+        def msg = prettyPrint(toJson([
+            "one", "two", "three"
+        ]))
+        ValidationResult validationResult = 
validator.validate(DUMMY_JSON_PROPERTY, msg, context)
+        assertTrue(validationResult.isValid())
+    }
+
+    @Test
+    void testEmpty() {
+        // Empty JSON
+        ValidationResult validationResult = 
validator.validate(DUMMY_JSON_PROPERTY, "{}", context)
+        assertTrue(validationResult.isValid())
+    }
+
+    @Test
+    void testInvalidJson() {
+        // Invalid JSON
+        ValidationResult validationResult = 
validator.validate(DUMMY_JSON_PROPERTY, "\"Name\" : \"Smith, John\"", context)
+        assertFalse(validationResult.isValid())
+        assertTrue(validationResult.getExplanation().contains("not a valid 
JSON representation"))
+        validationResult = validator.validate(DUMMY_JSON_PROPERTY, 
"bncjbhjfjhj", context)
+        assertFalse(validationResult.isValid())
+    }
+}

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-commons/nifi-utils/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-commons/nifi-utils/pom.xml b/nifi-commons/nifi-utils/pom.xml
index 26d64ae..5a023b6 100644
--- a/nifi-commons/nifi-utils/pom.xml
+++ b/nifi-commons/nifi-utils/pom.xml
@@ -40,10 +40,5 @@
             <artifactId>nifi-api</artifactId>
             <version>1.7.0-SNAPSHOT</version>
         </dependency>
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-            <version>2.8.1</version>
-        </dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java
----------------------------------------------------------------------
diff --git 
a/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java
 
b/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java
index b1e39fa..0ea7c17 100644
--- 
a/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java
+++ 
b/nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java
@@ -16,6 +16,15 @@
  */
 package org.apache.nifi.processor.util;
 
+import org.apache.nifi.components.PropertyValue;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.components.Validator;
+import org.apache.nifi.expression.AttributeExpression.ResultType;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.DataUnit;
+import org.apache.nifi.util.FormatUtils;
+
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URI;
@@ -30,18 +39,6 @@ import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Pattern;
 
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonSyntaxException;
-import org.apache.nifi.components.PropertyValue;
-import org.apache.nifi.components.ValidationContext;
-import org.apache.nifi.components.ValidationResult;
-import org.apache.nifi.components.Validator;
-import org.apache.nifi.expression.AttributeExpression.ResultType;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.processor.DataUnit;
-import org.apache.nifi.util.FormatUtils;
-
 public class StandardValidators {
 
     //
@@ -483,25 +480,6 @@ public class StandardValidators {
 
     public static final Validator FILE_EXISTS_VALIDATOR = new 
FileExistsValidator(true);
 
-    /**
-     * {@link Validator} that ensures the value is a valid JSON
-     */
-    public static final Validator JSON_VALIDATOR = (subject, input, context) 
-> {
-        if (context.isExpressionLanguageSupported(subject) && 
context.isExpressionLanguagePresent(input)) {
-            return new 
ValidationResult.Builder().subject(subject).input(input).explanation("Expression
 Language Present").valid(true).build();
-        }
-
-        try {
-            new Gson().fromJson(input, JsonElement.class);
-        } catch (JsonSyntaxException e) {
-            return new 
ValidationResult.Builder().subject(subject).input(input).valid(false)
-                    .explanation(subject + " is not a valid JSON 
representation due to " + e.getLocalizedMessage())
-                    .build();
-        }
-
-        return new 
ValidationResult.Builder().subject(subject).input(input).valid(true).build();
-    };
-
     //
     //
     // FACTORY METHODS FOR VALIDATORS

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestStandardValidators.java
----------------------------------------------------------------------
diff --git 
a/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestStandardValidators.java
 
b/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestStandardValidators.java
index 147ed13..ffebb9d 100644
--- 
a/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestStandardValidators.java
+++ 
b/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/validator/TestStandardValidators.java
@@ -16,12 +16,6 @@
  */
 package org.apache.nifi.util.validator;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-
-import java.util.concurrent.TimeUnit;
-
 import org.apache.nifi.components.ValidationContext;
 import org.apache.nifi.components.ValidationResult;
 import org.apache.nifi.components.Validator;
@@ -29,6 +23,12 @@ import org.apache.nifi.processor.util.StandardValidators;
 import org.junit.Test;
 import org.mockito.Mockito;
 
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
 public class TestStandardValidators {
 
     @Test
@@ -288,42 +288,4 @@ public class TestStandardValidators {
         vr = val.validate("foo", "2016-01-01T01:01:01.000Z", vc);
         assertTrue(vr.isValid());
     }
-
-    @Test
-    public void testJSONObjectValidator() {
-        final Validator validator = StandardValidators.JSON_VALIDATOR;
-        final ValidationContext context = mock(ValidationContext.class);
-        final String DUMMY_JSON_PROPERTY = "JSONProperty";
-        ValidationResult validationResult;
-
-        // Flat JSON
-        validationResult = validator.validate(DUMMY_JSON_PROPERTY,"{\"Name\" : 
\"Crockford, Douglas\"}", context);
-        assertTrue(validationResult.isValid());
-
-        // Nested JSON
-        validationResult = validator.validate(DUMMY_JSON_PROPERTY, "{ \"Name\" 
: \"Crockford, Douglas\", \"ContactInfo\": { \"Mobile\" : 0987654321, \"Email\" 
: \"[email protected]\" } }", context);
-        assertTrue(validationResult.isValid());
-
-        // JSON object with JSON array
-        validationResult = validator.validate(DUMMY_JSON_PROPERTY, "{ 
\"name\":\"Smith, John\", \"age\":30, \"cars\":[ \"Ford\", \"BMW\", \"Fiat\" ] 
} ", context);
-        assertTrue(validationResult.isValid());
-
-        // JSON array
-        validationResult = validator.validate(DUMMY_JSON_PROPERTY, "[\"one\", 
\"two\", \"three\"]", context);
-        assertTrue(validationResult.isValid());
-
-        // JSON Primitives
-        validationResult = validator.validate(DUMMY_JSON_PROPERTY, 
"bncjbhjfjhj", context);
-        assertTrue(validationResult.isValid());
-
-        // Empty JSON
-        validationResult = validator.validate(DUMMY_JSON_PROPERTY, "{}", 
context);
-        assertTrue(validationResult.isValid());
-
-        // Invalid JSON
-        validationResult = validator.validate(DUMMY_JSON_PROPERTY, "\"Name\" : 
\"Smith, John\"", context);
-        assertFalse(validationResult.isValid());
-        assertTrue(validationResult.getExplanation().contains("not a valid 
JSON representation"));
-
-    }
 }

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-commons/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-commons/pom.xml b/nifi-commons/pom.xml
index 41d5076..f652f56 100644
--- a/nifi-commons/pom.xml
+++ b/nifi-commons/pom.xml
@@ -31,6 +31,7 @@
         <module>nifi-security-utils</module>
         <module>nifi-socket-utils</module>
         <module>nifi-utils</module>
+        <module>nifi-json-utils</module>
         <module>nifi-web-utils</module>
         <module>nifi-write-ahead-log</module>
         <module>nifi-site-to-site-client</module>

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/pom.xml
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/pom.xml
 
b/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/pom.xml
index 09cb0ea..5abe3b3 100644
--- 
a/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/pom.xml
+++ 
b/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/pom.xml
@@ -110,6 +110,12 @@ language governing permissions and limitations under the 
License. -->
             <version>1.7.0-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-json-utils</artifactId>
+            <version>1.7.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/main/java/org/apache/nifi/processors/elasticsearch/ElasticSearchRestProcessor.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/main/java/org/apache/nifi/processors/elasticsearch/ElasticSearchRestProcessor.java
 
b/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/main/java/org/apache/nifi/processors/elasticsearch/ElasticSearchRestProcessor.java
index 43df991..ccf04ca 100644
--- 
a/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/main/java/org/apache/nifi/processors/elasticsearch/ElasticSearchRestProcessor.java
+++ 
b/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/main/java/org/apache/nifi/processors/elasticsearch/ElasticSearchRestProcessor.java
@@ -24,6 +24,7 @@ import org.apache.nifi.expression.ExpressionLanguageScope;
 import org.apache.nifi.flowfile.FlowFile;
 import org.apache.nifi.processor.ProcessContext;
 import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.util.JsonValidator;
 import org.apache.nifi.processor.util.StandardValidators;
 
 import java.io.ByteArrayOutputStream;
@@ -55,7 +56,7 @@ public interface ElasticSearchRestProcessor {
                     "If this parameter is not set, the query will be read from 
the flowfile content.")
             .required(false)
             
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
-            .addValidator(StandardValidators.JSON_VALIDATOR)
+            .addValidator(JsonValidator.INSTANCE)
             .build();
     PropertyDescriptor QUERY_ATTRIBUTE = new PropertyDescriptor.Builder()
             .name("el-query-attribute")

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/pom.xml 
b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/pom.xml
index 8469e29..394464d 100644
--- a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/pom.xml
+++ b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/pom.xml
@@ -80,6 +80,12 @@
             <artifactId>json</artifactId>
             <version>1.8</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-json-utils</artifactId>
+            <version>1.7.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/factory/CredentialPropertyDescriptors.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/factory/CredentialPropertyDescriptors.java
 
b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/factory/CredentialPropertyDescriptors.java
index 2531ab0..7fde8ad 100644
--- 
a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/factory/CredentialPropertyDescriptors.java
+++ 
b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/factory/CredentialPropertyDescriptors.java
@@ -18,6 +18,7 @@ package org.apache.nifi.processors.gcp.credentials.factory;
 
 import org.apache.nifi.components.PropertyDescriptor;
 import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.processor.util.JsonValidator;
 import org.apache.nifi.processor.util.StandardValidators;
 
 /**
@@ -83,7 +84,7 @@ public final class CredentialPropertyDescriptors {
             .displayName("Service Account JSON")
             
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
             .required(false)
-            .addValidator(StandardValidators.JSON_VALIDATOR)
+            .addValidator(JsonValidator.INSTANCE)
             .description("The raw JSON containing a Service Account keyfile.")
             .sensitive(true)
             .build();

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-services-api/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-services-api/pom.xml 
b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-services-api/pom.xml
index 6e7a526..6a3f44b 100644
--- a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-services-api/pom.xml
+++ b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-services-api/pom.xml
@@ -45,6 +45,11 @@
             <groupId>com.github.stephenc.findbugs</groupId>
             <artifactId>findbugs-annotations</artifactId>
             <version>1.3.9-1</version>
-        </dependency>        
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.9.4</version>
+        </dependency> <!-- TODO: Remove this when the next version of 
google-auth-library-oauth2-http is released and brings this in-->
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/pom.xml
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/pom.xml 
b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/pom.xml
index ebecc65..32420be 100644
--- a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/pom.xml
+++ b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/pom.xml
@@ -85,5 +85,11 @@
             <version>18.0</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-json-utils</artifactId>
+            <version>1.7.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java
 
b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java
index 3cf80ad..10eb0c7 100644
--- 
a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java
+++ 
b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java
@@ -38,6 +38,7 @@ import org.apache.nifi.processor.ProcessContext;
 import org.apache.nifi.processor.ProcessSession;
 import org.apache.nifi.processor.Relationship;
 import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.JsonValidator;
 import org.apache.nifi.processor.util.StandardValidators;
 import org.bson.Document;
 import org.bson.json.JsonWriterSettings;
@@ -79,7 +80,7 @@ public class GetMongo extends AbstractMongoProcessor {
                 "that will result in a full collection fetch using a \"{}\" 
query.")
         .required(false)
         
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
-        .addValidator(StandardValidators.JSON_VALIDATOR)
+        .addValidator(JsonValidator.INSTANCE)
         .build();
 
     static final PropertyDescriptor PROJECTION = new 
PropertyDescriptor.Builder()
@@ -87,14 +88,14 @@ public class GetMongo extends AbstractMongoProcessor {
             .description("The fields to be returned from the documents in the 
result set; must be a valid BSON document")
             .required(false)
             
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
-            .addValidator(StandardValidators.JSON_VALIDATOR)
+            .addValidator(JsonValidator.INSTANCE)
             .build();
     static final PropertyDescriptor SORT = new PropertyDescriptor.Builder()
             .name("Sort")
             .description("The fields by which to sort; must be a valid BSON 
document")
             .required(false)
             
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
-            .addValidator(StandardValidators.JSON_VALIDATOR)
+            .addValidator(JsonValidator.INSTANCE)
             .build();
     static final PropertyDescriptor LIMIT = new PropertyDescriptor.Builder()
             .name("Limit")

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongo.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongo.java
 
b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongo.java
index 839ad9e..620ee7c 100644
--- 
a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongo.java
+++ 
b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/PutMongo.java
@@ -39,6 +39,7 @@ import org.apache.nifi.processor.ProcessContext;
 import org.apache.nifi.processor.ProcessSession;
 import org.apache.nifi.processor.Relationship;
 import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.JsonValidator;
 import org.apache.nifi.processor.util.StandardValidators;
 import org.apache.nifi.stream.io.StreamUtils;
 import org.apache.nifi.util.StringUtils;
@@ -100,7 +101,7 @@ public class PutMongo extends AbstractMongoProcessor {
         .displayName("Update Query")
         .description("Specify a full MongoDB query to be used for the lookup 
query to do an update/upsert.")
         .required(false)
-        .addValidator(StandardValidators.JSON_VALIDATOR)
+        .addValidator(JsonValidator.INSTANCE)
         
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
         .build();
 

http://git-wip-us.apache.org/repos/asf/nifi/blob/d2fd7e5e/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/RunMongoAggregation.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/RunMongoAggregation.java
 
b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/RunMongoAggregation.java
index ff32039..19969c4 100644
--- 
a/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/RunMongoAggregation.java
+++ 
b/nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/RunMongoAggregation.java
@@ -19,6 +19,7 @@
 
 package org.apache.nifi.processors.mongodb;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.mongodb.BasicDBObject;
 import com.mongodb.client.AggregateIterable;
 import com.mongodb.client.MongoCollection;
@@ -34,10 +35,9 @@ import org.apache.nifi.processor.ProcessContext;
 import org.apache.nifi.processor.ProcessSession;
 import org.apache.nifi.processor.Relationship;
 import org.apache.nifi.processor.exception.ProcessException;
-import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.processor.util.JsonValidator;
 import org.bson.Document;
 import org.bson.conversions.Bson;
-import com.fasterxml.jackson.databind.ObjectMapper;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -88,7 +88,7 @@ public class RunMongoAggregation extends 
AbstractMongoProcessor {
             
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
             .description("The aggregation query to be executed.")
             .required(true)
-            .addValidator(StandardValidators.JSON_VALIDATOR)
+            .addValidator(JsonValidator.INSTANCE)
             .build();
 
     static {

Reply via email to