summaryrefslogtreecommitdiffstats
path: root/aai-els-onap-logging
diff options
context:
space:
mode:
Diffstat (limited to 'aai-els-onap-logging')
-rw-r--r--aai-els-onap-logging/pom.xml130
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilter.java99
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptor.java147
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptor.java188
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDBMetricLog.java114
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDebugLog.java36
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java92
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiScheduledTaskAuditLog.java74
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/DBRequestWrapper.java26
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/ServiceName.java50
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java371
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/ObjectFactory.java93
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/PolicyException.java126
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RESTResponse.java80
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RequestError.java80
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java375
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/ObjectFactory.java93
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/Fault.java371
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ObjectFactory.java93
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RESTResponse.java80
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RequestError.java80
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ServiceException.java126
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java153
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIExceptionWithInfo.java135
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/AaiElsErrorCode.java31
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/CNName.java97
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/CustomLogPatternLayout.java28
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/CustomLogPatternLayoutEncoder.java40
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/DME2RestFlag.java55
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorLogHelper.java618
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObject.java377
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObjectFormatException.java30
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObjectNotFoundException.java51
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/LogFormatTools.java125
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java130
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContextNotExistsException.java26
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/StopWatch.java56
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/logging/StopWatchNotStartedException.java42
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java362
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfig.java226
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfigProxy.java41
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConstants.java164
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/FormatDate.java47
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java61
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/aai/util/MapperUtil.java122
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java82
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java135
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java57
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java67
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogServletFilter.java85
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/Constants.java46
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java238
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MetricLogClientFilter.java82
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponents.java80
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponentsList.java25
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java162
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingServletFilter.java330
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleHashMap.java37
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMap.java37
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleMap.java25
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleServletHeadersMap.java37
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogAdapter.java616
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java289
-rw-r--r--aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/package-info.java32
-rw-r--r--aai-els-onap-logging/src/test/java/org/onap/aai/util/MapperUtilTest.java91
65 files changed, 8494 insertions, 0 deletions
diff --git a/aai-els-onap-logging/pom.xml b/aai-els-onap-logging/pom.xml
new file mode 100644
index 00000000..8817adf5
--- /dev/null
+++ b/aai-els-onap-logging/pom.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.aai.aai-common</groupId>
+ <artifactId>aai-parent</artifactId>
+ <version>1.6.6-SNAPSHOT</version>
+ <relativePath>../aai-parent/pom.xml</relativePath>
+ </parent>
+ <artifactId>aai-els-onap-logging</artifactId>
+ <name>aai-els-onap-logging</name>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-oxm</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aspects</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-access</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.logging-analytics</groupId>
+ <artifactId>logging-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-jaxb-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilter.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilter.java
new file mode 100644
index 00000000..c826df3d
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilter.java
@@ -0,0 +1,99 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.aailog.filter;
+
+import org.onap.aai.aailog.logs.ServiceName;
+import org.onap.logging.filter.base.AuditLogContainerFilter;
+import org.onap.logging.filter.base.Constants;
+import org.onap.logging.filter.base.SimpleMap;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.MDC;
+
+import javax.annotation.Priority;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.PreMatching;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.UriInfo;
+
+@PreMatching
+@Priority(1)
+public class AaiAuditLogContainerFilter extends AuditLogContainerFilter {
+ @Override
+ public void setMDCPartnerName(SimpleMap headers) {
+ logger.trace("Checking X-ONAP-PartnerName header for partnerName.");
+ String partnerName = headers.get(ONAPLogConstants.Headers.PARTNER_NAME);
+ if (partnerName == null || partnerName.isEmpty()) {
+ logger.trace("No valid X-ONAP-PartnerName header value. Checking X-FromAppId header for partnerName.");
+ partnerName = headers.get (Constants.HttpHeaders.HEADER_FROM_APP_ID);
+ if (partnerName == null || partnerName.isEmpty()) {
+ logger.trace("No valid X-FromAppId header value. Checking User-Agent header for partnerName.");
+ partnerName = headers.get(HttpHeaders.USER_AGENT);
+ if (partnerName == null || partnerName.isEmpty()) {
+ logger.trace("No valid User-Agent header value. Checking X-ClientID header for partnerName.");
+ partnerName = headers.get(Constants.HttpHeaders.CLIENT_ID);
+ if (partnerName == null || partnerName.isEmpty()) {
+ logger.trace("No valid partnerName headers. Defaulting partnerName to UNKNOWN.");
+ partnerName = Constants.DefaultValues.UNKNOWN;
+ }
+ }
+ }
+ }
+ MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName);
+ }
+ @Override
+ protected void setServiceName(ContainerRequestContext containerRequest) {
+ UriInfo uriInfo = containerRequest.getUriInfo();
+ String serviceName = ServiceName.extractServiceName(uriInfo.getAbsolutePath().getRawPath());
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, serviceName);
+ }
+
+ @Override
+ protected void pre(SimpleMap headers, ContainerRequestContext request, HttpServletRequest httpServletRequest) {
+ try {
+ String requestId = getRequestId(headers);
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+ // handle the case where the request ID value was invalid and we had to generate a new one
+ addRequestIdHeader(request, requestId);
+ setInvocationId(headers);
+ setServiceName(request);
+ setMDCPartnerName(headers);
+ setServerFQDN();
+ setClientIPAddress(httpServletRequest);
+ setInstanceID();
+ setEntryTimeStamp();
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
+ additionalPreHandling(request);
+ setLogTimestamp();
+ setElapsedTime();
+ logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
+ } catch (Exception e) {
+ logger.warn("Error in AaiAuditContainerFilter pre", e);
+ }
+ }
+
+ protected void addRequestIdHeader(ContainerRequestContext containerRequest, String requestId) {
+ if (containerRequest.getHeaders().get(ONAPLogConstants.Headers.REQUEST_ID) != null) {
+ containerRequest.getHeaders().get(ONAPLogConstants.Headers.REQUEST_ID).clear();
+ }
+ containerRequest.getHeaders().add(ONAPLogConstants.Headers.REQUEST_ID, requestId);
+ };
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptor.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptor.java
new file mode 100644
index 00000000..51824b74
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptor.java
@@ -0,0 +1,147 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.aailog.filter;
+
+import org.onap.aai.aailog.logs.ServiceName;
+import org.onap.logging.filter.base.AbstractMetricLogFilter;
+import org.onap.logging.filter.base.Constants;
+import org.onap.logging.filter.base.MDCSetup;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.MDC;
+import org.springframework.http.HttpRequest;
+import org.springframework.http.client.ClientHttpRequestExecution;
+import org.springframework.http.client.ClientHttpRequestInterceptor;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.http.HttpHeaders;
+
+import javax.ws.rs.core.MultivaluedMap;
+import java.io.IOException;
+import java.util.List;
+import java.util.UUID;
+
+public class RestClientLoggingInterceptor extends AbstractMetricLogFilter<HttpRequest, ClientHttpResponse, HttpHeaders> implements ClientHttpRequestInterceptor {
+ @Override
+ public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
+ throws IOException
+ {
+ this.setInvocationId(request.getHeaders());
+ pre(request, request.getHeaders());
+ ClientHttpResponse resp = execution.execute(request, body);
+ post(request, resp);
+ return resp;
+
+ }
+ protected void pre(HttpRequest request, HttpHeaders requestHeaders) {
+ try {
+ setupMDC(request);
+ setupHeaders(request, requestHeaders);
+ super.logInvoke();
+ } catch (Exception e) {
+ logger.warn("Error in RestClientLoggingInterceptor pre", e);
+ }
+ }
+ protected void setupHeaders(HttpRequest clientRequest, HttpHeaders requestHeaders) {
+ String requestId = extractRequestID(requestHeaders);
+ addHeader(requestHeaders, ONAPLogConstants.Headers.REQUEST_ID, requestId);
+ addHeader(requestHeaders, Constants.HttpHeaders.HEADER_REQUEST_ID, requestId);
+ if (requestHeaders.getFirst(Constants.HttpHeaders.TRANSACTION_ID) == null ||
+ requestHeaders.getFirst(Constants.HttpHeaders.TRANSACTION_ID).isEmpty()) {
+ addHeader(requestHeaders, Constants.HttpHeaders.TRANSACTION_ID, requestId);
+ }
+ addHeader(requestHeaders, Constants.HttpHeaders.ECOMP_REQUEST_ID, requestId);
+ addHeader(requestHeaders, ONAPLogConstants.Headers.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID));
+ String pName = getProperty(Constants.Property.PARTNER_NAME);
+ if (pName != null && (!pName.isEmpty())) {
+ addHeader(requestHeaders, ONAPLogConstants.Headers.PARTNER_NAME, pName);
+ }
+ }
+ protected String extractRequestID(HttpHeaders requestHeaders) {
+ String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
+ if (requestId == null || requestId.isEmpty()) {
+ requestId = requestHeaders.getFirst(Constants.HttpHeaders.TRANSACTION_ID);
+ if (requestId == null || requestId.isEmpty()) {
+ requestId = UUID.randomUUID().toString();
+ }
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+ }
+ return requestId;
+ }
+ public void setInvocationId(HttpHeaders headers) {
+ String invocationId = null;
+
+ List<String> headerList = headers.get(ONAPLogConstants.Headers.INVOCATION_ID);
+ if (headerList != null && (!headerList.isEmpty())) {
+ for (String h : headerList) {
+ if ( h != null && (!h.isEmpty()) ) {
+ invocationId = h;
+ break;
+ }
+ }
+ headers.remove(ONAPLogConstants.Headers.INVOCATION_ID);
+ }
+ if (invocationId == null) {
+ invocationId = UUID.randomUUID().toString();
+ }
+ MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId);
+ }
+ @Override
+ protected void addHeader(HttpHeaders requestHeaders, String headerName, String headerValue) {
+ requestHeaders.add(headerName, headerValue);
+ }
+
+ protected String getTargetServiceName(HttpRequest request) {
+ return (getServiceName(request));
+ }
+ protected String getServiceName(HttpRequest request){
+ String path = request.getURI().getRawPath();
+ return(ServiceName.extractServiceName(path));
+ }
+
+ protected int getHttpStatusCode(ClientHttpResponse response) {
+ int result = 0;
+ if (response != null ) {
+ try {
+ result = response.getStatusCode().value();
+ }
+ catch (IOException e) {
+ logger.warn("Error in RestClientLoggingInterceptor getHttpStatusCode {}", e.getMessage());
+ }
+ }
+ return result;
+ }
+
+ protected String getResponseCode(ClientHttpResponse response) {
+ String result = "";
+ if (response != null ) {
+ try {
+ result = response.getStatusCode().toString();
+ }
+ catch (IOException e) {
+ logger.warn("Error in RestClientLoggingInterceptor getResponseCode {}", e.getMessage());
+ }
+ }
+ return result;
+ }
+
+ protected String getTargetEntity(HttpRequest request) {
+ //TODO where do we get this from?
+ return Constants.DefaultValues.UNKNOWN_TARGET_ENTITY;
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptor.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptor.java
new file mode 100644
index 00000000..7e332ec5
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptor.java
@@ -0,0 +1,188 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.aailog.filter;
+
+import com.sun.jersey.api.client.ClientHandler;
+import com.sun.jersey.api.client.ClientHandlerException;
+import com.sun.jersey.api.client.ClientRequest;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.filter.ClientFilter;
+import org.onap.aai.aailog.logs.ServiceName;
+import org.onap.logging.filter.base.Constants;
+import org.onap.logging.filter.base.MDCSetup;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.*;
+
+import javax.ws.rs.core.MultivaluedMap;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.UUID;
+
+public class RestControllerClientLoggingInterceptor extends ClientFilter {
+ private static final Logger logger = LoggerFactory.getLogger(RestControllerClientLoggingInterceptor.class);
+ private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN");
+ private final MDCSetup mdcSetup;
+ private final String partnerName;
+
+ public RestControllerClientLoggingInterceptor () {
+ mdcSetup = new MDCSetup();
+ partnerName = getPartnerName();
+ }
+
+ @Override
+ public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException {
+ ClientResponse clientResponse = null;
+ pre(clientRequest);
+ // Call the next client handler in the filter chain
+ ClientHandler nextHandler = getNext();
+ if (nextHandler != null) {
+ clientResponse = nextHandler.handle(clientRequest);
+ }
+ if (clientResponse != null) {
+ post(clientResponse);
+ }
+ return clientResponse;
+ }
+
+ protected String getTargetServiceName(ClientRequest clientRequest) {
+ return getServiceName(clientRequest);
+ }
+
+ protected String getServiceName(ClientRequest clientRequest) {
+ String path = clientRequest.getURI().getRawPath();
+ return ServiceName.extractServiceName(path);
+ }
+
+ protected int getHttpStatusCode(ClientResponse response) {
+ return response.getStatus();
+ }
+
+ protected String getResponseCode(ClientResponse clientResponse) {
+ return String.valueOf(clientResponse.getStatus());
+ }
+
+
+ protected String getTargetEntity(ClientRequest ClientRequest) {
+ return Constants.DefaultValues.UNKNOWN_TARGET_ENTITY;
+ };
+
+ protected void pre(ClientRequest clientRequest) {
+ try {
+ setInvocationId(clientRequest);
+ setupMDC(clientRequest);
+ setupHeaders(clientRequest);
+ logger.info(ONAPLogConstants.Markers.INVOKE, "Invoke");
+ } catch (Exception e) {
+ logger.warn("Error in RestControllerClientLoggingInterceptor pre", e.getMessage());
+ }
+ }
+ public void setInvocationId(ClientRequest clientRequest) {
+ String invocationId = null;
+ MultivaluedMap<String, Object> requestHeaders = clientRequest.getHeaders();
+ Object id = requestHeaders.get(ONAPLogConstants.Headers.INVOCATION_ID);
+ if (id != null) {
+ invocationId = (String)id;
+ }
+ requestHeaders.remove(ONAPLogConstants.Headers.INVOCATION_ID);
+ if (invocationId == null) {
+ invocationId = UUID.randomUUID().toString();
+ }
+ MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId);
+ }
+ protected void setupHeaders(ClientRequest clientRequest) {
+ String requestId = extractRequestID(clientRequest);
+ MultivaluedMap<String, Object> requestHeaders = clientRequest.getHeaders();
+ addHeader(requestHeaders, ONAPLogConstants.Headers.REQUEST_ID, requestId);
+ addHeader(requestHeaders, Constants.HttpHeaders.HEADER_REQUEST_ID, requestId);
+ Object requestIdObj = requestHeaders.getFirst(Constants.HttpHeaders.TRANSACTION_ID);
+ if (requestIdObj == null) {
+ addHeader(requestHeaders, Constants.HttpHeaders.TRANSACTION_ID, requestId);
+ }
+ addHeader(requestHeaders, Constants.HttpHeaders.ECOMP_REQUEST_ID, requestId);
+ addHeader(requestHeaders, ONAPLogConstants.Headers.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID));
+ if (partnerName != null && (!partnerName.isEmpty())){
+ addHeader(requestHeaders, ONAPLogConstants.Headers.PARTNER_NAME, partnerName);
+ }
+ }
+
+ protected void setupMDC(ClientRequest clientRequest) {
+ MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP,
+ ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
+ MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, getTargetServiceName(clientRequest));
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
+ mdcSetup.setInvocationIdFromMDC();
+
+ if (MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY) == null) {
+ String targetEntity = getTargetEntity(clientRequest);
+ if (targetEntity != null) {
+ MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, targetEntity);
+ } else {
+ MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, Constants.DefaultValues.UNKNOWN_TARGET_ENTITY);
+ }
+ }
+
+ if (MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME) == null) {
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, getServiceName(clientRequest));
+ }
+ mdcSetup.setServerFQDN();
+ }
+
+ protected String extractRequestID(ClientRequest clientRequest) {
+ String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
+ if (requestId == null || requestId.isEmpty()) {
+ MultivaluedMap<String, Object> requestHeaders = clientRequest.getHeaders();
+ Object requestIdObj = requestHeaders.getFirst(Constants.HttpHeaders.TRANSACTION_ID);
+ if (requestIdObj != null) {
+ requestId = (String)requestIdObj;
+ }
+ if ( requestId == null || requestId.isEmpty() ) {
+ requestId = UUID.randomUUID().toString();
+ }
+ mdcSetup.setLogTimestamp();
+ mdcSetup.setElapsedTimeInvokeTimestamp();
+ logger.warn("No value found in MDC when checking key {} value will be set to {}",
+ ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+ }
+ return requestId;
+ }
+
+ protected void post(ClientResponse clientResponse) {
+ try {
+ mdcSetup.setLogTimestamp();
+ mdcSetup.setElapsedTimeInvokeTimestamp();
+ mdcSetup.setResponseStatusCode(getHttpStatusCode(clientResponse));
+ mdcSetup.setResponseDescription(getHttpStatusCode(clientResponse));
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, getResponseCode(clientResponse));
+ logger.info(INVOKE_RETURN, "InvokeReturn");
+ mdcSetup.clearClientMDCs();
+ } catch (Exception e) {
+ logger.warn("Error in RestControllerClientLoggingInterceptor post", e.getMessage());
+ }
+ }
+ protected String getPartnerName() {
+ return mdcSetup.getProperty(Constants.Property.PARTNER_NAME);
+ }
+
+ protected void addHeader(MultivaluedMap<String, Object> requestHeaders, String headerName, String headerValue) {
+ requestHeaders.add(headerName, headerValue);
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDBMetricLog.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDBMetricLog.java
new file mode 100644
index 00000000..0269943b
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDBMetricLog.java
@@ -0,0 +1,114 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.aailog.logs;
+
+import org.onap.logging.filter.base.AbstractMetricLogFilter;
+import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.*;
+
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+public class AaiDBMetricLog
+ extends AbstractMetricLogFilter<DBRequestWrapper, Response, MultivaluedMap<String, Object>> {
+
+ protected static final Logger logger = LoggerFactory.getLogger(AaiDBMetricLog.class);
+ private final String partnerName;
+ private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN");
+ private static final String TARGET_ENTITY = ONAPComponents.AAI.toString() + ".DB";
+ public AaiDBMetricLog(String subcomponent) {
+ partnerName = getPartnerName(subcomponent);
+ }
+
+ @Override
+ protected void addHeader(MultivaluedMap<String, Object> requestHeaders, String headerName, String headerValue) {
+ requestHeaders.add(headerName, headerValue);
+ }
+
+ @Override
+ protected String getTargetServiceName(DBRequestWrapper request) {
+ return (getServiceName(request));
+ }
+
+ @Override
+ protected String getServiceName(DBRequestWrapper request) {
+ String path = request.getUri().getRawPath();
+ return ServiceName.extractServiceName(path);
+ }
+
+ @Override
+ protected int getHttpStatusCode(Response response) {
+ int intCode = response.getStatus();
+ return intCode;
+ }
+
+ @Override
+ protected String getResponseCode(Response response) {
+ return String.valueOf(response.getStatus());
+ }
+
+ @Override
+ protected String getTargetEntity(DBRequestWrapper request) {
+ return TARGET_ENTITY;
+ }
+
+ protected String getPartnerName(String subcomponent) {
+ StringBuilder sb = new StringBuilder(ONAPComponents.AAI.toString()).append(subcomponent);
+ return (sb.toString());
+ }
+
+ public void pre(DBRequestWrapper request) {
+ try {
+ setupMDC(request);
+ setLogTimestamp();
+ logger.info(ONAPLogConstants.Markers.INVOKE, "Invoke");
+ } catch (Exception e) {
+ logger.warn("Error in AaiDBMetricLog pre", e);
+ }
+ }
+ public void post(DBRequestWrapper request, Response response) {
+ try {
+ setLogTimestamp();
+ setElapsedTimeInvokeTimestamp();
+ setResponseStatusCode(getHttpStatusCode(response));
+ setResponseDescription(getHttpStatusCode(response));
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, getResponseCode(response));
+ logger.info(INVOKE_RETURN, "InvokeReturn");
+ clearClientMDCs();
+ } catch (Exception e) {
+ logger.warn("Error in AaiDBMetricLog post", e);
+ }
+ }
+ @Override
+ public void setResponseStatusCode(int code) {
+ String statusCode;
+ if (code / 100 == 2) {
+ statusCode = ONAPLogConstants.ResponseStatus.COMPLETE.toString();
+ }
+ else {
+ statusCode = ONAPLogConstants.ResponseStatus.ERROR.toString();
+ setErrorCode(code);
+ setErrorDesc(code);
+ }
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode);
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDebugLog.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDebugLog.java
new file mode 100644
index 00000000..ef11f08e
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDebugLog.java
@@ -0,0 +1,36 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.aailog.logs;
+
+import org.onap.logging.filter.base.MDCSetup;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.MDC;
+
+import java.util.UUID;
+
+public class AaiDebugLog extends MDCSetup {
+
+ public void setupMDC() {
+ String requestId = UUID.randomUUID().toString();
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+ setLogTimestamp();
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java
new file mode 100644
index 00000000..b0fb079c
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiDmaapMetricLog.java
@@ -0,0 +1,92 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.aailog.logs;
+
+import org.onap.aai.logging.AaiElsErrorCode;
+import org.onap.logging.filter.base.MDCSetup;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.*;
+
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.regex.PatternSyntaxException;
+
+public class AaiDmaapMetricLog extends MDCSetup {
+
+ protected static final Logger logger = LoggerFactory.getLogger(AaiDmaapMetricLog.class);
+ private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN");
+ private static final String TARGET_ENTITY = "DMaaP";
+
+ public AaiDmaapMetricLog() {
+ }
+ public void pre(String targetServiceName, String event, String transactionId, String serviceName) {
+
+ try {
+ MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP,
+ ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
+ setLogTimestamp();
+ setElapsedTimeInvokeTimestamp();
+ MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, targetServiceName);
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
+ MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, TARGET_ENTITY);
+ if (transactionId != null && !(transactionId.isEmpty())) {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, transactionId);
+ }
+ if (serviceName != null && !(serviceName.isEmpty())) {
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, serviceName);
+ }
+ setInvocationIdFromMDC();
+ logger.info(ONAPLogConstants.Markers.INVOKE, event );
+
+ } catch (Exception e) {
+ logger.warn("Error in AaiDmaapMetricLog pre", e.getMessage());
+ }
+ }
+
+ public void post(String responseCode, String errorDescription) {
+
+ try {
+ setLogTimestamp();
+ setElapsedTimeInvokeTimestamp();
+ setResponseStatusCode(responseCode, errorDescription);
+ logger.info(INVOKE_RETURN, "InvokeReturn");
+ clearClientMDCs();
+ } catch (Exception e) {
+ logger.warn("Error in AaiDmaapMetricLog post", e.getMessage());
+ }
+ }
+
+ public void setResponseStatusCode(String aaiElsErrorCode, String errorDescription) {
+ String statusCode;
+ if (AaiElsErrorCode.SUCCESS.equals(aaiElsErrorCode)) {
+ statusCode = ONAPLogConstants.ResponseStatus.COMPLETE.toString();
+ }
+ else {
+ statusCode = ONAPLogConstants.ResponseStatus.ERROR.toString();
+ MDC.put(ONAPLogConstants.MDCs.ERROR_CODE, aaiElsErrorCode);
+ MDC.put(ONAPLogConstants.MDCs.ERROR_DESC, errorDescription);
+ }
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode);
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, aaiElsErrorCode);
+
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiScheduledTaskAuditLog.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiScheduledTaskAuditLog.java
new file mode 100644
index 00000000..60460fff
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/AaiScheduledTaskAuditLog.java
@@ -0,0 +1,74 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.aailog.logs;
+
+import org.onap.logging.filter.base.MDCSetup;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import javax.ws.rs.core.Response;
+import java.util.UUID;
+
+@Component
+@Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class AaiScheduledTaskAuditLog extends MDCSetup {
+ protected static Logger logger = LoggerFactory.getLogger(AaiScheduledTaskAuditLog.class);
+
+ public void logBefore(String serviceName, String partnerName) {
+ try {
+ String requestId = UUID.randomUUID().toString();
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+ setInvocationIdFromMDC();
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, serviceName);
+ MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName);
+ setServerFQDN();
+ setClientIPAddress(null);
+ setInstanceID();
+ setEntryTimeStamp();
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
+ setLogTimestamp();
+ setElapsedTime();
+ logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
+ } catch (Exception e) {
+ logger.warn("Error in AaiScheduledTaskAuditLog logBefore", e.getMessage());
+ }
+
+ }
+
+ public void logAfter() {
+ try {
+ // TODO: how do we know if there was an error
+ setResponseStatusCode(Response.Status.OK.getStatusCode());
+ setLogTimestamp();
+ setElapsedTime();
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting.");
+ } catch (Exception e) {
+ logger.warn("Error in AaiScheduledTaskAuditLog logAfter", e.getMessage());
+ } finally {
+ MDC.clear();
+ }
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/DBRequestWrapper.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/DBRequestWrapper.java
new file mode 100644
index 00000000..2b78613d
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/DBRequestWrapper.java
@@ -0,0 +1,26 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.aailog.logs;
+import java.net.URI;
+
+public interface DBRequestWrapper {
+ public URI getUri();
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/ServiceName.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/ServiceName.java
new file mode 100644
index 00000000..97f042f0
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/logs/ServiceName.java
@@ -0,0 +1,50 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.aailog.logs;
+
+public class ServiceName {
+ /**
+ * Extract the service name from a URI path
+ * Service name should be the URI path up to two levels down from the version or less
+ * @param path the URI path
+ * @return the service name
+ */
+ public static String extractServiceName (String path) {
+ StringBuilder sBuilder = new StringBuilder();
+ String[] parts = path.split("/");
+ String part = "";
+ for (int i = 0; i < parts.length; i++) {
+ part = parts[i];
+ if (i < 5) {
+ sBuilder.append(part).append("/");
+ } else {
+ break;
+ }
+ }
+ if ((sBuilder.length() > 0) && (sBuilder.charAt(sBuilder.length()-1) == '/')) {
+ sBuilder.deleteCharAt(sBuilder.length()-1);
+ }
+ String serviceName = sBuilder.toString();
+ if (serviceName != null && (!serviceName.isEmpty())) {
+ serviceName = serviceName.replaceAll(",", "\\\\,");
+ }
+ return serviceName;
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java
new file mode 100644
index 00000000..d1403ad2
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/Fault.java
@@ -0,0 +1,371 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2015.02.11 at 04:54:39 PM EST
+//
+
+package org.onap.aai.domain.restPolicyException;
+
+import javax.xml.bind.annotation.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="requestError">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="policyException">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="variables">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {"requestError"})
+@XmlRootElement(name = "Fault")
+public class Fault {
+
+ @XmlElement(required = true)
+ protected RequestError requestError;
+
+ /**
+ * Gets the value of the requestError property.
+ *
+ * @return
+ * possible object is
+ * {@link RequestError }
+ *
+ */
+ public RequestError getRequestError() {
+ return requestError;
+ }
+
+ /**
+ * Sets the value of the requestError property.
+ *
+ * @param value
+ * allowed object is
+ * {@link RequestError }
+ *
+ */
+ public void setRequestError(RequestError value) {
+ this.requestError = value;
+ }
+
+ /**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="policyException">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="variables">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {"policyException"})
+ public static class RequestError {
+
+ @XmlElement(required = true)
+ protected PolicyException policyException;
+
+ /**
+ * Gets the value of the policyException property.
+ *
+ * @return
+ * possible object is
+ * {@link PolicyException }
+ *
+ */
+ public PolicyException getPolicyException() {
+ return policyException;
+ }
+
+ /**
+ * Sets the value of the policyException property.
+ *
+ * @param value
+ * allowed object is
+ * {@link PolicyException }
+ *
+ */
+ public void setPolicyException(PolicyException value) {
+ this.policyException = value;
+ }
+
+ /**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="variables">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {"messageId", "text", "variables"})
+ public static class PolicyException {
+
+ @XmlElement(required = true)
+ protected String messageId;
+ @XmlElement(required = true)
+ protected String text;
+ @XmlElement(required = true)
+ protected Variables variables;
+
+ /**
+ * Gets the value of the messageId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMessageId() {
+ return messageId;
+ }
+
+ /**
+ * Sets the value of the messageId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMessageId(String value) {
+ this.messageId = value;
+ }
+
+ /**
+ * Gets the value of the text property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * Sets the value of the text property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setText(String value) {
+ this.text = value;
+ }
+
+ /**
+ * Gets the value of the variables property.
+ *
+ * @return
+ * possible object is
+ * {@link Variables }
+ *
+ */
+ public Variables getVariables() {
+ return variables;
+ }
+
+ /**
+ * Sets the value of the variables property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Variables }
+ *
+ */
+ public void setVariables(Variables value) {
+ this.variables = value;
+ }
+
+ /**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {"variable"})
+ public static class Variables {
+
+ protected List<String> variable;
+
+ /**
+ * Gets the value of the variable property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the variable property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ *
+ * <pre>
+ * getVariable().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ * @return the variable
+ */
+ public List<String> getVariable() {
+ if (variable == null) {
+ variable = new ArrayList<String>();
+ }
+ return this.variable;
+ }
+
+ }
+
+ }
+
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/ObjectFactory.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/ObjectFactory.java
new file mode 100644
index 00000000..d7837f9f
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/ObjectFactory.java
@@ -0,0 +1,93 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2015.02.11 at 04:54:39 PM EST
+//
+
+package org.onap.aai.domain.restPolicyException;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.onap.aai.domain.restPolicyException package.
+ * <p>
+ * An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package:
+ * org.onap.aai.domain.restPolicyException
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**a
+ * * Create an instance of {@link Fult }.
+ *
+ * @return the fault
+ */
+ public Fault createFault() {
+ return new Fault();
+ }
+
+ /**
+ * Create an instance of {@link Fault.RequestError }
+ *
+ * @return the request error
+ */
+ public Fault.RequestError createFaultRequestError() {
+ return new Fault.RequestError();
+ }
+
+ /**
+ * Create an instance of {@link Fault.RequestError.PolicyException }
+ *
+ * @return the policy exception
+ */
+ public Fault.RequestError.PolicyException createFaultRequestErrorPolicyException() {
+ return new Fault.RequestError.PolicyException();
+ }
+
+ /**
+ * Create an instance of {@link Fault.RequestError.PolicyException.Variables }
+ *
+ * @return the variables
+ */
+ public Fault.RequestError.PolicyException.Variables createFaultRequestErrorPolicyExceptionVariables() {
+ return new Fault.RequestError.PolicyException.Variables();
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/PolicyException.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/PolicyException.java
new file mode 100644
index 00000000..ae6b6da1
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/PolicyException.java
@@ -0,0 +1,126 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.domain.restPolicyException;
+
+import com.fasterxml.jackson.annotation.*;
+
+import javax.annotation.Generated;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({"messageId", "text", "variables"})
+public class PolicyException {
+
+ @JsonProperty("messageId")
+ private String messageId;
+ @JsonProperty("text")
+ private String text;
+ @JsonProperty("variables")
+ private List<String> variables = new ArrayList<String>();
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * Gets the message id.
+ *
+ * @return The messageId
+ */
+ @JsonProperty("messageId")
+ public String getMessageId() {
+ return messageId;
+ }
+
+ /**
+ * Sets the message id.
+ *
+ * @param messageId The messageId
+ */
+ @JsonProperty("messageId")
+ public void setMessageId(String messageId) {
+ this.messageId = messageId;
+ }
+
+ /**
+ * Gets the text.
+ *
+ * @return The text
+ */
+ @JsonProperty("text")
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * Sets the text.
+ *
+ * @param text The text
+ */
+ @JsonProperty("text")
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * Gets the variables.
+ *
+ * @return The variables
+ */
+ @JsonProperty("variables")
+ public List<String> getVariables() {
+ return variables;
+ }
+
+ /**
+ * Sets the variables.
+ *
+ * @param variables The variables
+ */
+ @JsonProperty("variables")
+ public void setVariables(List<String> variables) {
+ this.variables = variables;
+ }
+
+ /**
+ * Gets the additional properties.
+ *
+ * @return the additional properties
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /**
+ * Sets the additional property.
+ *
+ * @param name the name
+ * @param value the value
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RESTResponse.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RESTResponse.java
new file mode 100644
index 00000000..e1df4512
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RESTResponse.java
@@ -0,0 +1,80 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.domain.restPolicyException;
+
+import com.fasterxml.jackson.annotation.*;
+
+import javax.annotation.Generated;
+import java.util.HashMap;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({"requestError"})
+public class RESTResponse {
+
+ @JsonProperty("requestError")
+ private RequestError requestError;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * Gets the request error.
+ *
+ * @return The requestError
+ */
+ @JsonProperty("requestError")
+ public RequestError getRequestError() {
+ return requestError;
+ }
+
+ /**
+ * Sets the request error.
+ *
+ * @param requestError The requestError
+ */
+ @JsonProperty("requestError")
+ public void setRequestError(RequestError requestError) {
+ this.requestError = requestError;
+ }
+
+ /**
+ * Gets the additional properties.
+ *
+ * @return the additional properties
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /**
+ * Sets the additional property.
+ *
+ * @param name the name
+ * @param value the value
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RequestError.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RequestError.java
new file mode 100644
index 00000000..2b041840
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restPolicyException/RequestError.java
@@ -0,0 +1,80 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.domain.restPolicyException;
+
+import com.fasterxml.jackson.annotation.*;
+
+import javax.annotation.Generated;
+import java.util.HashMap;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({"policyException"})
+public class RequestError {
+
+ @JsonProperty("policyException")
+ private PolicyException policyException;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * Gets the policy exception.
+ *
+ * @return The policyException
+ */
+ @JsonProperty("policyException")
+ public PolicyException getPolicyException() {
+ return policyException;
+ }
+
+ /**
+ * Sets the policy exception.
+ *
+ * @param policyException The policyException
+ */
+ @JsonProperty("policyException")
+ public void setPolicyException(PolicyException policyException) {
+ this.policyException = policyException;
+ }
+
+ /**
+ * Gets the additional properties.
+ *
+ * @return the additional properties
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /**
+ * Sets the additional property.
+ *
+ * @param name the name
+ * @param value the value
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java
new file mode 100644
index 00000000..268b7673
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/Info.java
@@ -0,0 +1,375 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2015.10.28 at 05:53:17 PM EDT
+//
+
+package org.onap.aai.domain.restResponseInfo;
+
+import javax.xml.bind.annotation.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="responseMessages" minOccurs="0">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="responseMessage" maxOccurs="unbounded" minOccurs="0">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="variables">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {"responseMessages"})
+@XmlRootElement(name = "Info")
+public class Info {
+
+ protected ResponseMessages responseMessages;
+
+ /**
+ * Gets the value of the responseMessages property.
+ *
+ * @return
+ * possible object is
+ * {@link ResponseMessages }
+ *
+ */
+ public ResponseMessages getResponseMessages() {
+ return responseMessages;
+ }
+
+ /**
+ * Sets the value of the responseMessages property.
+ *
+ * @param value
+ * allowed object is
+ * {@link ResponseMessages }
+ *
+ */
+ public void setResponseMessages(ResponseMessages value) {
+ this.responseMessages = value;
+ }
+
+ /**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="responseMessage" maxOccurs="unbounded" minOccurs="0">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="variables">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {"responseMessage"})
+ public static class ResponseMessages {
+
+ protected List<ResponseMessage> responseMessage;
+
+ /**
+ * Gets the value of the responseMessage property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the responseMessage property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ *
+ * <pre>
+ * getResponseMessage().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link ResponseMessage }
+ *
+ * @return the response message
+ */
+ public List<ResponseMessage> getResponseMessage() {
+ if (responseMessage == null) {
+ responseMessage = new ArrayList<ResponseMessage>();
+ }
+ return this.responseMessage;
+ }
+
+ /**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="variables">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {"messageId", "text", "variables"})
+ public static class ResponseMessage {
+
+ @XmlElement(required = true)
+ protected String messageId;
+ @XmlElement(required = true)
+ protected String text;
+ @XmlElement(required = true)
+ protected Variables variables;
+
+ /**
+ * Gets the value of the messageId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMessageId() {
+ return messageId;
+ }
+
+ /**
+ * Sets the value of the messageId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMessageId(String value) {
+ this.messageId = value;
+ }
+
+ /**
+ * Gets the value of the text property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * Sets the value of the text property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setText(String value) {
+ this.text = value;
+ }
+
+ /**
+ * Gets the value of the variables property.
+ *
+ * @return
+ * possible object is
+ * {@link Variables }
+ *
+ */
+ public Variables getVariables() {
+ return variables;
+ }
+
+ /**
+ * Sets the value of the variables property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Variables }
+ *
+ */
+ public void setVariables(Variables value) {
+ this.variables = value;
+ }
+
+ /**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {"variable"})
+ public static class Variables {
+
+ protected List<String> variable;
+
+ /**
+ * Gets the value of the variable property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the variable property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ *
+ * <pre>
+ * getVariable().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ * @return the variable
+ */
+ public List<String> getVariable() {
+ if (variable == null) {
+ variable = new ArrayList<String>();
+ }
+ return this.variable;
+ }
+
+ }
+
+ }
+
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/ObjectFactory.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/ObjectFactory.java
new file mode 100644
index 00000000..4efafb23
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restResponseInfo/ObjectFactory.java
@@ -0,0 +1,93 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2015.10.28 at 05:53:17 PM EDT
+//
+
+package org.onap.aai.domain.restResponseInfo;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.onap.aai.domain.restResponseInfo package.
+ * <p>
+ * An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package:
+ * org.onap.aai.domain.restResponseInfo
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link Info }.
+ *
+ * @return the info
+ */
+ public Info createInfo() {
+ return new Info();
+ }
+
+ /**
+ * Create an instance of {@link Info.ResponseMessages }
+ *
+ * @return the response messages
+ */
+ public Info.ResponseMessages createInfoResponseMessages() {
+ return new Info.ResponseMessages();
+ }
+
+ /**
+ * Create an instance of {@link Info.ResponseMessages.ResponseMessage }
+ *
+ * @return the response message
+ */
+ public Info.ResponseMessages.ResponseMessage createInfoResponseMessagesResponseMessage() {
+ return new Info.ResponseMessages.ResponseMessage();
+ }
+
+ /**
+ * Create an instance of {@link Info.ResponseMessages.ResponseMessage.Variables }
+ *
+ * @return the variables
+ */
+ public Info.ResponseMessages.ResponseMessage.Variables createInfoResponseMessagesResponseMessageVariables() {
+ return new Info.ResponseMessages.ResponseMessage.Variables();
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/Fault.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/Fault.java
new file mode 100644
index 00000000..09558455
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/Fault.java
@@ -0,0 +1,371 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2015.02.11 at 04:54:29 PM EST
+//
+
+package org.onap.aai.domain.restServiceException;
+
+import javax.xml.bind.annotation.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="requestError">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="serviceException">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="variables">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {"requestError"})
+@XmlRootElement(name = "Fault")
+public class Fault {
+
+ @XmlElement(required = true)
+ protected RequestError requestError;
+
+ /**
+ * Gets the value of the requestError property.
+ *
+ * @return
+ * possible object is
+ * {@link RequestError }
+ *
+ */
+ public RequestError getRequestError() {
+ return requestError;
+ }
+
+ /**
+ * Sets the value of the requestError property.
+ *
+ * @param value
+ * allowed object is
+ * {@link RequestError }
+ *
+ */
+ public void setRequestError(RequestError value) {
+ this.requestError = value;
+ }
+
+ /**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="serviceException">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="variables">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {"serviceException"})
+ public static class RequestError {
+
+ @XmlElement(required = true)
+ protected ServiceException serviceException;
+
+ /**
+ * Gets the value of the serviceException property.
+ *
+ * @return
+ * possible object is
+ * {@link ServiceException }
+ *
+ */
+ public ServiceException getServiceException() {
+ return serviceException;
+ }
+
+ /**
+ * Sets the value of the serviceException property.
+ *
+ * @param value
+ * allowed object is
+ * {@link ServiceException }
+ *
+ */
+ public void setServiceException(ServiceException value) {
+ this.serviceException = value;
+ }
+
+ /**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="variables">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {"messageId", "text", "variables"})
+ public static class ServiceException {
+
+ @XmlElement(required = true)
+ protected String messageId;
+ @XmlElement(required = true)
+ protected String text;
+ @XmlElement(required = true)
+ protected Variables variables;
+
+ /**
+ * Gets the value of the messageId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMessageId() {
+ return messageId;
+ }
+
+ /**
+ * Sets the value of the messageId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMessageId(String value) {
+ this.messageId = value;
+ }
+
+ /**
+ * Gets the value of the text property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * Sets the value of the text property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setText(String value) {
+ this.text = value;
+ }
+
+ /**
+ * Gets the value of the variables property.
+ *
+ * @return
+ * possible object is
+ * {@link Variables }
+ *
+ */
+ public Variables getVariables() {
+ return variables;
+ }
+
+ /**
+ * Sets the value of the variables property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Variables }
+ *
+ */
+ public void setVariables(Variables value) {
+ this.variables = value;
+ }
+
+ /**
+ * <p>
+ * Java class for anonymous complex type.
+ *
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="variable" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {"variable"})
+ public static class Variables {
+
+ protected List<String> variable;
+
+ /**
+ * Gets the value of the variable property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the variable property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ *
+ * <pre>
+ * getVariable().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ * @return the variable
+ */
+ public List<String> getVariable() {
+ if (variable == null) {
+ variable = new ArrayList<String>();
+ }
+ return this.variable;
+ }
+
+ }
+
+ }
+
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ObjectFactory.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ObjectFactory.java
new file mode 100644
index 00000000..95eb2cba
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ObjectFactory.java
@@ -0,0 +1,93 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2015.02.11 at 04:54:29 PM EST
+//
+
+package org.onap.aai.domain.restServiceException;
+
+import javax.xml.bind.annotation.XmlRegistry;
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.onap.aai.domain.restServiceException package.
+ * <p>
+ * An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package:
+ * org.onap.aai.domain.restServiceException
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link Fault }.
+ *
+ * @return the fault
+ */
+ public Fault createFault() {
+ return new Fault();
+ }
+
+ /**
+ * Create an instance of {@link Fault.RequestError }
+ *
+ * @return the request error
+ */
+ public Fault.RequestError createFaultRequestError() {
+ return new Fault.RequestError();
+ }
+
+ /**
+ * Create an instance of {@link Fault.RequestError.ServiceException }
+ *
+ * @return the service exception
+ */
+ public Fault.RequestError.ServiceException createFaultRequestErrorServiceException() {
+ return new Fault.RequestError.ServiceException();
+ }
+
+ /**
+ * Create an instance of {@link Fault.RequestError.ServiceException.Variables }
+ *
+ * @return the variables
+ */
+ public Fault.RequestError.ServiceException.Variables createFaultRequestErrorServiceExceptionVariables() {
+ return new Fault.RequestError.ServiceException.Variables();
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RESTResponse.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RESTResponse.java
new file mode 100644
index 00000000..d812c37b
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RESTResponse.java
@@ -0,0 +1,80 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.domain.restServiceException;
+
+import com.fasterxml.jackson.annotation.*;
+
+import javax.annotation.Generated;
+import java.util.HashMap;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({"requestError"})
+public class RESTResponse {
+
+ @JsonProperty("requestError")
+ private RequestError requestError;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * Gets the request error.
+ *
+ * @return The requestError
+ */
+ @JsonProperty("requestError")
+ public RequestError getRequestError() {
+ return requestError;
+ }
+
+ /**
+ * Sets the request error.
+ *
+ * @param requestError The requestError
+ */
+ @JsonProperty("requestError")
+ public void setRequestError(RequestError requestError) {
+ this.requestError = requestError;
+ }
+
+ /**
+ * Gets the additional properties.
+ *
+ * @return the additional properties
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /**
+ * Sets the additional property.
+ *
+ * @param name the name
+ * @param value the value
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RequestError.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RequestError.java
new file mode 100644
index 00000000..79fca83f
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/RequestError.java
@@ -0,0 +1,80 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.domain.restServiceException;
+
+import com.fasterxml.jackson.annotation.*;
+
+import javax.annotation.Generated;
+import java.util.HashMap;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({"serviceException"})
+public class RequestError {
+
+ @JsonProperty("serviceException")
+ private ServiceException serviceException;
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * Gets the service exception.
+ *
+ * @return The serviceException
+ */
+ @JsonProperty("serviceException")
+ public ServiceException getServiceException() {
+ return serviceException;
+ }
+
+ /**
+ * Sets the service exception.
+ *
+ * @param serviceException The serviceException
+ */
+ @JsonProperty("serviceException")
+ public void setServiceException(ServiceException serviceException) {
+ this.serviceException = serviceException;
+ }
+
+ /**
+ * Gets the additional properties.
+ *
+ * @return the additional properties
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /**
+ * Sets the additional property.
+ *
+ * @param name the name
+ * @param value the value
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ServiceException.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ServiceException.java
new file mode 100644
index 00000000..f215bd58
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/restServiceException/ServiceException.java
@@ -0,0 +1,126 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.domain.restServiceException;
+
+import com.fasterxml.jackson.annotation.*;
+
+import javax.annotation.Generated;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({"messageId", "text", "variables"})
+public class ServiceException {
+
+ @JsonProperty("messageId")
+ private String messageId;
+ @JsonProperty("text")
+ private String text;
+ @JsonProperty("variables")
+ private List<String> variables = new ArrayList<String>();
+ @JsonIgnore
+ private Map<String, Object> additionalProperties = new HashMap<String, Object>();
+
+ /**
+ * Gets the message id.
+ *
+ * @return The messageId
+ */
+ @JsonProperty("messageId")
+ public String getMessageId() {
+ return messageId;
+ }
+
+ /**
+ * Sets the message id.
+ *
+ * @param messageId The messageId
+ */
+ @JsonProperty("messageId")
+ public void setMessageId(String messageId) {
+ this.messageId = messageId;
+ }
+
+ /**
+ * Gets the text.
+ *
+ * @return The text
+ */
+ @JsonProperty("text")
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * Sets the text.
+ *
+ * @param text The text
+ */
+ @JsonProperty("text")
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * Gets the variables.
+ *
+ * @return The variables
+ */
+ @JsonProperty("variables")
+ public List<String> getVariables() {
+ return variables;
+ }
+
+ /**
+ * Sets the variables.
+ *
+ * @param variables The variables
+ */
+ @JsonProperty("variables")
+ public void setVariables(List<String> variables) {
+ this.variables = variables;
+ }
+
+ /**
+ * Gets the additional properties.
+ *
+ * @return the additional properties
+ */
+ @JsonAnyGetter
+ public Map<String, Object> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ /**
+ * Sets the additional property.
+ *
+ * @param name the name
+ * @param value the value
+ */
+ @JsonAnySetter
+ public void setAdditionalProperty(String name, Object value) {
+ this.additionalProperties.put(name, value);
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java b/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java
new file mode 100644
index 00000000..24228e83
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java
@@ -0,0 +1,153 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright © 2018 IBM.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.exceptions;
+
+import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.logging.ErrorObject;
+import org.onap.aai.logging.ErrorObjectNotFoundException;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+public class AAIException extends Exception {
+
+ private static final String UPDATE_ERROR_PROPERTIES_BEFORE_USING_THIS_EXCEPTION_CODE =
+ " - update error.properties before using this exception code";
+ private static final String FAILED_TO_INSTANTIATE_AAI_EXCEPTION_WITH_CODE =
+ "Failed to instantiate AAIException with code=";
+ public static final String DEFAULT_EXCEPTION_CODE = "AAI_4000";
+ private static final long serialVersionUID = 1L;
+
+ private final String code;
+ private final ErrorObject errorObject;
+ private final Collection<String> templateVars;
+
+ /**
+ * Instantiates a new AAI exception.
+ */
+ public AAIException() {
+ super();
+ this.code = DEFAULT_EXCEPTION_CODE;
+ this.templateVars = new LinkedList<>();
+
+ try {
+ this.errorObject = ErrorLogHelper.getErrorObject(getCode());
+ } catch (ErrorObjectNotFoundException e) {
+ throw new RuntimeException(FAILED_TO_INSTANTIATE_AAI_EXCEPTION_WITH_CODE + getCode()
+ + UPDATE_ERROR_PROPERTIES_BEFORE_USING_THIS_EXCEPTION_CODE);
+ }
+ }
+
+ /**
+ * Instantiates a new AAI exception.
+ *
+ * @param code the code
+ */
+ public AAIException(String code) {
+ super();
+
+ this.code = code;
+ this.templateVars = new LinkedList<>();
+
+ try {
+ this.errorObject = ErrorLogHelper.getErrorObject(getCode());
+ } catch (ErrorObjectNotFoundException e) {
+ throw new RuntimeException(FAILED_TO_INSTANTIATE_AAI_EXCEPTION_WITH_CODE + getCode()
+ + UPDATE_ERROR_PROPERTIES_BEFORE_USING_THIS_EXCEPTION_CODE);
+ }
+ }
+
+ /**
+ * Instantiates a new AAI exception.
+ *
+ * @param code the code
+ * @param details the details
+ */
+ public AAIException(String code, String details) {
+ super(details);
+
+ this.code = code;
+ this.templateVars = new LinkedList<>();
+
+ try {
+ this.errorObject = ErrorLogHelper.getErrorObject(getCode());
+ errorObject.setDetails(details);
+ } catch (ErrorObjectNotFoundException e) {
+ throw new RuntimeException(FAILED_TO_INSTANTIATE_AAI_EXCEPTION_WITH_CODE + getCode()
+ + UPDATE_ERROR_PROPERTIES_BEFORE_USING_THIS_EXCEPTION_CODE);
+ }
+ }
+
+ /**
+ * Instantiates a new AAI exception.
+ *
+ * @param code the code
+ * @param cause the cause
+ */
+ public AAIException(String code, Throwable cause) {
+ super(cause);
+
+ this.code = code;
+ this.templateVars = new LinkedList<>();
+
+ try {
+ this.errorObject = ErrorLogHelper.getErrorObject(getCode());
+ } catch (ErrorObjectNotFoundException e) {
+ throw new RuntimeException(FAILED_TO_INSTANTIATE_AAI_EXCEPTION_WITH_CODE + getCode()
+ + UPDATE_ERROR_PROPERTIES_BEFORE_USING_THIS_EXCEPTION_CODE);
+ }
+ }
+
+ /**
+ * Instantiates a new AAI exception.
+ *
+ * @param code the code
+ * @param cause the cause
+ * @param details the details
+ */
+ public AAIException(String code, Throwable cause, String details) {
+ super(details, cause);
+
+ this.code = code;
+ this.templateVars = new LinkedList<>();
+
+ try {
+ this.errorObject = ErrorLogHelper.getErrorObject(getCode());
+ } catch (ErrorObjectNotFoundException e) {
+ throw new RuntimeException(FAILED_TO_INSTANTIATE_AAI_EXCEPTION_WITH_CODE + getCode()
+ + UPDATE_ERROR_PROPERTIES_BEFORE_USING_THIS_EXCEPTION_CODE);
+ }
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public ErrorObject getErrorObject() {
+ return errorObject;
+ }
+
+ public Collection<String> getTemplateVars() {
+ return templateVars;
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIExceptionWithInfo.java b/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIExceptionWithInfo.java
new file mode 100644
index 00000000..e7f2901e
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIExceptionWithInfo.java
@@ -0,0 +1,135 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.exceptions;
+
+import java.util.HashMap;
+
+public class AAIExceptionWithInfo extends AAIException {
+
+ HashMap<String, Object> infoHash;
+ String info;
+
+ /**
+ * Instantiates a new AAI exception with info.
+ *
+ * @param infoHash the info hash
+ * @param info the info
+ */
+ public AAIExceptionWithInfo(HashMap<String, Object> infoHash, String info) {
+ super();
+ setInfoHash(infoHash);
+ setInfo(info);
+ }
+
+ /**
+ * Instantiates a new AAI exception with info.
+ *
+ * @param code the code
+ * @param infoHash the info hash
+ * @param info the info
+ */
+ public AAIExceptionWithInfo(String code, HashMap<String, Object> infoHash, String info) {
+ super(code);
+ setInfoHash(infoHash);
+ setInfo(info);
+ }
+
+ /**
+ * Instantiates a new AAI exception with info.
+ *
+ * @param code the code
+ * @param details the details
+ * @param infoHash the info hash
+ * @param info the info
+ */
+ public AAIExceptionWithInfo(String code, String details, HashMap<String, Object> infoHash, String info) {
+ super(code, details);
+ setInfoHash(infoHash);
+ setInfo(info);
+ }
+
+ /**
+ * Instantiates a new AAI exception with info.
+ *
+ * @param code the code
+ * @param cause the cause
+ * @param infoHash the info hash
+ * @param info the info
+ */
+ public AAIExceptionWithInfo(String code, Throwable cause, HashMap<String, Object> infoHash, String info) {
+ super(code, cause);
+ setInfoHash(infoHash);
+ setInfo(info);
+ }
+
+ /**
+ * Instantiates a new AAI exception with info.
+ *
+ * @param code the code
+ * @param cause the cause
+ * @param details the details
+ * @param infoHash the info hash
+ * @param info the info
+ */
+ public AAIExceptionWithInfo(String code, Throwable cause, String details, HashMap<String, Object> infoHash,
+ String info) {
+ super(code, cause, details);
+ setInfoHash(infoHash);
+ setInfo(info);
+ }
+
+ /**
+ * Gets the info hash.
+ *
+ * @return the info hash
+ */
+ public HashMap<String, Object> getInfoHash() {
+ return infoHash;
+ }
+
+ /**
+ * Sets the info hash.
+ *
+ * @param infoHash the info hash
+ */
+ public void setInfoHash(HashMap<String, Object> infoHash) {
+ this.infoHash = infoHash;
+ }
+
+ /**
+ * Gets the info.
+ *
+ * @return the info
+ */
+ public String getInfo() {
+ return info;
+ }
+
+ /**
+ * Sets the info.
+ *
+ * @param info the new info
+ */
+ public void setInfo(String info) {
+ this.info = info;
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/AaiElsErrorCode.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/AaiElsErrorCode.java
new file mode 100644
index 00000000..769103ba
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/AaiElsErrorCode.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+public class AaiElsErrorCode {
+ public static final String SUCCESS = "0";
+ public static final String PERMISSION_ERROR = "100";
+ public static final String AVAILABILITY_TIMEOUT_ERROR = "200";
+ public static final String DATA_ERROR = "300";
+ public static final String SCHEMA_ERROR = "400";
+ public static final String BUSINESS_PROCESS_ERROR = "500";
+ public static final String UNKNOWN_ERROR = "900";
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CNName.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CNName.java
new file mode 100644
index 00000000..10e4782e
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CNName.java
@@ -0,0 +1,97 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+import ch.qos.logback.access.pattern.AccessConverter;
+import ch.qos.logback.access.spi.IAccessEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.security.auth.x500.X500Principal;
+import javax.servlet.http.HttpServletRequest;
+import java.security.cert.X509Certificate;
+
+import static java.util.Base64.getDecoder;
+
+public class CNName extends AccessConverter {
+ protected static final Logger LOGGER = LoggerFactory.getLogger(CNName.class);
+
+ /**
+ * Converts access events to String response codes
+ *
+ * @param accessEvent the IAccessEvent
+ */
+ public String convert(IAccessEvent accessEvent) {
+ if (!isStarted()) {
+ return "INACTIVE_HEADER_CONV";
+ }
+
+ String cipherSuite = (String) accessEvent.getRequest().getAttribute("javax.servlet.request.cipher_suite");
+ String authUser = null;
+ if (cipherSuite != null) {
+ try {
+ X509Certificate certChain[] = (X509Certificate[]) accessEvent.getRequest()
+ .getAttribute("javax.servlet.request.X509Certificate");
+ if (certChain == null || certChain.length == 0) {
+
+ HttpServletRequest request = accessEvent.getRequest();
+
+ String authorization = request.getHeader("Authorization");
+
+ // Set the auth user to "-" so if the authorization header is not found
+ // Or if the decoded basic auth credentials are not found in the format required
+ // it should return "-"
+ // If the decoded string is in the right format, find the index of ":"
+ // Then get the substring of the starting point to the colon not including the colon
+
+ authUser = "-";
+
+ if (authorization != null && authorization.startsWith("Basic ")) {
+ String credentials = authorization.replace("Basic ", "");
+ byte[] userCredentials = getDecoder().decode(credentials.getBytes("utf-8"));
+ credentials = new String(userCredentials);
+
+ int codePoint = credentials.indexOf(':');
+
+ if (codePoint != -1) {
+ authUser = credentials.substring(0, codePoint);
+ }
+
+ }
+
+ return authUser;
+
+ } else {
+ X509Certificate clientCert = certChain[0];
+ X500Principal subjectDN = clientCert.getSubjectX500Principal();
+ authUser = subjectDN.toString();
+ return authUser;
+ }
+ } catch (Exception e) {
+ LOGGER.error(e.getMessage(), e);
+ return "-";
+ }
+ } else {
+ return "-";
+ }
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CustomLogPatternLayout.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CustomLogPatternLayout.java
new file mode 100644
index 00000000..63cc49f7
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CustomLogPatternLayout.java
@@ -0,0 +1,28 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+public class CustomLogPatternLayout extends ch.qos.logback.access.PatternLayout {
+ static {
+ defaultConverterMap.put("z", CNName.class.getName());
+ defaultConverterMap.put("y", DME2RestFlag.class.getName());
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CustomLogPatternLayoutEncoder.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CustomLogPatternLayoutEncoder.java
new file mode 100644
index 00000000..010d828b
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/CustomLogPatternLayoutEncoder.java
@@ -0,0 +1,40 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+import ch.qos.logback.access.PatternLayout;
+
+public class CustomLogPatternLayoutEncoder extends ch.qos.logback.access.PatternLayoutEncoder {
+
+ /**
+ * @{inheritDoc}
+ */
+ @Override
+ public void start() {
+ PatternLayout patternLayout = new CustomLogPatternLayout();
+ patternLayout.setContext(context);
+ patternLayout.setPattern(getPattern());
+ patternLayout.start();
+ this.layout = patternLayout;
+ super.start();
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/DME2RestFlag.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/DME2RestFlag.java
new file mode 100644
index 00000000..768c095b
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/DME2RestFlag.java
@@ -0,0 +1,55 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+import ch.qos.logback.access.pattern.AccessConverter;
+import ch.qos.logback.access.spi.IAccessEvent;
+
+public class DME2RestFlag extends AccessConverter {
+
+ /**
+ * @{inheritDoc}
+ */
+ @Override
+ public String convert(IAccessEvent accessEvent) {
+ if (!isStarted()) {
+ return "INACTIVE_HEADER_CONV";
+ }
+
+ String flag = "-";
+
+ if (accessEvent.getRequestParameter("envContext").length > 0
+ && !accessEvent.getRequestParameter("envContext")[0].isEmpty()
+ && !accessEvent.getRequestParameter("envContext")[0].equals("-")
+ && accessEvent.getRequestParameter("routeOffer").length > 0
+ && !accessEvent.getRequestParameter("routeOffer")[0].isEmpty()
+ && !accessEvent.getRequestParameter("routeOffer")[0].equals("-")
+ && accessEvent.getRequestParameter("version").length > 0
+ && !accessEvent.getRequestParameter("version")[0].isEmpty()
+ && !accessEvent.getRequestParameter("version")[0].equals("-")) {
+ flag = "DME2";
+ } else {
+ flag = "REST";
+ }
+
+ return flag;
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorLogHelper.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorLogHelper.java
new file mode 100644
index 00000000..4ef2a237
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorLogHelper.java
@@ -0,0 +1,618 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+import org.apache.commons.lang.StringUtils;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.util.AAIConstants;
+import org.onap.aai.util.MapperUtil;
+import org.onap.logging.filter.base.Constants;
+import org.onap.logging.filter.base.MDCSetup;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+import javax.ws.rs.core.MediaType;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.*;
+import java.util.Map.Entry;
+
+/**
+ *
+ * This classes loads the application error properties file
+ * and provides a method that returns an ErrorObject
+ *
+ */
+
+public class ErrorLogHelper {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ErrorLogHelper.class);
+ private static final HashMap<String, ErrorObject> ERROR_OBJECTS = new HashMap<String, ErrorObject>();
+
+ static {
+ try {
+ loadProperties();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load error.properties file", e);
+ } catch (ErrorObjectFormatException e) {
+ throw new RuntimeException("Failed to parse error.properties file", e);
+ }
+ }
+
+ /**
+ * Load properties.
+ * @throws IOException the exception
+ * @throws ErrorObjectFormatException
+ */
+ public static void loadProperties() throws IOException, ErrorObjectFormatException {
+ final String filePath = AAIConstants.AAI_HOME_ETC_APP_PROPERTIES + "error.properties";
+ final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("error.properties");
+ final Properties properties = new Properties();
+
+ try (final FileInputStream fis = new FileInputStream(filePath)) {
+ LOGGER.info("Found the error.properties in the following location: {}", AAIConstants.AAI_HOME_ETC_APP_PROPERTIES);
+ properties.load(fis);
+ } catch(Exception ex){
+ LOGGER.info("Unable to find the error.properties from filesystem so using file in jar");
+ if (is != null) {
+ properties.load(is);
+ } else {
+ LOGGER.error("Expected to find the error.properties in the jar but unable to find it");
+ }
+ }
+
+ for (Entry<Object, Object> entry : properties.entrySet()) {
+ final String key = (String) entry.getKey();
+ final String value = (String) entry.getValue();
+ final String[] errorProperties = value.split(":");
+
+ if (errorProperties.length < 7)
+ throw new ErrorObjectFormatException();
+
+ final ErrorObject errorObject = new ErrorObject();
+
+ errorObject.setDisposition(errorProperties[0].trim());
+ errorObject.setCategory(errorProperties[1].trim());
+ errorObject.setSeverity(errorProperties[2].trim());
+ errorObject.setErrorCode(errorProperties[3].trim());
+ errorObject.setHTTPResponseCode(errorProperties[4].trim());
+ errorObject.setRESTErrorCode(errorProperties[5].trim());
+ errorObject.setErrorText(errorProperties[6].trim());
+ if (errorProperties.length > 7) {
+ errorObject.setAaiElsErrorCode(errorProperties[7].trim());
+ }
+
+ ERROR_OBJECTS.put(key, errorObject);
+ }
+ }
+
+ /**
+ * Logs a known A&AI exception (i.e. one that can be found in error.properties)
+ *
+ * @param code for the error in the error.properties file
+ * @throws IOException
+ * @throws ErrorObjectNotFoundException
+ */
+ public static ErrorObject getErrorObject(String code) throws ErrorObjectNotFoundException {
+
+ if (code == null)
+ throw new IllegalArgumentException("Key cannot be null");
+
+ final ErrorObject errorObject = ERROR_OBJECTS.get(code);
+
+ if (errorObject == null) {
+ LOGGER.warn("Unknown AAIException with code=" + code + ". Using default AAIException");
+ return ERROR_OBJECTS.get(AAIException.DEFAULT_EXCEPTION_CODE);
+ }
+
+ return errorObject;
+ }
+
+ /**
+ * Determines whether category is policy or not. If policy (1), this is a POL error, else it's a SVC error.
+ * The AAIRESTException may contain a different ErrorObject than that created with the REST error key.
+ * This allows lower level exception detail to be returned to the client to help troubleshoot the problem.
+ * If no error object is embedded in the AAIException, one will be created using the error object from the
+ * AAIException.
+ *
+ * @param are must have a restError value whose numeric value must match what should be returned in the REST API
+ * @param variables optional list of variables to flesh out text in error string
+ * @return appropriately formatted JSON response per the REST API spec.
+ * @throws IOException
+ * @deprecated
+ */
+ public static String getRESTAPIErrorResponse(AAIException are, ArrayList<String> variables) {
+ List<MediaType> acceptHeaders = new ArrayList<MediaType>();
+ acceptHeaders.add(MediaType.APPLICATION_JSON_TYPE);
+
+ return getRESTAPIErrorResponse(acceptHeaders, are, variables);
+ }
+
+ /**
+ * Determines whether category is policy or not. If policy (1), this is a POL error, else it's a SVC error.
+ * The AAIRESTException may contain a different ErrorObject than that created with the REST error key.
+ * This allows lower level exception detail to be returned to the client to help troubleshoot the problem.
+ * If no error object is embedded in the AAIException, one will be created using the error object from the
+ * AAIException.
+ *
+ * @param acceptHeadersOrig the accept headers orig
+ * @param are must have a restError value whose numeric value must match what should be returned in the REST API
+ * @param variables optional list of variables to flesh out text in error string
+ * @return appropriately formatted JSON response per the REST API spec.
+ */
+ public static String getRESTAPIErrorResponse(List<MediaType> acceptHeadersOrig, AAIException are,
+ ArrayList<String> variables) {
+
+ StringBuilder text = new StringBuilder();
+ String response = null;
+
+ List<MediaType> acceptHeaders = new ArrayList<MediaType>();
+ // we might have an exception but no accept header, so we'll set default to JSON
+ boolean foundValidAcceptHeader = false;
+ for (MediaType mt : acceptHeadersOrig) {
+ if (MediaType.APPLICATION_XML_TYPE.isCompatible(mt) || MediaType.APPLICATION_JSON_TYPE.isCompatible(mt)) {
+ acceptHeaders.add(mt);
+ foundValidAcceptHeader = true;
+ }
+ }
+ if (foundValidAcceptHeader == false) {
+ // override the exception, client needs to set an appropriate Accept header
+ are = new AAIException("AAI_4014");
+ acceptHeaders.add(MediaType.APPLICATION_JSON_TYPE);
+ }
+
+ final ErrorObject eo = are.getErrorObject();
+
+ int restErrorCode = Integer.parseInt(eo.getRESTErrorCode());
+
+ ErrorObject restErrorObject;
+
+ try {
+ restErrorObject = ErrorLogHelper.getErrorObject("AAI_" + restErrorCode);
+ } catch (ErrorObjectNotFoundException e) {
+ LOGGER.warn("Failed to find related error object AAI_" + restErrorCode + " for error object "
+ + eo.getErrorCode() + "; using AAI_" + restErrorCode);
+ restErrorObject = eo;
+ }
+
+ text.append(restErrorObject.getErrorText());
+
+ // We want to always append the (msg=%n) (ec=%n+1) to the text, but have to find value of n
+ // This assumes that the variables in the ArrayList, which might be more than are needed to flesh out the
+ // error, are ordered based on the error string.
+ int localDataIndex = StringUtils.countMatches(restErrorObject.getErrorText(), "%");
+ text.append(" (msg=%").append(localDataIndex + 1).append(") (ec=%").append(localDataIndex + 2).append(")");
+
+ if (variables == null) {
+ variables = new ArrayList<String>();
+ }
+
+ if (variables.size() < localDataIndex) {
+ ErrorLogHelper.logError("AAI_4011", "data missing for rest error");
+ while (variables.size() < localDataIndex) {
+ variables.add("null");
+ }
+ }
+
+ // This will put the error code and error text into the right positions
+ if (are.getMessage() == null || are.getMessage().length() == 0) {
+ variables.add(localDataIndex++, eo.getErrorText());
+ } else {
+ variables.add(localDataIndex++, eo.getErrorText() + ":" + are.getMessage());
+ }
+ variables.add(localDataIndex, eo.getErrorCodeString());
+
+ for (MediaType mediaType : acceptHeaders) {
+ if (MediaType.APPLICATION_XML_TYPE.isCompatible(mediaType)) {
+ JAXBContext context = null;
+ try {
+ if (eo.getCategory().equals("1")) {
+
+ context = JAXBContext.newInstance(org.onap.aai.domain.restPolicyException.Fault.class);
+ Marshaller m = context.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+
+ org.onap.aai.domain.restPolicyException.ObjectFactory factory =
+ new org.onap.aai.domain.restPolicyException.ObjectFactory();
+ org.onap.aai.domain.restPolicyException.Fault fault = factory.createFault();
+ org.onap.aai.domain.restPolicyException.Fault.RequestError requestError =
+ factory.createFaultRequestError();
+ org.onap.aai.domain.restPolicyException.Fault.RequestError.PolicyException policyException =
+ factory.createFaultRequestErrorPolicyException();
+ org.onap.aai.domain.restPolicyException.Fault.RequestError.PolicyException.Variables polvariables =
+ factory.createFaultRequestErrorPolicyExceptionVariables();
+
+ policyException.setMessageId("POL" + eo.getRESTErrorCode());
+ policyException.setText(text.toString());
+ for (int i = 0; i < variables.size(); i++) {
+ polvariables.getVariable().add(variables.get(i));
+ }
+ policyException.setVariables(polvariables);
+ requestError.setPolicyException(policyException);
+ fault.setRequestError(requestError);
+
+ StringWriter sw = new StringWriter();
+ m.marshal(fault, sw);
+
+ response = sw.toString();
+
+ } else {
+
+ context = JAXBContext.newInstance(org.onap.aai.domain.restServiceException.Fault.class);
+ Marshaller m = context.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+
+ org.onap.aai.domain.restServiceException.ObjectFactory factory =
+ new org.onap.aai.domain.restServiceException.ObjectFactory();
+ org.onap.aai.domain.restServiceException.Fault fault = factory.createFault();
+ org.onap.aai.domain.restServiceException.Fault.RequestError requestError =
+ factory.createFaultRequestError();
+ org.onap.aai.domain.restServiceException.Fault.RequestError.ServiceException serviceException =
+ factory.createFaultRequestErrorServiceException();
+ org.onap.aai.domain.restServiceException.Fault.RequestError.ServiceException.Variables svcvariables =
+ factory.createFaultRequestErrorServiceExceptionVariables();
+ serviceException.setMessageId("SVC" + eo.getRESTErrorCode());
+ serviceException.setText(text.toString());
+ for (int i = 0; i < variables.size(); i++) {
+ svcvariables.getVariable().add(variables.get(i));
+ }
+ serviceException.setVariables(svcvariables);
+ requestError.setServiceException(serviceException);
+ fault.setRequestError(requestError);
+
+ StringWriter sw = new StringWriter();
+ m.marshal(fault, sw);
+
+ response = sw.toString();
+
+ }
+ } catch (Exception ex) {
+ LOGGER.error(
+ "We were unable to create a rest exception to return on an API because of a parsing error "
+ + ex.getMessage());
+ }
+ } else {
+ try {
+ if (eo.getCategory().equals("1")) {
+ org.onap.aai.domain.restPolicyException.RESTResponse restresp =
+ new org.onap.aai.domain.restPolicyException.RESTResponse();
+ org.onap.aai.domain.restPolicyException.RequestError reqerr =
+ new org.onap.aai.domain.restPolicyException.RequestError();
+ org.onap.aai.domain.restPolicyException.PolicyException polexc =
+ new org.onap.aai.domain.restPolicyException.PolicyException();
+ polexc.setMessageId("POL" + eo.getRESTErrorCode());
+ polexc.setText(text.toString());
+ polexc.setVariables(variables);
+ reqerr.setPolicyException(polexc);
+ restresp.setRequestError(reqerr);
+ response = (MapperUtil.writeAsJSONString((Object) restresp));
+
+ } else {
+ org.onap.aai.domain.restServiceException.RESTResponse restresp =
+ new org.onap.aai.domain.restServiceException.RESTResponse();
+ org.onap.aai.domain.restServiceException.RequestError reqerr =
+ new org.onap.aai.domain.restServiceException.RequestError();
+ org.onap.aai.domain.restServiceException.ServiceException svcexc =
+ new org.onap.aai.domain.restServiceException.ServiceException();
+ svcexc.setMessageId("SVC" + eo.getRESTErrorCode());
+ svcexc.setText(text.toString());
+ svcexc.setVariables(variables);
+ reqerr.setServiceException(svcexc);
+ restresp.setRequestError(reqerr);
+ response = (MapperUtil.writeAsJSONString((Object) restresp));
+ }
+ } catch (Exception ex) {
+ LOGGER.error(
+ "We were unable to create a rest exception to return on an API because of a parsing error "
+ + ex.getMessage());
+ }
+ }
+ }
+
+ return response;
+ }
+
+ /**
+ * Gets the RESTAPI error response with logging.
+ *
+ * @param acceptHeadersOrig the accept headers orig
+ * @param are the are
+ * @param variables the variables
+ */
+ public static String getRESTAPIErrorResponseWithLogging(List<MediaType> acceptHeadersOrig, AAIException are,
+ ArrayList<String> variables) {
+ String response = ErrorLogHelper.getRESTAPIErrorResponse(acceptHeadersOrig, are, variables);
+ logException(are);
+ return response;
+ }
+
+ /**
+ * Gets the RESTAPI info response.
+ *
+ * @param acceptHeaders the accept headers
+ * @param areList the are list
+ * @return the RESTAPI info response
+ */
+ public static Object getRESTAPIInfoResponse(List<MediaType> acceptHeaders,
+ HashMap<AAIException, ArrayList<String>> areList) {
+
+ Object respObj = null;
+
+ org.onap.aai.domain.restResponseInfo.ObjectFactory factory =
+ new org.onap.aai.domain.restResponseInfo.ObjectFactory();
+ org.onap.aai.domain.restResponseInfo.Info info = factory.createInfo();
+ org.onap.aai.domain.restResponseInfo.Info.ResponseMessages responseMessages =
+ factory.createInfoResponseMessages();
+ Iterator<Entry<AAIException, ArrayList<String>>> it = areList.entrySet().iterator();
+
+ while (it.hasNext()) {
+ Entry<AAIException, ArrayList<String>> pair = (Entry<AAIException, ArrayList<String>>) it.next();
+ AAIException are = pair.getKey();
+ ArrayList<String> variables = pair.getValue();
+
+ StringBuilder text = new StringBuilder();
+
+ ErrorObject eo = are.getErrorObject();
+
+ int restErrorCode = Integer.parseInt(eo.getRESTErrorCode());
+ ErrorObject restErrorObject;
+ try {
+ restErrorObject = ErrorLogHelper.getErrorObject("AAI_" + String.format("%04d", restErrorCode));
+ } catch (ErrorObjectNotFoundException e) {
+ restErrorObject = eo;
+ }
+ text.append(restErrorObject.getErrorText());
+
+ // We want to always append the (msg=%n) (ec=%n+1) to the text, but have to find value of n
+ // This assumes that the variables in the ArrayList, which might be more than are needed to flesh out the
+ // error, are ordered based on the error string.
+ int localDataIndex = StringUtils.countMatches(restErrorObject.getErrorText(), "%");
+ text.append(" (msg=%").append(localDataIndex + 1).append(") (rc=%").append(localDataIndex + 2).append(")");
+
+ if (variables == null) {
+ variables = new ArrayList<String>();
+ }
+
+ if (variables.size() < localDataIndex) {
+ ErrorLogHelper.logError("AAI_4011", "data missing for rest error");
+ while (variables.size() < localDataIndex) {
+ variables.add("null");
+ }
+ }
+
+ // This will put the error code and error text into the right positions
+ if (are.getMessage() == null) {
+ variables.add(localDataIndex++, eo.getErrorText());
+ } else {
+ variables.add(localDataIndex++, eo.getErrorText() + ":" + are.getMessage());
+ }
+ variables.add(localDataIndex, eo.getErrorCodeString());
+
+ try {
+ org.onap.aai.domain.restResponseInfo.Info.ResponseMessages.ResponseMessage responseMessage =
+ factory.createInfoResponseMessagesResponseMessage();
+ org.onap.aai.domain.restResponseInfo.Info.ResponseMessages.ResponseMessage.Variables infovariables =
+ factory.createInfoResponseMessagesResponseMessageVariables();
+
+ responseMessage.setMessageId("INF" + eo.getRESTErrorCode());
+ responseMessage.setText(text.toString());
+ for (int i = 0; i < variables.size(); i++) {
+ infovariables.getVariable().add(variables.get(i));
+ }
+
+ responseMessage.setVariables(infovariables);
+ responseMessages.getResponseMessage().add(responseMessage);
+
+ } catch (Exception ex) {
+ LOGGER.error("We were unable to create a rest exception to return on an API because of a parsing error "
+ + ex.getMessage());
+ }
+ }
+
+ info.setResponseMessages(responseMessages);
+ respObj = (Object) info;
+
+ return respObj;
+ }
+
+ /**
+ * Determines whether category is policy or not. If policy (1), this is a POL error, else it's a SVC error.
+ * The AAIRESTException may contain a different ErrorObject than that created with the REST error key.
+ * This allows lower level exception detail to be returned to the client to help troubleshoot the problem.
+ * If no error object is embedded in the AAIException, one will be created using the error object from the
+ * AAIException.
+ *
+ * @param are must have a restError value whose numeric value must match what should be returned in the REST API
+ * @param variables optional list of variables to flesh out text in error string
+ * @return appropriately formatted JSON response per the REST API spec.
+ */
+ public static String getRESTAPIPolicyErrorResponseXML(AAIException are, ArrayList<String> variables) {
+
+ StringBuilder text = new StringBuilder();
+ String response = null;
+ JAXBContext context = null;
+
+ ErrorObject eo = are.getErrorObject();
+
+ int restErrorCode = Integer.parseInt(eo.getRESTErrorCode());
+ ErrorObject restErrorObject;
+ try {
+ restErrorObject = ErrorLogHelper.getErrorObject("AAI_" + restErrorCode);
+ } catch (ErrorObjectNotFoundException e) {
+ restErrorObject = eo;
+ }
+
+ text.append(restErrorObject.getErrorText());
+
+ // We want to always append the (msg=%n) (ec=%n+1) to the text, but have to find value of n
+ // This assumes that the variables in the ArrayList, which might be more than are needed to flesh out the
+ // error, are ordered based on the error string.
+ int localDataIndex = StringUtils.countMatches(restErrorObject.getErrorText(), "%");
+ text.append(" (msg=%").append(localDataIndex + 1).append(") (ec=%").append(localDataIndex + 2).append(")");
+
+ if (variables == null) {
+ variables = new ArrayList<String>();
+ }
+
+ if (variables.size() < localDataIndex) {
+ ErrorLogHelper.logError("AAI_4011", "data missing for rest error");
+ while (variables.size() < localDataIndex) {
+ variables.add("null");
+ }
+ }
+
+ // This will put the error code and error text into the right positions
+ if (are.getMessage() == null) {
+ variables.add(localDataIndex++, eo.getErrorText());
+ } else {
+ variables.add(localDataIndex++, eo.getErrorText() + ":" + are.getMessage());
+ }
+ variables.add(localDataIndex, eo.getErrorCodeString());
+
+ try {
+ if (eo.getCategory().equals("1")) {
+
+ context = JAXBContext.newInstance(org.onap.aai.domain.restPolicyException.Fault.class);
+ Marshaller m = context.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+
+ org.onap.aai.domain.restPolicyException.ObjectFactory factory =
+ new org.onap.aai.domain.restPolicyException.ObjectFactory();
+ org.onap.aai.domain.restPolicyException.Fault fault = factory.createFault();
+ org.onap.aai.domain.restPolicyException.Fault.RequestError requestError =
+ factory.createFaultRequestError();
+ org.onap.aai.domain.restPolicyException.Fault.RequestError.PolicyException policyException =
+ factory.createFaultRequestErrorPolicyException();
+ org.onap.aai.domain.restPolicyException.Fault.RequestError.PolicyException.Variables polvariables =
+ factory.createFaultRequestErrorPolicyExceptionVariables();
+
+ policyException.setMessageId("POL" + eo.getRESTErrorCode());
+ policyException.setText(text.toString());
+ for (int i = 0; i < variables.size(); i++) {
+ polvariables.getVariable().add(variables.get(i));
+ }
+ policyException.setVariables(polvariables);
+ requestError.setPolicyException(policyException);
+ fault.setRequestError(requestError);
+
+ StringWriter sw = new StringWriter();
+ m.marshal(fault, sw);
+
+ response = sw.toString();
+
+ } else {
+
+ context = JAXBContext.newInstance(org.onap.aai.domain.restServiceException.Fault.class);
+ Marshaller m = context.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+
+ org.onap.aai.domain.restServiceException.ObjectFactory factory =
+ new org.onap.aai.domain.restServiceException.ObjectFactory();
+ org.onap.aai.domain.restServiceException.Fault fault = factory.createFault();
+ org.onap.aai.domain.restServiceException.Fault.RequestError requestError =
+ factory.createFaultRequestError();
+ org.onap.aai.domain.restServiceException.Fault.RequestError.ServiceException serviceException =
+ factory.createFaultRequestErrorServiceException();
+ org.onap.aai.domain.restServiceException.Fault.RequestError.ServiceException.Variables svcvariables =
+ factory.createFaultRequestErrorServiceExceptionVariables();
+ serviceException.setMessageId("POL" + eo.getRESTErrorCode());
+ serviceException.setText(text.toString());
+ for (int i = 0; i < variables.size(); i++) {
+ svcvariables.getVariable().add(variables.get(i));
+ }
+ serviceException.setVariables(svcvariables);
+ requestError.setServiceException(serviceException);
+ fault.setRequestError(requestError);
+
+ StringWriter sw = new StringWriter();
+ m.marshal(fault, sw);
+
+ response = sw.toString();
+
+ }
+ } catch (Exception ex) {
+ LOGGER.error("We were unable to create a rest exception to return on an API because of a parsing error "
+ + ex.getMessage());
+ }
+ return response;
+ }
+
+ public static void logException(AAIException e) {
+ final ErrorObject errorObject = e.getErrorObject();
+ /*
+ String severityCode = errorObject.getSeverityCode(errorObject.getSeverity());
+
+ Severify should be left empty per Logging Specification 2019.11
+ if (!StringUtils.isEmpty(severityCode)) {
+ int sevCode = Integer.parseInt(severityCode);
+ if (sevCode > 0 && sevCode <= 3) {
+ LoggingContext.severity(sevCode);
+ }
+ }
+ */
+ String stackTrace = "";
+ try {
+ stackTrace = LogFormatTools.getStackTop(e);
+ } catch (Exception a) {
+ // ignore
+ }
+ final String errorMessage = new StringBuilder().append(errorObject.getErrorText()).append(":")
+ .append(errorObject.getRESTErrorCode()).append(":").append(errorObject.getHTTPResponseCode())
+ .append(":").append(e.getMessage()).toString().replaceAll("\\n", "^");
+
+ MDCSetup mdcSetup = new MDCSetup();
+ mdcSetup.setResponseStatusCode(errorObject.getHTTPResponseCode().getStatusCode());
+ mdcSetup.setErrorCode(Integer.parseInt(errorObject.getAaiElsErrorCode()));
+ String serviceName = MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME);
+ if (serviceName == null || serviceName.isEmpty()) {
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, Constants.DefaultValues.UNKNOWN);
+ }
+ MDC.put(ONAPLogConstants.MDCs.ERROR_DESC, errorMessage);
+ final String details =
+ new StringBuilder().append(errorObject.getErrorCodeString()).append(" ").append(stackTrace).toString();
+
+ if (errorObject.getSeverity().equalsIgnoreCase("WARN"))
+ LOGGER.warn(details);
+ else if (errorObject.getSeverity().equalsIgnoreCase("ERROR"))
+ LOGGER.error(details);
+ else if (errorObject.getSeverity().equalsIgnoreCase("FATAL"))
+ LOGGER.error(details);
+ else if (errorObject.getSeverity().equals("INFO"))
+ LOGGER.info(details);
+ }
+
+ public static void logError(String code) {
+ logError(code, "");
+ }
+
+ public static void logError(String code, String message) {
+ logException(new AAIException(code, message));
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObject.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObject.java
new file mode 100644
index 00000000..2e849d25
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObject.java
@@ -0,0 +1,377 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+import javax.ws.rs.core.Response.Status;
+
+/**
+ *
+ * Contains the definition of all error message fields to be mapped from the Error
+ * properties file
+ *
+ */
+public class ErrorObject {
+
+ private String disposition;
+ private String category;
+ private String severity;
+ private Status httpResponseCode = Status.INTERNAL_SERVER_ERROR; // default
+ private String restErrorCode = "3002";
+ private String errorCode;
+ private String errorText;
+ private String details;
+ private String aaiElsErrorCode = AaiElsErrorCode.UNKNOWN_ERROR;
+
+ /**
+ * Instantiates a new error object.
+ */
+ public ErrorObject() {
+ super();
+ }
+
+ /**
+ * Creates an error object
+ *
+ * @param disposition the disposition
+ * @param category the category
+ * @param severity the severity
+ * @param httpResponseCode the http response code
+ * @param restErrorCode the rest error code
+ * @param errorCode the error code
+ * @param errorText the error text
+ */
+ public ErrorObject(String disposition, String category, String severity, Integer httpResponseCode,
+ String restErrorCode, String errorCode, String errorText) {
+ super();
+ this.setDisposition(disposition);
+ this.setCategory(category);
+ this.severity = severity;
+ this.setHTTPResponseCode(httpResponseCode);
+ this.setRESTErrorCode(restErrorCode);
+ this.setErrorCode(errorCode);
+ this.setErrorText(errorText);
+ this.setAaiElsErrorCode(AaiElsErrorCode.UNKNOWN_ERROR);
+ }
+
+ // OLD STARTS HERE
+
+ /**
+ * Instantiates a new error object.
+ * @param severity the severity
+ * @param errorCode the error code
+ * @param errorText the error text
+ * @param disposition the disposition
+ * @param category the category
+ */
+ public ErrorObject(String severity, String errorCode, String errorText, String disposition, String category) {
+ this(severity, Status.INTERNAL_SERVER_ERROR, errorCode, errorText, disposition, category);
+ }
+
+ /**
+ * Instantiates a new error object.
+ *
+ * @param severity the severity
+ * @param httpResponseCode the http response code
+ * @param errorCode the error code
+ * @param errorText the error text
+ * @param disposition the disposition
+ * @param category the category
+ */
+ public ErrorObject(String severity, Integer httpResponseCode, String errorCode, String errorText,
+ String disposition, String category) {
+ super();
+ this.severity = severity;
+ this.setHTTPResponseCode(httpResponseCode);
+ this.setErrorCode(errorCode);
+ this.setErrorText(errorText);
+ this.setDisposition(disposition);
+ this.setCategory(category);
+ this.setAaiElsErrorCode(AaiElsErrorCode.UNKNOWN_ERROR);
+ }
+
+ /**
+ * Instantiates a new error object.
+ *
+ * @param severity the severity
+ * @param httpResponseCode the http response code
+ * @param errorCode the error code
+ * @param errorText the error text
+ * @param disposition the disposition
+ * @param category the category
+ */
+ public ErrorObject(String severity, Status httpResponseCode, String errorCode, String errorText, String disposition,
+ String category) {
+ super();
+ this.severity = severity;
+ this.setHTTPResponseCode(httpResponseCode);
+ this.setErrorCode(errorCode);
+ this.setErrorText(errorText);
+ this.setDisposition(disposition);
+ this.setCategory(category);
+ this.setAaiElsErrorCode(AaiElsErrorCode.UNKNOWN_ERROR);
+ }
+
+ /**
+ * Gets the disposition.
+ *
+ * @return the disposition
+ */
+ public String getDisposition() {
+ return disposition;
+ }
+
+ /**
+ * Sets the disposition.
+ *
+ * @param disposition the new disposition
+ */
+ public void setDisposition(String disposition) {
+ this.disposition = disposition;
+ }
+
+ /**
+ * Gets the category.
+ *
+ * @return the category
+ */
+ public String getCategory() {
+ return category;
+ }
+
+ /**
+ * Sets the category.
+ *
+ * @param category the new category
+ */
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ /**
+ * Gets the severity.
+ *
+ * @return the severity
+ */
+ public String getSeverity() {
+ return severity;
+ }
+
+ /**
+ * Sets the severity.
+ *
+ * @param severity the new severity
+ */
+ public void setSeverity(String severity) {
+ this.severity = severity;
+ }
+
+ /**
+ * Gets the error code.
+ *
+ * @return the error code
+ */
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ /**
+ * Sets the error code.
+ *
+ * @param errorCode the new error code
+ */
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ /**
+ * Gets the HTTP response code.
+ *
+ * @return the HTTP response code
+ */
+ public Status getHTTPResponseCode() {
+ return httpResponseCode;
+ }
+
+ /**
+ * Sets the HTTP response code.
+ *
+ * @param httpResponseCode the new HTTP response code
+ */
+ public void setHTTPResponseCode(Integer httpResponseCode) {
+ this.httpResponseCode = Status.fromStatusCode(httpResponseCode);
+ if (this.httpResponseCode == null) {
+ throw new IllegalArgumentException(
+ "setHTTPResponseCode was passed an invalid Integer value, fix error.properties or your code "
+ + httpResponseCode);
+ }
+ }
+
+ /**
+ * Sets the HTTP response code.
+ *
+ * @param httpResponseCode the new HTTP response code
+ */
+ public void setHTTPResponseCode(String httpResponseCode) {
+ this.httpResponseCode = Status.fromStatusCode(Integer.valueOf(httpResponseCode));
+ if (this.httpResponseCode == null) {
+ throw new IllegalArgumentException(
+ "setHTTPResponseCode was passed an invalid String value, fix error.properties or your code "
+ + httpResponseCode);
+ }
+ }
+
+ /**
+ * Sets the REST error code.
+ *
+ * @param restErrorCode the new REST error code
+ */
+ public void setRESTErrorCode(String restErrorCode) {
+ this.restErrorCode = restErrorCode;
+ }
+
+ /**
+ * Gets the REST error code.
+ *
+ * @return the REST error code
+ */
+ public String getRESTErrorCode() {
+ return this.restErrorCode;
+ }
+
+ /**
+ * Sets the HTTP response code.
+ *
+ * @param httpResponseCode the new HTTP response code
+ */
+ public void setHTTPResponseCode(Status httpResponseCode) {
+ this.httpResponseCode = httpResponseCode;
+ if (this.httpResponseCode == null) {
+ throw new IllegalArgumentException(
+ "setHTTPResponseCode was passed an invalid String value, fix error.properties or your code "
+ + httpResponseCode);
+ }
+ }
+
+ /**
+ * Gets the error text.
+ *
+ * @return the error text
+ */
+ public String getErrorText() {
+ return errorText;
+ }
+
+ /**
+ * Sets the error text.
+ *
+ * @param errorText the new error text
+ */
+ public void setErrorText(String errorText) {
+ this.errorText = errorText;
+ }
+
+ /**
+ * Gets the details.
+ *
+ * @return the details
+ */
+ public String getDetails() {
+ return details;
+ }
+
+ /**
+ * Sets the details.
+ *
+ * @param details the new details
+ */
+ public void setDetails(String details) {
+ this.details = details == null ? "" : details;
+ }
+ /**
+ * Sets the aai els error code.
+ *
+ * @param elsErrorCode the new code
+ */
+ public void setAaiElsErrorCode(String elsErrorCode) {
+ aaiElsErrorCode = elsErrorCode;
+ }
+ /**
+ * Gets the aai els error code.
+ *
+ * @return the code
+ */
+ public String getAaiElsErrorCode() {
+ return (aaiElsErrorCode);
+ }
+ /**
+ * Gets the error code string. This is also the string
+ * configured in Nagios to alert on
+ *
+ * @return the error code string
+ */
+ // Get the X.Y.Z representation of the error code
+ public String getErrorCodeString() {
+ String prefix = null;
+ switch (disposition) {
+ default:
+ prefix = "";
+ break;
+ case "5":
+ prefix = "ERR.";
+ break;
+ }
+ return prefix + disposition + "." + category + "." + errorCode;
+ }
+
+ /**
+ * Gets the severity Code. This is also the string
+ * configured in Nagios to alert on
+ *
+ * @return the severity
+ */
+ // Get the numerical value of severity
+ public String getSeverityCode(String severity) {
+ String severityCode = "";
+ switch (severity) {
+ case "WARN":
+ severityCode = "1";
+ break;
+ case "ERROR":
+ severityCode = "2";
+ break;
+ case "FATAL":
+ severityCode = "3";
+ break;
+ }
+ return severityCode;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return "ErrorObject [errorCode=" + errorCode + ", errorText=" + errorText + ", restErrorCode=" + restErrorCode
+ + ", httpResponseCode=" + httpResponseCode + ", severity=" + severity + ", disposition=" + disposition
+ + ", category=" + category + "]";
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObjectFormatException.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObjectFormatException.java
new file mode 100644
index 00000000..8d53f2e3
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObjectFormatException.java
@@ -0,0 +1,30 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+public class ErrorObjectFormatException extends Exception {
+
+ private static final long serialVersionUID = 3732705544448553685L;
+
+ public ErrorObjectFormatException() {
+ super();
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObjectNotFoundException.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObjectNotFoundException.java
new file mode 100644
index 00000000..3daf7137
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/ErrorObjectNotFoundException.java
@@ -0,0 +1,51 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+public class ErrorObjectNotFoundException extends Exception {
+
+ private static final long serialVersionUID = 4115316781400786740L;
+
+ public ErrorObjectNotFoundException() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public ErrorObjectNotFoundException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ErrorObjectNotFoundException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ErrorObjectNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ErrorObjectNotFoundException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ // TODO Auto-generated constructor stub
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LogFormatTools.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LogFormatTools.java
new file mode 100644
index 00000000..3f0d80ae
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LogFormatTools.java
@@ -0,0 +1,125 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.util.AAIConfig;
+import org.onap.aai.util.AAIConstants;
+
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+public class LogFormatTools {
+
+ private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
+ private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern(DATE_FORMAT).withZone(ZoneOffset.UTC);
+
+ public static String getCurrentDateTime() {
+ return DTF.format(ZonedDateTime.now());
+ }
+
+ public static String toDate(long timestamp) {
+ return DTF.format(Instant.ofEpochMilli(timestamp));
+ }
+
+ public static long toTimestamp(String date) {
+ return ZonedDateTime.parse(date, DTF).toInstant().toEpochMilli();
+ }
+
+ /**
+ * Gets the stack top.
+ *
+ * @param e the e
+ * @return the stack top
+ * @throws NumberFormatException the number format exception
+ * @throws AAIException the AAI exception
+ */
+ public static String getStackTop(Throwable e) {
+ // StringBuilder is more efficient than StringBuffer and should only
+ // StringBuffer is only supposed to be used if multiple threads are modifying
+ // the same object and since this object is created locally not necessary
+ StringBuilder stackMessage = new StringBuilder();
+ int maxStackTraceEntries = 10;
+ try {
+ maxStackTraceEntries = Integer.valueOf(AAIConfig.get(AAIConstants.LOGGING_MAX_STACK_TRACE_ENTRIES));
+ } catch (AAIException a) {
+ // ignore, use default
+ } catch (NumberFormatException n) {
+ // ignore, use default
+ }
+ if (e != null) {
+ Throwable rootCause = ExceptionUtils.getRootCause(e);
+ if (rootCause != null) {
+ stackMessage.append("root cause=" + ExceptionUtils.getRootCause(e));
+ StackTraceElement[] elements = rootCause.getStackTrace();
+ int i = 0;
+ for (StackTraceElement element : elements) {
+ if (i < maxStackTraceEntries) {
+ stackMessage.append(" ClassName- ");
+ stackMessage.append(element.getClassName());
+ stackMessage.append(" :LineNumber- ");
+ stackMessage.append(element.getLineNumber());
+ stackMessage.append(" :MethodName- ");
+ stackMessage.append(element.getMethodName());
+ }
+ i++;
+ }
+ } else if (e.getCause() != null) {
+ stackMessage.append("cause=" + e.getCause());
+ StackTraceElement[] elements = e.getCause().getStackTrace();
+ int i = 0;
+ for (StackTraceElement element : elements) {
+ if (i < maxStackTraceEntries) {
+ stackMessage.append(" ClassName- ");
+ stackMessage.append(element.getClassName());
+ stackMessage.append(" :LineNumber- ");
+ stackMessage.append(element.getLineNumber());
+ stackMessage.append(" :MethodName- ");
+ stackMessage.append(element.getMethodName());
+ }
+ i++;
+ }
+ } else if (e.getStackTrace() != null) {
+ stackMessage.append("ex=" + e.toString());
+ StackTraceElement[] elements = e.getStackTrace();
+ int i = 0;
+ for (StackTraceElement element : elements) {
+ if (i < maxStackTraceEntries) {
+ stackMessage.append(" ClassName- ");
+ stackMessage.append(element.getClassName());
+ stackMessage.append(" :LineNumber- ");
+ stackMessage.append(element.getLineNumber());
+ stackMessage.append(" :MethodName- ");
+ stackMessage.append(element.getMethodName());
+ }
+ i++;
+ }
+ }
+ }
+ String stackMessageStr = stackMessage.toString();
+ stackMessageStr = stackMessageStr.replaceAll("\\n", "^");
+ return stackMessageStr;
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java
new file mode 100644
index 00000000..13f324ec
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContext.java
@@ -0,0 +1,130 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+public class LoggingContext {
+
+ private static final Logger logger = LoggerFactory.getLogger(LoggingContext.class);
+
+ // Response codes from Logging Guidelines
+ public static final String SUCCESS = "0";
+ public static final String PERMISSION_ERROR = "100";
+ public static final String AVAILABILITY_TIMEOUT_ERROR = "200";
+ public static final String DATA_ERROR = "300";
+ public static final String SCHEMA_ERROR = "400";
+ public static final String BUSINESS_PROCESS_ERROR = "500";
+ public static final String UNKNOWN_ERROR = "900";
+
+ public static final Map<String, String> responseMap = new HashMap();
+
+
+ // Specific Log Event Fields
+ public static enum LoggingField {
+ START_TIME("startTime"), REQUEST_ID("requestId"), SERVICE_INSTANCE_ID("serviceInstanceId"), SERVER_NAME(
+ "serverName"), SERVICE_NAME("serviceName"), PARTNER_NAME("partnerName"), STATUS_CODE(
+ "statusCode"), RESPONSE_CODE("responseCode"), RESPONSE_DESCRIPTION(
+ "responseDescription"), INSTANCE_UUID("instanceUUID"), SEVERITY(
+ "severity"), SERVER_IP_ADDRESS(
+ "serverIpAddress"), ELAPSED_TIME("elapsedTime"), SERVER(
+ "server"), CLIENT_IP_ADDRESS("clientIpAddress"), UNUSED(
+ "unused"), PROCESS_KEY("processKey"), CUSTOM_FIELD_1(
+ "customField1"), CUSTOM_FIELD_2(
+ "customField2"), CUSTOM_FIELD_3(
+ "customField3"), CUSTOM_FIELD_4(
+ "customField4"),
+
+ // Specific Metric Log Event Fields
+ TARGET_ENTITY("targetEntity"), TARGET_SERVICE_NAME("targetServiceName"),
+ // A&AI Specific Log Event Fields
+ COMPONENT("component"), STOP_WATCH_START("stopWatchStart");
+
+ private final String text;
+
+ private LoggingField(final String text) {
+ this.text = text;
+ }
+
+ public String toString() {
+ return text;
+ }
+ }
+
+ public static void init() {
+ LoggingContext.clear();
+
+ }
+
+ public static void elapsedTime(long elapsedTime, TimeUnit timeUnit) {
+ MDC.put(LoggingField.ELAPSED_TIME.toString(),
+ String.valueOf(TimeUnit.MILLISECONDS.convert(elapsedTime, timeUnit)));
+ }
+
+ public static boolean isStopWatchStarted() {
+ final String rawStopWatchStart = MDC.get(LoggingField.STOP_WATCH_START.toString());
+ if (rawStopWatchStart == null) {
+ return false;
+ }
+ return true;
+ }
+
+ public static void stopWatchStart() {
+ MDC.put(LoggingField.STOP_WATCH_START.toString(), String.valueOf(System.nanoTime()));
+ }
+
+ public static double stopWatchStop() {
+ final long stopWatchEnd = System.nanoTime();
+ final String rawStopWatchStart = MDC.get(LoggingField.STOP_WATCH_START.toString());
+
+ if (rawStopWatchStart == null)
+ throw new StopWatchNotStartedException();
+
+ final Long stopWatchStart = Long.valueOf(rawStopWatchStart);
+
+ MDC.remove(LoggingField.STOP_WATCH_START.toString());
+
+ final double elapsedTimeMillis = (stopWatchEnd - stopWatchStart) / 1000.0 / 1000.0;
+
+ LoggingContext.elapsedTime((long) elapsedTimeMillis, TimeUnit.MILLISECONDS);
+
+ return elapsedTimeMillis;
+ }
+
+ public static void put(String key, String value) {
+ MDC.put(key, value);
+ }
+
+ public static void clear() {
+ MDC.clear();
+ }
+
+ public static void remove(String key) {
+ MDC.remove(key);
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContextNotExistsException.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContextNotExistsException.java
new file mode 100644
index 00000000..f1d4c59c
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/LoggingContextNotExistsException.java
@@ -0,0 +1,26 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+public class LoggingContextNotExistsException extends RuntimeException {
+
+ private static final long serialVersionUID = -4965807709525739623L;
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/StopWatch.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/StopWatch.java
new file mode 100644
index 00000000..0d93827f
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/StopWatch.java
@@ -0,0 +1,56 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+import org.onap.aai.logging.LoggingContext.LoggingField;
+
+public final class StopWatch {
+
+ private StopWatch() {
+ }
+
+ public static void start() {
+ LoggingContext.stopWatchStart();
+ }
+
+ public static double stop() {
+ return LoggingContext.stopWatchStop();
+ }
+
+ public static void conditionalStart() {
+ if (LoggingContext.isStopWatchStarted()) {
+ return;
+ }
+ start();
+ }
+
+ public static double stopIfStarted() {
+ if (LoggingContext.isStopWatchStarted()) {
+ return (stop());
+ }
+ return (0);
+ }
+
+ public static void clear() {
+ LoggingContext.remove(LoggingField.STOP_WATCH_START.toString());
+ LoggingContext.remove(LoggingField.ELAPSED_TIME.toString());
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/logging/StopWatchNotStartedException.java b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/StopWatchNotStartedException.java
new file mode 100644
index 00000000..e4819c5c
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/logging/StopWatchNotStartedException.java
@@ -0,0 +1,42 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.logging;
+
+public class StopWatchNotStartedException extends RuntimeException {
+
+ private static final long serialVersionUID = -4540164295822859408L;
+
+ public StopWatchNotStartedException() {
+ super();
+ }
+
+ public StopWatchNotStartedException(String message) {
+ super(message);
+ }
+
+ public StopWatchNotStartedException(Throwable cause) {
+ super(cause);
+ }
+
+ public StopWatchNotStartedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java
new file mode 100644
index 00000000..7de6af28
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIApplicationConfig.java
@@ -0,0 +1,362 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.util;
+
+import org.apache.commons.io.IOUtils;
+import org.eclipse.jetty.util.security.Password;
+import org.onap.aai.exceptions.AAIException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class AAIApplicationConfig {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AAIApplicationConfig.class);
+ private static String GLOBAL_PROP_FILE_NAME = "application.properties";
+ private static final String SERVER_CERTS_LOCATION_PROP_NAME = "server.certs.location";
+ private static final String PASSPHRASSES_FILENAME = ".passphrases";
+ private static final String PASSWORD_FILENAME = ".password";
+ private static final String TRUSTSTORE_PASSWORD_PROP_NAME = "cadi_truststore_password";
+ private static final String SERVER_SSL_KEYSTORE_PROP_NAME = "server.ssl.key-store";
+ private static final String SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME = "server.ssl.key-store.pkcs12";
+ private static final String SERVER_SSL_TRUSTSTORE_PROP_NAME = "server.ssl.trust-store";
+ private static Properties serverProps;
+ private static boolean propsInitialized = false;
+ private static String TRUSTSTORE_PASSWORD = null;
+ private static String KEYSTORE_PASSWORD = null;
+ private static final String PROPERTY_REGEX = "\\$\\{([^\\$\\{\\}]+)\\}";
+
+ /**
+ * Instantiates a new AAI config.
+ */
+ // Don't instantiate
+ private AAIApplicationConfig() {
+ }
+
+ /**
+ * Inits the.
+ *
+ * @throws AAIException the AAI exception
+ */
+ public synchronized static void init() {
+ /*LoggingContext.save();
+ LoggingContext.component("config");
+ LoggingContext.partnerName("NA");
+ LoggingContext.targetEntity("AAI");
+ LoggingContext.requestId(UUID.randomUUID().toString());
+ LoggingContext.serviceName("AAI");
+ LoggingContext.targetServiceName("init");
+ LoggingContext.statusCode(StatusCode.COMPLETE);*/
+
+ LOGGER.info("Initializing AAIApplicationConfig");
+
+ AAIApplicationConfig.reloadConfig();
+
+ //LoggingContext.restore();
+ }
+
+ /**
+ * Reload config.
+ */
+ public synchronized static void reloadConfig() {
+
+ Properties newServerProps = new Properties();
+ LOGGER.debug("Reloading config from " + GLOBAL_PROP_FILE_NAME);
+
+ try {
+ InputStream is = AAIApplicationConfig.class.getClassLoader().getResourceAsStream(GLOBAL_PROP_FILE_NAME);
+ newServerProps.load(is);
+ propsInitialized = true;
+ serverProps = newServerProps;
+ TRUSTSTORE_PASSWORD = retrieveTruststorePassword();
+ KEYSTORE_PASSWORD = retrieveKeystorePassword();
+ } catch (Exception fnfe) {
+ final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("application.properties");
+ LOGGER.info("Unable to find the application.properties from filesystem so using file in jar");
+ if (is != null) {
+ try {
+ newServerProps.load(is);
+ serverProps = newServerProps;
+ TRUSTSTORE_PASSWORD = retrieveTruststorePassword();
+ KEYSTORE_PASSWORD = retrieveKeystorePassword();
+ } catch (IOException e) {
+ LOGGER.warn("Encountered IO Exception during loading of props from inputstream", e);
+ }
+ } else {
+ LOGGER.error("Expected to find the properties file in the jar but unable to find it");
+ }
+ }
+ }
+
+ /**
+ * Gets the key value
+ *
+ * @param key the key
+ * @param defaultValue the default value
+ * @return the string
+ */
+ public static String get(String key, String defaultValue) {
+ String result = defaultValue;
+ try {
+ result = get(key);
+ } catch (AAIException a) {
+ }
+ if (result == null || result.isEmpty()) {
+ result = defaultValue;
+ }
+ return (result);
+ }
+
+ /**
+ * Gets the key value
+ *
+ * @param key the key
+ * @return the string
+ * @throws AAIException the AAI exception
+ */
+ public static String get(String key) throws AAIException {
+ String response = null;
+
+ if (!propsInitialized || (serverProps == null)) {
+ reloadConfig();
+ }
+
+ if ((key.endsWith("password") || key.endsWith("passwd") || key.endsWith("apisecret"))
+ && serverProps.containsKey(key + ".x")) {
+ String valx = serverProps.getProperty(key + ".x");
+ return Password.deobfuscate(valx);
+ }
+
+ if (!serverProps.containsKey(key)) {
+ throw new AAIException("AAI_4005", "Property key " + key + " cannot be found");
+ } else {
+ response = serverProps.getProperty(key);
+ if (response == null || response.isEmpty()) {
+ throw new AAIException("AAI_4005", "Property key " + key + " is null or empty");
+ }
+ response = replaceProperties(response);
+ }
+ return response;
+ }
+
+ /**
+ * Gets the keystore path
+ *
+ * @return the string
+ * @throws AAIException the AAI exception
+ */
+ public static String getKeystore() throws AAIException {
+ return (get(SERVER_SSL_KEYSTORE_PROP_NAME));
+ }
+ /**
+ * Gets the PKCS12 keystore path
+ *
+ * @return the string
+ * @throws AAIException the AAI exception
+ */
+ public static String getKeystorePkcs12() throws AAIException {
+ return (get(SERVER_SSL_KEYSTORE_PKCS12_PROP_NAME));
+ }
+ /**
+ * Gets the keystore path
+ *
+ * @return the string
+ * @throws AAIException the AAI exception
+ */
+ public static String getTruststore() throws AAIException {
+ return (get(SERVER_SSL_TRUSTSTORE_PROP_NAME));
+ }
+
+ /**
+ * Retrieve the keystore password
+ *
+ * @return the password
+ */
+ private static String retrieveKeystorePassword() {
+ String certPath = serverProps.getProperty(SERVER_CERTS_LOCATION_PROP_NAME);
+ if (certPath == null) {
+ return null;
+ }
+ try {
+ certPath = replaceProperties(certPath);
+ }
+ catch (AAIException e) {
+ return null;
+ }
+
+ File passwordFile = null;
+ InputStream passwordStream = null;
+ String keystorePassword = null;
+
+ // Override the passwords from application.properties if we find AAF certman files
+ try {
+ passwordFile = new File(certPath + PASSWORD_FILENAME);
+ passwordStream = new FileInputStream(passwordFile);
+ keystorePassword = IOUtils.toString(passwordStream, Charset.defaultCharset());
+ if (keystorePassword != null) {
+ keystorePassword = keystorePassword.trim();
+ }
+
+ } catch (IOException e) {
+ LOGGER.warn("Not using AAF Certman password file, e=" + e.getMessage());
+ } catch (NullPointerException n) {
+ LOGGER.warn("Not using AAF Certman passphrases file, e=" + n.getMessage());
+ } finally {
+ if (passwordStream != null) {
+ try {
+ passwordStream.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+ return keystorePassword;
+ }
+
+ /**
+ * Get the keystore password
+ *
+ * @return the password
+ */
+ public static String getKeystorePassword() {
+ return (KEYSTORE_PASSWORD);
+ }
+
+ /**
+ * Gets the truststore password
+ *
+ * @return the password
+ */
+ private static String retrieveTruststorePassword() {
+ String certPath = serverProps.getProperty(SERVER_CERTS_LOCATION_PROP_NAME);
+ if (certPath == null) {
+ return null;
+ }
+ try {
+ certPath = replaceProperties(certPath);
+ }
+ catch (AAIException e) {
+ return null;
+ }
+ File passphrasesFile = null;
+ InputStream passphrasesStream = null;
+ String truststorePassword = null;
+ try {
+ passphrasesFile = new File(certPath + PASSPHRASSES_FILENAME);
+ passphrasesStream = new FileInputStream(passphrasesFile);
+
+
+ Properties passphrasesProps = new Properties();
+ passphrasesProps.load(passphrasesStream);
+ truststorePassword = passphrasesProps.getProperty(TRUSTSTORE_PASSWORD_PROP_NAME);
+ if (truststorePassword != null) {
+ truststorePassword = truststorePassword.trim();
+ }
+
+ } catch (IOException e) {
+ LOGGER.warn("Not using AAF Certman passphrases file, e=" + e.getMessage());
+ } catch (NullPointerException n) {
+ LOGGER.warn("Not using AAF Certman passphrases file, e=" + n.getMessage());
+ } finally {
+ if (passphrasesStream != null) {
+ try {
+ passphrasesStream.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ return truststorePassword;
+ }
+
+ /**
+ * Get the trustore password
+ *
+ * @return the password
+ */
+ public static String getTruststorePassword() {
+ return (TRUSTSTORE_PASSWORD);
+ }
+
+ /**
+ * Gets the int value for the key.
+ *
+ * @param key the key
+ * @return the int
+ * @throws AAIException the AAI exception
+ */
+ public static int getInt(String key) throws AAIException {
+ return Integer.parseInt(AAIApplicationConfig.get(key));
+ }
+
+ /**
+ * Gets the int.
+ *
+ * @param key the key
+ * @return the int
+ */
+ public static int getInt(String key, String value) {
+ return Integer.parseInt(AAIApplicationConfig.get(key, value));
+ }
+
+ /**
+ * Gets the server props.
+ *
+ * @return the server props
+ */
+ public static Properties getServerProps() {
+ return serverProps;
+ }
+
+ /**
+ * Check if a null or an Empty string is passed in.
+ *
+ * @param s the s
+ * @return boolean
+ */
+ public static boolean isEmpty(String s) {
+ return (s == null || s.length() == 0);
+ }
+
+ private static String replaceProperties(String originalValue) throws AAIException {
+ final Pattern p = Pattern.compile(PROPERTY_REGEX);
+ Matcher m = p.matcher(originalValue);
+ /*if (!m.matches()) {
+ return originalValue;
+ }*/
+ StringBuffer sb = new StringBuffer();
+ while(m.find()) {
+ String text = m.group(1);
+ String replacement = get(text);
+ m.appendReplacement(sb, replacement);
+ }
+ m.appendTail(sb);
+ return(sb.toString());
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfig.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfig.java
new file mode 100644
index 00000000..8d3e2cc8
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfig.java
@@ -0,0 +1,226 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.util;
+
+import org.eclipse.jetty.util.security.Password;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.logging.ErrorLogHelper;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AAIConfig {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AAIConfig.class);
+ private static final String GLOBAL_PROP_FILE_NAME = AAIConstants.AAI_CONFIG_FILENAME;
+ private static Properties serverProps;
+ private static boolean propsInitialized = false;
+
+ /**
+ * Instantiates a new AAI config.
+ */
+ // Don't instantiate
+ private AAIConfig() {
+ }
+
+ /**
+ * Inits the.
+ *
+ * @throws AAIException the AAI exception
+ */
+ public synchronized static void init() throws AAIException {
+
+ LOGGER.info("Initializing AAIConfig");
+
+ AAIConfig.getConfigFile();
+ AAIConfig.reloadConfig();
+
+ if (AAIConstants.AAI_NODENAME == null || AAIConstants.AAI_NODENAME == "") {
+ ErrorLogHelper.logError("AAI_4005", " AAI_NODENAME is not defined");
+ } else {
+ LOGGER.info("A&AI Server Node Name = " + AAIConstants.AAI_NODENAME);
+ }
+ }
+
+ /**
+ * Gets the config file.
+ *
+ * @return the config file
+ */
+ public static String getConfigFile() {
+ return GLOBAL_PROP_FILE_NAME;
+ }
+
+ /**
+ * Reload config.
+ */
+ public synchronized static void reloadConfig() {
+
+ String propFileName = GLOBAL_PROP_FILE_NAME;
+ Properties newServerProps = new Properties();
+
+ LOGGER.debug("Reloading config from " + propFileName);
+
+ try (InputStream is = new FileInputStream(propFileName)) {
+ LOGGER.info("Found the aaiconfig.properties in the following location: {}", GLOBAL_PROP_FILE_NAME);
+ newServerProps.load(is);
+ propsInitialized = true;
+ serverProps = newServerProps;
+ } catch (Exception fnfe) {
+ final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("aaiconfig.properties");
+ LOGGER.info("Unable to find the aaiconfig.properties from filesystem so using file in jar");
+ if (is != null) {
+ try {
+ newServerProps.load(is);
+ serverProps = newServerProps;
+ } catch (IOException e) {
+ LOGGER.warn("Encountered IO Exception during loading of aaiconfig props from inputstream", e);
+ }
+ } else {
+ LOGGER.error("Expected to find the error.properties in the jar but unable to find it");
+ }
+ }
+ }
+
+ /**
+ * Gets the.
+ *
+ * @param key the key
+ * @param defaultValue the default value
+ * @return the string
+ */
+ public static String get(String key, String defaultValue) {
+ String result = defaultValue;
+ try {
+ result = get(key);
+ } catch (AAIException a) {
+ }
+ if (result == null || result.isEmpty()) {
+ result = defaultValue;
+ }
+ return (result);
+ }
+
+ /**
+ * Gets the.
+ *
+ * @param key the key
+ * @return the string
+ * @throws AAIException the AAI exception
+ */
+ public static String get(String key) throws AAIException {
+ String response = null;
+
+ if (key.equals(AAIConstants.AAI_NODENAME)) {
+ // Get this from InetAddress rather than the properties file
+ String nodeName = getNodeName();
+ if (nodeName != null) {
+ return nodeName;
+ }
+ // else get from property file
+ }
+
+ if (!propsInitialized || (serverProps == null)) {
+ reloadConfig();
+ }
+
+ if ((key.endsWith("password") || key.endsWith("passwd") || key.endsWith("apisecret"))
+ && serverProps.containsKey(key + ".x")) {
+ String valx = serverProps.getProperty(key + ".x");
+ return Password.deobfuscate(valx);
+ }
+
+ if (!serverProps.containsKey(key)) {
+ throw new AAIException("AAI_4005", "Property key " + key + " cannot be found");
+ } else {
+ response = serverProps.getProperty(key);
+ if (response == null || response.isEmpty()) {
+ throw new AAIException("AAI_4005", "Property key " + key + " is null or empty");
+ }
+ }
+ return response;
+ }
+
+ /**
+ * Gets the int.
+ *
+ * @param key the key
+ * @return the int
+ * @throws AAIException the AAI exception
+ */
+ public static int getInt(String key) throws AAIException {
+ return Integer.parseInt(AAIConfig.get(key));
+ }
+
+ /**
+ * Gets the int.
+ *
+ * @param key the key
+ * @return the int
+ */
+ public static int getInt(String key, String value) {
+ return Integer.parseInt(AAIConfig.get(key, value));
+ }
+
+ /**
+ * Gets the server props.
+ *
+ * @return the server props
+ */
+ public static Properties getServerProps() {
+ return serverProps;
+ }
+
+ /**
+ * Gets the node name.
+ *
+ * @return the node name
+ */
+ public static String getNodeName() {
+ try {
+ InetAddress ip = InetAddress.getLocalHost();
+ if (ip != null) {
+ String hostname = ip.getHostName();
+ if (hostname != null) {
+ return hostname;
+ }
+ }
+ } catch (Exception e) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * Check if a null or an Empty string is passed in.
+ *
+ * @param s the s
+ * @return boolean
+ */
+ public static boolean isEmpty(String s) {
+ return (s == null || s.length() == 0);
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfigProxy.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfigProxy.java
new file mode 100644
index 00000000..faacc527
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConfigProxy.java
@@ -0,0 +1,41 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.util;
+
+/**
+ * <b>AAIConfigProxy</b> is a interface trying to proxy calls
+ * to the AAIConfig class in which there are only static methods
+ * The main reason for this interface existence is to simplify
+ * unit testing edge cases in which it is harder to simulate
+ *
+ * Note: If there is a better way to do this,
+ * it is encouraged to change this early on
+ */
+// TODO - Find an better name for this interface name
+public interface AAIConfigProxy {
+
+ default String get(String key, String defaultValue){
+ return AAIConfig.get(key, defaultValue);
+ }
+
+ default int getInt(String key, String defaultValue){
+ return AAIConfig.getInt(key, defaultValue);
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConstants.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConstants.java
new file mode 100644
index 00000000..3ddd008f
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/AAIConstants.java
@@ -0,0 +1,164 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright © 2018 IBM.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.util;
+
+public final class AAIConstants {
+ private static final String AJSC_HOME = "AJSC_HOME";
+ //
+ //
+ /** Default to unix file separator if system property file.separator is null */
+ public static final String AAI_FILESEP =
+ (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
+ //
+ /** Default to opt aai if system property aai.home is null, using file.separator */
+ public static final String AAI_HOME =
+ (System.getProperty(AJSC_HOME) == null) ? AAI_FILESEP + "opt" + AAI_FILESEP + "app" + AAI_FILESEP + "aai"
+ : System.getProperty(AJSC_HOME);
+ public static final String AAI_BUNDLECONFIG_NAME =
+ (System.getProperty("BUNDLECONFIG_DIR") == null) ? "bundleconfig" : System.getProperty("BUNDLECONFIG_DIR");
+ public static final String AAI_HOME_BUNDLECONFIG = (System.getProperty(AJSC_HOME) == null)
+ ? AAI_FILESEP + "opt" + AAI_FILESEP + "app" + AAI_FILESEP + "aai" + AAI_FILESEP + AAI_BUNDLECONFIG_NAME
+ : System.getProperty(AJSC_HOME) + AAI_FILESEP + AAI_BUNDLECONFIG_NAME;
+
+ /** etc directory, relative to AAI_HOME */
+ public static final String AAI_HOME_ETC = AAI_HOME_BUNDLECONFIG + AAI_FILESEP + "etc" + AAI_FILESEP;
+ public static final String AAI_HOME_ETC_APP_PROPERTIES = AAI_HOME_ETC + "appprops" + AAI_FILESEP;
+ public static final String AAI_HOME_ETC_AUTH = AAI_HOME_ETC + "auth" + AAI_FILESEP;
+ public static final String AAI_CONFIG_FILENAME = AAI_HOME_ETC_APP_PROPERTIES + "aaiconfig.properties";
+ public static final String AAI_AUTH_CONFIG_FILENAME = AAI_HOME_ETC_AUTH + "aai_policy.json";
+ public static final String REALTIME_DB_CONFIG = AAI_HOME_ETC_APP_PROPERTIES + "janusgraph-realtime.properties";
+ public static final String CACHED_DB_CONFIG = AAI_HOME_ETC_APP_PROPERTIES + "janusgraph-cached.properties";
+ public static final String AAI_HOME_ETC_OXM = AAI_HOME_ETC + "oxm" + AAI_FILESEP;
+ public static final String AAI_EVENT_DMAAP_PROPS =
+ AAI_HOME_ETC_APP_PROPERTIES + "aaiEventDMaaPPublisher.properties";
+ public static final String DELTA_EVENT_DMAAP_PROPS =
+ AAI_HOME_ETC_APP_PROPERTIES + "delta-event-publisher.properties";
+ public static final String AAI_HOME_ETC_SCRIPT = AAI_HOME_ETC + AAI_FILESEP + "scriptdata" + AAI_FILESEP;
+
+ public static final String AAI_LOGBACK_PROPS = "logback.xml";
+ public static final String AAI_SCHEMA_MOD_LOGBACK_PROPS = "schemaMod-logback.xml";
+ public static final String AAI_FORCE_DELETE_LOGBACK_PROPS = "forceDelete-logback.xml";
+
+ public static final String AAI_TRUSTSTORE_FILENAME = "aai.truststore.filename";
+ public static final String AAI_TRUSTSTORE_PASSWD = "aai.truststore.passwd";
+ public static final String AAI_KEYSTORE_FILENAME = "aai.keystore.filename";
+ public static final String AAI_KEYSTORE_PASSWD = "aai.keystore.passwd";
+
+ public static final String AAI_SERVER_URL_BASE = "aai.server.url.base";
+ public static final String AAI_SERVER_URL = "aai.server.url";
+ public static final String AAI_OLDSERVER_URL = "aai.oldserver.url";
+ public static final String AAI_LOCAL_REST = "https://localhost:%d/aai/%s/";
+ public static final String AAI_LOCAL_OVERRIDE = "aai.server.localhost.override.url";
+ public static final String AAI_LOCAL_OVERRIDE_DEFAULT = "NA";
+ public static final String AAI_LOCAL_REST_OVERRIDE = "%s/aai/%s/";
+
+ public static final int AAI_RESOURCES_PORT = 8447;
+ public static final int AAI_QUERY_PORT = 8446;
+ public static final int AAI_LEGACY_PORT = 8443;
+
+ public static final String AAI_DEFAULT_API_VERSION = "v10";
+ public static final String AAI_DEFAULT_API_VERSION_PROP = "aai.default.api.version";
+ public static final String AAI_NOTIFICATION_CURRENT_VERSION = "aai.notification.current.version";
+
+ public static final String AAI_NODENAME = "aai.config.nodename";
+
+ /*
+ * Logs the objects being deleted when an client deletes objects via implied delete during PUT operation
+ */
+ public static final String AAI_IMPLIED_DELETE_LOG_ENABLED = "aai.implied.delete.log.enabled";
+ /*
+ * Specifies how many objects maximum to log
+ */
+ public static final String AAI_IMPLIED_DELETE_LOG_LIMIT = "aai.implied.delete.log.limit";
+
+ /**
+ * Specifies which clients should the implied delete be allowed
+ *
+ * If the aaiconfig properties has the below property:
+ *
+ * <code>
+ * aai.implied.delete.whitelist.sdnc=*
+ * aai.implied.delete.whitelist.sdc='pserver','vserver'
+ * </code>
+ *
+ * Then SDNC can do implied delete on any object and could potentially delete any children
+ * and SDC is allowed to do implicit delete on any child of pserver
+ *
+ * So the following request would return 200 and ends up deleting p-interfaces
+ * since the X-FromAppId is SDC and they are allowed to delete any child of pserver
+ *
+ * PUT /aai/v$/cloud-infrastructure/pservers/pserver
+ *
+ * Headers:
+ *
+ * X-FromAppId: SDC
+ * X-TransactionId: Some-Transaction-Id
+ * Content-Type: application/json
+ *
+ * <code>
+ * {
+ * "hostname": "pserver",
+ * "p-interfaces":{}
+ * }
+ * </code>
+ */
+ public static final String AAI_IMPLIED_DELETE_WHITELIST = "aai.implied.delete.whitelist.";
+
+ public static final String AAI_BULKCONSUMER_LIMIT = "aai.bulkconsumer.payloadlimit";
+ public static final String AAI_BULKCONSUMER_OVERRIDE_LIMIT = "aai.bulkconsumer.payloadoverride";
+
+ public static final String AAI_TRAVERSAL_TIMEOUT_LIMIT = "aai.traversal.timeoutlimit";
+ public static final String AAI_TRAVERSAL_TIMEOUT_ENABLED = "aai.traversal.timeoutenabled";
+ public static final String AAI_TRAVERSAL_TIMEOUT_APP = "aai.traversal.timeout.appspecific";
+
+ public static final String AAI_GRAPHADMIN_TIMEOUT_LIMIT = "aai.graphadmin.timeoutlimit";
+ public static final String AAI_GRAPHADMIN_TIMEOUT_ENABLED = "aai.graphadmin.timeoutenabled";
+ public static final String AAI_GRAPHADMIN_TIMEOUT_APP = "aai.graphadmin.timeout.appspecific";
+
+ public static final String AAI_CRUD_TIMEOUT_LIMIT = "aai.crud.timeoutlimit";
+ public static final String AAI_CRUD_TIMEOUT_ENABLED = "aai.crud.timeoutenabled";
+ public static final String AAI_CRUD_TIMEOUT_APP = "aai.crud.timeout.appspecific";
+
+ public static final String AAI_RESVERSION_ENABLEFLAG = "aai.resourceversion.enableflag";
+ public static final String AAI_RESVERSION_DISABLED_UUID = "aai.resourceversion.disabled.uuid";
+ public static final String AAI_RESVERSION_DISABLED_UUID_DEFAULT = "38cf3090-6a0c-4e9d-8142-4332a7352846";
+
+ public static final long HISTORY_MAX_HOURS = 192;
+
+ public static final String LOGGING_MAX_STACK_TRACE_ENTRIES = "aai.logging.maxStackTraceEntries";
+
+ /*** UEB ***/
+ public static final String UEB_PUB_PARTITION_AAI = "AAI";
+
+ /** Micro-service Names */
+ public static final String AAI_TRAVERSAL_MS = "aai-traversal";
+ public static final String AAI_RESOURCES_MS = "aai-resources";
+
+ /**
+ * Instantiates a new AAI constants.
+ */
+ private AAIConstants() {
+ // prevent instantiation
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/FormatDate.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/FormatDate.java
new file mode 100644
index 00000000..9ee2b71d
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/FormatDate.java
@@ -0,0 +1,47 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.util;
+
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+public class FormatDate {
+
+ private final String timeZone;
+ private final String pattern;
+
+ public FormatDate(String pattern) {
+ this.pattern = pattern;
+ this.timeZone = "GMT";
+ }
+
+ public FormatDate(String pattern, String timeZone) {
+ this.pattern = pattern;
+ this.timeZone = timeZone;
+ }
+
+ public String getDateTime() {
+
+ final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
+ return formatter.format(ZonedDateTime.now(ZoneId.of(timeZone)));
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java
new file mode 100644
index 00000000..a41ad27b
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/HbaseSaltPrefixer.java
@@ -0,0 +1,61 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.util;
+
+/*
+ * logging to hbase encountered hotspotting issues, so per
+ * http://archive.cloudera.com/cdh5/cdh/5/hbase-0.98.6-cdh5.3.8/book/rowkey.design.html
+ * we decided to salt the rowkeys
+ * as these keys are generated in a couple places, I made a class to contain that logic
+ */
+public class HbaseSaltPrefixer {
+ private int NUM_REGION_BUCKETS = 3; // the number of hbase region servers per cluster
+
+ private static class SingletonHolder {
+ private static final HbaseSaltPrefixer INSTANCE = new HbaseSaltPrefixer();
+ }
+
+ /**
+ * Instantiates a new hbase salt prefixer.
+ */
+ private HbaseSaltPrefixer() {
+ }
+
+ /**
+ * Gets the single instance of HbaseSaltPrefixer.
+ *
+ * @return single instance of HbaseSaltPrefixer
+ */
+ public static HbaseSaltPrefixer getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+
+ /**
+ * Prepend salt.
+ *
+ * @param key the key
+ * @return the string
+ */
+ public String prependSalt(String key) {
+ int salt = key.hashCode() % NUM_REGION_BUCKETS;
+ return salt + "-" + key;
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/MapperUtil.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/MapperUtil.java
new file mode 100644
index 00000000..d856999e
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/MapperUtil.java
@@ -0,0 +1,122 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright © 2018 IBM.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.util;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
+import org.onap.aai.exceptions.AAIException;
+
+public class MapperUtil {
+
+ /**
+ * Instantiates MapperUtil.
+ */
+ private MapperUtil() {
+ // prevent instantiation
+ }
+
+ /**
+ * Read as object of.
+ *
+ * @param <T> the generic type
+ * @param clazz the clazz
+ * @param value the value
+ * @return the t
+ * @throws AAIException the AAI exception
+ */
+ public static <T> T readAsObjectOf(Class<T> clazz, String value) throws AAIException {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.readValue(value, clazz);
+ } catch (Exception e) {
+ throw new AAIException("AAI_4007", e);
+ }
+ }
+
+ /**
+ * Read with dashes as object of.
+ *
+ * @param <T> the generic type
+ * @param clazz the clazz
+ * @param value the value
+ * @return the t
+ * @throws AAIException the AAI exception
+ */
+ public static <T> T readWithDashesAsObjectOf(Class<T> clazz, String value) throws AAIException {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ mapper.registerModule(new JaxbAnnotationModule());
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
+
+ return mapper.readValue(value, clazz);
+ } catch (Exception e) {
+ throw new AAIException("AAI_4007", e);
+ }
+ }
+
+ /**
+ * Write as JSON string.
+ *
+ * @param obj the obj
+ * @return the string
+ * @throws AAIException the AAI exception
+ */
+ public static String writeAsJSONString(Object obj) throws AAIException {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ return mapper.writeValueAsString(obj);
+ } catch (Exception e) {
+ throw new AAIException("AAI_4008", e);
+ }
+ }
+
+ /**
+ * Write as JSON string with dashes.
+ *
+ * @param obj the obj
+ * @return the string
+ * @throws AAIException the AAI exception
+ */
+ public static String writeAsJSONStringWithDashes(Object obj) throws AAIException {
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
+ mapper.configure(SerializationFeature.INDENT_OUTPUT, false);
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
+
+ mapper.registerModule(new JaxbAnnotationModule());
+ return mapper.writeValueAsString(obj);
+ } catch (Exception e) {
+ throw new AAIException("AAI_4008", e);
+ }
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java
new file mode 100644
index 00000000..ce2f4489
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractAuditLogFilter.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import javax.servlet.http.HttpServletRequest;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+public abstract class AbstractAuditLogFilter<GenericRequest, GenericResponse> extends MDCSetup {
+ protected static final Logger logger = LoggerFactory.getLogger(AbstractAuditLogFilter.class);
+
+ protected void pre(SimpleMap headers, GenericRequest request, HttpServletRequest httpServletRequest) {
+ try {
+ String requestId = getRequestId(headers);
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+ setInvocationId(headers);
+ setServiceName(request);
+ setMDCPartnerName(headers);
+ setServerFQDN();
+ setClientIPAddress(httpServletRequest);
+ setInstanceID();
+ setEntryTimeStamp();
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
+ additionalPreHandling(request);
+ setLogTimestamp();
+ setElapsedTime();
+ logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
+ } catch (Exception e) {
+ logger.warn("Error in AbstractInboundFilter pre", e);
+ }
+ }
+
+ protected void post(GenericResponse response) {
+ try {
+ int responseCode = getResponseCode(response);
+ setResponseStatusCode(responseCode);
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(responseCode));
+ setResponseDescription(responseCode);
+ setLogTimestamp();
+ setElapsedTime();
+ logger.info(ONAPLogConstants.Markers.EXIT, "Exiting.");
+ additionalPostHandling(response);
+ } catch (Exception e) {
+ logger.warn("Error in AbstractInboundFilter post", e);
+ } finally {
+ MDC.clear();
+ }
+ }
+
+ protected abstract int getResponseCode(GenericResponse response);
+
+ protected abstract void setServiceName(GenericRequest request);
+
+ protected void additionalPreHandling(GenericRequest request) {
+ // override to add additional pre handling
+ }
+
+ protected void additionalPostHandling(GenericResponse response) {
+ // override to add additional post handling
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java
new file mode 100644
index 00000000..ab1daab5
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.UUID;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+
+public abstract class AbstractMetricLogFilter<Request, Response, RequestHeaders> extends MDCSetup {
+ protected static final Logger logger = LoggerFactory.getLogger(AbstractMetricLogFilter.class);
+ private final String partnerName;
+ private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN");
+
+ public AbstractMetricLogFilter() {
+ partnerName = getPartnerName();
+ }
+
+ protected abstract void addHeader(RequestHeaders requestHeaders, String headerName, String headerValue);
+
+ protected abstract String getTargetServiceName(Request request);
+
+ protected abstract String getServiceName(Request request);
+
+ protected abstract int getHttpStatusCode(Response response);
+
+ protected abstract String getResponseCode(Response response);
+
+ protected abstract String getTargetEntity(Request request);
+
+ protected void pre(Request request, RequestHeaders requestHeaders) {
+ try {
+ setupMDC(request);
+ setupHeaders(request, requestHeaders);
+ logger.info(ONAPLogConstants.Markers.INVOKE, "Invoke");
+ } catch (Exception e) {
+ logger.warn("Error in AbstractMetricLogFilter pre", e);
+ }
+ }
+
+ protected void setupHeaders(Request clientRequest, RequestHeaders requestHeaders) {
+ String requestId = extractRequestID();
+ addHeader(requestHeaders, ONAPLogConstants.Headers.REQUEST_ID, requestId);
+ addHeader(requestHeaders, Constants.HttpHeaders.HEADER_REQUEST_ID, requestId);
+ addHeader(requestHeaders, Constants.HttpHeaders.TRANSACTION_ID, requestId);
+ addHeader(requestHeaders, Constants.HttpHeaders.ECOMP_REQUEST_ID, requestId);
+ addHeader(requestHeaders, ONAPLogConstants.Headers.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID));
+ addHeader(requestHeaders, ONAPLogConstants.Headers.PARTNER_NAME, partnerName);
+ }
+
+ protected void setupMDC(Request request) {
+ MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP,
+ ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
+ // setup time stamp defaults
+ setLogTimestamp();
+ setElapsedTimeInvokeTimestamp();
+ MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, getTargetServiceName(request));
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
+ setInvocationIdFromMDC();
+
+ if (MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY) == null) {
+ String targetEntity = getTargetEntity(request);
+ if (targetEntity != null) {
+ MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, targetEntity);
+ } else {
+ MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, Constants.DefaultValues.UNKNOWN_TARGET_ENTITY);
+ }
+ }
+
+ if (MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME) == null) {
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, getServiceName(request));
+ }
+ setServerFQDN();
+ }
+
+ protected String extractRequestID() {
+ String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
+ if (requestId == null || requestId.isEmpty()) {
+ requestId = UUID.randomUUID().toString();
+ setLogTimestamp();
+ setElapsedTimeInvokeTimestamp();
+ logger.warn("No value found in MDC when checking key {} value will be set to {}",
+ ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+ }
+ return requestId;
+ }
+
+ protected void post(Request request, Response response) {
+ try {
+ setLogTimestamp();
+ setElapsedTimeInvokeTimestamp();
+ setResponseStatusCode(getHttpStatusCode(response));
+ setResponseDescription(getHttpStatusCode(response));
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, getResponseCode(response));
+ logger.info(INVOKE_RETURN, "InvokeReturn");
+ clearClientMDCs();
+ } catch (Exception e) {
+ logger.warn("Error in AbstractMetricLogFilter post", e);
+ }
+ }
+
+ protected String getPartnerName() {
+ return getProperty(Constants.Property.PARTNER_NAME);
+ }
+
+ protected void logInvoke() {
+ logger.info(ONAPLogConstants.Markers.INVOKE, "Invoke");
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java
new file mode 100644
index 00000000..28495c84
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import java.util.Enumeration;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.HttpHeaders;
+
+public abstract class AbstractServletFilter {
+
+ protected String getSecureRequestHeaders(HttpServletRequest httpRequest) {
+ StringBuilder sb = new StringBuilder();
+ String header;
+ for (Enumeration<String> e = httpRequest.getHeaderNames(); e.hasMoreElements();) {
+ header = e.nextElement();
+ sb.append(header);
+ sb.append(":");
+ if (header.equalsIgnoreCase(HttpHeaders.AUTHORIZATION)) {
+ sb.append(Constants.REDACTED);
+ } else {
+ sb.append(httpRequest.getHeader(header));
+ }
+ sb.append(";");
+ }
+ return sb.toString();
+ }
+
+ protected String formatResponseHeaders(HttpServletResponse response) {
+ StringBuilder sb = new StringBuilder();
+ for (String headerName : response.getHeaderNames()) {
+ sb.append(headerName);
+ sb.append(":");
+ sb.append(response.getHeader(headerName));
+ sb.append(";");
+ }
+ return sb.toString();
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java
new file mode 100644
index 00000000..a0194850
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import java.io.IOException;
+import javax.annotation.Priority;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.container.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.Providers;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+@Priority(1)
+public class AuditLogContainerFilter extends AbstractAuditLogFilter<ContainerRequestContext, ContainerResponseContext>
+ implements ContainerRequestFilter, ContainerResponseFilter {
+
+ @Context
+ private HttpServletRequest httpServletRequest;
+
+ @Context
+ private Providers providers;
+
+ @Override
+ public void filter(ContainerRequestContext containerRequest) {
+ SimpleMap headers = new SimpleJaxrsHeadersMap(containerRequest.getHeaders());
+ pre(headers, containerRequest, httpServletRequest);
+ }
+
+ @Override
+ public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
+ throws IOException {
+ post(responseContext);
+ }
+
+ @Override
+ protected void setServiceName(ContainerRequestContext containerRequest) {
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, containerRequest.getUriInfo().getPath());
+ }
+
+ @Override
+ protected int getResponseCode(ContainerResponseContext response) {
+ return response.getStatus();
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogServletFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogServletFilter.java
new file mode 100644
index 00000000..a8f5eae9
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogServletFilter.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import java.io.IOException;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.MDC;
+
+public class AuditLogServletFilter extends AbstractAuditLogFilter<HttpServletRequest, HttpServletResponse>
+ implements Filter {
+
+ @Override
+ public void destroy() {
+ // this method does nothing
+ }
+
+ @Override
+ public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain filterChain)
+ throws IOException, ServletException {
+ try {
+ if (request != null && request instanceof HttpServletRequest) {
+ pre((HttpServletRequest) request);
+ }
+ filterChain.doFilter(request, response);
+ } finally {
+ if (request != null && request instanceof HttpServletRequest) {
+ post((HttpServletRequest) request, (HttpServletResponse) response);
+ }
+ MDC.clear();
+ }
+ }
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ // this method does nothing
+ }
+
+ protected void pre(HttpServletRequest request) {
+ SimpleMap headers = new SimpleServletHeadersMap(request);
+ pre(headers, request, request);
+ }
+
+ @Override
+ protected void setServiceName(HttpServletRequest request) {
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, request.getRequestURI());
+ }
+
+ private void post(HttpServletRequest request, HttpServletResponse response) {
+ post(response);
+ }
+
+ @Override
+ protected int getResponseCode(HttpServletResponse response) {
+ return response.getStatus();
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/Constants.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/Constants.java
new file mode 100644
index 00000000..be28f0bc
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/Constants.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+public class Constants {
+ protected static final String REDACTED = "***REDACTED***";
+
+ public static final class DefaultValues {
+ public static final String UNKNOWN = "UNKNOWN";
+ public static final String UNKNOWN_TARGET_ENTITY = "Unknown-Target-Entity";
+ }
+
+ public static final class HttpHeaders {
+ public static final String HEADER_FROM_APP_ID = "X-FromAppId";
+ public static final String ONAP_PARTNER_NAME = "X-ONAP-PartnerName";
+ public static final String HEADER_REQUEST_ID = "X-RequestID";
+ public static final String TRANSACTION_ID = "X-TransactionID";
+ public static final String ECOMP_REQUEST_ID = "X-ECOMP-RequestID";
+ public static final String ONAP_REQUEST_ID = "X-ONAP-RequestID";
+ public static final String CLIENT_ID = "X-ClientID";
+ public static final String INVOCATION_ID_HEADER = "X-InvocationID";
+ public static final String TARGET_ENTITY_HEADER = "X-Target-Entity";
+ }
+
+ public static final class Property {
+ public static final String PARTNER_NAME = "partnerName";
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java
new file mode 100644
index 00000000..369a9f20
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java
@@ -0,0 +1,238 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+import java.util.UUID;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+
+public class MDCSetup {
+
+ protected static Logger logger = LoggerFactory.getLogger(MDCSetup.class);
+
+ private static final String INSTANCE_UUID = UUID.randomUUID().toString();
+
+ public void setInstanceID() {
+ MDC.put(ONAPLogConstants.MDCs.INSTANCE_UUID, INSTANCE_UUID);
+ }
+
+ public void setServerFQDN() {
+ String serverFQDN = "";
+ InetAddress addr = null;
+ try {
+ addr = InetAddress.getLocalHost();
+ serverFQDN = addr.getCanonicalHostName();
+ MDC.put(ONAPLogConstants.MDCs.SERVER_IP_ADDRESS, addr.getHostAddress());
+ } catch (UnknownHostException e) {
+ logger.warn("Cannot Resolve Host Name");
+ serverFQDN = "";
+ }
+ MDC.put(ONAPLogConstants.MDCs.SERVER_FQDN, serverFQDN);
+ }
+
+ public void setClientIPAddress(HttpServletRequest httpServletRequest) {
+ String clientIpAddress = "";
+ if (httpServletRequest != null) {
+ // This logic is to avoid setting the client ip address to that of the load
+ // balancer in front of the application
+ String getForwadedFor = httpServletRequest.getHeader("X-Forwarded-For");
+ if (getForwadedFor != null) {
+ clientIpAddress = getForwadedFor;
+ } else {
+ clientIpAddress = httpServletRequest.getRemoteAddr();
+ }
+ }
+ MDC.put(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS, clientIpAddress);
+ }
+
+ public void setEntryTimeStamp() {
+ MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP,
+ ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
+ }
+
+ public String getRequestId(SimpleMap headers) {
+ logger.trace("Checking X-ONAP-RequestID header for requestId.");
+ String requestId = headers.get(ONAPLogConstants.Headers.REQUEST_ID);
+ if (requestId != null && !requestId.isEmpty() && isValidUUID(requestId)) {
+ return requestId;
+ }
+ if (requestId != null && !requestId.isEmpty()) {
+ //invalid
+ return UUID.randomUUID().toString();
+ }
+ logger.trace("No valid X-ONAP-RequestID header value. Checking X-RequestID header for requestId.");
+ requestId = headers.get(Constants.HttpHeaders.HEADER_REQUEST_ID);
+ if (requestId != null && !requestId.isEmpty() && isValidUUID(requestId)) {
+ return requestId;
+ }
+ if (requestId != null && !requestId.isEmpty()) {
+ //invalid
+ return UUID.randomUUID().toString();
+ }
+ logger.trace("No valid X-RequestID header value. Checking X-TransactionID header for requestId.");
+ requestId = headers.get(Constants.HttpHeaders.TRANSACTION_ID);
+ if (requestId != null && !requestId.isEmpty() && isValidUUID(requestId)) {
+ return requestId;
+ }
+ if (requestId != null && !requestId.isEmpty()) {
+ //invalid
+ return UUID.randomUUID().toString();
+ }
+ logger.trace("No valid X-TransactionID header value. Checking X-ECOMP-RequestID header for requestId.");
+ requestId = headers.get(Constants.HttpHeaders.ECOMP_REQUEST_ID);
+ if (requestId != null && !requestId.isEmpty() && isValidUUID(requestId)) {
+ return requestId;
+ }
+ if (requestId != null && !requestId.isEmpty()) {
+ //invalid
+ return UUID.randomUUID().toString();
+ }
+ return requestId;
+ }
+ protected boolean isValidUUID(String transId) {
+ try {
+ UUID.fromString(transId);
+ } catch (IllegalArgumentException e) {
+ return false;
+ }
+ return true;
+ }
+ public void setInvocationId(SimpleMap headers) {
+ String invocationId = headers.get(ONAPLogConstants.Headers.INVOCATION_ID);
+ if (invocationId == null || invocationId.isEmpty())
+ invocationId = UUID.randomUUID().toString();
+ MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId);
+ }
+
+ public void setInvocationIdFromMDC() {
+ String invocationId = MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID);
+ if (invocationId == null || invocationId.isEmpty())
+ invocationId = UUID.randomUUID().toString();
+ MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId);
+ }
+
+ public void setMDCPartnerName(SimpleMap headers) {
+ logger.trace("Checking X-ONAP-PartnerName header for partnerName.");
+ String partnerName = headers.get(ONAPLogConstants.Headers.PARTNER_NAME);
+ if (partnerName == null || partnerName.isEmpty()) {
+ logger.trace("No valid X-ONAP-PartnerName header value. Checking User-Agent header for partnerName.");
+ partnerName = headers.get(HttpHeaders.USER_AGENT);
+ if (partnerName == null || partnerName.isEmpty()) {
+ logger.trace("No valid User-Agent header value. Checking X-ClientID header for partnerName.");
+ partnerName = headers.get(Constants.HttpHeaders.CLIENT_ID);
+ if (partnerName == null || partnerName.isEmpty()) {
+ logger.trace("No valid partnerName headers. Defaulting partnerName to UNKNOWN.");
+ partnerName = Constants.DefaultValues.UNKNOWN;
+ }
+ }
+ }
+ MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName);
+ }
+
+ public void setLogTimestamp() {
+ MDC.put(ONAPLogConstants.MDCs.LOG_TIMESTAMP,
+ ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
+ }
+
+ public void setElapsedTime() {
+ DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
+ ZonedDateTime entryTimestamp =
+ ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP), timeFormatter);
+ ZonedDateTime endTimestamp = ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP), timeFormatter);
+
+ MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME,
+ Long.toString(ChronoUnit.MILLIS.between(entryTimestamp, endTimestamp)));
+ }
+
+ public void setElapsedTimeInvokeTimestamp() {
+ DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
+ ZonedDateTime entryTimestamp =
+ ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP), timeFormatter);
+ ZonedDateTime endTimestamp = ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP), timeFormatter);
+
+ MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME,
+ Long.toString(ChronoUnit.MILLIS.between(entryTimestamp, endTimestamp)));
+ }
+
+ public void setResponseStatusCode(int code) {
+ String statusCode;
+ if (Response.Status.Family.familyOf(code).equals(Response.Status.Family.SUCCESSFUL)) {
+ statusCode = ONAPLogConstants.ResponseStatus.COMPLETE.toString();
+ } else {
+ statusCode = ONAPLogConstants.ResponseStatus.ERROR.toString();
+ setErrorCode(code);
+ setErrorDesc(code);
+ }
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode);
+ }
+
+ public void setTargetEntity(ONAPComponentsList targetEntity) {
+ MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, targetEntity.toString());
+ }
+
+ public void clearClientMDCs() {
+ //MDC.remove(ONAPLogConstants.MDCs.INVOCATION_ID);
+ MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION);
+ MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE);
+ MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE);
+ MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY);
+ MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME);
+ MDC.remove(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP);
+ MDC.remove(ONAPLogConstants.MDCs.ERROR_CODE);
+ MDC.remove(ONAPLogConstants.MDCs.ERROR_DESC);
+ }
+
+ public void setResponseDescription(int statusCode) {
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION, Response.Status.fromStatusCode(statusCode).toString());
+ }
+
+ public void setErrorCode(int statusCode) {
+ MDC.put(ONAPLogConstants.MDCs.ERROR_CODE, String.valueOf(statusCode));
+ }
+
+ public void setErrorDesc(int statusCode) {
+ MDC.put(ONAPLogConstants.MDCs.ERROR_DESC, Response.Status.fromStatusCode(statusCode).toString());
+ }
+
+ public String getProperty(String property) {
+ logger.info("Checking for system property [{}]", property);
+ String propertyValue = System.getProperty(property);
+ if (propertyValue == null || propertyValue.isEmpty()) {
+ logger.info("System property was null or empty. Checking environment variable for: {}", property);
+ propertyValue = System.getenv(property);
+ if (propertyValue == null || propertyValue.isEmpty()) {
+ logger.info("Environment variable: {} was null or empty", property );
+ }
+ }
+ return propertyValue;
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MetricLogClientFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MetricLogClientFilter.java
new file mode 100644
index 00000000..da4d9827
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MetricLogClientFilter.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import javax.annotation.Priority;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.container.PreMatching;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.Providers;
+
+@Priority(0)
+public class MetricLogClientFilter
+ extends AbstractMetricLogFilter<ClientRequestContext, ClientResponseContext, MultivaluedMap<String, Object>>
+ implements ClientRequestFilter, ClientResponseFilter {
+
+ @Context
+ private Providers providers;
+
+ @Override
+ public void filter(ClientRequestContext clientRequest) {
+ pre(clientRequest, clientRequest.getHeaders());
+ }
+
+ @Override
+ public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) {
+ post(requestContext, responseContext);
+ }
+
+ @Override
+ protected void addHeader(MultivaluedMap<String, Object> requestHeaders, String headerName, String headerValue) {
+ requestHeaders.add(headerName, headerValue);
+ }
+
+ @Override
+ protected String getTargetServiceName(ClientRequestContext request) {
+ return request.getUri().toString();
+ }
+
+ @Override
+ protected String getServiceName(ClientRequestContext request) {
+ return request.getUri().getPath();
+ }
+
+ @Override
+ protected int getHttpStatusCode(ClientResponseContext response) {
+ return response.getStatus();
+ }
+
+ @Override
+ protected String getResponseCode(ClientResponseContext response) {
+ return String.valueOf(response.getStatus());
+ }
+
+ @Override
+ protected String getTargetEntity(ClientRequestContext request) {
+ return Constants.DefaultValues.UNKNOWN_TARGET_ENTITY;
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponents.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponents.java
new file mode 100644
index 00000000..06fbba9a
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponents.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+public enum ONAPComponents implements ONAPComponentsList {
+ OPENSTACK_ADAPTER,
+ BPMN,
+ GRM,
+ AAI,
+ DMAAP,
+ POLICY,
+ CATALOG_DB,
+ REQUEST_DB,
+ SNIRO,
+ SDC,
+ EXTERNAL,
+ VNF_ADAPTER,
+ SDNC_ADAPTER,
+ MULTICLOUD,
+ CLAMP,
+ PORTAL,
+ VID,
+ APPC,
+ DCAE,
+ HOLMES,
+ SDNC,
+ SO,
+ VFC,
+ ESR,
+ DBC,
+ DR,
+ MR,
+ OPTF;
+
+
+ public static Set<ONAPComponents> getSOInternalComponents() {
+ return EnumSet.of(OPENSTACK_ADAPTER, BPMN, CATALOG_DB, REQUEST_DB, VNF_ADAPTER, SDNC_ADAPTER);
+ }
+
+ public static Set<ONAPComponents> getDMAAPInternalComponents() {
+ return EnumSet.of(DBC, DR, MR);
+ }
+
+ public static Set<ONAPComponents> getAAIInternalComponents() {
+ return EnumSet.of(ESR);
+ }
+
+ @Override
+ public String toString() {
+ if (getSOInternalComponents().contains(this))
+ return SO + "." + this.name();
+ else if (getDMAAPInternalComponents().contains(this))
+ return DMAAP + "." + this.name();
+ else if (getAAIInternalComponents().contains(this))
+ return AAI + "." + this.name();
+ else
+ return this.name();
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponentsList.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponentsList.java
new file mode 100644
index 00000000..7ffc2517
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/ONAPComponentsList.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+public interface ONAPComponentsList {
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java
new file mode 100644
index 00000000..88c95aa4
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java
@@ -0,0 +1,162 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.client.ClientResponseContext;
+import javax.ws.rs.client.ClientResponseFilter;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.WriterInterceptor;
+import javax.ws.rs.ext.WriterInterceptorContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PayloadLoggingClientFilter implements ClientRequestFilter, ClientResponseFilter, WriterInterceptor {
+
+ private static final Logger logger = LoggerFactory.getLogger(PayloadLoggingClientFilter.class);
+ private static final String ENTITY_STREAM_PROPERTY = "LoggingFilter.entityStream";
+ private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
+ private final int maxEntitySize;
+
+ public PayloadLoggingClientFilter() {
+ maxEntitySize = 1024 * 1024;
+ }
+
+ public PayloadLoggingClientFilter(int maxPayloadSize) {
+ this.maxEntitySize = Integer.min(maxPayloadSize, 1024 * 1024);
+ }
+
+ protected InputStream logInboundEntity(final StringBuilder b, InputStream stream, final Charset charset)
+ throws IOException {
+ if (!stream.markSupported()) {
+ stream = new BufferedInputStream(stream);
+ }
+ stream.mark(maxEntitySize + 1);
+ final byte[] entity = new byte[maxEntitySize + 1];
+ final int entitySize = stream.read(entity);
+ if (entitySize != -1) {
+ b.append(new String(entity, 0, Math.min(entitySize, maxEntitySize), charset));
+ }
+ if (entitySize > maxEntitySize) {
+ b.append("...more...");
+ }
+ b.append('\n');
+ stream.reset();
+ return stream;
+ }
+
+ @Override
+ public void filter(ClientRequestContext requestContext) throws IOException {
+ if (requestContext.hasEntity()) {
+ final OutputStream stream = new LoggingStream(requestContext.getEntityStream());
+ requestContext.setEntityStream(stream);
+ requestContext.setProperty(ENTITY_STREAM_PROPERTY, stream);
+ }
+ String method = formatMethod(requestContext);
+ logger.debug("Sending HTTP {} to:{} with request headers:{}", method, requestContext.getUri(),
+ getHeaders(requestContext.getHeaders()));
+ }
+
+ protected String getHeaders(MultivaluedMap<String, Object> headers) {
+ MultivaluedMap<String, Object> printHeaders = new MultivaluedHashMap<>();
+ for (String header : headers.keySet()) {
+ if (!header.equals(HttpHeaders.AUTHORIZATION)) {
+ printHeaders.add(header, headers.getFirst(header));
+ } else {
+ printHeaders.add(header, Constants.REDACTED);;
+ }
+ }
+ return printHeaders.toString();
+ }
+
+ @Override
+ public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
+ String method = formatMethod(requestContext);
+ logger.debug("Response from method:{} performed on uri:{} has http status code:{} and response headers:{}",
+ method, requestContext.getUri(), responseContext.getStatus(), responseContext.getHeaders().toString());
+ if (responseContext.hasEntity()) {
+ final StringBuilder sb = new StringBuilder();
+ responseContext.setEntityStream(logInboundEntity(sb, responseContext.getEntityStream(), DEFAULT_CHARSET));
+ logger.debug(sb.toString());
+ }
+ }
+
+ @Override
+ public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
+ final LoggingStream stream = (LoggingStream) context.getProperty(ENTITY_STREAM_PROPERTY);
+ context.proceed();
+ if (stream != null) {
+ logger.debug(stream.getStringBuilder(DEFAULT_CHARSET).toString());
+ }
+ }
+
+ private class LoggingStream extends FilterOutputStream {
+
+ private final StringBuilder sb = new StringBuilder();
+ private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ LoggingStream(OutputStream out) {
+ super(out);
+ }
+
+ StringBuilder getStringBuilder(Charset charset) {
+ // write entity to the builder
+ final byte[] entity = baos.toByteArray();
+
+ sb.append(new String(entity, 0, entity.length, charset));
+ if (entity.length > maxEntitySize) {
+ sb.append("...more...");
+ }
+ sb.append('\n');
+
+ return sb;
+ }
+
+ @Override
+ public void write(final int i) throws IOException {
+ if (baos.size() <= maxEntitySize) {
+ baos.write(i);
+ }
+ out.write(i);
+ }
+ }
+
+ protected String formatMethod(ClientRequestContext requestContext) {
+ String httpMethodOverride = requestContext.getHeaderString("X-HTTP-Method-Override");
+ if (httpMethodOverride == null) {
+ return requestContext.getMethod();
+ } else {
+ return requestContext.getMethod() + " (overridden to " + httpMethodOverride + ")";
+ }
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingServletFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingServletFilter.java
new file mode 100644
index 00000000..fa8533a7
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/PayloadLoggingServletFilter.java
@@ -0,0 +1,330 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.zip.GZIPInputStream;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ReadListener;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.WriteListener;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+public class PayloadLoggingServletFilter extends AbstractServletFilter implements Filter {
+
+ private static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(PayloadLoggingServletFilter.class);
+
+ private static class ByteArrayServletStream extends ServletOutputStream {
+ ByteArrayOutputStream baos;
+
+ ByteArrayServletStream(ByteArrayOutputStream baos) {
+ this.baos = baos;
+ }
+
+ @Override
+ public void write(int param) throws IOException {
+ baos.write(param);
+ }
+
+ @Override
+ public boolean isReady() {
+ return true;
+ }
+
+ @Override
+ public void setWriteListener(WriteListener arg0) {
+ // this method does nothing
+ }
+ }
+
+ private static class ByteArrayPrintWriter extends PrintWriter {
+ private ByteArrayOutputStream baos;
+ private int errorCode = -1;
+ private String errorMsg = "";
+ private boolean errored = false;
+
+ public ByteArrayPrintWriter(ByteArrayOutputStream out) {
+ super(out);
+ this.baos = out;
+ }
+
+ public ServletOutputStream getStream() {
+ return new ByteArrayServletStream(baos);
+ }
+
+ public Boolean hasErrored() {
+ return errored;
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ public String getErrorMsg() {
+ return errorMsg;
+ }
+
+ public void setError(int code) {
+ errorCode = code;
+ errored = true;
+ }
+
+ public void setError(int code, String msg) {
+ errorMsg = msg;
+ errorCode = code;
+ errored = true;
+ }
+
+ }
+
+ private class BufferedServletInputStream extends ServletInputStream {
+ ByteArrayInputStream bais;
+
+ public BufferedServletInputStream(ByteArrayInputStream bais) {
+ this.bais = bais;
+ }
+
+ @Override
+ public int available() {
+ return bais.available();
+ }
+
+ @Override
+ public int read() {
+ return bais.read();
+ }
+
+ @Override
+ public int read(byte[] buf, int off, int len) {
+ return bais.read(buf, off, len);
+ }
+
+ @Override
+ public boolean isFinished() {
+ return available() < 1;
+ }
+
+ @Override
+ public boolean isReady() {
+ return true;
+ }
+
+ @Override
+ public void setReadListener(ReadListener arg0) {
+ // this method does nothing
+ }
+
+ }
+
+ private class BufferedRequestWrapper extends HttpServletRequestWrapper {
+ ByteArrayInputStream bais;
+ ByteArrayOutputStream baos;
+ BufferedServletInputStream bsis;
+ byte[] buffer;
+
+ public BufferedRequestWrapper(HttpServletRequest req) throws IOException {
+ super(req);
+
+ InputStream is = req.getInputStream();
+ baos = new ByteArrayOutputStream();
+ byte[] buf = new byte[1024];
+ int letti;
+ while ((letti = is.read(buf)) > 0) {
+ baos.write(buf, 0, letti);
+ }
+ buffer = baos.toByteArray();
+ }
+
+ @Override
+ public ServletInputStream getInputStream() {
+ try {
+ bais = new ByteArrayInputStream(buffer);
+ bsis = new BufferedServletInputStream(bais);
+ } catch (Exception ex) {
+ log.error("Exception in getInputStream", ex);
+ }
+ return bsis;
+ }
+
+ public byte[] getBuffer() {
+ return buffer;
+ }
+ }
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ // this method does nothing
+ }
+
+ @Override
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
+ throws IOException, ServletException {
+ final HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
+ BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest);
+
+ StringBuilder requestHeaders = new StringBuilder("REQUEST|");
+ requestHeaders.append(httpRequest.getMethod());
+ requestHeaders.append(":");
+ requestHeaders.append(httpRequest.getRequestURL().toString());
+ requestHeaders.append("|");
+ requestHeaders.append(getSecureRequestHeaders(httpRequest));
+ log.info(requestHeaders.toString());
+
+ log.info("REQUEST BODY|" + new String(bufferedRequest.getBuffer()));
+
+ final HttpServletResponse response = (HttpServletResponse) servletResponse;
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ByteArrayPrintWriter pw = new ByteArrayPrintWriter(baos);
+
+ HttpServletResponse wrappedResp = new HttpServletResponseWrapper(response) {
+ @Override
+ public PrintWriter getWriter() {
+ return pw;
+ }
+
+ @Override
+ public ServletOutputStream getOutputStream() {
+ return pw.getStream();
+ }
+
+ @Override
+ public void sendError(int sc) throws IOException {
+ super.sendError(sc);
+ pw.setError(sc);
+
+ }
+
+ @Override
+ public void sendError(int sc, String msg) throws IOException {
+ super.sendError(sc, msg);
+ pw.setError(sc, msg);
+ }
+ };
+
+ try {
+ filterChain.doFilter(bufferedRequest, wrappedResp);
+ } catch (Exception e) {
+ log.error("Chain Exception", e);
+ throw e;
+ } finally {
+ try {
+ byte[] bytes = baos.toByteArray();
+ StringBuilder responseHeaders = new StringBuilder("RESPONSE HEADERS|");
+ responseHeaders.append(formatResponseHeaders(response));
+ responseHeaders.append("Status:");
+ responseHeaders.append(response.getStatus());
+ responseHeaders.append(";IsCommited:" + wrappedResp.isCommitted());
+
+ log.info(responseHeaders.toString());
+
+ if ("gzip".equals(response.getHeader("Content-Encoding"))) {
+ log.info("UNGZIPED RESPONSE BODY|" + decompressGZIPByteArray(bytes));
+ } else {
+ log.info("RESPONSE BODY|" + new String(bytes));
+ }
+
+ if (pw.hasErrored()) {
+ log.info("ERROR RESPONSE|" + pw.getErrorCode() + ":" + pw.getErrorMsg());
+ } else {
+ if (!wrappedResp.isCommitted()) {
+ response.getOutputStream().write(bytes);
+ response.getOutputStream().flush();
+ }
+ }
+ } catch (Exception e) {
+ log.error("Exception in response filter", e);
+ }
+ }
+ }
+
+ @Override
+ public void destroy() {
+ // this method does nothing
+ }
+
+ private String decompressGZIPByteArray(byte[] bytes) {
+ BufferedReader in = null;
+ InputStreamReader inR = null;
+ ByteArrayInputStream byteS = null;
+ GZIPInputStream gzS = null;
+ StringBuilder str = new StringBuilder();
+ try {
+ byteS = new ByteArrayInputStream(bytes);
+ gzS = new GZIPInputStream(byteS);
+ inR = new InputStreamReader(gzS);
+ in = new BufferedReader(inR);
+
+ if (in != null) {
+ String content;
+ while ((content = in.readLine()) != null) {
+ str.append(content);
+ }
+ }
+
+ } catch (Exception e) {
+ log.error("Failed get read GZIPInputStream", e);
+ } finally {
+ if (byteS != null)
+ try {
+ byteS.close();
+ } catch (IOException e1) {
+ log.error("Failed to close ByteStream", e1);
+ }
+ if (gzS != null)
+ try {
+ gzS.close();
+ } catch (IOException e2) {
+ log.error("Failed to close GZStream", e2);
+ }
+ if (inR != null)
+ try {
+ inR.close();
+ } catch (IOException e3) {
+ log.error("Failed to close InputReader", e3);
+ }
+ if (in != null)
+ try {
+ in.close();
+ } catch (IOException e) {
+ log.error("Failed to close BufferedReader", e);
+ }
+ }
+ return str.toString();
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleHashMap.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleHashMap.java
new file mode 100644
index 00000000..1e9cedb7
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleHashMap.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import java.util.HashMap;
+
+public class SimpleHashMap implements SimpleMap {
+ private HashMap<String, String> map;
+
+ public SimpleHashMap(HashMap<String, String> map) {
+ this.map = map;
+ }
+
+ @Override
+ public String get(String key) {
+ return map.get(key);
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMap.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMap.java
new file mode 100644
index 00000000..50074782
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMap.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import javax.ws.rs.core.MultivaluedMap;
+
+public class SimpleJaxrsHeadersMap implements SimpleMap {
+ MultivaluedMap<String, String> map;
+
+ public SimpleJaxrsHeadersMap(MultivaluedMap<String, String> map) {
+ this.map = map;
+ }
+
+ @Override
+ public String get(String key) {
+ return map.getFirst(key);
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleMap.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleMap.java
new file mode 100644
index 00000000..9543721f
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleMap.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+public interface SimpleMap {
+ String get(String key);
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleServletHeadersMap.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleServletHeadersMap.java
new file mode 100644
index 00000000..e6a91fbe
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/SimpleServletHeadersMap.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - Logging
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.filter.base;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class SimpleServletHeadersMap implements SimpleMap {
+ private HttpServletRequest request;
+
+ public SimpleServletHeadersMap(HttpServletRequest request) {
+ this.request = request;
+ }
+
+ @Override
+ public String get(String key) {
+ return request.getHeader(key);
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogAdapter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogAdapter.java
new file mode 100644
index 00000000..aafc74d4
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogAdapter.java
@@ -0,0 +1,616 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j;
+
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.UUID;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.MDC;
+import org.slf4j.Marker;
+import org.slf4j.event.Level;
+
+/**
+ * Extensible adapter for cheaply meeting ONAP logging obligations using
+ * an SLF4J facade.
+ *
+ * <p>This can be used with any SLF4J-compatible logging provider, with
+ * appropriate provider configuration.</p>
+ *
+ * <p>The basics are that:
+ * <ul>
+ * <li>{@link #entering} sets all MDCs.</li>
+ * <li>{@link #exiting} unsets all MDCs *and* logs response information.</li>
+ * <li>{@link #invoke} logs and returns a UUID to passed during invocation,
+ * and optionally sets these for you on your downstream request by way of
+ * an adapter.</li>
+ * <li>Call {@link #getServiceDescriptor()} and its setters to set service-related MDCs.</li>
+ * <li>Call {@link #getResponseDescriptor()} and its setters to set response-related MDCs.</li>
+ * </ul>
+ * </p>
+ *
+ * <p>Minimal usage is:
+ * <ol>
+ * <li>#entering(RequestAdapter)</li>
+ * <li>#invoke, #invoke, ...</li>
+ * <li>#getResponse + setters (or #setResponse)</li>
+ * <li>#exiting</li>
+ * </ol>
+ * </p>
+ *
+ * <p> ... if you're happy for service information to be automatically derived as follows:
+ * <ul>
+ * <li><tt>ServiceName</tt> - from <tt>HttpServletRequest#getRequestURI()</tt></li>
+ * <li><tt>InstanceUUID</tt> - classloader-scope UUID.</li>
+ * </ul>
+ * </p>
+ *
+ * <p>... and if those defaults don't suit, then you can override using properties on
+ * {@link #getServiceDescriptor()}, or by injecting your own adapter using
+ * {@link #setServiceDescriptor(ServiceDescriptor)}, or by overriding
+ * a <tt>protected</tt> methods like{@link #setEnteringMDCs}.</p>
+ *
+ * <p>For everything else:
+ * <ul>
+ * <li>The underlying SLF4J {@link Logger} can be retrieved using {@link #unwrap}.
+ * Use this or create your own using the usual SLF4J factor.</li>
+ * <li>Set whatever MDCs you like.</li>
+ * <li>Log whatever else you like.</li>
+ * </ul>
+ * </p>
+ */
+public class ONAPLogAdapter {
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Constants.
+ //
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /** String constant for messages <tt>ENTERING</tt>, <tt>EXITING</tt>, etc. */
+ private static final String EMPTY_MESSAGE = "";
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Fields.
+ //
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /** Automatic UUID, overrideable per adapter or per invocation. */
+ private static UUID sInstanceUUID = UUID.randomUUID();
+
+ /** Logger delegate. */
+ private Logger mLogger;
+
+ /** Overrideable descriptor for the service doing the logging. */
+ private ServiceDescriptor mServiceDescriptor = new ServiceDescriptor();
+
+ /** Overrideable descriptor for the response returned by the service doing the logging. */
+ private ResponseDescriptor mResponseDescriptor = new ResponseDescriptor();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Constructors.
+ //
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Construct adapter.
+ *
+ * @param logger non-null logger.
+ */
+ public ONAPLogAdapter(final Logger logger) {
+ this.mLogger = checkNotNull(logger);
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Public methods.
+ //
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Get logger.
+ *
+ * @return unwrapped logger.
+ */
+ public Logger unwrap() {
+ return this.mLogger;
+ }
+
+ /**
+ * Report <tt>ENTERING</tt> marker.
+ *
+ * @param request non-null incoming request (wrapper).
+ * @return this.
+ */
+ public ONAPLogAdapter entering(final RequestAdapter request) {
+
+ checkNotNull(request);
+
+ // Default the service name.
+
+ this.setEnteringMDCs(request);
+ this.mLogger.info(ONAPLogConstants.Markers.ENTRY, EMPTY_MESSAGE);
+
+ return this;
+ }
+
+ /**
+ * Report <tt>ENTERING</tt> marker.
+ *
+ * @param request non-null incoming request.
+ * @return this.
+ */
+ public ONAPLogAdapter entering(final HttpServletRequest request) {
+ return this.entering(new HttpServletRequestAdapter(checkNotNull(request)));
+ }
+
+ /**
+ * Report <tt>EXITING</tt> marker.
+ *
+ * @return this.
+ */
+ public ONAPLogAdapter exiting() {
+ try {
+ this.mResponseDescriptor.setMDCs();
+ this.mLogger.info(ONAPLogConstants.Markers.EXIT, EMPTY_MESSAGE);
+ }
+ finally {
+ MDC.clear();
+ }
+ return this;
+ }
+
+ /**
+ * Report pending invocation with <tt>INVOKE</tt> marker.
+ *
+ * <p>If you call this variant, then YOU are assuming responsibility for
+ * setting the requisite ONAP headers.</p>
+ *
+ * @param sync whether synchronous.
+ * @return invocation ID to be passed with invocation.
+ */
+ public UUID invoke(final ONAPLogConstants.InvocationMode sync) {
+
+ final UUID invocationID = UUID.randomUUID();
+
+ // Derive SYNC/ASYNC marker.
+
+ final Marker marker = (sync == null) ? ONAPLogConstants.Markers.INVOKE : sync.getMarker();
+
+ // Log INVOKE*, with the invocationID as the message body.
+ // (We didn't really want this kind of behavior in the standard,
+ // but is it worse than new, single-message MDC?)
+
+ this.mLogger.info(marker, "{}", invocationID);
+ return invocationID;
+ }
+
+ /**
+ * Report pending invocation with <tt>INVOKE</tt> marker,
+ * setting standard ONAP logging headers automatically.
+ *
+ * @param builder request builder, for setting headers.
+ * @param sync whether synchronous, nullable.
+ * @return invocation ID to be passed with invocation.
+ */
+ public UUID invoke(final RequestBuilder builder,
+ final ONAPLogConstants.InvocationMode sync) {
+
+ // Sync can be defaulted. Builder cannot.
+
+ checkNotNull(builder);
+
+ // Log INVOKE, and retain invocation ID for header + return.
+
+ final UUID invocationID = this.invoke(sync);
+
+ // Set standard HTTP headers on (southbound request) builder.
+
+ builder.setHeader(ONAPLogConstants.Headers.REQUEST_ID,
+ defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.REQUEST_ID)));
+ builder.setHeader(ONAPLogConstants.Headers.INVOCATION_ID,
+ defaultToEmpty(invocationID));
+ builder.setHeader(ONAPLogConstants.Headers.PARTNER_NAME,
+ defaultToEmpty(MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME)));
+
+ return invocationID;
+ }
+
+ /**
+ * Report vanilla <tt>INVOKE</tt> marker.
+ *
+ * @param builder builder for downstream requests, if you want the
+ * standard ONAP headers to be added automatically.
+ * @return invocation ID to be passed with invocation.
+ */
+ public UUID invoke(final RequestBuilder builder) {
+ return this.invoke(builder, (ONAPLogConstants.InvocationMode)null);
+ }
+
+ /**
+ * Get descriptor, for overriding service details.
+ * @return non-null descriptor.
+ */
+ public ServiceDescriptor getServiceDescriptor() {
+ return checkNotNull(this.mServiceDescriptor);
+ }
+
+ /**
+ * Override {@link ServiceDescriptor}.
+ * @param d non-null override.
+ * @return this.
+ */
+ public ONAPLogAdapter setServiceDescriptor(final ServiceDescriptor d) {
+ this.mServiceDescriptor = checkNotNull(d);
+ return this;
+ }
+
+ /**
+ * Get descriptor, for setting response details.
+ * @return non-null descriptor.
+ */
+ public ResponseDescriptor getResponseDescriptor() {
+ return checkNotNull(this.mResponseDescriptor);
+ }
+
+ /**
+ * Override {@link ResponseDescriptor}.
+ * @param d non-null override.
+ * @return this.
+ */
+ public ONAPLogAdapter setResponseDescriptor(final ResponseDescriptor d) {
+ this.mResponseDescriptor = checkNotNull(d);
+ return this;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Protected methods.
+ //
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Set MDCs that persist for the duration of an invocation.
+ *
+ * <p>It would be better to roll this into {@link #entering}, like
+ * with {@link #exiting}. Then it would be easier to do, but it
+ * would mean more work. </p>
+ *
+ * @param request incoming HTTP request.
+ * @return this.
+ */
+ protected ONAPLogAdapter setEnteringMDCs(final RequestAdapter<?> request) {
+
+ // Extract MDC values from standard HTTP headers.
+
+ final String requestID = defaultToUUID(request.getHeader(ONAPLogConstants.Headers.REQUEST_ID));
+ final String invocationID = defaultToUUID(request.getHeader(ONAPLogConstants.Headers.INVOCATION_ID));
+ final String partnerName = defaultToEmpty(request.getHeader(ONAPLogConstants.Headers.PARTNER_NAME));
+
+ // Set standard MDCs. Override this entire method if you want to set
+ // others, OR set them BEFORE or AFTER the invocation of #entering,
+ // depending on where you need them to appear, OR extend the
+ // ServiceDescriptor to add them.
+
+ MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP,
+ ZonedDateTime.now(ZoneOffset.UTC)
+ .format(DateTimeFormatter.ISO_INSTANT));
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestID);
+ MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationID);
+ MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName);
+ MDC.put(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS, defaultToEmpty(request.getClientAddress()));
+ MDC.put(ONAPLogConstants.MDCs.SERVER_FQDN, defaultToEmpty(request.getServerAddress()));
+
+ // Delegate to the service adapter, for service-related DMCs.
+
+ this.mServiceDescriptor.setMDCs();
+
+ // Default the service name to the requestURI, in the event that
+ // no value has been provided.
+
+ if (MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME) == null ||
+ MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME).equalsIgnoreCase(EMPTY_MESSAGE)) {
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, request.getRequestURI());
+ }
+
+ return this;
+ }
+
+ /**
+ * Dependency-free nullcheck.
+ *
+ * @param in to be checked.
+ * @param <T> argument (and return) type.
+ * @return input arg.
+ */
+ protected static <T> T checkNotNull(final T in) {
+ if (in == null) {
+ throw new NullPointerException();
+ }
+ return in;
+ }
+
+ /**
+ * Dependency-free string default.
+ *
+ * @param in to be filtered.
+ * @return input string or null.
+ */
+ protected static String defaultToEmpty(final Object in) {
+ if (in == null) {
+ return "";
+ }
+ return in.toString();
+ }
+
+ /**
+ * Dependency-free string default.
+ *
+ * @param in to be filtered.
+ * @return input string or null.
+ */
+ protected static String defaultToUUID(final String in) {
+ if (in == null) {
+ return UUID.randomUUID().toString();
+ }
+ return in;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Inner classes.
+ //
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Extensible descriptor for reporting service details.
+ *
+ * <p>In most cases extension isn't required. </p>
+ */
+ public static class ServiceDescriptor {
+
+ /** <tt>ServiceName</tt>. */
+ protected String mName;
+
+ /** <tt>InstanceUUID</tt>. */
+ protected String mUUID = sInstanceUUID.toString();
+
+ /**
+ * Set name.
+ * @param name <tt>ServiceName</tt>.
+ * @return this.
+ */
+ public ServiceDescriptor setServiceName(final String name) {
+ this.mName = name;
+ return this;
+ }
+
+ /**
+ * Set name.
+ * @param uuid <tt>InstanceUUID</tt>.
+ * @return this.
+ */
+ public ServiceDescriptor setServiceUUID(final String uuid) {
+ this.mUUID = uuid;
+ return this;
+ }
+
+ /**
+ * Set MDCs. Once set they remain set until everything is cleared.
+ */
+ protected void setMDCs() {
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, defaultToEmpty(this.mName));
+ MDC.put(ONAPLogConstants.MDCs.INSTANCE_UUID, defaultToEmpty(this.mUUID));
+ }
+ }
+
+ /**
+ * Response is different in that response MDCs are normally only
+ * reported once, for a single log message. (But there's no method
+ * for clearing them, because this is only expected to be called
+ * during <tt>#exiting</tt>.)
+ */
+ public static class ResponseDescriptor {
+
+ /** Response errorcode. */
+ protected String mCode;
+
+ /** Response description. */
+ protected String mDescription;
+
+ /** Response severity. */
+ protected Level mSeverity;
+
+ /** Response status, of {<tt>COMPLETED</tt>, <tt>ERROR</tt>}. */
+ protected ONAPLogConstants.ResponseStatus mStatus;
+
+ /**
+ * Setter.
+ *
+ * @param code response (error) code.
+ * @return this.
+ */
+ public ResponseDescriptor setResponseCode(final String code) {
+ this.mCode = code;
+ return this;
+ }
+
+ /**
+ * Setter.
+ *
+ * @param description response description.
+ * @return this.
+ */
+ public ResponseDescriptor setResponseDescription(final String description) {
+ this.mDescription = description;
+ return this;
+ }
+
+ /**
+ * Setter.
+ *
+ * @param severity response outcome severity.
+ * @return this.
+ */
+ public ResponseDescriptor setResponseSeverity(final Level severity) {
+ this.mSeverity = severity;
+ return this;
+ }
+
+ /**
+ * Setter.
+ *
+ * @param status response overall status.
+ * @return this.
+ */
+ public ResponseDescriptor setResponseStatus(final ONAPLogConstants.ResponseStatus status) {
+ this.mStatus = status;
+ return this;
+ }
+
+ /**
+ * Overrideable method to set MDCs based on property values.
+ */
+ protected void setMDCs() {
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, defaultToEmpty(this.mCode));
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION, defaultToEmpty(this.mDescription));
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_SEVERITY, defaultToEmpty(this.mSeverity));
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, defaultToEmpty(this.mStatus));
+ }
+ }
+
+ /**
+ * Adapter for reading information from an incoming HTTP request.
+ *
+ * <p>Incoming is generally easy, because in most cases you'll be able to
+ * get your hands on the <tt>HttpServletRequest</tt>.</p>
+ *
+ * <p>Perhaps should be generalized to refer to constants instead of
+ * requiring the implementation of specific methods.</p>
+ *
+ * @param <T> type, for chaining.
+ */
+ public interface RequestAdapter<T extends RequestAdapter> {
+
+ /**
+ * Get header by name.
+ * @param name header name.
+ * @return header value, or null.
+ */
+ String getHeader(String name);
+
+ /**
+ * Get client address.
+ * @return address, if available.
+ */
+ String getClientAddress();
+
+ /**
+ * Get server address.
+ * @return address, if available.
+ */
+ String getServerAddress();
+
+ /**
+ * Get default service name, from service URI.
+ * @return service name default.
+ */
+ String getRequestURI();
+ }
+
+ /**
+ * Default {@link RequestBuilder} impl for {@link HttpServletRequest}, which
+ * will should available for most incoming REST requests.
+ */
+ public static class HttpServletRequestAdapter implements RequestAdapter<HttpServletRequestAdapter> {
+
+ /** Wrapped HTTP request. */
+ private final HttpServletRequest mRequest;
+
+ /**
+ * Construct adapter for HTTP request.
+ * @param request to be wrapped;
+ */
+ public HttpServletRequestAdapter(final HttpServletRequest request) {
+ this.mRequest = checkNotNull(request);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getHeader(final String name) {
+ return this.mRequest.getHeader(name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getClientAddress() {
+ return this.mRequest.getRemoteAddr();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getServerAddress() {
+ return this.mRequest.getServerName();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getRequestURI() {
+ return this.mRequest.getRequestURI();
+ }
+ }
+
+ /**
+ * Header builder, which (unlike {@link RequestAdapter} will tend to
+ * vary a lot from caller to caller, since they each get to choose their
+ * own REST (or HTTP, or whatever) client APIs.
+ *
+ * <p>No default implementation, because there's no HTTP client that's
+ * sufficiently ubiquitous to warrant incurring a mandatory dependency.</p>
+ *
+ * @param <T> type, for chaining.
+ */
+ public interface RequestBuilder<T extends RequestBuilder> {
+
+ /**
+ * Set HTTP header.
+ * @param name header name.
+ * @param value header value.
+ * @return this.
+ */
+ T setHeader(String name, String value);
+ }
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java
new file mode 100644
index 00000000..77ca084d
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/ONAPLogConstants.java
@@ -0,0 +1,289 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j;
+
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+
+/**
+ * Constants for standard ONAP headers, MDCs, etc.
+ *
+ * <p>See <tt>package-info.java</tt>.</p>
+ */
+public final class ONAPLogConstants {
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Constructors.
+ //
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Hide and forbid construction.
+ */
+ private ONAPLogConstants() {
+ throw new UnsupportedOperationException();
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Inner classes.
+ //
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Marker constants.
+ */
+ public static final class Markers {
+
+ /** Marker reporting invocation. */
+ public static final Marker INVOKE = MarkerFactory.getMarker("INVOKE");
+
+ /** Marker reporting invocation return. */
+ public static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE_RETURN");
+
+ /** Marker reporting synchronous invocation. */
+ public static final Marker INVOKE_SYNCHRONOUS = build("INVOKE", "SYNCHRONOUS");
+
+ /** Marker reporting asynchronous invocation. */
+ public static final Marker INVOKE_ASYNCHRONOUS = build("INVOKE", "ASYNCHRONOUS");
+
+ /** Marker reporting entry into a component. */
+ public static final Marker ENTRY = MarkerFactory.getMarker("ENTRY");
+
+ /** Marker reporting exit from a component. */
+ public static final Marker EXIT = MarkerFactory.getMarker("EXIT");
+
+ /**
+ * Build nested, detached marker.
+ * @param m1 top token.
+ * @param m2 sub-token.
+ * @return detached Marker.
+ */
+ private static Marker build(final String m1, final String m2) {
+ final Marker marker = MarkerFactory.getDetachedMarker(m1);
+ marker.add(MarkerFactory.getDetachedMarker(m2));
+ return marker;
+ }
+
+ /**
+ * Hide and forbid construction.
+ */
+ private Markers() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ * MDC name constants.
+ */
+ public static final class MDCs {
+
+ // Tracing. ////////////////////////////////////////////////////////////
+
+ /** MDC correlating messages for an invocation. */
+ public static final String INVOCATION_ID = "InvocationID";
+
+ /** MDC correlating messages for a logical transaction. */
+ public static final String REQUEST_ID = "RequestID";
+
+ /** MDC recording calling partner name. */
+ public static final String PARTNER_NAME = "PartnerName";
+
+ /** MDC recording current service. */
+ public static final String SERVICE_NAME = "ServiceName";
+
+ /** MDC recording target service. */
+ public static final String TARGET_SERVICE_NAME = "TargetServiceName";
+
+ /** MDC recording target entity. */
+ public static final String TARGET_ENTITY = "TargetEntity";
+
+ /** MDC recording target element. */
+ public static final String TARGET_ELEMENT = "TargetElement";
+
+ /** MDC recording current service instance id. */
+ public static final String SERVICE_INSTANCE_ID = "ServiceInstanceID";
+
+ /** MDC recording current instance id. */
+ public static final String INSTANCE_UUID = "InstanceID";
+
+ // Network. ////////////////////////////////////////////////////////////
+
+ /** MDC recording caller address. */
+ public static final String CLIENT_IP_ADDRESS = "ClientIPAddress";
+
+ /** MDC recording server IP address. */
+ public static final String SERVER_IP_ADDRESS = "ServerIPAddress";
+
+ /** MDC recording server FQDN. */
+ public static final String SERVER_FQDN = "ServerFQDN";
+
+ /** MDC recording virtual server name. */
+ public static final String VIRTUAL_SERVER_NAME = "VirtualServerName";
+
+ /** MDC recording context name. */
+ public static final String CONTEXT_NAME = "ContextName";
+
+ /**
+ * MDC recording timestamp at the start of the current request,
+ * with the same scope as {@link #REQUEST_ID}.
+ *
+ * <p>Open issues:
+ * <ul>
+ * <ul>Easily confused with {@link #INVOKE_TIMESTAMP}.</ul>
+ * <ul>No mechanism for propagation between components, e.g. via HTTP headers.</ul>
+ * <ul>Whatever mechanism we define, it's going to be costly.</ul>
+ * </ul>
+ * </p>
+ * */
+ public static final String ENTRY_TIMESTAMP = "EntryTimestamp";
+
+ /** MDC recording timestamp at the start of the current invocation. */
+ public static final String INVOKE_TIMESTAMP = "InvokeTimestamp";
+
+ /** MDC recording elapsed time. */
+ public static final String ELAPSED_TIME = "ElapsedTime";
+
+ /** MDC recording log timestamp. */
+ public static final String LOG_TIMESTAMP = "LogTimestamp";
+
+ // Outcomes. ///////////////////////////////////////////////////////////
+
+ /** MDC reporting outcome code. */
+ public static final String RESPONSE_CODE = "ResponseCode";
+
+ /** MDC reporting outcome description. */
+ public static final String RESPONSE_DESCRIPTION = "ResponseDesc";
+
+ /** MDC reporting severity */
+ public static final String RESPONSE_SEVERITY = "Severity";
+
+ /** MDC reporting response status code */
+ public static final String RESPONSE_STATUS_CODE = "StatusCode";
+
+ /** MDC recording error code. */
+ public static final String ERROR_CODE = "ErrorCode";
+
+ /** MDC recording error description. */
+ public static final String ERROR_DESC = "ErrorDesc";
+
+ // Unsorted. ///////////////////////////////////////////////////////////
+
+ /**
+ * Hide and forbid construction.
+ */
+ private MDCs() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ * Header name constants.
+ */
+ public static final class Headers {
+
+ /** HTTP <tt>X-ONAP-RequestID</tt> header. */
+ public static final String REQUEST_ID = "X-ONAP-RequestID";
+
+ /** HTTP <tt>X-ONAP-InvocationID</tt> header. */
+ public static final String INVOCATION_ID = "X-ONAP-InvocationID";
+
+ /** HTTP <tt>X-ONAP-PartnerName</tt> header. */
+ public static final String PARTNER_NAME = "X-ONAP-PartnerName";
+
+ /**
+ * Hide and forbid construction.
+ */
+ private Headers() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Enums.
+ //
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Response success or not, for setting <tt>StatusCode</tt>.
+ */
+ public enum ResponseStatus {
+
+ /** Success. */
+ COMPLETE,
+
+ /** Not. */
+ ERROR,
+
+ /** In Progress. */
+ INPROGRESS
+ }
+
+ /**
+ * Synchronous or asynchronous execution, for setting invocation marker.
+ */
+ public enum InvocationMode {
+
+ /** Synchronous, blocking. */
+ SYNCHRONOUS("SYNCHRONOUS", Markers.INVOKE_SYNCHRONOUS),
+
+ /** Asynchronous, non-blocking. */
+ ASYNCHRONOUS("ASYNCHRONOUS", Markers.INVOKE_ASYNCHRONOUS);
+
+ /** Enum value. */
+ private String mString;
+
+ /** Corresponding marker. */
+ private Marker mMarker;
+
+ /**
+ * Construct enum.
+ *
+ * @param s enum value.
+ * @param m corresponding Marker.
+ */
+ InvocationMode(final String s, final Marker m) {
+ this.mString = s;
+ this.mMarker = m;
+ }
+
+ /**
+ * Get Marker for enum.
+ *
+ * @return Marker.
+ */
+ public Marker getMarker() {
+ return this.mMarker;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return this.mString;
+ }
+ }
+
+}
diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/package-info.java b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/package-info.java
new file mode 100644
index 00000000..d9a62472
--- /dev/null
+++ b/aai-els-onap-logging/src/main/java/org/onap/logging/ref/slf4j/package-info.java
@@ -0,0 +1,32 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j;
+
+/**
+ * <p>Code in here has potential application outside this reference
+ * example, and accordingly:
+ * <ul>
+ * <li>Packaged in <tt>common</tt>.</li>
+ * <li>Has minimal dependencies.</li>
+ * </ul>
+ * </p>
+ */ \ No newline at end of file
diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/MapperUtilTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/MapperUtilTest.java
new file mode 100644
index 00000000..14d80020
--- /dev/null
+++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/MapperUtilTest.java
@@ -0,0 +1,91 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright © 2018 IBM.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.json.JSONObject;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class MapperUtilTest {
+
+ private JSONObject expectedJson;
+ private JSONObject sampleJson;
+
+ @Before
+ public void setup() {
+ expectedJson = new JSONObject();
+ sampleJson = new JSONObject();
+ }
+
+ @Test
+ public void writeAsJSONStringTest() throws Exception {
+ expectedJson.put("color", "black");
+ expectedJson.put("shape", "box");
+ SampleClass sample = new SampleClass("black", "box");
+ Assert.assertEquals(expectedJson.toString(), MapperUtil.writeAsJSONString(sample));
+ }
+
+ @Test
+ public void readAsObjectOfTest() throws Exception {
+ sampleJson.put("color", "black");
+ sampleJson.put("shape", "box");
+ SampleClass expectedObject = new SampleClass("black", "box");
+ SampleClass actualObject = MapperUtil.readAsObjectOf(SampleClass.class, sampleJson.toString());
+ assertEquals(expectedObject.getColor(), actualObject.getColor());
+ assertEquals(expectedObject.getShape(), actualObject.getShape());
+ }
+}
+
+
+class SampleClass {
+ private String color;
+ private String shape;
+
+ public SampleClass() {
+
+ }
+
+ public SampleClass(String c, String s) {
+ color = c;
+ shape = s;
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+ public void setColor(String color) {
+ this.color = color;
+ }
+
+ public String getShape() {
+ return shape;
+ }
+
+ public void setShape(String shape) {
+ this.shape = shape;
+ }
+}