From 1072867dfac0df993cbd3e44bcc11a5cac7465fd Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Tue, 22 Sep 2020 12:16:46 -0400 Subject: Enabling Code Formatter Code Formatter was turned off due to java 11 migation Issue-ID: CCSDK-2852 Signed-off-by: Singal, Kapil (ks220y) Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8 --- .../ccsdk/cds/error/catalog/core/ErrorCatalogException.kt | 6 ++++-- .../org/onap/ccsdk/cds/error/catalog/core/ErrorCodes.kt | 3 +++ .../org/onap/ccsdk/cds/error/catalog/core/ErrorLibData.kt | 14 +++++++++----- .../cds/error/catalog/core/ErrorMessageLibConstants.kt | 1 + .../cds/error/catalog/core/utils/ErrorCatalogUtils.kt | 1 + 5 files changed, 18 insertions(+), 7 deletions(-) (limited to 'ms/error-catalog/core') diff --git a/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCatalogException.kt b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCatalogException.kt index 348b60ceb..f07f26227 100644 --- a/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCatalogException.kt +++ b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCatalogException.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.error.catalog.core interface ErrorCatalogExceptionFluent { + fun code(code: Int): T fun domain(domain: String): T fun action(action: String): T @@ -31,6 +32,7 @@ interface ErrorCatalogExceptionFluent { } open class ErrorCatalogException : RuntimeException { + var code: Int = -1 var domain: String = "" var name: String = ErrorCatalogCodes.GENERIC_FAILURE @@ -60,8 +62,8 @@ open class ErrorCatalogException : RuntimeException { constructor(code: Int, cause: Throwable, message: String, vararg args: Any?) : super(String.format(message, *args), cause) { - this.code = code - } + this.code = code + } open fun updateCode(code: Int): T { this.code = code diff --git a/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCodes.kt b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCodes.kt index 8023d97c8..895cd914a 100644 --- a/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCodes.kt +++ b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCodes.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.error.catalog.core object ErrorCatalogCodes { + const val GENERIC_FAILURE = "GENERIC_FAILURE" const val GENERIC_PROCESS_FAILURE = "GENERIC_PROCESS_FAILURE" const val INVALID_FILE_EXTENSION = "INVALID_FILE_EXTENSION" @@ -32,6 +33,7 @@ object ErrorCatalogCodes { } object HttpErrorCodes { + private val store: MutableMap = mutableMapOf() init { @@ -59,6 +61,7 @@ object HttpErrorCodes { } object GrpcErrorCodes { + private val store: MutableMap = mutableMapOf() init { diff --git a/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorLibData.kt b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorLibData.kt index 4158cfaf8..69209012d 100644 --- a/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorLibData.kt +++ b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorLibData.kt @@ -17,16 +17,17 @@ package org.onap.ccsdk.cds.error.catalog.core import com.fasterxml.jackson.annotation.JsonFormat -import org.slf4j.event.Level import org.onap.ccsdk.cds.error.catalog.core.ErrorMessageLibConstants.ERROR_CATALOG_DEFAULT_ERROR_CODE +import org.slf4j.event.Level import java.time.LocalDateTime import java.time.ZoneId import java.util.Date -import kotlin.collections.ArrayList open class ErrorPayload { + var code: Int = ERROR_CATALOG_DEFAULT_ERROR_CODE var status: String = "" + @get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") var timestamp: Date = controllerDate() var message: String = "" @@ -67,9 +68,11 @@ open class ErrorPayload { } fun isEqualTo(errorPayload: ErrorPayload): Boolean { - return (this.code == errorPayload.code && this.status == errorPayload.status && this.message == errorPayload.message && - this.logLevel == errorPayload.logLevel && this.debugMessage == errorPayload.debugMessage && - this.subErrors == errorPayload.subErrors) + return ( + this.code == errorPayload.code && this.status == errorPayload.status && this.message == errorPayload.message && + this.logLevel == errorPayload.logLevel && this.debugMessage == errorPayload.debugMessage && + this.subErrors == errorPayload.subErrors + ) } private fun controllerDate(): Date { @@ -96,6 +99,7 @@ data class ErrorCatalog( val action: String, val cause: String ) { + fun getMessage(): String { return "Cause: $cause ${System.lineSeparator()} Action : $action" } diff --git a/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorMessageLibConstants.kt b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorMessageLibConstants.kt index 6570e3e66..b6f334a7c 100644 --- a/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorMessageLibConstants.kt +++ b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorMessageLibConstants.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.error.catalog.core object ErrorMessageLibConstants { + const val ERROR_CATALOG_DOMAIN = "org.onap.ccsdk.cds.error.catalog" const val ERROR_CATALOG_TYPE = "error.catalog.type" const val ERROR_CATALOG_TYPE_PROPERTIES = "properties" diff --git a/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/utils/ErrorCatalogUtils.kt b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/utils/ErrorCatalogUtils.kt index f13a3604f..8fe1c5016 100644 --- a/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/utils/ErrorCatalogUtils.kt +++ b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/utils/ErrorCatalogUtils.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.error.catalog.core.utils import org.apache.commons.lang3.exception.ExceptionUtils object ErrorCatalogUtils { + private const val REGEX_PATTERN = "^cause=(.*),action=(.*)" private val regex = REGEX_PATTERN.toRegex() -- cgit 1.2.3-korg