summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java23
-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
4 files changed, 42 insertions, 28 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
index b3bc1401..c0a78fa0 100644
--- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
+++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +24,7 @@ package org.onap.policy.pap.main.comm;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-
+import org.apache.commons.lang3.builder.EqualsBuilder;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.Pdp;
@@ -221,13 +222,19 @@ public class PdpStatusMessageHandler {
}
private boolean validatePdpDetails(final PdpStatus message, final PdpGroup pdpGroup, final PdpSubGroup subGroup,
- final Pdp pdpInstanceDetails) {
-
- return message.getPdpGroup().equals(pdpGroup.getName())
- && message.getPdpSubgroup().equals(subGroup.getPdpType())
- && message.getState().equals(pdpInstanceDetails.getPdpState())
- && message.getSupportedPolicyTypes().containsAll(subGroup.getSupportedPolicyTypes())
- && message.getPdpType().equals(subGroup.getPdpType());
+ final Pdp pdpInstanceDetails) {
+
+ /*
+ * "EqualsBuilder" is a bit of a misnomer, as it uses containsAll() to check
+ * supported policy types. Nevertheless, it does the job and provides a convenient
+ * way to build a bunch of comparisons.
+ */
+ return new EqualsBuilder().append(message.getPdpGroup(), pdpGroup.getName())
+ .append(message.getPdpSubgroup(), subGroup.getPdpType())
+ .append(message.getPdpType(), subGroup.getPdpType())
+ .append(message.getState(), pdpInstanceDetails.getPdpState())
+ .append(message.getSupportedPolicyTypes().containsAll(subGroup.getSupportedPolicyTypes()), true)
+ .build();
}
private void updatePdpHealthStatus(final PdpStatus message, final PdpSubGroup pdpSubgroup, final Pdp pdpInstance,
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.
*