@Test public void testXACMLPdpRegisterThread() { LOGGER.info("XACMLPdpServletTest - testXACMLPdpRegisterThread"); try { OnapLoggingContext baseLoggingContext = new OnapLoggingContext(); baseLoggingContext.setServer("localhost"); XACMLPdpRegisterThread regThread = new XACMLPdpRegisterThread(baseLoggingContext); regThread.run(); assertTrue(true); } catch (Exception e) { LOGGER.error(ERROR_TEXT + e); fail(); } }
@Override public void run() { try { while (!XACMLPdpServlet.configThreadTerminate) { logger.info("XACMLPdpServlet: Taking requests from the queue"); PutRequest request = XACMLPdpServlet.queue.take(); logger.info("XACMLPdpServlet: Taking requests from the queue COMPLETED"); StdPDPStatus newStatus = new StdPDPStatus(); PDPEngine newEngine = null; synchronized (pdpStatusLock) { XACMLPdpServlet.status.setStatus(Status.UPDATING_CONFIGURATION); logger.info("created new PDPEngine"); newEngine = XACMLPdpLoader.loadEngine(newStatus, request.policyProperties, request.pipConfigProperties); } if (newEngine != null) { logger.info("XACMLPdpServlet: newEngine created, assigning newEngine to the pdpEngine."); synchronized (XACMLPdpServlet.pdpEngineLock) { XACMLPdpServlet.pdpEngine = newEngine; try { logger.info("Saving configuration."); if (request.policyProperties != null) { logger.info("Saving configuration: Policy Properties: " + request.policyProperties); try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPDPPolicyCache())) { request.policyProperties.store(os, ""); } } if (request.pipConfigProperties != null) { logger.info("Saving configuration: PIP Properties: " + request.pipConfigProperties); try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPIPConfig())) { request.pipConfigProperties.store(os, ""); } } newStatus.setStatus(Status.UP_TO_DATE); } catch (Exception e) { logger.error( XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to store new properties." + e); PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, "Failed to store new properties"); newStatus.setStatus(Status.LOAD_ERRORS); newStatus.addLoadWarning("Unable to save configuration: " + e.getMessage()); } } } else { newStatus.setStatus(Status.LAST_UPDATE_FAILED); } synchronized (pdpStatusLock) { XACMLPdpServlet.status.set(newStatus); } logger.info("New PDP Servlet Status: " + newStatus.getStatus()); if (Status.UP_TO_DATE.equals(newStatus.getStatus())) { XACMLPdpLoader.sendNotification(); } } } catch (InterruptedException e) { logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "interrupted" + e); PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, "interrupted"); Thread.currentThread().interrupt(); } }
XACMLPdpServlet extends HttpServlet implements Runnable { @Override public void run() { try { while (!XACMLPdpServlet.configThreadTerminate) { logger.info("XACMLPdpServlet: Taking requests from the queue"); PutRequest request = XACMLPdpServlet.queue.take(); logger.info("XACMLPdpServlet: Taking requests from the queue COMPLETED"); StdPDPStatus newStatus = new StdPDPStatus(); PDPEngine newEngine = null; synchronized (pdpStatusLock) { XACMLPdpServlet.status.setStatus(Status.UPDATING_CONFIGURATION); logger.info("created new PDPEngine"); newEngine = XACMLPdpLoader.loadEngine(newStatus, request.policyProperties, request.pipConfigProperties); } if (newEngine != null) { logger.info("XACMLPdpServlet: newEngine created, assigning newEngine to the pdpEngine."); synchronized (XACMLPdpServlet.pdpEngineLock) { XACMLPdpServlet.pdpEngine = newEngine; try { logger.info("Saving configuration."); if (request.policyProperties != null) { logger.info("Saving configuration: Policy Properties: " + request.policyProperties); try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPDPPolicyCache())) { request.policyProperties.store(os, ""); } } if (request.pipConfigProperties != null) { logger.info("Saving configuration: PIP Properties: " + request.pipConfigProperties); try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPIPConfig())) { request.pipConfigProperties.store(os, ""); } } newStatus.setStatus(Status.UP_TO_DATE); } catch (Exception e) { logger.error( XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to store new properties." + e); PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, "Failed to store new properties"); newStatus.setStatus(Status.LOAD_ERRORS); newStatus.addLoadWarning("Unable to save configuration: " + e.getMessage()); } } } else { newStatus.setStatus(Status.LAST_UPDATE_FAILED); } synchronized (pdpStatusLock) { XACMLPdpServlet.status.set(newStatus); } logger.info("New PDP Servlet Status: " + newStatus.getStatus()); if (Status.UP_TO_DATE.equals(newStatus.getStatus())) { XACMLPdpLoader.sendNotification(); } } } catch (InterruptedException e) { logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "interrupted" + e); PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, "interrupted"); Thread.currentThread().interrupt(); } } }
XACMLPdpServlet extends HttpServlet implements Runnable { @Override public void run() { try { while (!XACMLPdpServlet.configThreadTerminate) { logger.info("XACMLPdpServlet: Taking requests from the queue"); PutRequest request = XACMLPdpServlet.queue.take(); logger.info("XACMLPdpServlet: Taking requests from the queue COMPLETED"); StdPDPStatus newStatus = new StdPDPStatus(); PDPEngine newEngine = null; synchronized (pdpStatusLock) { XACMLPdpServlet.status.setStatus(Status.UPDATING_CONFIGURATION); logger.info("created new PDPEngine"); newEngine = XACMLPdpLoader.loadEngine(newStatus, request.policyProperties, request.pipConfigProperties); } if (newEngine != null) { logger.info("XACMLPdpServlet: newEngine created, assigning newEngine to the pdpEngine."); synchronized (XACMLPdpServlet.pdpEngineLock) { XACMLPdpServlet.pdpEngine = newEngine; try { logger.info("Saving configuration."); if (request.policyProperties != null) { logger.info("Saving configuration: Policy Properties: " + request.policyProperties); try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPDPPolicyCache())) { request.policyProperties.store(os, ""); } } if (request.pipConfigProperties != null) { logger.info("Saving configuration: PIP Properties: " + request.pipConfigProperties); try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPIPConfig())) { request.pipConfigProperties.store(os, ""); } } newStatus.setStatus(Status.UP_TO_DATE); } catch (Exception e) { logger.error( XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to store new properties." + e); PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, "Failed to store new properties"); newStatus.setStatus(Status.LOAD_ERRORS); newStatus.addLoadWarning("Unable to save configuration: " + e.getMessage()); } } } else { newStatus.setStatus(Status.LAST_UPDATE_FAILED); } synchronized (pdpStatusLock) { XACMLPdpServlet.status.set(newStatus); } logger.info("New PDP Servlet Status: " + newStatus.getStatus()); if (Status.UP_TO_DATE.equals(newStatus.getStatus())) { XACMLPdpLoader.sendNotification(); } } } catch (InterruptedException e) { logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "interrupted" + e); PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, "interrupted"); Thread.currentThread().interrupt(); } } XACMLPdpServlet(); }
XACMLPdpServlet extends HttpServlet implements Runnable { @Override public void run() { try { while (!XACMLPdpServlet.configThreadTerminate) { logger.info("XACMLPdpServlet: Taking requests from the queue"); PutRequest request = XACMLPdpServlet.queue.take(); logger.info("XACMLPdpServlet: Taking requests from the queue COMPLETED"); StdPDPStatus newStatus = new StdPDPStatus(); PDPEngine newEngine = null; synchronized (pdpStatusLock) { XACMLPdpServlet.status.setStatus(Status.UPDATING_CONFIGURATION); logger.info("created new PDPEngine"); newEngine = XACMLPdpLoader.loadEngine(newStatus, request.policyProperties, request.pipConfigProperties); } if (newEngine != null) { logger.info("XACMLPdpServlet: newEngine created, assigning newEngine to the pdpEngine."); synchronized (XACMLPdpServlet.pdpEngineLock) { XACMLPdpServlet.pdpEngine = newEngine; try { logger.info("Saving configuration."); if (request.policyProperties != null) { logger.info("Saving configuration: Policy Properties: " + request.policyProperties); try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPDPPolicyCache())) { request.policyProperties.store(os, ""); } } if (request.pipConfigProperties != null) { logger.info("Saving configuration: PIP Properties: " + request.pipConfigProperties); try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPIPConfig())) { request.pipConfigProperties.store(os, ""); } } newStatus.setStatus(Status.UP_TO_DATE); } catch (Exception e) { logger.error( XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to store new properties." + e); PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, "Failed to store new properties"); newStatus.setStatus(Status.LOAD_ERRORS); newStatus.addLoadWarning("Unable to save configuration: " + e.getMessage()); } } } else { newStatus.setStatus(Status.LAST_UPDATE_FAILED); } synchronized (pdpStatusLock) { XACMLPdpServlet.status.set(newStatus); } logger.info("New PDP Servlet Status: " + newStatus.getStatus()); if (Status.UP_TO_DATE.equals(newStatus.getStatus())) { XACMLPdpLoader.sendNotification(); } } } catch (InterruptedException e) { logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "interrupted" + e); PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, "interrupted"); Thread.currentThread().interrupt(); } } XACMLPdpServlet(); static int getNotificationDelay(); IntegrityMonitor getIm(); void setIm(IntegrityMonitor im); @Override void init(ServletConfig config); @Override void destroy(); @Override void run(); static PDPEngine getPDPEngine(); static Constructor<?> getCreateUpdatePolicyConstructor(); static Object getPDPEngineLock(); }
XACMLPdpServlet extends HttpServlet implements Runnable { @Override public void run() { try { while (!XACMLPdpServlet.configThreadTerminate) { logger.info("XACMLPdpServlet: Taking requests from the queue"); PutRequest request = XACMLPdpServlet.queue.take(); logger.info("XACMLPdpServlet: Taking requests from the queue COMPLETED"); StdPDPStatus newStatus = new StdPDPStatus(); PDPEngine newEngine = null; synchronized (pdpStatusLock) { XACMLPdpServlet.status.setStatus(Status.UPDATING_CONFIGURATION); logger.info("created new PDPEngine"); newEngine = XACMLPdpLoader.loadEngine(newStatus, request.policyProperties, request.pipConfigProperties); } if (newEngine != null) { logger.info("XACMLPdpServlet: newEngine created, assigning newEngine to the pdpEngine."); synchronized (XACMLPdpServlet.pdpEngineLock) { XACMLPdpServlet.pdpEngine = newEngine; try { logger.info("Saving configuration."); if (request.policyProperties != null) { logger.info("Saving configuration: Policy Properties: " + request.policyProperties); try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPDPPolicyCache())) { request.policyProperties.store(os, ""); } } if (request.pipConfigProperties != null) { logger.info("Saving configuration: PIP Properties: " + request.pipConfigProperties); try (OutputStream os = Files.newOutputStream(XACMLPdpLoader.getPIPConfig())) { request.pipConfigProperties.store(os, ""); } } newStatus.setStatus(Status.UP_TO_DATE); } catch (Exception e) { logger.error( XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to store new properties." + e); PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, "Failed to store new properties"); newStatus.setStatus(Status.LOAD_ERRORS); newStatus.addLoadWarning("Unable to save configuration: " + e.getMessage()); } } } else { newStatus.setStatus(Status.LAST_UPDATE_FAILED); } synchronized (pdpStatusLock) { XACMLPdpServlet.status.set(newStatus); } logger.info("New PDP Servlet Status: " + newStatus.getStatus()); if (Status.UP_TO_DATE.equals(newStatus.getStatus())) { XACMLPdpLoader.sendNotification(); } } } catch (InterruptedException e) { logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "interrupted" + e); PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, "interrupted"); Thread.currentThread().interrupt(); } } XACMLPdpServlet(); static int getNotificationDelay(); IntegrityMonitor getIm(); void setIm(IntegrityMonitor im); @Override void init(ServletConfig config); @Override void destroy(); @Override void run(); static PDPEngine getPDPEngine(); static Constructor<?> getCreateUpdatePolicyConstructor(); static Object getPDPEngineLock(); static final PdpRestMonitor monitor; }