aboutsummaryrefslogtreecommitdiffstats
path: root/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications
diff options
context:
space:
mode:
authorTarun Tej Velaga <tt3868@att.com>2017-07-24 17:13:43 +0000
committerTarun Tej Velaga <tt3868@att.com>2017-07-25 14:23:59 +0000
commite92ff832cf993db876f22b2d27562fedf59f5043 (patch)
tree47429eeaaf4241905d7ea1f71dbdb5c2d0504618 /ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications
parent570290dc6ba8198e653022c2f6f8e5d01cfa8d1b (diff)
[Policy-52, Policy-92, Policy-93] Policy Enhancements and bugfixes
Change-Id: I5675cf4527e17963b3142cf7184c0df31a766197 Signed-off-by: Tarun Tej Velaga <tt3868@att.com>
Diffstat (limited to 'ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications')
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java13
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java23
2 files changed, 16 insertions, 20 deletions
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java
index a226a3afe..214151d16 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java
@@ -36,6 +36,7 @@ import java.nio.file.Paths;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
@@ -81,7 +82,7 @@ public class NotificationController {
private static String pdpURL = null;
private static Boolean notificationFlag = false;
- public void check(PDPStatus newStatus,HashMap<String, PolicyDef> policyContainer) {
+ public void check(PDPStatus newStatus,Map<String, PolicyDef> policyContainer) {
boolean updated = false;
boolean removed = false;
Notification notification = new Notification();
@@ -167,15 +168,11 @@ public class NotificationController {
notificationJSON= record(notification);
}catch(Exception e){
LOGGER.error(e);
- // TODO:EELF Cleanup - Remove LOGGER
- //PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "");
}
NotificationServer.setUpdate(notificationJSON);
ManualNotificationUpdateThread.setUpdate(notificationJSON);
} catch (JsonProcessingException e) {
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage());
- // TODO:EELF Cleanup - Remove LOGGER
- //PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "");
}
}
}
@@ -194,15 +191,13 @@ public class NotificationController {
private void sendremove(PDPPolicy oldPolicy) {
removed = new Removed();
// Want to know what is removed ?
- // LOGGER.info("The Policy removed is: " + oldPolicy.getId());
- // LOGGER.info("The version no. is: " + oldPolicy.getVersion());
LOGGER.info("Policy removed: " + oldPolicy.getId()+ " with version number: " + oldPolicy.getVersion());
removed.setPolicyName(oldPolicy.getId());
removed.setVersionNo(oldPolicy.getVersion());
removeFile(oldPolicy);
}
- private void sendUpdate(PDPPolicy newPolicy,HashMap<String, PolicyDef> policyContainer) {
+ private void sendUpdate(PDPPolicy newPolicy,Map<String, PolicyDef> policyContainer) {
updated = new Updated();
// Want to know what is new ?
LOGGER.info("The new Policy is: " + newPolicy.getId());
@@ -327,8 +322,6 @@ public class NotificationController {
json = om.writeValueAsString(record);
} catch (JsonProcessingException e) {
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage());
- // TODO:EELF Cleanup - Remove LOGGER
- //PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "");
}
LOGGER.info(json);
return json;
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java
index 21fb8f3c9..55ab760af 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java
@@ -42,6 +42,7 @@ import org.openecomp.policy.common.logging.eelf.MessageCodes;
import org.openecomp.policy.common.logging.eelf.PolicyLogger;
import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.openecomp.policy.pdp.rest.api.services.NotificationService;
import org.openecomp.policy.rest.XACMLRestProperties;
import org.openecomp.policy.utils.BusPublisher;
import org.openecomp.policy.xacml.api.XACMLErrorConstants;
@@ -63,7 +64,7 @@ import com.att.research.xacml.util.XACMLProperties;
@ServerEndpoint(value = "/notifications")
public class NotificationServer {
private static final Logger LOGGER = FlexLogger.getLogger(NotificationServer.class);
- private static Queue<Session> queue = new ConcurrentLinkedQueue<Session>();
+ private static Queue<Session> queue = new ConcurrentLinkedQueue<>();
private static String update = null;
private static String hosts = null;
private static URL aURL = null;
@@ -104,7 +105,7 @@ public class NotificationServer {
LOGGER.debug("Notification set to " + propNotificationType);
if (propNotificationType.equals("ueb")){
-
+
String topic = null;
try {
aURL = new URL(pdpURL);
@@ -118,7 +119,7 @@ public class NotificationServer {
hosts = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_SERVERS);
String apiKey = XACMLProperties.getProperty(XACMLRestProperties.PROP_UEB_API_KEY);
String apiSecret = XACMLProperties.getProperty(XACMLRestProperties.PROP_UEB_API_SECRET);
-
+
LOGGER.debug("Creating Publisher for host: " + hosts + " with topic: " + topic);
CambriaBatchingPublisher pub = null;
try {
@@ -126,7 +127,7 @@ public class NotificationServer {
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "UEB properties are missing from the property file ");
throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE + "UEB properties are missing from the property file ");
}
-
+
hosts.trim();
topic.trim();
apiKey.trim();
@@ -136,8 +137,8 @@ public class NotificationServer {
.onTopic ( topic )
.authenticatedBy ( apiKey, apiSecret )
.build ()
- ;
-
+ ;
+
} catch (MalformedURLException e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error creating the UEB publisher" + e1.getMessage());
} catch (GeneralSecurityException e1) {
@@ -147,7 +148,7 @@ public class NotificationServer {
try {
pub.send( "MyPartitionKey", notification );
} catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending notification update" + e.getMessage() + e);
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending notification update" + e.getMessage());
}
// close the publisher. The batching publisher does not send events
// immediately, so you MUST use close to send any remaining messages.
@@ -156,7 +157,7 @@ public class NotificationServer {
// they're returned to your app. You could, for example, persist to disk
// and try again later.
final List<?> stuck = pub.close ( 20, TimeUnit.SECONDS );
-
+
if (!stuck.isEmpty()){
LOGGER.error( stuck.size() + " messages unsent" );
}else{
@@ -184,7 +185,7 @@ public class NotificationServer {
List<String> dmaapList = null;
if(dmaapServers.contains(",")) {
- dmaapList = new ArrayList<String>(Arrays.asList(dmaapServers.split("\\s*,\\s*")));
+ dmaapList = new ArrayList<>(Arrays.asList(dmaapServers.split("\\s*,\\s*")));
} else {
dmaapList = new ArrayList<>();
dmaapList.add(dmaapServers);
@@ -213,9 +214,11 @@ public class NotificationServer {
LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage());
}
}
+ NotificationService.sendNotification(notification);
}
-
+
public static void setUpdate(String update) {
NotificationServer.update = update;
}
+
}