Skip to content

Commit 7324827

Browse files
Merge pull request #238 from fjtirado/removing_everit
Removing gson and everit dependencies
2 parents e7d378d + b804116 commit 7324827

File tree

18 files changed

+367
-456
lines changed

18 files changed

+367
-456
lines changed

api/pom.xml

-12
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,19 @@
2626
<dependency>
2727
<groupId>com.fasterxml.jackson.core</groupId>
2828
<artifactId>jackson-core</artifactId>
29-
<version>[2.13.0,)</version>
3029
</dependency>
3130
<dependency>
3231
<groupId>com.fasterxml.jackson.core</groupId>
3332
<artifactId>jackson-databind</artifactId>
34-
<version>[2.13.0,)</version>
3533
</dependency>
3634
<dependency>
3735
<groupId>com.fasterxml.jackson.dataformat</groupId>
3836
<artifactId>jackson-dataformat-yaml</artifactId>
39-
<version>[2.13.0,)</version>
4037
</dependency>
4138
<dependency>
4239
<groupId>javax.validation</groupId>
4340
<artifactId>validation-api</artifactId>
4441
</dependency>
45-
<dependency>
46-
<groupId>org.json</groupId>
47-
<artifactId>json</artifactId>
48-
</dependency>
49-
<dependency>
50-
<groupId>com.github.erosb</groupId>
51-
<artifactId>everit-json-schema</artifactId>
52-
</dependency>
53-
5442
<!-- test -->
5543
<dependency>
5644
<groupId>org.junit.jupiter</groupId>

api/src/main/java/io/serverlessworkflow/api/deserializers/AuthDeserializer.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
import com.fasterxml.jackson.databind.JsonNode;
2121
import com.fasterxml.jackson.databind.ObjectMapper;
2222
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
23-
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
2423
import io.serverlessworkflow.api.auth.AuthDefinition;
2524
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
2625
import io.serverlessworkflow.api.utils.Utils;
2726
import io.serverlessworkflow.api.workflow.Auth;
2827
import java.io.IOException;
2928
import java.util.ArrayList;
3029
import java.util.List;
31-
import org.json.JSONObject;
3230
import org.slf4j.Logger;
3331
import org.slf4j.LoggerFactory;
3432

