|
18 | 18 | import com.fasterxml.jackson.core.JsonParser;
|
19 | 19 | import com.fasterxml.jackson.databind.DeserializationContext;
|
20 | 20 | import com.fasterxml.jackson.databind.JsonNode;
|
21 |
| -import com.fasterxml.jackson.databind.ObjectMapper; |
22 | 21 | import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
23 |
| -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; |
24 | 22 | import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
|
25 | 23 | import io.serverlessworkflow.api.utils.Utils;
|
26 | 24 | import io.serverlessworkflow.api.workflow.Constants;
|
27 | 25 | import java.io.IOException;
|
28 |
| -import org.json.JSONObject; |
29 | 26 | import org.slf4j.Logger;
|
30 | 27 | import org.slf4j.LoggerFactory;
|
31 | 28 |
|
@@ -64,21 +61,8 @@ public Constants deserialize(JsonParser jp, DeserializationContext ctxt) throws
|
64 | 61 | String constantsFileDef = node.asText();
|
65 | 62 | constants.setRefValue(constantsFileDef);
|
66 | 63 | String constantsFileSrc = Utils.getResourceFileAsString(constantsFileDef);
|
67 |
| - JsonNode constantsRefNode; |
68 |
| - ObjectMapper jsonWriter = new ObjectMapper(); |
69 | 64 | 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); |
82 | 66 | JsonNode refConstants = constantsRefNode.get("constants");
|
83 | 67 | if (refConstants != null) {
|
84 | 68 | constantsDefinition = refConstants;
|
|
0 commit comments