* ============LICENSE_START=======================================================
* ONAP-PDP-REST
* ================================================================================
* ============LICENSE_START=======================================================
* ONAP-PDP-REST
* ================================================================================
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private static volatile boolean configThreadTerminate = false;
private transient ONAPLoggingContext baseLoggingContext = null;
private transient IntegrityMonitor im;
private static volatile boolean configThreadTerminate = false;
private transient ONAPLoggingContext baseLoggingContext = null;
private transient IntegrityMonitor im;
queueSize = Integer.parseInt(XACMLProperties.getProperty("REQUEST_BUFFER_SIZE",String.valueOf(queueSize)));
initQueue(queueSize);
// Load our engine - this will use the latest configuration
queueSize = Integer.parseInt(XACMLProperties.getProperty("REQUEST_BUFFER_SIZE",String.valueOf(queueSize)));
initQueue(queueSize);
// Load our engine - this will use the latest configuration
baseLoggingContext = new ONAPLoggingContext();
// fixed data that will be the same in all logging output goes here
try {
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);
}
} catch (UnknownHostException e) {
logger.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get hostname for logging"+e);
}
this.doPutConfig(cache, request, response, loggingContext);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction ended");
this.doPutConfig(cache, request, response, loggingContext);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction ended");
protected void doPutConfig(String config, HttpServletRequest request, HttpServletResponse response, ONAPLoggingContext loggingContext) throws ServletException, IOException {
try {
// prevent multiple configuration changes from stacking up
protected void doPutConfig(String config, HttpServletRequest request, HttpServletResponse response, ONAPLoggingContext loggingContext) throws ServletException, IOException {
try {
// prevent multiple configuration changes from stacking up
if (XACMLPdpServlet.queue.remainingCapacity() <= 0) {
logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Queue capacity reached");
PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, "Queue capacity reached");
if (XACMLPdpServlet.queue.remainingCapacity() <= 0) {
logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Queue capacity reached");
PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, "Queue capacity reached");
XACMLPdpServlet.queue.offer(new PutRequest(newProperties, null));
loggingContext.transactionEnded();
auditLogger.info("Success");
XACMLPdpServlet.queue.offer(new PutRequest(newProperties, null));
loggingContext.transactionEnded();
auditLogger.info("Success");
XACMLPdpServlet.queue.offer(new PutRequest(null, newProperties));
loggingContext.transactionEnded();
auditLogger.info("Success");
XACMLPdpServlet.queue.offer(new PutRequest(null, newProperties));
loggingContext.transactionEnded();
auditLogger.info("Success");
XACMLPdpServlet.queue.offer(new PutRequest(newPolicyProperties, newPipProperties));
loggingContext.transactionEnded();
auditLogger.info("Success");
PolicyLogger.audit("Success");
XACMLPdpServlet.queue.offer(new PutRequest(newPolicyProperties, newPipProperties));
loggingContext.transactionEnded();
auditLogger.info("Success");
PolicyLogger.audit("Success");
try {
// variable not used, but constructor has needed side-effects so don't remove:
while (! XACMLPdpServlet.configThreadTerminate) {
try {
// variable not used, but constructor has needed side-effects so don't remove:
while (! XACMLPdpServlet.configThreadTerminate) {
StdPDPStatus newStatus = new StdPDPStatus();
PDPEngine newEngine = null;
synchronized(pdpStatusLock) {
XACMLPdpServlet.status.setStatus(Status.UPDATING_CONFIGURATION);
StdPDPStatus newStatus = new StdPDPStatus();
PDPEngine newEngine = null;
synchronized(pdpStatusLock) {
XACMLPdpServlet.status.setStatus(Status.UPDATING_CONFIGURATION);
newEngine = XACMLPdpLoader.loadEngine(newStatus, request.policyProperties, request.pipConfigProperties);
}
if (newEngine != null) {
newEngine = XACMLPdpLoader.loadEngine(newStatus, request.policyProperties, request.pipConfigProperties);
}
if (newEngine != null) {
synchronized(XACMLPdpServlet.pdpEngineLock) {
XACMLPdpServlet.pdpEngine = newEngine;
try {
logger.info("Saving configuration.");
if (request.policyProperties != null) {
synchronized(XACMLPdpServlet.pdpEngineLock) {
XACMLPdpServlet.pdpEngine = newEngine;
try {
logger.info("Saving configuration.");
if (request.policyProperties != null) {
try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPDPPolicyCache())) {
request.policyProperties.store(os, "");
}
}
if (request.pipConfigProperties != null) {
try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPDPPolicyCache())) {
request.policyProperties.store(os, "");
}
}
if (request.pipConfigProperties != null) {
try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPIPConfig())) {
request.pipConfigProperties.store(os, "");
}
try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPIPConfig())) {
request.pipConfigProperties.store(os, "");
}
} else {
newStatus.setStatus(Status.LAST_UPDATE_FAILED);
}
synchronized(pdpStatusLock) {
XACMLPdpServlet.status.set(newStatus);
}
} else {
newStatus.setStatus(Status.LAST_UPDATE_FAILED);
}
synchronized(pdpStatusLock) {
XACMLPdpServlet.status.set(newStatus);
}
}
} catch (InterruptedException e) {
logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "interrupted"+e);
}
} catch (InterruptedException e) {
logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "interrupted"+e);