@@ -69,21 +67,8 @@ public Auth deserialize(JsonParser jp, DeserializationContext ctxt) throws IOExc
6967
} else {
7068
String authFileDef = node.asText();
7169
String authFileSrc = Utils.getResourceFileAsString(authFileDef);
72-
JsonNode authRefNode;
73-
ObjectMapper jsonWriter = new ObjectMapper();
7470
if (authFileSrc != null && authFileSrc.trim().length() > 0) {
75-
// if its a yaml def convert to json first
76-
if (!authFileSrc.trim().startsWith("{")) {
77-
// convert yaml to json to validate
78-
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
79-
Object obj = yamlReader.readValue(authFileSrc, Object.class);
80-
81-
authRefNode =
82-
jsonWriter.readTree(new JSONObject(jsonWriter.writeValueAsString(obj)).toString());
83-
} else {
84-
authRefNode = jsonWriter.readTree(new JSONObject(authFileSrc).toString());
85-
}
86-
71+
JsonNode authRefNode = Utils.getNode(authFileSrc);
8772
JsonNode refAuth = authRefNode.get("auth");
8873
if (refAuth != null) {
8974
for (final JsonNode nodeEle : refAuth) {

api/src/main/java/io/serverlessworkflow/api/deserializers/ConstantsDeserializer.java

+1-17
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@
1818
import com.fasterxml.jackson.core.JsonParser;
1919
import com.fasterxml.jackson.databind.DeserializationContext;
2020
import com.fasterxml.jackson.databind.JsonNode;
21-
import com.fasterxml.jackson.databind.ObjectMapper;
2221
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
23-
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
2422
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
2523
import io.serverlessworkflow.api.utils.Utils;
2624
import io.serverlessworkflow.api.workflow.Constants;
2725
import java.io.IOException;
28-
import org.json.JSONObject;
2926
import org.slf4j.Logger;
3027
import org.slf4j.LoggerFactory;
3128

@@ -64,21 +61,8 @@ public Constants deserialize(JsonParser jp, DeserializationContext ctxt) throws
6461
String constantsFileDef = node.asText();
6562
constants.setRefValue(constantsFileDef);
6663
String constantsFileSrc = Utils.getResourceFileAsString(constantsFileDef);
67-
JsonNode constantsRefNode;
68-
ObjectMapper jsonWriter = new ObjectMapper();
6964
if (constantsFileSrc != null && constantsFileSrc.trim().length() > 0) {
70-
// if its a yaml def convert to json first
71-
if (!constantsFileSrc.trim().startsWith("{")) {
72-
// convert yaml to json to validate
73-
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
74-
Object obj = yamlReader.readValue(constantsFileSrc, Object.class);
75-
76-
constantsRefNode =
77-
jsonWriter.readTree(new JSONObject(jsonWriter.writeValueAsString(obj)).toString());
78-
} else {
79-
constantsRefNode = jsonWriter.readTree(new JSONObject(constantsFileSrc).toString());
80-
}
81-
65+
JsonNode constantsRefNode = Utils.getNode(constantsFileSrc);
8266
JsonNode refConstants = constantsRefNode.get("constants");
8367
if (refConstants != null) {
8468
constantsDefinition = refConstants;

api/src/main/java/io/serverlessworkflow/api/deserializers/ErrorsDeserializer.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
import com.fasterxml.jackson.databind.JsonNode;
2121
import com.fasterxml.jackson.databind.ObjectMapper;
2222
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
23-
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
2423
import io.serverlessworkflow.api.error.ErrorDefinition;
2524
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
2625
import io.serverlessworkflow.api.utils.Utils;
2726
import io.serverlessworkflow.api.workflow.Errors;
2827
import java.io.IOException;
2928
import java.util.ArrayList;
3029
import java.util.List;
31-
import org.json.JSONObject;
3230
import org.slf4j.Logger;
3331
import org.slf4j.LoggerFactory;
3432

@@ -69,21 +67,8 @@ public Errors deserialize(JsonParser jp, DeserializationContext ctxt) throws IOE
6967
} else {
7068
String errorsFileDef = node.asText();
7169
String errorsFileSrc = Utils.getResourceFileAsString(errorsFileDef);
72-
JsonNode errorsRefNode;
73-
ObjectMapper jsonWriter = new ObjectMapper();
7470
if (errorsFileSrc != null && errorsFileSrc.trim().length() > 0) {
75-
// if its a yaml def convert to json first
76-
if (!errorsFileSrc.trim().startsWith("{")) {
77-
// convert yaml to json to validate
78-
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
79-
Object obj = yamlReader.readValue(errorsFileSrc, Object.class);
80-
81-
errorsRefNode =
82-
jsonWriter.readTree(new JSONObject(jsonWriter.writeValueAsString(obj)).toString());
83-
} else {
84-
errorsRefNode = jsonWriter.readTree(new JSONObject(errorsFileSrc).toString());
85-
}
86-
71+
JsonNode errorsRefNode = Utils.getNode(errorsFileSrc);
8772
JsonNode refErrors = errorsRefNode.get("errors");
8873
if (refErrors != null) {
8974
for (final JsonNode nodeEle : refErrors) {

api/src/main/java/io/serverlessworkflow/api/deserializers/EventsDeserializer.java

+1-15
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
import com.fasterxml.jackson.databind.JsonNode;
2121
import com.fasterxml.jackson.databind.ObjectMapper;
2222
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
23-
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
2423
import io.serverlessworkflow.api.events.EventDefinition;
2524
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
2625
import io.serverlessworkflow.api.utils.Utils;
2726
import io.serverlessworkflow.api.workflow.Events;
2827
import java.io.IOException;
2928
import java.util.ArrayList;
3029
import java.util.List;
31-
import org.json.JSONObject;
3230
import org.slf4j.Logger;
3331
import org.slf4j.LoggerFactory;
3432

@@ -69,21 +67,9 @@ public Events deserialize(JsonParser jp, DeserializationContext ctxt) throws IOE
6967
} else {
7068
String eventsFileDef = node.asText();
7169
String eventsFileSrc = Utils.getResourceFileAsString(eventsFileDef);
72-
JsonNode eventsRefNode;
73-
ObjectMapper jsonWriter = new ObjectMapper();
7470
if (eventsFileSrc != null && eventsFileSrc.trim().length() > 0) {
7571
// if its a yaml def convert to json first
76-
if (!eventsFileSrc.trim().startsWith("{")) {
77-
// convert yaml to json to validate
78-
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
79-
Object obj = yamlReader.readValue(eventsFileSrc, Object.class);
80-
81-
eventsRefNode =
82-
jsonWriter.readTree(new JSONObject(jsonWriter.writeValueAsString(obj)).toString());
83-
} else {
84-
eventsRefNode = jsonWriter.readTree(new JSONObject(eventsFileSrc).toString());
85-
}
86-
72+
JsonNode eventsRefNode = Utils.getNode(eventsFileSrc);
8773
JsonNode refEvents = eventsRefNode.get("events");
8874
if (refEvents != null) {
8975
for (final JsonNode nodeEle : refEvents) {

api/src/main/java/io/serverlessworkflow/api/deserializers/FunctionsDeserializer.java

+1-14
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
import com.fasterxml.jackson.databind.JsonNode;
2121
import com.fasterxml.jackson.databind.ObjectMapper;
2222
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
23-
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
2423
import io.serverlessworkflow.api.functions.FunctionDefinition;
2524
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
2625
import io.serverlessworkflow.api.utils.Utils;
2726
import io.serverlessworkflow.api.workflow.Functions;
2827
import java.io.IOException;
2928
import java.util.ArrayList;
3029
import java.util.List;
31-
import org.json.JSONObject;
3230
import org.slf4j.Logger;
3331
import org.slf4j.LoggerFactory;
3432

@@ -69,20 +67,9 @@ public Functions deserialize(JsonParser jp, DeserializationContext ctxt) throws
6967
String functionsFileDef = node.asText();
7068
String functionsFileSrc = Utils.getResourceFileAsString(functionsFileDef);
7169
JsonNode functionsRefNode;
72-
ObjectMapper jsonWriter = new ObjectMapper();
7370
if (functionsFileSrc != null && functionsFileSrc.trim().length() > 0) {
7471
// if its a yaml def convert to json first
75-
if (!functionsFileSrc.trim().startsWith("{")) {
76-
// convert yaml to json to validate
77-
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
78-
Object obj = yamlReader.readValue(functionsFileSrc, Object.class);
79-
80-
functionsRefNode =
81-
jsonWriter.readTree(new JSONObject(jsonWriter.writeValueAsString(obj)).toString());
82-
} else {
83-
functionsRefNode = jsonWriter.readTree(new JSONObject(functionsFileSrc).toString());
84-
}
85-
72+
functionsRefNode = Utils.getNode(functionsFileSrc);
8673
JsonNode refFunctions = functionsRefNode.get("functions");
8774
if (refFunctions != null) {
8875
for (final JsonNode nodeEle : refFunctions) {

api/src/main/java/io/serverlessworkflow/api/deserializers/RetriesDeserializer.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
import com.fasterxml.jackson.databind.JsonNode;
2121
import com.fasterxml.jackson.databind.ObjectMapper;
2222
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
23-
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
2423
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
2524
import io.serverlessworkflow.api.retry.RetryDefinition;
2625
import io.serverlessworkflow.api.utils.Utils;
2726
import io.serverlessworkflow.api.workflow.Retries;
2827
import java.io.IOException;
2928
import java.util.ArrayList;
3029
import java.util.List;
31-
import org.json.JSONObject;
3230
import org.slf4j.Logger;
3331
import org.slf4j.LoggerFactory;
3432

@@ -69,21 +67,8 @@ public Retries deserialize(JsonParser jp, DeserializationContext ctxt) throws IO
6967
} else {
7068
String retriesFileDef = node.asText();
7169
String retriesFileSrc = Utils.getResourceFileAsString(retriesFileDef);
72-
JsonNode retriesRefNode;
73-
ObjectMapper jsonWriter = new ObjectMapper();
7470
if (retriesFileSrc != null && retriesFileSrc.trim().length() > 0) {
75-
// if its a yaml def convert to json first
76-
if (!retriesFileSrc.trim().startsWith("{")) {
77-
// convert yaml to json to validate
78-
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
79-
Object obj = yamlReader.readValue(retriesFileSrc, Object.class);
80-
81-
retriesRefNode =
82-
jsonWriter.readTree(new JSONObject(jsonWriter.writeValueAsString(obj)).toString());
83-
} else {
84-
retriesRefNode = jsonWriter.readTree(new JSONObject(retriesFileSrc).toString());
85-
}
86-
71+
JsonNode retriesRefNode = Utils.getNode(retriesFileSrc);
8772
JsonNode refRetries = retriesRefNode.get("retries");
8873
if (refRetries != null) {
8974
for (final JsonNode nodeEle : refRetries) {

api/src/main/java/io/serverlessworkflow/api/deserializers/SecretsDeserializer.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@
1818
import com.fasterxml.jackson.core.JsonParser;
1919
import com.fasterxml.jackson.databind.DeserializationContext;
2020
import com.fasterxml.jackson.databind.JsonNode;
21-
import com.fasterxml.jackson.databind.ObjectMapper;
2221
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
23-
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
2422
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
2523
import io.serverlessworkflow.api.utils.Utils;
2624
import io.serverlessworkflow.api.workflow.Secrets;
2725
import java.io.IOException;
2826
import java.util.ArrayList;
2927
import java.util.List;
30-
import org.json.JSONObject;
3128
import org.slf4j.Logger;
3229
import org.slf4j.LoggerFactory;
3330

@@ -66,21 +63,9 @@ public Secrets deserialize(JsonParser jp, DeserializationContext ctxt) throws IO
6663
} else {
6764
String secretsFileDef = node.asText();
6865
String secretsFileSrc = Utils.getResourceFileAsString(secretsFileDef);
69-
JsonNode secretsRefNode;
70-
ObjectMapper jsonWriter = new ObjectMapper();
7166
if (secretsFileSrc != null && secretsFileSrc.trim().length() > 0) {
7267
// if its a yaml def convert to json first
73-
if (!secretsFileSrc.trim().startsWith("{")) {
74-
// convert yaml to json to validate
75-
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
76-
Object obj = yamlReader.readValue(secretsFileSrc, Object.class);
77-
78-
secretsRefNode =
79-
jsonWriter.readTree(new JSONObject(jsonWriter.writeValueAsString(obj)).toString());
80-
} else {
81-
secretsRefNode = jsonWriter.readTree(new JSONObject(secretsFileSrc).toString());
82-
}
83-
68+
JsonNode secretsRefNode = Utils.getNode(secretsFileSrc);
8469
JsonNode refSecrets = secretsRefNode.get("secrets");
8570
if (refSecrets != null) {
8671
for (final JsonNode nodeEle : refSecrets) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.api.mapper;
17+
18+
import com.fasterxml.jackson.databind.ObjectMapper;
19+
20+
public class JsonObjectMapperFactory {
21+
22+
private static final ObjectMapper instance = new JsonObjectMapper();
23+
24+
public static final ObjectMapper mapper() {
25+
return instance;
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.api.mapper;
17+
18+
import com.fasterxml.jackson.databind.ObjectMapper;
19+
20+
public class YamlObjectMapperFactory {
21+
22+
private static final ObjectMapper instance = new YamlObjectMapper();
23+
24+
public static final ObjectMapper mapper() {
25+
return instance;
26+
}
27+
}

api/src/main/java/io/serverlessworkflow/api/schemaclient/ResourceSchemaClient.java

-38
This file was deleted.

0 commit comments

Comments
 (0)