From 3e54d3de51fa86255ca5059c59fd68aea0f59488 Mon Sep 17 00:00:00 2001 From: talio Date: Thu, 16 Nov 2017 10:05:26 +0200 Subject: nova server validator fixed validation of nova server name value inside env file Issue - Id : SDC-670 Change-Id: If407a2c1f601b4b724c50c1994fd056b569588ac Signed-off-by: talio --- .../heat/datatypes/DefinedHeatParameterTypes.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'openecomp-be/lib/openecomp-heat-lib/src') diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/DefinedHeatParameterTypes.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/DefinedHeatParameterTypes.java index d4b6a88ba9..54b071f651 100644 --- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/DefinedHeatParameterTypes.java +++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/DefinedHeatParameterTypes.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.heat.datatypes; import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.ClassUtils; import java.util.HashMap; import java.util.List; @@ -72,14 +73,13 @@ public enum DefinedHeatParameterTypes { return HeatBoolean.isValueBoolean(value); case COMMA_DELIMITED_LIST: - String valAsString = String.valueOf(value); - return valAsString.split(",") instanceof String[]; + return isValueCommaDelimitedList(value); case JSON: - return (value instanceof Map) || (value instanceof List); + return isValueJson(value); case STRING: - return true; + return isValueString(value); default: } } @@ -92,6 +92,20 @@ public enum DefinedHeatParameterTypes { || isValueIsFromGivenType(value, STRING.getType()); } + private static boolean isValueCommaDelimitedList(Object value) { + return String.valueOf(value).contains(",") + || isValueIsFromGivenType(value, DefinedHeatParameterTypes.STRING.type); + } + + private static boolean isValueString(Object value) { + return value instanceof String + || ClassUtils.isPrimitiveOrWrapper(value.getClass()); + } + + private static boolean isValueJson(Object value) { + return (value instanceof Map) || (value instanceof List); + } + public static boolean isEmptyValueInEnv(Object value) { return Objects.isNull(value); } -- cgit 1.2.3-korg