Merge "ONAP code change for log files consolidation"
[policy/engine.git] / ONAP-PDP-REST / src / main / java / org / onap / policy / pdp / rest / XACMLPdpLoader.java
index 7526af6..102d43f 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-PDP-REST
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -107,10 +107,12 @@ public class XACMLPdpLoader {
                        // - creating new "<PolicyId>.file" properties for files existing
                        // local
                        //
+                       LOGGER.info("XACMLPdpLoader: cache the policies.");
                        XACMLPdpLoader.cachePolicies(policyProperties);
                        //
                        // Validate the policies
                        //
+                       LOGGER.info("XACMLPdpLoader: validating the policies.");
                        XACMLPdpLoader.validatePolicies(policyProperties, status);
                        if (LOGGER.isDebugEnabled()) {
                                LOGGER.debug("Status: " + status);
@@ -189,14 +191,12 @@ public class XACMLPdpLoader {
                        LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR +error, e);
                        status.addLoadError(error);
                }
-               // Notification will be Sent Here.
-               sendNotification();
                return engine;
        }
 
        private static HashMap<String, PolicyDef> policyContainer = null;
        
-       private static void sendNotification(){ 
+       public static synchronized void sendNotification(){
                Thread notify = new Thread(){
                        public void run(){
                                try{
@@ -217,12 +217,13 @@ public class XACMLPdpLoader {
                                .getReferencedPolicyIDs(properties);
                policyContainer = new HashMap<String, PolicyDef>();
 
+               LOGGER.info("XACMLPdpLoader: load rootPolicies");
                for (String id : rootPolicies) {
                        loadPolicy(properties, status, id, true);
                }
                // remember which policies were root policies
                status.addAllLoadedRootPolicies(status.getLoadedPolicies());
-
+               LOGGER.info("XACMLPdpLoader: load referencedPolicies");
                for (String id : refPolicies) {
                        loadPolicy(properties, status, id, false);
                }
@@ -549,20 +550,14 @@ public class XACMLPdpLoader {
                                                                        // properties
                                                                        //
                                                                        changed = true;
+                                                               } catch (MalformedURLException e) {
+                                                                       papUrls.failed();
+                                                                       LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Policy '" + policy
+                                                                               + "' had bad URL in new configuration, URL='" + propLocation + "'");
                                                                } catch (Exception e) {
                                                                        papUrls.failed();
-                                                                       if (e instanceof MalformedURLException) {
-                                                                               LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Policy '"
-                                                                                               + policy
-                                                                                               + "' had bad URL in new configuration, URL='"
-                                                                                               + propLocation + "'");
-                                                                               
-                                                                       } else {
-                                                                               LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while retrieving policy "
-                                                                                               + policy
-                                                                                               + " from URL "
-                                                                                               + url + ", e=" + e);
-                                                                       }
+                                                                       LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while retrieving policy "
+                                                                               + policy + " from URL " + url + ", e=" + e);
                                                                }
                                                                papUrls.getNext();
                                                        }