diff options
author | Jorge Hernandez <jorge.hernandez-herrero@att.com> | 2019-06-21 16:31:55 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-06-21 16:31:55 +0000 |
commit | 314c360af45d80a51f2d70de32537d90e964c860 (patch) | |
tree | 4a982af8e6c55e081b36d51fcfba47cfd9f79153 /main/src/main/java/org/onap/policy/pap/main/rest/depundep/SessionData.java | |
parent | 79e76f5e61f62178b1e88cb00711395d1d07ca9f (diff) | |
parent | b346fda03f450ccf9f8adb143f872cfce6ba76a8 (diff) |
Merge "Allow integer version when using PDP Group Deploy"
Diffstat (limited to 'main/src/main/java/org/onap/policy/pap/main/rest/depundep/SessionData.java')
-rw-r--r-- | main/src/main/java/org/onap/policy/pap/main/rest/depundep/SessionData.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/depundep/SessionData.java b/main/src/main/java/org/onap/policy/pap/main/rest/depundep/SessionData.java index ee83fb74..437d7a11 100644 --- a/main/src/main/java/org/onap/policy/pap/main/rest/depundep/SessionData.java +++ b/main/src/main/java/org/onap/policy/pap/main/rest/depundep/SessionData.java @@ -54,7 +54,7 @@ public class SessionData { * If a version string matches this, then it is just a prefix (i.e., major or * major.minor). */ - private static final Pattern VERSION_PREFIX_PAT = Pattern.compile("[^.]+(?:[.][^.]*)?"); + private static final Pattern VERSION_PREFIX_PAT = Pattern.compile("[^.]+(?:[.][^.]+)?"); /** * DB provider. @@ -165,7 +165,7 @@ public class SessionData { // no version specified - get the latest filterBuilder.version(ToscaPolicyFilter.LATEST_VERSION); - } else if (VERSION_PREFIX_PAT.matcher(desiredVersion).matches()) { + } else if (isVersionPrefix(desiredVersion)) { // version prefix provided - match the prefix and then pick the latest filterBuilder.versionPrefix(desiredVersion + ".").version(ToscaPolicyFilter.LATEST_VERSION); @@ -176,6 +176,17 @@ public class SessionData { } /** + * Determines if a version contains only a prefix. + * + * @param version version to inspect + * @return {@code true} if the version contains only a prefix, {@code false} if it is + * fully qualified + */ + public static boolean isVersionPrefix(String version) { + return VERSION_PREFIX_PAT.matcher(version).matches(); + } + + /** * Adds an update and state-change to the sets, replacing any previous entries for the * given PDP. * |