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;
}
* @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);
}
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()) {
return policy;
}
+ /**
+ * 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.