diff options
author | James Forsyth <jf2512@att.com> | 2019-04-09 15:21:50 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-09 15:21:50 +0000 |
commit | 703072969c51068d6a7aadf7131a545eabab87cd (patch) | |
tree | f270dc541a82ca657f5183a3f0f0629c72a4364b /aai-core/src/main | |
parent | 698dc799f270196a60535e2532eaaa3a5c4ac962 (diff) | |
parent | c4a24d83e64beee32566a1f98187c4445741506b (diff) |
Merge "Update dmaap to use logging context"
Diffstat (limited to 'aai-core/src/main')
6 files changed, 67 insertions, 22 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/auth/AAIAuthCore.java b/aai-core/src/main/java/org/onap/aai/auth/AAIAuthCore.java index 5097ef41..6673c08a 100644 --- a/aai-core/src/main/java/org/onap/aai/auth/AAIAuthCore.java +++ b/aai-core/src/main/java/org/onap/aai/auth/AAIAuthCore.java @@ -231,6 +231,10 @@ public final class AAIAuthCore { authPolicyFunctionName = "search"; } else if (uri.startsWith(basePath + "/recents")) { authPolicyFunctionName = "recents"; + }else if (uri.startsWith(basePath + "/cq2gremlin")) { + authPolicyFunctionName = "cq2gremlin"; + }else if (uri.startsWith(basePath + "/cq2gremlintest")) { + authPolicyFunctionName = "cq2gremlintest"; }else if (uri.startsWith(basePath + "/util/echo")) { authPolicyFunctionName = "util"; } else if (uri.startsWith(basePath + "/tools")) { diff --git a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java index 2803f69b..14550891 100644 --- a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java +++ b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java @@ -24,6 +24,7 @@ package org.onap.aai.dmaap; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import java.util.Objects; +import java.util.UUID; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; @@ -72,7 +73,8 @@ public class AAIDmaapEventJMSConsumer implements MessageListener { String jsmMessageTxt = ""; String aaiEvent = ""; String eventName = ""; - + LoggingContext.save(); + LoggingContext.init(); if (message instanceof TextMessage) { try { jsmMessageTxt = ((TextMessage) message).getText(); @@ -84,24 +86,28 @@ public class AAIDmaapEventJMSConsumer implements MessageListener { return; } if (jo.getString("transId") != null) { - MDC.put("requestId", jo.getString("transId")); + LoggingContext.requestId(jo.getString("transId")); + } else { + final UUID generatedRequestUuid = UUID.randomUUID(); + LoggingContext.requestId(generatedRequestUuid.toString()); } if (jo.getString("fromAppId") != null) { - MDC.put("partnerName", jo.getString("fromAppId")); + LoggingContext.partnerName(jo.getString("fromAppId")); } if (jo.getString(EVENT_TOPIC) != null) { eventName = jo.getString(EVENT_TOPIC); } - MDC.put ("targetEntity", "DMAAP"); + LoggingContext.targetEntity ("DMAAP"); if (jo.getString(EVENT_TOPIC) != null) { eventName = jo.getString(EVENT_TOPIC); - MDC.put ("targetServiceName", eventName); + LoggingContext.targetServiceName(eventName); } - MDC.put ("serviceName", "AAI"); - MDC.put(LoggingField.STATUS_CODE.toString(), StatusCode.COMPLETE.toString()); - MDC.put(LoggingField.RESPONSE_CODE.toString(), "0"); + LoggingContext.serviceName("AAI"); + LoggingContext.statusCode(StatusCode.COMPLETE); + LoggingContext.responseCode(LoggingContext.SUCCESS); LOGGER.info(eventName + "|" + aaiEvent); + HttpEntity httpEntity = new HttpEntity(aaiEvent, httpHeaders); String transportType = environment.getProperty("dmaap.ribbon.transportType", "http"); @@ -115,12 +121,12 @@ public class AAIDmaapEventJMSConsumer implements MessageListener { LOGGER.error(eventName + "|Event Topic invalid."); } } catch (JMSException | JSONException e) { - MDC.put(LoggingField.STATUS_CODE.toString(), StatusCode.ERROR.toString()); - MDC.put(LoggingField.RESPONSE_CODE.toString(), "200"); + LoggingContext.statusCode(StatusCode.ERROR); + LoggingContext.responseCode(LoggingContext.DATA_ERROR); LOGGER.error("AAI_7350 Error parsing aaievent jsm message for sending to dmaap. {} {}", jsmMessageTxt, LogFormatTools.getStackTop(e)); } catch (Exception e) { - MDC.put(LoggingField.STATUS_CODE.toString(), StatusCode.ERROR.toString()); - MDC.put(LoggingField.RESPONSE_CODE.toString(), "200"); + LoggingContext.statusCode(StatusCode.ERROR); + LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR); LOGGER.error("AAI_7350 Error sending message to dmaap. {} {}" , jsmMessageTxt, LogFormatTools.getStackTop(e)); } } diff --git a/aai-core/src/main/java/org/onap/aai/logging/LoggingContext.java b/aai-core/src/main/java/org/onap/aai/logging/LoggingContext.java index 627a9d2e..50af1c68 100644 --- a/aai-core/src/main/java/org/onap/aai/logging/LoggingContext.java +++ b/aai-core/src/main/java/org/onap/aai/logging/LoggingContext.java @@ -51,7 +51,7 @@ public class LoggingContext { 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 = "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-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java index 656392a3..feb2aace 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/db/DBSerializer.java @@ -328,7 +328,7 @@ public class DBSerializer { boolean isComplexType = false; boolean isListType = false; if (!obj.isContainer()) { - this.touchStandardVertexProperties(obj.getDbName(), v, false); + this.touchStandardVertexProperties(v, false); } this.executePreSideEffects(obj, v); for (String property : properties) { diff --git a/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java b/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java index b9fb08f8..59e676f8 100644 --- a/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java +++ b/aai-core/src/main/java/org/onap/aai/util/AAIConstants.java @@ -58,6 +58,9 @@ public final class AAIConstants { 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; diff --git a/aai-core/src/main/java/org/onap/aai/util/RestController.java b/aai-core/src/main/java/org/onap/aai/util/RestController.java index ff725bb5..20bb0a9b 100644 --- a/aai-core/src/main/java/org/onap/aai/util/RestController.java +++ b/aai-core/src/main/java/org/onap/aai/util/RestController.java @@ -44,6 +44,8 @@ public class RestController implements RestControllerInterface { private String restSrvrBaseURL; + private String overrideLocalHost = null; + //To do - Come up with helper function that will automatically //generate the REST API path based on path parameter(s) and query parameter(s)! public static final String REST_APIPATH_COMPLEXES = "cloud-infrastructure/complexes"; @@ -160,10 +162,18 @@ public class RestController implements RestControllerInterface { restObject.set(t); - if (oldserver) + if (oldserver) { url = AAIConfig.get(AAIConstants.AAI_OLDSERVER_URL) + path; - else - url = String.format(AAIConstants.AAI_LOCAL_REST, port, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + } else { + if ( overrideLocalHost == null ) { + overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT); + } + if ( AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost )) { + url = String.format(AAIConstants.AAI_LOCAL_REST, port, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + } else { + url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + } + } initRestClient(); LOGGER.debug(url + " for the get REST API"); ClientResponse cres = client.resource(url) @@ -325,10 +335,18 @@ public class RestController implements RestControllerInterface { initRestClient(); - if (oldserver) + if (oldserver) { url = AAIConfig.get(AAIConstants.AAI_OLDSERVER_URL) + path; - else - url = String.format(AAIConstants.AAI_LOCAL_REST, port, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + } else { + if ( overrideLocalHost == null ) { + overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT); + } + if ( AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost )) { + url = String.format(AAIConstants.AAI_LOCAL_REST, port, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + } else { + url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + } + } ClientResponse cres = client.resource(url) .accept("application/json") @@ -378,7 +396,14 @@ public class RestController implements RestControllerInterface { initRestClient(); String request = "{}"; - url = String.format(AAIConstants.AAI_LOCAL_REST, port, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + if ( overrideLocalHost == null ) { + overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT); + } + if ( AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost )) { + url = String.format(AAIConstants.AAI_LOCAL_REST, port, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + } else { + url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + } ClientResponse cres = client.resource(url) .accept("application/json") .header("X-TransactionId", transId) @@ -561,7 +586,14 @@ public class RestController implements RestControllerInterface { int statusCode = -1; try { - url = String.format(AAIConstants.AAI_LOCAL_REST, AAIConstants.AAI_RESOURCES_PORT, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + if ( overrideLocalHost == null ) { + overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT); + } + if ( AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost )) { + url = String.format(AAIConstants.AAI_LOCAL_REST, AAIConstants.AAI_RESOURCES_PORT, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + } else { + url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; + } initRestClient(); do { |