From dd64c2c344196e30543fda9a7840bd5b3e03f587 Mon Sep 17 00:00:00 2001 From: Krzysztof Opasiak Date: Mon, 28 Jan 2019 21:24:13 +0100 Subject: Use helper class to retrieve network logger Instead of abusing constant from Topic interface use new dedicated helper class to retrive network logger. Issue-ID: POLICY-1486 Depends-On: Ic1f07466e1ab6abcc00098e617f0e82da19e852d Change-Id: I453a14c3dda337f2a4d08914ead32b37adc17353 Signed-off-by: Krzysztof Opasiak --- .../guard/PolicyGuardXacmlHelperEmbedded.java | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'controlloop/templates/template.demo.clc') diff --git a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java index 1e9f3371b..075482ee2 100644 --- a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java +++ b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java @@ -3,13 +3,14 @@ * guard * ================================================================================ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,6 +48,7 @@ import java.util.UUID; import org.apache.commons.io.IOUtils; import org.apache.http.entity.ContentType; import org.json.JSONObject; +import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.guard.PolicyGuardResponse; import org.onap.policy.guard.PolicyGuardXacmlRequestAttributes; @@ -57,8 +59,7 @@ import org.slf4j.LoggerFactory; public class PolicyGuardXacmlHelperEmbedded { private static final Logger logger = LoggerFactory.getLogger(PolicyGuardXacmlHelperEmbedded.class); - private static final Logger netLogger = - LoggerFactory.getLogger(org.onap.policy.common.endpoints.event.comm.Topic.NETWORK_LOGGER); + private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger(); // Constant for the system line separator private static final String SYSTEM_LS = System.lineSeparator(); @@ -68,7 +69,7 @@ public class PolicyGuardXacmlHelperEmbedded { // REST timeout, initialized from 'pdpx.timeout' property private int timeout = 20000; - + public PolicyGuardXacmlHelperEmbedded() { init(PolicyEngine.manager.getEnvironment()); } @@ -89,7 +90,7 @@ public class PolicyGuardXacmlHelperEmbedded { /** * Call PDP. - * + * * @param xacmlReq the XACML request * @return the response */ @@ -140,7 +141,7 @@ public class PolicyGuardXacmlHelperEmbedded { /** * This makes an HTTP POST call to a running PDP RESTful servlet to get a decision. - * + * * @param is the InputStream * @param authorization the Authorization * @param clientauth the ClientAuth @@ -230,7 +231,7 @@ public class PolicyGuardXacmlHelperEmbedded { /** * Call embedded PDP. - * + * * @param xacmlReq the XACML request * @return the response */ @@ -239,7 +240,7 @@ public class PolicyGuardXacmlHelperEmbedded { Properties props = new Properties(); // // Get properties - // + // try ( InputStream is = new FileInputStream(propfile); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr) ) { @@ -285,7 +286,7 @@ public class PolicyGuardXacmlHelperEmbedded { /** * Parse XACML PDP response. - * + * * @param xacmlResponse the XACML response * @return the PolicyGuardResponse */ @@ -482,7 +483,7 @@ public class PolicyGuardXacmlHelperEmbedded { // if content length is -1, response is chunked, and // TCP connection will be dropped at the end byte[] buf = new byte[contentLength < 0 ? 1024 : contentLength]; - + int offset = 0; do { int size = inputStream.read(buf, offset, buf.length - offset); -- cgit 1.2.3-korg