Fix audit log to contain ending timestamp 97/25897/2
authorMike Babinski <mb1915@att.com>
Fri, 8 Dec 2017 00:02:50 +0000 (00:02 +0000)
committerMike Babinski <mb1915@att.com>
Tue, 12 Dec 2017 16:44:02 +0000 (16:44 +0000)
Add transaction end  method

Change-Id: Ie818bb1650b0847800ce5481a85c5d2c8d7f4b9c
Issue-ID: POLICY-494
Signed-off-by: Mike Babinski <mb1915@att.com>
ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/handler/DeleteHandler.java
ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java
ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java

index ab04923..7f612a5 100644 (file)
@@ -373,6 +373,7 @@ public class DeleteHandler {
                        }                       
                }
                if (responseString.equals("success")) {
+                       loggingContext.transactionEnded();
                        PolicyLogger.info("Policy successfully deleted!");
                        PolicyLogger.audit("Policy successfully deleted!");
                        response.setStatus(HttpServletResponse.SC_OK);
@@ -449,8 +450,8 @@ public class DeleteHandler {
                }
                if (response==null){
                        response = "success";
+                       loggingContext.transactionEnded();
                        PolicyLogger.audit("Policy successfully deleted!");
-                       PolicyLogger.audit("Transaction Ended Successfully");
                }
                loggingContext.transactionEnded();
                PolicyLogger.audit("Transaction Ended");
index 14b312f..49400d6 100644 (file)
@@ -248,8 +248,8 @@ public class XACMLPdpRegisterThread implements Runnable {
                                }
                        } catch (Exception e) {
                                LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+                               loggingContext.transactionEnded();
                                PolicyLogger.audit("Transaction Failed - See Error.log");
-               loggingContext.transactionEnded();
                                papUrls.failed();
                        } finally {
                                // cleanup the connection
index b824312..04572cc 100644 (file)
@@ -229,8 +229,8 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable {
                baseLoggingContext = new ONAPLoggingContext();
                // fixed data that will be the same in all logging output goes here
                try {
-                       String ipaddress = InetAddress.getLocalHost().getHostAddress();
-                       baseLoggingContext.setServer(ipaddress);
+                       String hostname = InetAddress.getLocalHost().getCanonicalHostName();
+                       baseLoggingContext.setServer(hostname);
                } catch (UnknownHostException e) {
                        logger.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get hostname for logging"+e);
                }