diff options
Diffstat (limited to 'src/main')
3 files changed, 38 insertions, 7 deletions
diff --git a/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java b/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java index f07d0d3..805fe34 100644 --- a/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java +++ b/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 European Software Marketing Ltd. + * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2019 European Software Marketing Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.modelloader.restclient; import com.google.gson.Gson; @@ -38,6 +39,8 @@ import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import java.util.Base64; import java.util.Collections; import java.util.List; @@ -52,8 +55,12 @@ import javax.ws.rs.core.Response; import org.json.JSONException; import org.json.JSONObject; import org.onap.aai.babel.service.data.BabelArtifact; +import org.onap.aai.cl.api.LogFields; +import org.onap.aai.cl.api.LogLine; import org.onap.aai.cl.api.Logger; import org.onap.aai.cl.eelf.LoggerFactory; +import org.onap.aai.cl.mdc.MdcContext; +import org.onap.aai.cl.mdc.MdcOverride; import org.onap.aai.modelloader.config.ModelLoaderConfig; import org.onap.aai.modelloader.service.ModelLoaderMsgs; @@ -64,6 +71,9 @@ import org.onap.aai.modelloader.service.ModelLoaderMsgs; public class HttpsBabelServiceClient implements BabelServiceClient { private static final Logger logger = LoggerFactory.getInstance().getLogger(HttpsBabelServiceClient.class); + private static final Logger metricsLogger = + LoggerFactory.getInstance().getMetricsLogger(HttpsBabelServiceClient.class); + private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); private static final String SSL_PROTOCOL = "TLS"; private static final String KEYSTORE_ALGORITHM = "SunX509"; @@ -156,7 +166,7 @@ public class HttpsBabelServiceClient implements BabelServiceClient { public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { try { finalLocalTm.checkServerTrusted(chain, authType); - } catch (CertificateException e) { + } catch (CertificateException e) { // NOSONAR defaultTrustManager.checkServerTrusted(chain, authType); } } @@ -209,6 +219,9 @@ public class HttpsBabelServiceClient implements BabelServiceClient { + " Artifact version: " + artifactVersion + " Artifact payload: " + encodedPayload); } + MdcOverride override = new MdcOverride(); + override.addAttribute(MdcContext.MDC_START_TIME, ZonedDateTime.now().format(formatter)); + WebResource webResource = client.resource(config.getBabelBaseUrl() + config.getBabelGenerateArtifactsUrl()); ClientResponse response = webResource.type("application/json") .header(AaiRestClient.HEADER_TRANS_ID, Collections.singletonList(transactionId)) @@ -221,6 +234,15 @@ public class HttpsBabelServiceClient implements BabelServiceClient { "Babel response " + response.getStatus() + " " + sanitizedJson); } + metricsLogger.info(ModelLoaderMsgs.BABEL_REST_REQUEST, new LogFields() // + .setField(LogLine.DefinedFields.TARGET_ENTITY, "Babel") + .setField(LogLine.DefinedFields.STATUS_CODE, + Response.Status.fromStatusCode(response.getStatus()).getFamily() + .equals(Response.Status.Family.SUCCESSFUL) ? "COMPLETE" : "ERROR") + .setField(LogLine.DefinedFields.RESPONSE_CODE, response.getStatus()) + .setField(LogLine.DefinedFields.RESPONSE_DESCRIPTION, response.getStatusInfo().toString()), // + override, response.toString()); + if (response.getStatus() != Response.Status.OK.getStatusCode()) { throw new BabelServiceClientException(sanitizedJson); } diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderMsgs.java b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderMsgs.java index 26a9efa..a73d053 100644 --- a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderMsgs.java +++ b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderMsgs.java @@ -86,7 +86,12 @@ public enum ModelLoaderMsgs implements LogMessageEnum { ARTIFACT_PARSE_ERROR, /** - * Arguments: {0} = info request payload. + * Arguments: {0} = info request for metrics. + **/ + BABEL_REST_REQUEST, + + /** + * Arguments: {0} = info request details. **/ BABEL_REST_REQUEST_PAYLOAD, diff --git a/src/main/resources/org/onap/aai/modelloader/service/ModelLoaderMsgs.properties b/src/main/resources/org/onap/aai/modelloader/service/ModelLoaderMsgs.properties index d337915..b4aadf5 100644 --- a/src/main/resources/org/onap/aai/modelloader/service/ModelLoaderMsgs.properties +++ b/src/main/resources/org/onap/aai/modelloader/service/ModelLoaderMsgs.properties @@ -2,8 +2,8 @@ # ============LICENSE_START==========================================
# org.onap.aai
# ===================================================================
-# Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
-# Copyright © 2017-2018 European Software Marketing Ltd.
+# Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2019 European Software Marketing Ltd.
# ===================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -98,7 +98,11 @@ AAI_REST_REQUEST_PAYLOAD=\ UNSUPPORTED_ARTIFACT_TYPE=\
MDLSVC0011I|\
The downloaded artifact: {0} has an unsupported type of: {1}|\
-
+
+BABEL_REST_REQUEST=\
+ MDLSVC0012I|\
+ {0}|\
+
# ERROR Level Logs
ASDC_CONNECTION_ERROR=\
MDLSVC2001E|\
|