aboutsummaryrefslogtreecommitdiffstats
path: root/common-app-api
diff options
context:
space:
mode:
authorTal Gitelman <tal.gitelman@att.com>2018-11-25 11:49:39 +0200
committerMichael Lando <michael.lando@intl.att.com>2018-11-26 17:22:11 +0000
commit4d34afb67ad28e83e07cdd365c985b6fb8745ebe (patch)
tree0a1109df00d7cc34f9300ea7f67c0ea211067e30 /common-app-api
parent8f2c29ba8962f036c2b4c652f6072d477a81d4f0 (diff)
SDC can not handle complex string in tosca yaml
Issue-ID: SDC-1918 Change-Id: I86957b5d4bf0dab5ca749623efbccd6f4b535f10 Signed-off-by: Tal Gitelman <tal.gitelman@att.com>
Diffstat (limited to 'common-app-api')
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java30
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java2
2 files changed, 30 insertions, 2 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
index 0ee097b979..adfa457166 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
@@ -259,7 +259,35 @@ public class ValidationUtils {
}
public static String normaliseWhitespace(String str) {
- return StringUtil.normaliseWhitespace(str);
+ StringBuilder sb = new StringBuilder(str.length());
+ appendNormalisedWhitespace(sb, str, false);
+ return sb.toString();
+ }
+
+ private static void appendNormalisedWhitespace(StringBuilder accum, String string, boolean stripLeading) {
+ boolean lastWasWhite = false;
+ boolean reachedNonWhite = false;
+
+ int len = string.length();
+ int c;
+ for (int i = 0; i < len; i+= Character.charCount(c)) {
+ c = string.codePointAt(i);
+ if (isWhitespace(c)) {
+ if ((stripLeading && !reachedNonWhite) || lastWasWhite)
+ continue;
+ accum.append(' ');
+ lastWasWhite = true;
+ }
+ else {
+ accum.appendCodePoint(c);
+ lastWasWhite = false;
+ reachedNonWhite = true;
+ }
+ }
+ }
+
+ private static boolean isWhitespace(int c){
+ return c == ' ';
}
public static String stripOctets(String str) {
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java
index e59f6a061f..9806bffc5e 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java
@@ -146,7 +146,7 @@ public class CommonUtilsTest {
public void testnormaliseWhitespace() {
assertEquals("goo boo", ValidationUtils.normaliseWhitespace("goo boo"));
- assertEquals("goo boo ", ValidationUtils.normaliseWhitespace("goo boo "));
+ assertEquals("goo boo ", ValidationUtils.normaliseWhitespace("goo boo "));
assertEquals("goo boo", ValidationUtils.normaliseWhitespace("goo boo"));
}