diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-04-16 17:18:10 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-16 17:18:10 +0000 |
commit | 241aa508172037a7fd5a17d4d9217e660a2bad48 (patch) | |
tree | f8cd7f66d6aa985a4eddbd2bea919f039c4c4dc7 /main | |
parent | bdcdec03d07abebbdf40afdff74e4fd540ce78b4 (diff) | |
parent | 3bdc959fb751bd85544cbbe003cd46b721e17375 (diff) |
Merge "Fix more sonar issues"
Diffstat (limited to 'main')
3 files changed, 27 insertions, 20 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java index b9a0a6dc..c17d4086 100644 --- a/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java +++ b/main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java @@ -260,7 +260,7 @@ public abstract class RequestImpl implements Request { String reason = checkResponse(response); if (reason != null) { - logger.info("{} PDP data mismatch via {}: {}", getName(), infra, reason); + logger.info("{} PDP data mismatch via {} {}: {}", getName(), infra, topic, reason); listener.failure(pdpName, reason); return; } diff --git a/main/src/main/java/org/onap/policy/pap/main/rest/depundep/ProviderBase.java b/main/src/main/java/org/onap/policy/pap/main/rest/depundep/ProviderBase.java index 999941f2..07d04c24 100644 --- a/main/src/main/java/org/onap/policy/pap/main/rest/depundep/ProviderBase.java +++ b/main/src/main/java/org/onap/policy/pap/main/rest/depundep/ProviderBase.java @@ -148,11 +148,10 @@ public abstract class ProviderBase<R extends SimpleResponse> { * @param desiredPolicy the policy desired, with the "name" and optional * "policyVersion" populated * @return the matching Policy type - * @throws PfModelException if a DAO error occurred - * @throws PolicyPapRuntimeException if there is no matching policy type + * @throws PolicyPapRuntimeException if there is no matching policy type or a DAO + * error occurs */ - private ToscaPolicy getPolicy(SessionData data, ToscaPolicyIdentifierOptVersion desiredPolicy) - throws PfModelException { + private ToscaPolicy getPolicy(SessionData data, ToscaPolicyIdentifierOptVersion desiredPolicy) { return data.getPolicy(desiredPolicy); } 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 b7aff765..5cd2f803 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 @@ -102,21 +102,7 @@ public class SessionData { try { ToscaPolicyFilterBuilder filterBuilder = ToscaPolicyFilter.builder().name(desiredPolicy.getName()); - - String version = desiredPolicy.getVersion(); - if (version == null) { - // no version specified - get the latest - filterBuilder.version(ToscaPolicyFilter.LATEST_VERSION); - - } else if (VERSION_PREFIX_PAT.matcher(version).matches()) { - // version prefix provided - match the prefix and then pick the latest - filterBuilder.versionPrefix(version + ".").version(ToscaPolicyFilter.LATEST_VERSION); - - } else { - // must be an exact match - filterBuilder.version(version); - } - + setPolicyFilterVersion(filterBuilder, desiredPolicy.getVersion()); List<ToscaPolicy> lst = dao.getFilteredPolicyList(filterBuilder.build()); if (lst.isEmpty()) { @@ -139,6 +125,28 @@ public class SessionData { } /** + * Sets the "version" in a policy filter. + * + * @param filterBuilder filter builder whose version should be set + * @param desiredVersion desired version + */ + private void setPolicyFilterVersion(ToscaPolicyFilterBuilder filterBuilder, String desiredVersion) { + + if (desiredVersion == null) { + // no version specified - get the latest + filterBuilder.version(ToscaPolicyFilter.LATEST_VERSION); + + } else if (VERSION_PREFIX_PAT.matcher(desiredVersion).matches()) { + // version prefix provided - match the prefix and then pick the latest + filterBuilder.versionPrefix(desiredVersion + ".").version(ToscaPolicyFilter.LATEST_VERSION); + + } else { + // must be an exact match + filterBuilder.version(desiredVersion); + } + } + + /** * Adds an update and state-change to the sets, replacing any previous entries for the * given PDP. * |