* ================================================================================
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (C) 2018 CMCC All rights reserved.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
-import org.onap.so.logger.MsoLogger;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* NS Create Input Parameter For VFC Adapter<br>
*/
public class NSResourceInputParameter {
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, NSResourceInputParameter.class);
+ private static final Logger logger = LoggerFactory.getLogger(NSResourceInputParameter.class);
private NsOperationKey nsOperationKey;
mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
jsonString = mapper.writeValueAsString(this);
} catch (Exception e) {
- LOGGER.debug("Exception:", e);
+ logger.debug("Exception:", e);
}
return jsonString;
}
marshaller.marshal(this, bs);
return bs.toString();
} catch (Exception e) {
- LOGGER.debug("Exception:", e);
+ logger.debug("Exception:", e);
return "";
}
}
* ================================================================================
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
-import org.onap.so.logger.MsoLogger;
-import org.onap.so.utils.UUIDChecker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
@Component
public class HealthCheckHandler {
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, HealthCheckHandler.class);
+ private static Logger logger = LoggerFactory.getLogger(HealthCheckHandler.class);
private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";
@Path("/healthcheck")
@Produces("text/html")
public Response healthcheck(@QueryParam("requestId") String requestId) {
- MsoLogger.setServiceName("Healthcheck");
- UUIDChecker.verifyOldUUID(requestId, msoLogger);
return HEALTH_CHECK_RESPONSE;
}
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Modifications Copyright (C) 2018 IBM.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.so.adapters.vfc.model.RestfulResponse;
import org.onap.so.adapters.vfc.util.JsonUtil;
import org.onap.so.adapters.vfc.util.ValidateUtil;
-import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Path("/v1/vfcadapter")
public class VfcAdapterRest {
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, VfcAdapterRest.class);
+ private static final Logger logger = LoggerFactory.getLogger(VfcAdapterRest.class);
private static final String REQUEST_DEBUG_MSG="body from request is {}";
private static final String APPLICATION_EXCEPTION="ApplicationException: ";
@Autowired
public Response createNfvoNs(String data) {
try {
ValidateUtil.assertObjectNotNull(data);
- LOGGER.debug(REQUEST_DEBUG_MSG + data);
+ logger.debug(REQUEST_DEBUG_MSG + data);
NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class);
RestfulResponse rsp = driverMgr.createNs(nsInput);
return buildResponse(rsp);
} catch(ApplicationException e) {
- LOGGER.debug(APPLICATION_EXCEPTION, e);
+ logger.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
try {
ValidateUtil.assertObjectNotNull(data);
- LOGGER.debug(REQUEST_DEBUG_MSG + data);
+ logger.debug(REQUEST_DEBUG_MSG + data);
NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
RestfulResponse rsp = driverMgr.deleteNs(nsOperationKey, nsInstanceId);
return buildResponse(rsp);
} catch(ApplicationException e) {
- LOGGER.debug(APPLICATION_EXCEPTION, e);
+ logger.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
public Response queryNfvoJobStatus(String data, @PathParam("jobId") String jobId) {
try {
ValidateUtil.assertObjectNotNull(data);
- LOGGER.debug(REQUEST_DEBUG_MSG + data);
+ logger.debug(REQUEST_DEBUG_MSG + data);
NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
RestfulResponse rsp = driverMgr.getNsProgress(nsOperationKey, jobId);
return buildResponse(rsp);
} catch(ApplicationException e) {
- LOGGER.debug(APPLICATION_EXCEPTION, e);
+ logger.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
public Response instantiateNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) {
try {
ValidateUtil.assertObjectNotNull(data);
- LOGGER.debug(REQUEST_DEBUG_MSG + data);
+ logger.debug(REQUEST_DEBUG_MSG + data);
NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class);
RestfulResponse rsp = driverMgr.instantiateNs(nsInstanceId, nsInput);
return buildResponse(rsp);
} catch(ApplicationException e) {
- LOGGER.debug(APPLICATION_EXCEPTION, e);
+ logger.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
public Response terminateNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) {
try {
ValidateUtil.assertObjectNotNull(data);
- LOGGER.debug(REQUEST_DEBUG_MSG + data);
+ logger.debug(REQUEST_DEBUG_MSG + data);
NsOperationKey nsOperationKey = JsonUtil.unMarshal(data, NsOperationKey.class);
RestfulResponse rsp = driverMgr.terminateNs(nsOperationKey, nsInstanceId);
return buildResponse(rsp);
} catch(ApplicationException e) {
- LOGGER.debug(APPLICATION_EXCEPTION, e);
+ logger.debug(APPLICATION_EXCEPTION, e);
return e.buildErrorResponse();
}
}
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response scaleNfvoNs(String data, @PathParam("nsInstanceId") String nsInstanceId) {
- try {
- ValidateUtil.assertObjectNotNull(data);
- LOGGER.debug("Scale Ns Request Received.Body from request is {}" + data);
- NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class);
- RestfulResponse rsp = driverMgr.scaleNs(nsInstanceId, nsInput);
- return buildResponse(rsp);
- } catch(ApplicationException e) {
- LOGGER.debug(APPLICATION_EXCEPTION, e);
- return e.buildErrorResponse();
- }
+ try {
+ ValidateUtil.assertObjectNotNull(data);
+ logger.debug("Scale Ns Request Received.Body from request is {}" + data);
+ NSResourceInputParameter nsInput = JsonUtil.unMarshal(data, NSResourceInputParameter.class);
+ RestfulResponse rsp = driverMgr.scaleNs(nsInstanceId, nsInput);
+ return buildResponse(rsp);
+ } catch (ApplicationException e) {
+ logger.debug(APPLICATION_EXCEPTION, e);
+ return e.buildErrorResponse();
+ }
}
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Modifications Copyright (C) 2018 IBM.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Interface for json analyzing.<br/>
/**
* Log service
*/
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, JsonUtil.class);
+ private static final Logger logger = LoggerFactory.getLogger(JsonUtil.class);
/**
* Mapper.
try {
return MAPPER.readValue(jsonstr, type);
} catch (IOException e) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
+ logger.error("{} {} {}", MessageEnum.RA_NS_EXC.toString(), MsoLogger.ErrorCode.BusinessProcesssError.getValue(),
UNMARSHAL_FAIL_MSG, e);
throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG);
}
try {
return MAPPER.readValue(jsonstr, type);
} catch (IOException e) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
+ logger.error("{} {} {}", MessageEnum.RA_NS_EXC.toString(), MsoLogger.ErrorCode.BusinessProcesssError.getValue(),
UNMARSHAL_FAIL_MSG, e);
throw new ApplicationException(HttpCode.BAD_REQUEST, UNMARSHAL_FAIL_MSG);
}
try {
return MAPPER.writeValueAsString(srcObj);
} catch (IOException e) {
- LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError,
+ logger.error("{} {} {}", MessageEnum.RA_NS_EXC.toString(), MsoLogger.ErrorCode.BusinessProcesssError.getValue(),
"fail to marshal json", e);
throw new ApplicationException(HttpCode.BAD_REQUEST, "srcObj marshal failed!");
}
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Modifications Copyright (C) 2018.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.so.adapters.vfc.model.RestfulResponse;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
/**
* Log service
*/
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, RestfulUtil.class);
+ private static final Logger logger = LoggerFactory.getLogger(RestfulUtil.class);
private static final int DEFAULT_TIME_OUT = 60000;
Integer msbPort = env.getProperty("mso.msb-port", Integer.class, DEFAULT_MSB_PORT);
String msbEndpoint = UriBuilder.fromPath("").host(msbIp).port(msbPort).scheme("http").build().toString();
- LOGGER.debug("msbEndpoint in vfc adapter: " + msbEndpoint);
+ logger.debug("msbEndpoint in vfc adapter: {}", msbEndpoint);
return msbEndpoint;
}
public RestfulResponse send(String url, String methodType, String content) {
String msbUrl = getMsbHost() + url;
- LOGGER.debug("Begin to sent message " + methodType +": " + msbUrl);
+ logger.debug("Begin to sent message {}: {}", methodType, msbUrl);
HttpRequestBase method = null;
HttpResponse httpResponse = null;
method = httpDelete;
}
- // now VFC have no auth
- // String userCredentials =
- // SDNCAdapterProperties.getEncryptedProperty(Constants.SDNC_AUTH_PROP,
- // Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY);
- // String authorization = "Basic " +
- // DatatypeConverter.printBase64Binary(userCredentials.getBytes());
- // method.setHeader("Authorization", authorization);
-
httpResponse = client.execute(method);
String responseContent = null;
int statusCode = httpResponse.getStatusLine().getStatusCode();
String statusMessage = httpResponse.getStatusLine().getReasonPhrase();
- LOGGER.debug("VFC Response: " + statusCode + " " + statusMessage
+ logger.debug("VFC Response: {} {}", statusCode, statusMessage
+ (responseContent == null ? "" : System.lineSeparator() + responseContent));
if(httpResponse.getStatusLine().getStatusCode() >= 300) {
if(null != method) {
method.reset();
} else {
- LOGGER.debug("method is NULL:");
+ logger.debug("method is NULL:");
}
method = null;
try {
EntityUtils.consume(httpResponse.getEntity());
} catch(Exception e) {
- LOGGER.debug("Exception :", e);
+ logger.debug("Exception :", e);
}
}
try {
method.reset();
} catch(Exception e) {
- LOGGER.debug("Exception :", e);
+ logger.debug("Exception :", e);
}
}
}
}
private static void logError(String errMsg, Throwable t) {
- LOGGER.error(MessageEnum.RA_NS_EXC, VFC_ADAPTER, "", MsoLogger.ErrorCode.AvailabilityError, errMsg, t);
+ logger.error("{} {} {} {}", MessageEnum.RA_NS_EXC.toString(), VFC_ADAPTER,
+ MsoLogger.ErrorCode.AvailabilityError.getValue(), errMsg, t);
}
private static void logError(String errMsg) {
- LOGGER.error(MessageEnum.RA_NS_EXC, VFC_ADAPTER, "", MsoLogger.ErrorCode.AvailabilityError, errMsg);
+ logger.error("{} {} {} {}", MessageEnum.RA_NS_EXC.toString(), VFC_ADAPTER,
+ MsoLogger.ErrorCode.AvailabilityError.toString(), errMsg);
}
private static RestfulResponse createResponse(int statusCode, String content) {