aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java')
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java35
1 files changed, 19 insertions, 16 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java
index 2e2a74015..e9db043bf 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java
@@ -3,6 +3,7 @@
* ONAP-PAP-REST
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,14 +34,14 @@ import java.util.List;
import java.util.UUID;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.rest.XACMLRestProperties;
-import org.onap.policy.rest.jpa.PolicyDBDaoEntity;
+import org.onap.policy.rest.XacmlRestProperties;
+import org.onap.policy.rest.jpa.PolicyDbDaoEntity;
import org.onap.policy.utils.PeCryptoUtils;
public class NotifyOtherPaps {
private static final Logger LOGGER = FlexLogger.getLogger(NotifyOtherPaps.class);
- private List<PolicyDBDaoEntity> failedPaps = null;
+ private List<PolicyDbDaoEntity> failedPaps = null;
public void notifyOthers(long entityId, String entityType) {
notifyOthers(entityId, entityType, null);
@@ -55,10 +56,10 @@ public class NotifyOtherPaps {
*/
public void notifyOthers(long entityId, String entityType, String newGroupId) {
LOGGER.debug("notifyOthers(long entityId, String entityType, long newGroupId) as notifyOthers(" + entityId + ","
- + entityType + "," + newGroupId + ") called");
+ + entityType + "," + newGroupId + ") called");
failedPaps = new ArrayList<>();
- List<?> otherServers = PolicyDBDao.getPolicyDBDaoInstance().getOtherServers();
+ List<?> otherServers = PolicyDbDao.getPolicyDbDaoInstance().getOtherServers();
// Notify other paps
startNotifyThreads(otherServers, entityId, entityType, newGroupId);
// Retry for failed paps
@@ -67,7 +68,7 @@ public class NotifyOtherPaps {
}
}
- private void startNotifyThreads(List<?> otherServers, long entityId, String entityType, String newGroupId) {
+ protected void startNotifyThreads(List<?> otherServers, long entityId, String entityType, String newGroupId) {
LinkedList<Thread> notifyThreads = new LinkedList<>();
// we're going to run notifications in parallel threads to speed things
// up
@@ -102,10 +103,9 @@ public class NotifyOtherPaps {
@Override
public void run() {
- PolicyDBDao dao = new PolicyDBDao();
- PolicyDBDaoEntity dbdEntity = (PolicyDBDaoEntity) obj;
- String otherPap = dbdEntity.getPolicyDBDaoUrl();
- String username = dbdEntity.getUsername();
+ PolicyDbDao dao = new PolicyDbDao();
+ PolicyDbDaoEntity dbdEntity = (PolicyDbDaoEntity) obj;
+ String otherPap = dbdEntity.getPolicyDbDaoUrl();
String txt;
try {
txt = PeCryptoUtils.decrypt(dbdEntity.getPassword());
@@ -116,7 +116,6 @@ public class NotifyOtherPaps {
}
HttpURLConnection connection = null;
- UUID requestId = UUID.randomUUID();
URL url;
String papUrl;
try {
@@ -143,11 +142,11 @@ public class NotifyOtherPaps {
return;
}
if (newGroupId == null) {
- url = new URL(otherPap + "?policydbdaourl=" + papUrl + "&entityid=" + entityId + "&entitytype="
- + entityType);
+ url = new URL(
+ otherPap + "?policydbdaourl=" + papUrl + "&entityid=" + entityId + "&entitytype=" + entityType);
} else {
url = new URL(otherPap + "?policydbdaourl=" + papUrl + "&entityid=" + entityId + "&entitytype="
- + entityType + "&extradata=" + newGroupId);
+ + entityType + "&extradata=" + newGroupId);
}
} catch (MalformedURLException e) {
LOGGER.warn("Caught MalformedURLException on: new URL()", e);
@@ -174,6 +173,10 @@ public class NotifyOtherPaps {
LOGGER.warn("Caught ProtocolException on connection.setRequestMethod(\"PUT\");", e);
return;
}
+
+ String username = dbdEntity.getUsername();
+ UUID requestId = UUID.randomUUID();
+
Base64.Encoder encoder = Base64.getEncoder();
String encoding = encoder.encodeToString((username + ":" + txt).getBytes(StandardCharsets.UTF_8));
connection.setRequestProperty("Authorization", "Basic " + encoding);
@@ -183,7 +186,7 @@ public class NotifyOtherPaps {
int readTimeout;
try {
readTimeout =
- Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_NOTIFY_TIMEOUT));
+ Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_NOTIFY_TIMEOUT));
} catch (Exception e) {
LOGGER.error("xacml.rest.pap.notify.timeoutms property not set, using a default.", e);
readTimeout = 10000;
@@ -212,7 +215,7 @@ public class NotifyOtherPaps {
LOGGER.info("PolicyDBDao: NotifyOtherThread received response 200 from pap server on notify");
} else {
LOGGER.warn("PolicyDBDao: NotifyOtherThread connection response code not 200, received: "
- + connection.getResponseCode());
+ + connection.getResponseCode());
failedPaps.add(dbdEntity);
}
} catch (Exception e) {