summaryrefslogtreecommitdiffstats
path: root/adapters/mso-requests-db-adapter/src/main/java
diff options
context:
space:
mode:
authorSmokowski, Steve (ss835w) <ss835w@us.att.com>2018-08-30 19:06:46 -0400
committerSmokowski, Steve (ss835w) <ss835w@us.att.com>2018-08-31 10:35:31 -0400
commitb92b1f86492d1fb0e546ef5124116abdf2d07dc9 (patch)
treef57ba276175711fd1a180ee7978d5ab464220711 /adapters/mso-requests-db-adapter/src/main/java
parent138f17fce465cdabb928525983323319162f20d2 (diff)
Update Logging
Add CXF interceptor for SOAP based logging Clean up extra logging statements Add UT to ensure MDC properly populated Change package name on Jax-RS Filter to be more accurate Issue-ID: SO-947 Change-Id: I3a2afc58de3bf370675658ce3d19cf899b90def7 Change-Id: I3a2afc58de3bf370675658ce3d19cf899b90def7 Signed-off-by: Smokowski, Steve (ss835w) <ss835w@us.att.com>
Diffstat (limited to 'adapters/mso-requests-db-adapter/src/main/java')
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java45
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java15
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java67
3 files changed, 60 insertions, 67 deletions
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
index d0eae88c9e..92a9df1071 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
@@ -23,10 +23,8 @@
package org.onap.so.adapters.requestsdb;
import java.sql.Timestamp;
-
import javax.jws.WebService;
import javax.transaction.Transactional;
-
import org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbException;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.OperationStatus;
@@ -37,7 +35,6 @@ import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
import org.onap.so.db.request.data.repository.OperationStatusRepository;
import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
import org.onap.so.db.request.data.repository.SiteStatusRepository;
-import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
import org.onap.so.requestsdb.RequestsDbConstant;
import org.onap.so.utils.UUIDChecker;
@@ -48,13 +45,7 @@ import org.springframework.stereotype.Component;
@WebService(serviceName = "RequestsDbAdapter", endpointInterface = "org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter", targetNamespace = "http://org.onap.so/requestsdb")
@Component
@Primary
-public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
-
- private static final String SUCCESSFUL = "Successful";
-
- private static final String GET_INFRA_REQUEST = "Get Infra request";
-
- private static final String ERROR = "Error ";
+public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, MsoRequestsDbAdapterImpl.class);
@@ -76,8 +67,6 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
RequestStatusType requestStatus, String progress, String vnfOutputs, String serviceInstanceId,
String networkId, String vnfId, String vfModuleId, String volumeGroupId, String serviceInstanceName,
String configurationId, String configurationName, String vfModuleName) throws MsoRequestsDbException {
- MsoLogger.setLogContext(requestId, serviceInstanceId);
- long startTime = System.currentTimeMillis();
try {
InfraActiveRequests request = infraActive.findOneByRequestIdOrClientRequestId(requestId, requestId);
if (request == null) {
@@ -132,15 +121,11 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
}
request.setLastModifiedBy(lastModifiedBy);
infraActive.save(request);
-
} catch (Exception e) {
String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId;
- logger.error(ERROR + MsoLogger.ErrorCode.BusinessProcesssError + " for " + GET_INFRA_REQUEST + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e);
- logger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error);
- throw new MsoRequestsDbException(error, e);
+ logger.error(error, e);
+ throw new MsoRequestsDbException(error, MsoLogger.ErrorCode.BusinessProcesssError, e);
}
- logger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESSFUL);
-
}
private void setProgress(String progress, InfraActiveRequests request) {
@@ -153,15 +138,10 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
@Override
@Transactional
- public InfraActiveRequests getInfraRequest(String requestId) throws MsoRequestsDbException {
- long startTime = System.currentTimeMillis();
- MsoLogger.setLogContext(requestId, null);
-
+ public InfraActiveRequests getInfraRequest(String requestId) throws MsoRequestsDbException {
logger.debug("Call to MSO Infra RequestsDb adapter get method with request Id: " + requestId);
-
InfraActiveRequests request = null;
try {
-
request = infraActive.findOneByRequestIdOrClientRequestId(requestId, requestId);
if (request == null) {
String error = "Entity not found. Unable to retrieve MSO Infra Requests DB for Request ID " + requestId;
@@ -169,11 +149,9 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
}
} catch (Exception e) {
String error = "Error retrieving MSO Infra Requests DB for Request ID " + requestId;
- logger.error(ERROR + MsoLogger.ErrorCode.BusinessProcesssError + " for " + GET_INFRA_REQUEST + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e);
- logger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error);
- throw new MsoRequestsDbException(error, e);
+ logger.error(error,e);
+ throw new MsoRequestsDbException(error,MsoLogger.ErrorCode.BusinessProcesssError , e);
}
- logger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESSFUL);
return request;
}
@@ -188,18 +166,14 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
@Transactional
public boolean getSiteStatus(String siteName) {
UUIDChecker.generateUUID(logger);
- long startTime = System.currentTimeMillis();
SiteStatus siteStatus;
logger.debug("Request database - get Site Status with Site name:" + siteName);
-
siteStatus = siteRepo.findOneBySiteName(siteName);
if (siteStatus == null) {
// if not exist in DB, it means the site is not disabled, thus
// return true
- logger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESSFUL);
return true;
- } else {
- logger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, SUCCESSFUL);
+ } else {
return siteStatus.getStatus();
}
}
@@ -226,9 +200,8 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
if (operStatus == null) {
String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: "
+ operationId;
- MsoRequestsDbException e = new MsoRequestsDbException(error);
- logger.error(ERROR+ MsoLogger.ErrorCode.BusinessProcesssError + " - " + MessageEnum.RA_DB_REQUEST_NOT_EXIST + " - " + error, e);
- throw e;
+ logger.error(error);
+ throw new MsoRequestsDbException(error,MsoLogger.ErrorCode.BusinessProcesssError);
}
operStatus.setUserId(userId);
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java
index a7e9cab6ba..0404c10760 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/CXFConfiguration.java
@@ -28,6 +28,8 @@ import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter;
+import org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor;
+import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
@@ -43,8 +45,12 @@ public class CXFConfiguration {
@Autowired
private MsoRequestsDbAdapter requestDbAdapterImpl;
-
-
+ @Autowired
+ private SOAPLoggingInInterceptor soapInInterceptor;
+
+ @Autowired
+ private SOAPLoggingOutInterceptor soapOutInterceptor;
+
@Bean
public ServletRegistrationBean cxfServlet() {
@@ -58,7 +64,10 @@ public class CXFConfiguration {
LoggingFeature logFeature = new LoggingFeature();
logFeature.setPrettyLogging(true);
logFeature.initialize(bus);
- endpoint.getFeatures().add(logFeature);
+ endpoint.getFeatures().add(logFeature);
+ endpoint.getInInterceptors().add(soapInInterceptor);
+ endpoint.getOutInterceptors().add(soapOutInterceptor);
+ endpoint.getOutFaultInterceptors().add(soapOutInterceptor);
return endpoint;
}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java
index 660761143e..e6d736d2ad 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/exceptions/MsoRequestsDbException.java
@@ -23,6 +23,8 @@ package org.onap.so.adapters.requestsdb.exceptions;
import javax.xml.ws.WebFault;
+import org.onap.so.exceptions.MSOException;
+import org.onap.so.logger.MsoLogger.ErrorCode;
/**
* This class simply extends Exception (without addition additional functionality)
@@ -31,32 +33,41 @@ import javax.xml.ws.WebFault;
*
*/
@WebFault (name="MsoRequestsDbException", faultBean="org.onap.so.adapters.requestsdb.exceptions.MsoRequestsDbExceptionBean", targetNamespace="http://org.onap.so/requestsdb")
-public class MsoRequestsDbException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- private MsoRequestsDbExceptionBean faultInfo;
-
- public MsoRequestsDbException (String msg) {
- super(msg);
- faultInfo = new MsoRequestsDbExceptionBean (msg);
- }
-
- public MsoRequestsDbException (Throwable e) {
- super(e);
- faultInfo = new MsoRequestsDbExceptionBean (e.getMessage());
- }
-
- public MsoRequestsDbException (String msg, Throwable e) {
- super (msg, e);
- faultInfo = new MsoRequestsDbExceptionBean (msg);
- }
-
- public MsoRequestsDbExceptionBean getFaultInfo() {
- return faultInfo;
- }
-
- public void setFaultInfo(MsoRequestsDbExceptionBean faultInfo) {
- this.faultInfo = faultInfo;
- }
+public class MsoRequestsDbException extends MSOException {
+
+ private static final long serialVersionUID = 1L;
+
+ private MsoRequestsDbExceptionBean faultInfo;
+
+
+ public MsoRequestsDbException (String msg) {
+ super(msg);
+ faultInfo = new MsoRequestsDbExceptionBean (msg);
+ }
+
+ public MsoRequestsDbException (Throwable e) {
+ super(e);
+ faultInfo = new MsoRequestsDbExceptionBean (e.getMessage());
+ }
+
+ public MsoRequestsDbException (String msg, Throwable e) {
+ super (msg, e);
+ faultInfo = new MsoRequestsDbExceptionBean (msg);
+ }
+
+ public MsoRequestsDbException(String msg, ErrorCode errorCode) {
+ super(msg,errorCode.getValue());
+ }
+
+ public MsoRequestsDbException(String msg, ErrorCode errorCode, Throwable t) {
+ super(msg,errorCode.getValue(), t);
+ }
+
+ public MsoRequestsDbExceptionBean getFaultInfo() {
+ return faultInfo;
+ }
+
+ public void setFaultInfo(MsoRequestsDbExceptionBean faultInfo) {
+ this.faultInfo = faultInfo;
+ }
}