From: James Forsyth Date: Tue, 28 Nov 2017 17:19:08 +0000 (+0000) Subject: Merge "Bump minor version" X-Git-Tag: v1.2.0~28 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=d65ec2eb24496c2eb901e7c18826c48041ca2c74;hp=b56bceb5df5a3135452c417d601aba068dafdadc;p=aai%2Faai-common.git Merge "Bump minor version" --- 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 1e61c659..7d9dcce5 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 @@ -48,7 +48,16 @@ public class LoggingContext { private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(LoggingContext.class); private static final String PREVIOUS_CONTEXTS_KEY = "_PREVIOUS_CONTEXTS"; - + + //Response codes from ECOMP 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 = "200"; + public static final String SCHEMA_ERROR = "400"; + public static final String BUSINESS_PROCESS_ERROR = "500"; + public static final String UNKNOWN_ERROR = "900"; + //ECOMP Specific Log Event Fields public static enum LoggingField { START_TIME("startTime"), @@ -75,7 +84,7 @@ public class LoggingContext { //ECOMP Specific Metric Log Event Fields TARGET_ENTITY("targetEntity"), - + TARGET_SERVICE_NAME("targetServiceName"), //A&AI Specific Log Event Fields COMPONENT("component"), STOP_WATCH_START("stopWatchStart"); @@ -99,7 +108,7 @@ public class LoggingContext { LoggingContext.serverIpAddress(); } - private static void startTime() { + public static void startTime() { MDC.put(LoggingField.START_TIME.toString(), LogFormatTools.getCurrentDateTime()); } @@ -115,8 +124,7 @@ public class LoggingContext { MDC.put(LoggingField.REQUEST_ID.toString(), requestId.toString()); } - public static void requestId(String requestId) throws AAIException { - + public static void requestId(String requestId) { try { if(requestId == null){ throw new IllegalArgumentException(); @@ -129,7 +137,15 @@ public class LoggingContext { } catch (IllegalArgumentException e) { final UUID generatedRequestUuid = UUID.randomUUID(); MDC.put(LoggingField.REQUEST_ID.toString(), generatedRequestUuid.toString()); - LOGGER.warn("Unable to use UUID " + requestId + " (Not formatted properly). Using generated UUID=" + generatedRequestUuid); + LoggingContext.save(); + AAIException ex = new AAIException("AAI_7405", e); + String responseCode = Integer.toString(ex.getErrorObject().getHTTPResponseCode().getStatusCode()); + LoggingContext.responseCode(responseCode); + + LOGGER.warn("Unable to use UUID " + requestId + " (Not formatted properly). Using generated UUID=" + + generatedRequestUuid); + LoggingContext.restore(); + } } @@ -177,6 +193,10 @@ public class LoggingContext { MDC.put(LoggingField.SEVERITY.toString(), String.valueOf(severity)); } + public static void successStatusFields() { + responseCode(SUCCESS); + statusCode(LoggingContext.StatusCode.COMPLETE); + } private static void serverIpAddress() { try { MDC.put(LoggingField.SERVER_IP_ADDRESS.toString(), InetAddress.getLocalHost().getHostAddress()); @@ -247,6 +267,17 @@ public class LoggingContext { MDC.put(LoggingField.TARGET_ENTITY.toString(), targetEntity); } + public static void targetServiceName(String targetServiceName) { + MDC.put(LoggingField.TARGET_SERVICE_NAME.toString(), targetServiceName); + } + + 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())); } @@ -328,10 +359,12 @@ public class LoggingContext { @SuppressWarnings("unchecked") final Iterator keys = previousContext.keys(); - + boolean foundElapsedTime = false; while (keys.hasNext()) { final String key = keys.next(); - + if (LoggingField.ELAPSED_TIME.toString().equals(key)) { + foundElapsedTime = true; + } try { MDC.put(key, previousContext.getString(key)); } catch (JSONException e) { @@ -339,12 +372,22 @@ public class LoggingContext { // or the value is invalid (they are all strings) } } - + if ( !foundElapsedTime ) { + MDC.remove(LoggingField.ELAPSED_TIME.toString()); + } MDC.put(PREVIOUS_CONTEXTS_KEY, removeLast(previousContexts).toString()); } catch (JSONException e) { //Ignore, the previousContext is serialized from a JSONObject } } + public static void restoreIfPossible() { + try { + restore(); + } + catch (LoggingContextNotExistsException e) { + //Ignore + } + } /** * AJSC declares an ancient version of org.json:json in one of the parent POMs of this project. 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 9b7afe52..9c0eac0e 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 @@ -38,7 +38,6 @@ public final class AAIConstants { /** 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_V2_OUTPUT_TRANSFORMS = AAIConstants.AAI_HOME_ETC_APP_PROPERTIES + AAIConstants.AAI_FILESEP + "output" + AAIConstants.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"; @@ -142,6 +141,9 @@ public final class AAIConstants { /** Service description for LRSI */ public static final String AAI_SERVICEDESCRIPTION_LRSI = "aai.servicedescription.lrsi"; + /** 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. */ diff --git a/aai-schema/src/main/resources/aai_schema/aai_schema_v12.xsd b/aai-schema/src/main/resources/aai_schema/aai_schema_v12.xsd index 21448d2c..346a825c 100644 --- a/aai-schema/src/main/resources/aai_schema/aai_schema_v12.xsd +++ b/aai-schema/src/main/resources/aai_schema/aai_schema_v12.xsd @@ -7247,6 +7247,20 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" + + + + @org.onap.aai.annotations.Metadata(description="DHV Site Effective Bandwidth") + + + + + + + @org.onap.aai.annotations.Metadata(description="Velocloud Nominal Throughput - VNT") + + + diff --git a/aai-schema/src/main/resources/oxm/aai_oxm_v12.xml b/aai-schema/src/main/resources/oxm/aai_oxm_v12.xml index e9a4c172..9f9b2131 100644 --- a/aai-schema/src/main/resources/oxm/aai_oxm_v12.xml +++ b/aai-schema/src/main/resources/oxm/aai_oxm_v12.xml @@ -2942,7 +2942,17 @@ + + + + + + + + + +