X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ECOMP-PDP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fpolicy%2Fpdp%2Frest%2Fnotifications%2FNotificationController.java;h=57678461d7a6ee409c7618277f8f5f1f919b3064;hb=d80880b097d08f9ab9dda54355216890a4b345dc;hp=4c933776ce66012863c7f13ef10a8968f01d3881;hpb=7e547eaa55920dfbc9691eab33bb728395b50cf2;p=policy%2Fengine.git 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 4c933776c..57678461d 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 @@ -22,12 +22,10 @@ package org.openecomp.policy.pdp.rest.notifications; import java.io.File; import java.io.FileFilter; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; @@ -36,6 +34,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,12 +80,12 @@ public class NotificationController { private static String pdpURL = null; private static Boolean notificationFlag = false; - public void check(PDPStatus newStatus,HashMap policyContainer) { + public void check(PDPStatus newStatus,Map policyContainer) { boolean updated = false; boolean removed = false; Notification notification = new Notification(); - HashSet removedPolicies = new HashSet(); - HashSet updatedPolicies = new HashSet(); + HashSet removedPolicies = new HashSet<>(); + HashSet updatedPolicies = new HashSet<>(); if (oldStatus == null) { oldStatus = newStatus; @@ -167,15 +166,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, ""); + LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage() +e); } } } @@ -185,7 +180,7 @@ public class NotificationController { try { NotificationServer.sendNotification(notificationJSON, propNotificationType, pdpURL); } catch (Exception e) { - LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage()); + LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage() + e); } notificationFlag = false; } @@ -194,15 +189,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 policyContainer) { + private void sendUpdate(PDPPolicy newPolicy,Map policyContainer) { updated = new Updated(); // Want to know what is new ? LOGGER.info("The new Policy is: " + newPolicy.getId()); @@ -229,7 +222,7 @@ public class NotificationController { while (allOfs.hasNext()) { AllOf allOf = allOfs.next(); Iterator matches = allOf.getMatches(); - HashMap matchValues = new HashMap(); + HashMap matchValues = new HashMap<>(); while (matches.hasNext()) { Match match = matches.next(); LOGGER.info("Attribute Value is: "+ match.getAttributeValue().getValue().toString()); @@ -326,9 +319,7 @@ public class NotificationController { try { 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.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e.getMessage() + e); } LOGGER.info(json); return json; @@ -339,7 +330,7 @@ public class NotificationController { if(updated && removed){ notification.setNotificationType(NotificationType.BOTH); if(notification.getLoadedPolicies()!=null){ - HashSet updatedPolicies = new HashSet(); + HashSet updatedPolicies = new HashSet<>(); for(Updated oldUpdatedPolicy: notification.getLoadedPolicies()){ Updated updatePolicy = oldUpdatedPolicy; if(notification.getRemovedPolicies()!=null){ @@ -377,7 +368,7 @@ public class NotificationController { delete = true; dir = new File(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_WEBAPPS)+File.separator+"Action"); } - if(delete && dir!=null){ + if(delete){ FileFilter fileFilter = new WildcardFileFilter(oldPolicy.getId().substring(0, oldPolicy.getId().lastIndexOf("."))+".*"); File[] configFile = dir.listFiles(fileFilter); if(configFile.length==1){ @@ -385,9 +376,7 @@ public class NotificationController { } } }catch(Exception e){ - LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Couldn't remove the policy/config file " + oldPolicy.getName()); - // TODO:EELF Cleanup - Remove LOGGER - //PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Couldn't remove the policy file " + oldPolicy.getName()); + LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Couldn't remove the policy/config file " + oldPolicy.getName() + e); } } @@ -417,11 +406,7 @@ public class NotificationController { IOUtils.copy(is, os); break; } - } catch (MalformedURLException e) { - LOGGER.error(e + e.getMessage()); - } catch(FileNotFoundException e){ - LOGGER.error(e + e.getMessage()); - } catch (IOException e) { + } catch (Exception e) { LOGGER.error(e + e.getMessage()); } papUrls.getNext();