Removed LoggerFactoryWrapper references to use NetLoggerUtil.
Issue-ID: POLICY-1499
Change-Id: I6f7066f4523736672e17d2e1e609c38c44852769
Signed-off-by: Daniel Cruz <dc443y@att.com>
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.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PolicyGuardXacmlHelper {
private static final Logger logger = LoggerFactory.getLogger(PolicyGuardXacmlHelper.class);
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
-
- // Constant for the systme line separator
- private static final String SYSTEM_LS = System.lineSeparator();
private UrlEntry[] restUrls = null;
private int restUrlIndex = 0;
//
UrlEntry urlEntry = restUrls[restUrlIndex];
String jsonRequestString = jsonReq.toString();
- netLogger.info("[OUT|{}|{}|]{}{}", "GUARD", urlEntry.restUrl, SYSTEM_LS, jsonRequestString);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, urlEntry.restUrl.toString(), jsonRequestString);
response = callRestfulPdp(new ByteArrayInputStream(jsonReq.toString().getBytes()), urlEntry.restUrl,
urlEntry.authorization, urlEntry.clientAuth, urlEntry.environment);
- netLogger.info("[IN|{}|{}|]{}{}", "GUARD", urlEntry.restUrl, SYSTEM_LS, response);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, urlEntry.restUrl.toString(), response);
} catch (Exception e) {
logger.error("Error in sending RESTful request: ", e);
}
import java.util.UUID;
import org.onap.policy.aai.util.Serialization;
-import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.rest.RestManager;
import org.onap.policy.rest.RestManager.Pair;
import org.slf4j.Logger;
*/
public final class AaiManager {
- /** The Constant LINE_SEPARATOR. */
- private static final String LINE_SEPARATOR = System.lineSeparator();
-
/** The Constant logger. */
private static final Logger logger = LoggerFactory.getLogger(AaiManager.class);
- /** The Constant netLogger. */
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
-
/** The rest manager. */
// The REST manager used for processing REST calls for this AAI manager
private final RestManager restManager;
logger.debug("RestManager.post before");
String requestJson = Serialization.gsonPretty.toJson(request);
- netLogger.info("[OUT|{}|{}|]{}{}", "AAI", url, LINE_SEPARATOR, requestJson);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, requestJson);
Pair<Integer, String> httpDetails =
restManager.post(url, username, password, headers, "application/json", requestJson);
logger.debug("RestManager.post after");
int attemptsLeft = 3;
while (attemptsLeft-- > 0) {
- netLogger.info("[OUT|{}|{}|]", "AAI", urlGet);
+ NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", CommInfrastructure.REST, urlGet);
Pair<Integer, String> httpDetailsGet = restManager.get(urlGet, username, password, headers);
if (httpDetailsGet == null) {
logger.info("AAI GET Null Response to {}", urlGet);
final Class<T> classOfResponse) {
try {
T response = Serialization.gsonPretty.fromJson(httpDetails.second, classOfResponse);
- netLogger.info("[IN|{}|{}|]{}{}", "AAI", url, LINE_SEPARATOR, httpDetails.second);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, url, httpDetails.second);
return response;
} catch (JsonSyntaxException e) {
logger.error("postQuery threw: ", e);
import java.util.Map;
import org.drools.core.WorkingMemory;
-import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.rest.RestManager;
import org.onap.policy.rest.RestManager.Pair;
import org.slf4j.LoggerFactory;
public final class SdncManager implements Runnable {
- private static final String SYSTEM_LS = System.lineSeparator();
private String sdncUrlBase;
private String username;
private SdncRequest sdncRequest;
private WorkingMemory workingMem;
private static final Logger logger = LoggerFactory.getLogger(SdncManager.class);
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
// The REST manager used for processing REST calls for this Sdnc manager
private RestManager restManager;
try {
String sdncRequestJson = Serialization.gsonPretty.toJson(sdncRequest);
- netLogger.info("[OUT|{}|{}|]{}{}", "Sdnc", sdncUrl, SYSTEM_LS, sdncRequestJson);
- logger.info("[OUT|{}|{}|]{}{}", "Sdnc", sdncUrl, SYSTEM_LS, sdncRequestJson);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, sdncUrl, sdncRequestJson);
+ logger.info("[OUT|{}|{}|]{}{}", CommInfrastructure.REST, sdncUrl, NetLoggerUtil.SYSTEM_LS, sdncRequestJson);
httpDetails = restManager.post(sdncUrl, username, password, headers, "application/json",
sdncRequestJson);
try {
SdncResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, SdncResponse.class);
- netLogger.info("[IN|{}|{}|]{}{}", "Sdnc", sdncUrl, SYSTEM_LS, httpDetails.second);
- logger.info("[IN|{}|{}|]{}{}", "Sdnc", sdncUrl, SYSTEM_LS, httpDetails.second);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, sdncUrl, httpDetails.second);
+ logger.info("[IN|{}|{}|]{}{}", "Sdnc", sdncUrl, NetLoggerUtil.SYSTEM_LS, httpDetails.second);
String body = Serialization.gsonPretty.toJson(response);
logger.info("Response to Sdnc Heal post:");
logger.info(body);
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.drools.core.WorkingMemory;
-import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.rest.RestManager;
import org.onap.policy.rest.RestManager.Pair;
*/
public final class SoManager {
private static final Logger logger = LoggerFactory.getLogger(SoManager.class);
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
private static ExecutorService executors = Executors.newCachedThreadPool();
final String password, final SoRequest request) {
// Issue the HTTP POST request to SO to create the service instance
String requestJson = Serialization.gsonPretty.toJson(request);
- netLogger.info("[OUT|{}|{}|{}|{}|{}|{}|]{}{}", "SO", url, username, password, createSimpleHeaders(), MEDIA_TYPE,
- LINE_SEPARATOR, requestJson);
+ NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|{}|{}|{}|{}|]{}{}", "SO", url, username, password,
+ createSimpleHeaders(), MEDIA_TYPE, LINE_SEPARATOR, requestJson);
Pair<Integer, String> httpResponse =
restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, requestJson);
.equals(SoOperationType.SCALE_OUT)) {
url = urlBase + "/serviceInstantiation/v7/serviceInstances/" + serviceInstanceId + "/vnfs/"
+ vnfInstanceId + "/vfModules/scaleOut";
- netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, LINE_SEPARATOR, soJson);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, soJson);
httpResponse = restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, soJson);
} else if (request.getOperationType() != null && request.getOperationType()
.equals(SoOperationType.DELETE_VF_MODULE)) {
url = urlBase + "/serviceInstances/v7/" + serviceInstanceId + "/vnfs/" + vnfInstanceId
+ "/vfModules/" + vfModuleInstanceId;
- netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, LINE_SEPARATOR, soJson);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, soJson);
httpResponse = restManager.delete(url, username, password, createSimpleHeaders(), MEDIA_TYPE, soJson);
} else {
return null;
}
// Issue a GET to find the current status of our request
- netLogger.info("[OUT|{}|{}|{}|{}|{}|{}|]{}", "SO", urlGet, username, password, createSimpleHeaders(),
- MEDIA_TYPE, LINE_SEPARATOR);
+ NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|{}|{}|{}|{}|]{}", "SO", urlGet, username, password,
+ createSimpleHeaders(), MEDIA_TYPE, LINE_SEPARATOR);
Pair<Integer, String> httpResponse = restManager.get(urlGet, username, password, createSimpleHeaders());
// Get our response
response.setHttpResponseCode(httpResponse.first);
}
- netLogger.info("[IN|{}|{}|]{}{}", "SO", requestUrl, LINE_SEPARATOR, httpResponse.second);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, requestUrl, httpResponse.second);
if (logger.isDebugEnabled()) {
logger.debug("***** Response to SO Request to URL {}:", requestUrl);
import java.util.Map;
import org.drools.core.WorkingMemory;
-import org.onap.policy.common.utils.slf4j.LoggerFactoryWrapper;
+import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.rest.RestManager;
import org.onap.policy.rest.RestManager.Pair;
import org.slf4j.LoggerFactory;
public final class VfcManager implements Runnable {
- private static final String SYSTEM_LS = System.lineSeparator();
private String vfcUrlBase;
private String username;
private VfcRequest vfcRequest;
private WorkingMemory workingMem;
private static final Logger logger = LoggerFactory.getLogger(VfcManager.class);
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
// The REST manager used for processing REST calls for this VFC manager
private RestManager restManager;
String vfcUrl = vfcUrlBase + "/ns/" + vfcRequest.getNsInstanceId() + "/heal";
try {
String vfcRequestJson = Serialization.gsonPretty.toJson(vfcRequest);
- netLogger.info("[OUT|{}|{}|]{}{}", "VFC", vfcUrl, SYSTEM_LS, vfcRequestJson);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, vfcUrl, vfcRequestJson);
httpDetails = restManager.post(vfcUrl, username, password, headers, "application/json", vfcRequestJson);
} catch (Exception e) {
try {
VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class);
- netLogger.info("[IN|{}|{}|]{}{}", "VFC", vfcUrl, SYSTEM_LS, httpDetails.second);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, vfcUrl, httpDetails.second);
String body = Serialization.gsonPretty.toJson(response);
logger.debug("Response to VFC Heal post:");
logger.debug(body);
VfcResponse responseGet = null;
while (attemptsLeft-- > 0) {
- netLogger.info("[OUT|{}|{}|]", "VFC", urlGet);
+ NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", "VFC", urlGet);
Pair<Integer, String> httpDetailsGet = restManager.get(urlGet, username, password, headers);
responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.second, VfcResponse.class);
- netLogger.info("[IN|{}|{}|]{}{}", "VFC", urlGet, SYSTEM_LS, httpDetailsGet.second);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, vfcUrl, httpDetailsGet.second);
responseGet.setRequestId(vfcRequest.getRequestId().toString());
body = Serialization.gsonPretty.toJson(responseGet);
logger.debug("Response to VFC Heal get:");
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.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.guard.PolicyGuardResponse;
import org.onap.policy.guard.PolicyGuardXacmlRequestAttributes;
public class PolicyGuardXacmlHelperEmbedded {
private static final Logger logger = LoggerFactory.getLogger(PolicyGuardXacmlHelperEmbedded.class);
- private static final Logger netLogger = LoggerFactoryWrapper.getNetworkLogger();
- // Constant for the system line separator
- private static final String SYSTEM_LS = System.lineSeparator();
private String propfile;
private UrlEntry[] restUrls = null;
private int restUrlIndex = 0;
//
UrlEntry urlEntry = restUrls[restUrlIndex];
String jsonRequestString = jsonReq.toString();
- netLogger.info("[OUT|{}|{}|]{}{}", "GUARD", urlEntry.restUrl, SYSTEM_LS, jsonRequestString);
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, urlEntry.restUrl.toString(), jsonRequestString);
response = callRestfulPdp(new ByteArrayInputStream(jsonReq.toString().getBytes()), urlEntry.restUrl,
urlEntry.authorization, urlEntry.clientAuth, urlEntry.environment);
- netLogger.info("[IN|{}|{}|]{}{}", "GUARD", urlEntry.restUrl, SYSTEM_LS, response);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, urlEntry.restUrl.toString(), response);
} catch (Exception e) {
logger.error("Error in sending RESTful request", e);
}