aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-04-16 09:31:48 -0400
committerJim Hahn <jrh3@att.com>2019-04-16 09:46:18 -0400
commit3bdc959fb751bd85544cbbe003cd46b721e17375 (patch)
treeb83867a166969056dd9b3f643a1a1cc897677ee3 /main
parent8714a151ff87751b54c362c8a9248995e665e896 (diff)
Fix more sonar issues
Added another unused parameter from RequestImpl to a logging message. Removed "throws PfModelException" from ProviderBase. Shorten lambda function in SessionData. Change-Id: I5c0ba99bd92ac94bdeacd2398fbc65f081ef85ad Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/msgdata/RequestImpl.java2
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/depundep/ProviderBase.java7
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/rest/depundep/SessionData.java38
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.
*