summaryrefslogtreecommitdiffstats
path: root/common-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'common-be/src')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaConcatFunction.java4
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java22
2 files changed, 20 insertions, 6 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaConcatFunction.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaConcatFunction.java
index 62307fb4be..975721be26 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaConcatFunction.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaConcatFunction.java
@@ -53,4 +53,8 @@ public class ToscaConcatFunction implements ToscaFunction, ToscaFunctionParamete
);
}
+ public void addParameter(final ToscaFunctionParameter functionParameter) {
+ this.parameters.add(functionParameter);
+ }
+
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java
index fda832b98e..363af1cdeb 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaFunctionJsonDeserializer.java
@@ -105,9 +105,11 @@ public class ToscaFunctionJsonDeserializer extends StdDeserializer<ToscaFunction
final DeserializationContext context) throws JsonMappingException {
final ToscaGetFunctionDataDefinition toscaGetFunction = new ToscaGetFunctionDataDefinition();
toscaGetFunction.setFunctionType(ToscaGetFunctionType.fromToscaFunctionType(toscaFunctionType).orElse(null));
- toscaGetFunction.setSourceName(node.get("sourceName").asText());
- toscaGetFunction.setPropertyUniqueId(node.get("propertyUniqueId").asText());
- final String propertySource = node.get("propertySource").asText();
+ toscaGetFunction.setSourceName(getAsTextOrElseNull(node, "sourceName"));
+ toscaGetFunction.setSourceUniqueId(getAsTextOrElseNull(node, "sourceUniqueId"));
+ toscaGetFunction.setPropertyName(getAsTextOrElseNull(node, "propertyName"));
+ toscaGetFunction.setPropertyUniqueId(getAsTextOrElseNull(node, "propertyUniqueId"));
+ final String propertySource = getAsTextOrElseNull(node, "propertySource");
if (StringUtils.isNotEmpty(propertySource)) {
final PropertySource propertySource1 = PropertySource.findType(propertySource).orElseThrow(() ->
context.instantiationException(ToscaGetFunctionDataDefinition.class,
@@ -115,9 +117,6 @@ public class ToscaFunctionJsonDeserializer extends StdDeserializer<ToscaFunction
);
toscaGetFunction.setPropertySource(propertySource1);
}
- toscaGetFunction.setPropertyName(node.get("propertyName").asText());
- toscaGetFunction.setSourceName(node.get("sourceName").asText());
- toscaGetFunction.setSourceUniqueId(node.get("sourceUniqueId").asText());
final JsonNode propertyPathFromSourceNode = node.get("propertyPathFromSource");
if (propertyPathFromSourceNode != null) {
if (!propertyPathFromSourceNode.isArray()) {
@@ -131,6 +130,17 @@ public class ToscaFunctionJsonDeserializer extends StdDeserializer<ToscaFunction
return toscaGetFunction;
}
+ private String getAsTextOrElseNull(final JsonNode node, final String fieldName) {
+ final JsonNode jsonNode = node.get(fieldName);
+ if (jsonNode == null) {
+ return null;
+ }
+ if (!jsonNode.isTextual()) {
+ return null;
+ }
+ return jsonNode.asText();
+ }
+
private ToscaConcatFunction deserializeConcatFunction(final JsonNode concatFunctionJsonNode,
final DeserializationContext context) throws IOException {
final var toscaConcatFunction = new ToscaConcatFunction();