summaryrefslogtreecommitdiffstats
path: root/ms/error-catalog/core
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2020-09-22 12:16:46 -0400
committerSingal, Kapil (ks220y) <ks220y@att.com>2020-09-22 13:49:05 -0400
commit1072867dfac0df993cbd3e44bcc11a5cac7465fd (patch)
tree4a821659cf3b50cf946cbb535d528be8508e9fff /ms/error-catalog/core
parentd97021cd756d63402545fdc2e14ac7611c3da118 (diff)
Enabling Code Formatter
Code Formatter was turned off due to java 11 migation Issue-ID: CCSDK-2852 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8
Diffstat (limited to 'ms/error-catalog/core')
-rw-r--r--ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCatalogException.kt6
-rw-r--r--ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCodes.kt3
-rw-r--r--ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorLibData.kt14
-rw-r--r--ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorMessageLibConstants.kt1
-rw-r--r--ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/utils/ErrorCatalogUtils.kt1
5 files changed, 18 insertions, 7 deletions
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<T> {
+
fun code(code: Int): T
fun domain(domain: String): T
fun action(action: String): T
@@ -31,6 +32,7 @@ interface ErrorCatalogExceptionFluent<T> {
}
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 <T : ErrorCatalogException> 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<String, Int> = mutableMapOf()
init {
@@ -59,6 +61,7 @@ object HttpErrorCodes {
}
object GrpcErrorCodes {
+
private val store: MutableMap<String, Int> = 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()