diff --git a/DEPENDENCIES b/DEPENDENCIES
index e7a9b3ea16..50b09b7df1 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -9,8 +9,8 @@ maven/mavencentral/com.aayushatharva.brotli4j/native-windows-x86_64/1.11.0, Apac
maven/mavencentral/com.aayushatharva.brotli4j/service/1.11.0, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.apicatalog/titanium-json-ld/1.3.2, Apache-2.0, approved, #8912
maven/mavencentral/com.carrotsearch.thirdparty/simple-xml-safe/2.7.1, Apache-2.0, approved, clearlydefined
-maven/mavencentral/com.damnhandy/handy-uri-templates/2.1.8, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.eatthepath/fast-uuid/0.2.0, MIT, approved, clearlydefined
+maven/mavencentral/com.ethlo.time/itu/1.8.0, Apache-2.0, approved, #12927
maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.4, Apache-2.0, approved, #7947
maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.16.1, Apache-2.0, approved, #11606
maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.15.4, MIT AND Apache-2.0, approved, #7932
@@ -18,7 +18,7 @@ maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.16.1, Apache-2.0 AN
maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.1, Apache-2.0, approved, #7934
maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.4, Apache-2.0, approved, #7934
maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.16.1, Apache-2.0, approved, #11605
-maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.1, Apache-2.0, approved, #8802
+maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.3, Apache-2.0, approved, #8802
maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.4, Apache-2.0, approved, #8802
maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jakarta-jsonp/2.15.2, Apache-2.0, approved, #9179
maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jakarta-jsonp/2.15.4, Apache-2.0, approved, #9179
@@ -45,8 +45,8 @@ maven/mavencentral/com.google.guava/failureaccess/1.0.2, Apache-2.0, approved, C
maven/mavencentral/com.google.guava/guava/33.0.0-jre, Apache-2.0 AND CC0-1.0, approved, #12173
maven/mavencentral/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava, Apache-2.0, approved, CQ22657
maven/mavencentral/com.google.j2objc/j2objc-annotations/2.8, Apache-2.0, approved, clearlydefined
-maven/mavencentral/com.ibm.icu/icu4j/74.2, , approved, #11936
maven/mavencentral/com.jayway.jsonpath/json-path/2.9.0, Apache-2.0, approved, clearlydefined
+maven/mavencentral/com.networknt/json-schema-validator/1.4.0, Apache-2.0 AND Unicode-TOU, approved, #13812
maven/mavencentral/com.nimbusds/content-type/2.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.nimbusds/lang-tag/1.7, Apache-2.0, approved, clearlydefined
maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.37.3, Apache-2.0, approved, #11701
@@ -190,7 +190,6 @@ maven/mavencentral/jakarta.validation/jakarta.validation-api/3.0.2, Apache-2.0,
maven/mavencentral/jakarta.ws.rs/jakarta.ws.rs-api/3.1.0, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.rest
maven/mavencentral/jakarta.xml.bind/jakarta.xml.bind-api/4.0.2, BSD-3-Clause, approved, ee4j.jaxb
maven/mavencentral/javax.jms/javax.jms-api/2.0.1, CDDL-1.1 OR GPL-2.0 WITH Classpath-exception-2.0, approved, #1516
-maven/mavencentral/joda-time/joda-time/2.10.2, Apache-2.0, approved, clearlydefined
maven/mavencentral/junit/junit/4.13.2, EPL-2.0, approved, CQ23636
maven/mavencentral/net.bytebuddy/byte-buddy-agent/1.14.12, Apache-2.0, approved, #7164
maven/mavencentral/net.bytebuddy/byte-buddy-agent/1.14.4, Apache-2.0, approved, #7164
@@ -203,9 +202,6 @@ maven/mavencentral/net.java.dev.jna/jna/5.13.0, Apache-2.0 AND LGPL-2.1-or-later
maven/mavencentral/net.javacrumbs.json-unit/json-unit-assertj/3.2.7, Apache-2.0, approved, clearlydefined
maven/mavencentral/net.javacrumbs.json-unit/json-unit-core/3.2.7, Apache-2.0, approved, clearlydefined
maven/mavencentral/net.javacrumbs.json-unit/json-unit-json-path/3.2.7, Apache-2.0, approved, clearlydefined
-maven/mavencentral/net.jimblackler.jsonschemafriend/core/0.12.4, Apache-2.0, approved, #10911
-maven/mavencentral/net.jimblackler.jsonschemafriend/extra/0.12.4, Apache-2.0, approved, #10910
-maven/mavencentral/net.jimblackler/jsonschemafriend/0.12.4, Apache-2.0, approved, #10912
maven/mavencentral/net.jodah/typetools/0.6.3, Apache-2.0, approved, clearlydefined
maven/mavencentral/net.minidev/accessors-smart/2.4.11, Apache-2.0, approved, #7515
maven/mavencentral/net.minidev/accessors-smart/2.5.1, Apache-2.0, approved, clearlydefined
@@ -364,10 +360,6 @@ maven/mavencentral/org.glassfish.jersey.media/jersey-media-json-jackson/3.1.5, E
maven/mavencentral/org.glassfish.jersey.media/jersey-media-multipart/3.1.3, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey
maven/mavencentral/org.glassfish.jersey.media/jersey-media-multipart/3.1.5, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jersey
maven/mavencentral/org.glassfish/jakarta.json/2.0.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jsonp
-maven/mavencentral/org.graalvm.js/js/21.3.9, UPL-1.0 AND (UPL-1.0 AND GPL-2.0-only WITH Classpath-exception-2.0) AND BSD-3-Clause AND MPL-2.0, approved, #6714
-maven/mavencentral/org.graalvm.regex/regex/21.3.9, UPL-1.0 AND Unicode-TOU, approved, #6719
-maven/mavencentral/org.graalvm.sdk/graal-sdk/21.3.9, UPL-1.0, approved, #6717
-maven/mavencentral/org.graalvm.truffle/truffle-api/21.3.9, UPL-1.0, approved, #6718
maven/mavencentral/org.hamcrest/hamcrest-core/2.2, BSD-3-Clause, approved, clearlydefined
maven/mavencentral/org.hamcrest/hamcrest/2.2, BSD-3-Clause, approved, clearlydefined
maven/mavencentral/org.hdrhistogram/HdrHistogram/2.1.12, BSD-2-Clause OR LicenseRef-Public-Domain, approved, CQ13192
@@ -388,8 +380,6 @@ maven/mavencentral/org.jetbrains/annotations/17.0.0, Apache-2.0, approved, clear
maven/mavencentral/org.jetbrains/annotations/24.0.1, Apache-2.0, approved, #7417
maven/mavencentral/org.jodd/jodd-lagarto/6.0.6, BSD-2-Clause, approved, clearlydefined
maven/mavencentral/org.jodd/jodd-util/6.1.0, BSD-2-Clause, approved, clearlydefined
-maven/mavencentral/org.jruby.jcodings/jcodings/1.0.58, MIT, approved, CQ10635
-maven/mavencentral/org.jruby.joni/joni/2.2.1, MIT, approved, #8771
maven/mavencentral/org.jsoup/jsoup/1.17.2, MIT AND Apache-2.0, approved, #11785
maven/mavencentral/org.junit.jupiter/junit-jupiter-api/5.9.2, EPL-2.0, approved, #3133
maven/mavencentral/org.junit.jupiter/junit-jupiter-api/5.9.3, EPL-2.0, approved, #3133
diff --git a/irs-api/pom.xml b/irs-api/pom.xml
index f5fc91b2b0..48d41ab03b 100644
--- a/irs-api/pom.xml
+++ b/irs-api/pom.xml
@@ -153,15 +153,9 @@
${irs-registry-client.version}
- net.jimblackler
- jsonschemafriend
- ${jsonschemafriend.version}
-
-
- org.jsoup
- jsoup
-
-
+ com.networknt
+ json-schema-validator
+ ${json-schema-validator.version}
diff --git a/irs-api/src/main/java/org/eclipse/tractusx/irs/services/validation/JsonValidatorService.java b/irs-api/src/main/java/org/eclipse/tractusx/irs/services/validation/JsonValidatorService.java
index 9d95eefe23..fdbd7940ff 100644
--- a/irs-api/src/main/java/org/eclipse/tractusx/irs/services/validation/JsonValidatorService.java
+++ b/irs-api/src/main/java/org/eclipse/tractusx/irs/services/validation/JsonValidatorService.java
@@ -23,16 +23,17 @@
********************************************************************************/
package org.eclipse.tractusx.irs.services.validation;
-import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
+import com.networknt.schema.InputFormat;
+import com.networknt.schema.JsonSchema;
+import com.networknt.schema.JsonSchemaException;
+import com.networknt.schema.JsonSchemaFactory;
+import com.networknt.schema.SpecVersion;
+import com.networknt.schema.ValidationMessage;
import lombok.extern.slf4j.Slf4j;
-import net.jimblackler.jsonschemafriend.GenerationException;
-import net.jimblackler.jsonschemafriend.Schema;
-import net.jimblackler.jsonschemafriend.SchemaStore;
-import net.jimblackler.jsonschemafriend.Validator;
import org.eclipse.tractusx.irs.data.JsonParseException;
-import org.eclipse.tractusx.irs.util.JsonUtil;
import org.springframework.stereotype.Service;
/**
@@ -41,17 +42,7 @@
@Service
@Slf4j
public class JsonValidatorService {
- private final SchemaStore schemaStore = new SchemaStore();
- private final JsonUtil parser;
-
- /**
- * Creates a new validation service
- *
- * @param parser the parser to use for the JSON
- */
- public JsonValidatorService(final JsonUtil parser) {
- this.parser = parser;
- }
+ private final JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V4);
/**
* Validate the payload against the schema.
@@ -63,15 +54,11 @@ public JsonValidatorService(final JsonUtil parser) {
public ValidationResult validate(final String jsonSchema, final String jsonPayload) throws InvalidSchemaException {
log.debug("Trying to validate JSON ({}) with schema ({})", jsonPayload, jsonSchema);
- final Schema schema = loadSchema(jsonSchema);
+ final JsonSchema schemaFromString = loadSchema(jsonSchema);
- final Validator validator = new Validator();
try {
- final Object payload = parser.fromString(jsonPayload, Object.class);
-
- final List errors = new ArrayList<>();
- validator.validate(schema, payload, validationError -> errors.add(validationError.getMessage()));
- return createValidationResult(errors);
+ final Set errors = schemaFromString.validate(jsonPayload, InputFormat.JSON);
+ return createValidationResult(errors.stream().map(ValidationMessage::getMessage).toList());
} catch (final IllegalStateException | JsonParseException e) {
log.warn("Unable to validate JSON payload ({})", jsonPayload, e);
@@ -92,10 +79,10 @@ private ValidationResult createValidationResult(final List errors) {
}
}
- private Schema loadSchema(final String jsonSchema) throws InvalidSchemaException {
+ private JsonSchema loadSchema(final String jsonSchema) throws InvalidSchemaException {
try {
- return schemaStore.loadSchemaJson(jsonSchema);
- } catch (final GenerationException e) {
+ return factory.getSchema(jsonSchema);
+ } catch (final JsonSchemaException e) {
throw new InvalidSchemaException("Cannot load JSON schema for validation", e);
}
}
diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/services/validation/JsonValidatorServiceTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/services/validation/JsonValidatorServiceTest.java
index 8e188c7681..510c14fe51 100644
--- a/irs-api/src/test/java/org/eclipse/tractusx/irs/services/validation/JsonValidatorServiceTest.java
+++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/services/validation/JsonValidatorServiceTest.java
@@ -33,19 +33,16 @@
import java.nio.file.Path;
import java.util.Objects;
-import org.eclipse.tractusx.irs.util.JsonUtil;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
class JsonValidatorServiceTest {
- private final JsonValidatorService testee = new JsonValidatorService(new JsonUtil());
+ private final JsonValidatorService testee = new JsonValidatorService();
@Test
- @Disabled("Should not pass validation, but currently payload is valid with schema v.3.0.0")
void shouldFailWhenSchemaIsInThirdVerAndPayloadInSecondVer() throws Exception {
final String schema = readFile("/json-schema/slab-v3.0.0.json");
- final String payload = readFile("/__files/integrationtesting/singleLevelBomAsBuilt-2.json");
+ final String payload = readFile("/__files/integrationtesting/singleLevelBomAsBuilt#2.0.0.json");
final ValidationResult result = testee.validate(schema, payload);
diff --git a/irs-api/src/test/resources/__files/assemblyPartRelationship.json b/irs-api/src/test/resources/__files/assemblyPartRelationship.json
index d2f8ccf472..26455e853d 100644
--- a/irs-api/src/test/resources/__files/assemblyPartRelationship.json
+++ b/irs-api/src/test/resources/__files/assemblyPartRelationship.json
@@ -4,10 +4,7 @@
{
"quantity": {
"quantityNumber": 0.11,
- "measurementUnit": {
- "datatypeURI": "urn:bamm:io.openmanufacturing:meta-model:1.0.0#kilogram",
- "lexicalValue": "kilogram"
- }
+ "measurementUnit": "unit:kilogram"
},
"lifecycleContext": "AsBuilt",
"createdOn": "2022-02-03T14:48:54.709Z",
@@ -17,10 +14,7 @@
{
"quantity": {
"quantityNumber": 0.1204,
- "measurementUnit": {
- "datatypeURI": "urn:bamm:io.openmanufacturing:meta-model:1.0.0#kilogram",
- "lexicalValue": "kilogram"
- }
+ "measurementUnit": "unit:kilogram"
},
"lifecycleContext": "AsBuilt",
"createdOn": "2022-02-03T14:48:54.709Z",
@@ -30,10 +24,7 @@
{
"quantity": {
"quantityNumber": 1,
- "measurementUnit": {
- "datatypeURI": "urn:bamm:io.openmanufacturing:meta-model:1.0.0#piece",
- "lexicalValue": "piece"
- }
+ "measurementUnit": "unit:piece"
},
"lifecycleContext": "AsBuilt",
"createdOn": "2022-02-03T14:48:54.709Z",
@@ -43,10 +34,7 @@
{
"quantity": {
"quantityNumber": 1,
- "measurementUnit": {
- "datatypeURI": "urn:bamm:io.openmanufacturing:meta-model:1.0.0#piece",
- "lexicalValue": "piece"
- }
+ "measurementUnit": "unit:piece"
},
"lifecycleContext": "AsBuilt",
"createdOn": "2022-02-03T14:48:54.709Z",
@@ -56,10 +44,7 @@
{
"quantity": {
"quantityNumber": 1,
- "measurementUnit": {
- "datatypeURI": "urn:bamm:io.openmanufacturing:meta-model:1.0.0#piece",
- "lexicalValue": "piece"
- }
+ "measurementUnit": "unit:piece"
},
"lifecycleContext": "AsBuilt",
"createdOn": "2022-02-03T14:48:54.709Z",
@@ -79,7 +64,7 @@
{
"quantity": {
"quantityNumber": 1,
- "measurementUnit": null
+ "measurementUnit": "unit:piece"
},
"lifecycleContext": "AsBuilt",
"createdOn": "2022-02-03T14:48:54.709Z",
@@ -89,10 +74,7 @@
{
"quantity": {
"quantityNumber": 1,
- "measurementUnit": {
- "datatypeURI": "urn:bamm:io.openmanufacturing:meta-model:1.0.0#piece",
- "lexicalValue": "piece"
- }
+ "measurementUnit": "unit:piece"
},
"lifecycleContext": "AsBuilt",
"createdOn": "2022-02-03T14:48:54.709Z",
@@ -102,10 +84,7 @@
{
"quantity": {
"quantityNumber": 1,
- "measurementUnit": {
- "datatypeURI": "urn:bamm:io.openmanufacturing:meta-model:1.0.0#piece",
- "lexicalValue": "piece"
- }
+ "measurementUnit": "unit:piece"
},
"lifecycleContext": "AsBuilt",
"createdOn": "2022-02-03T14:48:54.709Z",
@@ -115,10 +94,7 @@
{
"quantity": {
"quantityNumber": 1,
- "measurementUnit": {
- "datatypeURI": "urn:bamm:io.openmanufacturing:meta-model:1.0.0#piece",
- "lexicalValue": "piece"
- }
+ "measurementUnit": "unit:piece"
},
"lifecycleContext": "AsBuilt",
"createdOn": "2022-02-03T14:48:54.709Z",
@@ -128,10 +104,7 @@
{
"quantity": {
"quantityNumber": 1,
- "measurementUnit": {
- "datatypeURI": "urn:bamm:io.openmanufacturing:meta-model:1.0.0#piece",
- "lexicalValue": "piece"
- }
+ "measurementUnit": "unit:piece"
},
"lifecycleContext": "AsBuilt",
"createdOn": "2022-02-03T14:48:54.709Z",
diff --git a/irs-api/src/test/resources/__files/integrationtesting/batch-1.json b/irs-api/src/test/resources/__files/integrationtesting/batch-1.json
index b044897ad0..52371ee6e5 100644
--- a/irs-api/src/test/resources/__files/integrationtesting/batch-1.json
+++ b/irs-api/src/test/resources/__files/integrationtesting/batch-1.json
@@ -10,7 +10,7 @@
}
],
"manufacturingInformation": {
- "date": "2022-02-04T14:48:54",
+ "date": "2022-02-04T14:48:54Z",
"country": "HUR"
},
"catenaXId": "urn:uuid:334cce52-1f52-4bc9-9dd1-410bbe497bbc",
diff --git a/irs-api/src/test/resources/__files/integrationtesting/batch-2.json b/irs-api/src/test/resources/__files/integrationtesting/batch-2.json
index d86f962cb3..e7a8bc291b 100644
--- a/irs-api/src/test/resources/__files/integrationtesting/batch-2.json
+++ b/irs-api/src/test/resources/__files/integrationtesting/batch-2.json
@@ -10,7 +10,7 @@
}
],
"manufacturingInformation": {
- "date": "2022-02-04T14:48:54",
+ "date": "2022-02-04T14:48:54Z",
"country": "HUR"
},
"catenaXId": "urn:uuid:7e4541ea-bb0f-464c-8cb3-021abccbfaf5",
diff --git a/irs-api/src/test/resources/__files/integrationtesting/batch-3.json b/irs-api/src/test/resources/__files/integrationtesting/batch-3.json
index f62643532a..45501acb1e 100644
--- a/irs-api/src/test/resources/__files/integrationtesting/batch-3.json
+++ b/irs-api/src/test/resources/__files/integrationtesting/batch-3.json
@@ -10,7 +10,7 @@
}
],
"manufacturingInformation": {
- "date": "2022-02-04T14:48:54",
+ "date": "2022-02-04T14:48:54Z",
"country": "HUR"
},
"catenaXId": "urn:uuid:a314ad6b-77ea-417e-ae2d-193b3e249e99",
diff --git a/irs-api/src/test/resources/__files/integrationtesting/singleLevelBomAsBuilt#2.0.0.json b/irs-api/src/test/resources/__files/integrationtesting/singleLevelBomAsBuilt#2.0.0.json
new file mode 100644
index 0000000000..9889be9e15
--- /dev/null
+++ b/irs-api/src/test/resources/__files/integrationtesting/singleLevelBomAsBuilt#2.0.0.json
@@ -0,0 +1,16 @@
+{
+ "catenaXId": "urn:uuid:7e4541ea-bb0f-464c-8cb3-021abccbfaf5",
+ "childItems": [
+ {
+ "catenaXId": "urn:uuid:a314ad6b-77ea-417e-ae2d-193b3e249e99",
+ "quantity": {
+ "quantityNumber": 0.4014,
+ "measurementUnit": "unit:kilogram"
+ },
+ "hasAlternatives": true,
+ "businessPartner": "BPNL00000000TEST",
+ "createdOn": "2022-02-03T14:48:54.709Z",
+ "lastModifiedOn": "2022-02-03T14:48:54.709Z"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/irs-api/src/test/resources/__files/integrationtesting/singleLevelBomAsBuilt-2.json b/irs-api/src/test/resources/__files/integrationtesting/singleLevelBomAsBuilt-2.json
index 9889be9e15..a7700632f2 100644
--- a/irs-api/src/test/resources/__files/integrationtesting/singleLevelBomAsBuilt-2.json
+++ b/irs-api/src/test/resources/__files/integrationtesting/singleLevelBomAsBuilt-2.json
@@ -4,8 +4,8 @@
{
"catenaXId": "urn:uuid:a314ad6b-77ea-417e-ae2d-193b3e249e99",
"quantity": {
- "quantityNumber": 0.4014,
- "measurementUnit": "unit:kilogram"
+ "value": 0.4014,
+ "unit": "unit:kilogram"
},
"hasAlternatives": true,
"businessPartner": "BPNL00000000TEST",
diff --git a/pom.xml b/pom.xml
index 7d56ccd0dd..a9ee43e4aa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -97,7 +97,7 @@
1.78
3.5.2
1.17.2
- 0.12.4
+ 1.4.0
2.16.1
3.12.0
4.12.0