[POLICY-117] Resolve the Policy Critical issues
[policy/engine.git] / ECOMP-PDP-REST / src / main / java / org / openecomp / policy / pdp / rest / notifications / NotificationController.java
index a226a3a..5767846 100644 (file)
@@ -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,7 +80,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 +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<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());
@@ -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;
@@ -415,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();