summaryrefslogtreecommitdiffstats
path: root/cps-service/src/main/java
diff options
context:
space:
mode:
authoraditya puthuparambil <aditya.puthuparambil@bell.ca>2022-09-20 08:47:02 +0000
committerGerrit Code Review <gerrit@onap.org>2022-09-20 08:47:02 +0000
commitdd151f17eed71ea1ef7c2e6e5fe9168a5ae37abb (patch)
tree9581774d8e6438a0eb49cdbb03f29ebdc8f59b85 /cps-service/src/main/java
parent9978739d2f5d5abb48b29822ac9470fc8758cd0f (diff)
parentce559bf358caf180ba3b61d43a2cf86dd3f3e111 (diff)
Merge "Xpath to NodeId invalid"
Diffstat (limited to 'cps-service/src/main/java')
-rw-r--r--cps-service/src/main/java/org/onap/cps/utils/YangUtils.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java b/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java
index 8c32010d7b..5e1b486aa0 100644
--- a/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java
+++ b/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java
@@ -52,7 +52,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class YangUtils {
private static final String XPATH_DELIMITER_REGEX = "\\/";
- private static final String XPATH_NODE_KEY_ATTRIBUTES_REGEX = "\\[.+";
+ private static final String XPATH_NODE_KEY_ATTRIBUTES_REGEX = "\\[.*?\\]";
+ //Might cause an issue with [] inside [] in key-values
/**
* Parses jsonData into NormalizedNode according to given schema context.
@@ -149,10 +150,11 @@ public class YangUtils {
}
private static String[] xpathToNodeIdSequence(final String xpath) {
- final String[] xpathNodeIdSequence = Arrays.stream(xpath.split(XPATH_DELIMITER_REGEX))
- .map(identifier -> identifier.replaceFirst(XPATH_NODE_KEY_ATTRIBUTES_REGEX, ""))
- .filter(identifier -> !identifier.isEmpty())
- .toArray(String[]::new);
+ final String[] xpathNodeIdSequence = Arrays.stream(xpath
+ .replaceAll(XPATH_NODE_KEY_ATTRIBUTES_REGEX, "")
+ .split(XPATH_DELIMITER_REGEX))
+ .filter(identifier -> !identifier.isEmpty())
+ .toArray(String[]::new);
if (xpathNodeIdSequence.length < 1) {
throw new DataValidationException("Invalid xpath.", "Xpath contains no node identifiers.");
}