summaryrefslogtreecommitdiffstats
path: root/ms/error-catalog
diff options
context:
space:
mode:
Diffstat (limited to 'ms/error-catalog')
-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
-rw-r--r--ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogConfiguration.kt1
-rw-r--r--ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogDBService.kt9
-rw-r--r--ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogExceptionHandler.kt30
-rw-r--r--ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogLoadService.kt14
-rw-r--r--ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogService.kt12
-rwxr-xr-xms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/domain/Domain.kt8
-rw-r--r--ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/domain/ErrorMessageModel.kt1
12 files changed, 65 insertions, 35 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()
diff --git a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogConfiguration.kt b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogConfiguration.kt
index f0a75e087..8fc5edf37 100644
--- a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogConfiguration.kt
+++ b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogConfiguration.kt
@@ -28,6 +28,7 @@ open class ErrorCatalogConfiguration
@Component
@ConfigurationProperties(prefix = "error.catalog")
open class ErrorCatalogProperties {
+
lateinit var type: String
lateinit var applicationId: String
var errorDefinitionDir: String? = null
diff --git a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogDBService.kt b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogDBService.kt
index 95b44e683..4bb042e95 100644
--- a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogDBService.kt
+++ b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogDBService.kt
@@ -41,7 +41,7 @@ open class ErrorCatalogDBService(
* This is a getAllDomains method to retrieve all the Domain in Error Catalog Database by pages
*
* @return Page<Domain> list of the domains by page
- </Domain> */
+ </Domain> */
open fun getAllDomains(pageRequest: Pageable): Page<Domain> {
return domainRepository.findAll(pageRequest)
}
@@ -50,7 +50,7 @@ open class ErrorCatalogDBService(
* This is a getAllDomains method to retrieve all the Domain in Error Catalog Database
*
* @return List<Domain> list of the domains
- </Domain> */
+ </Domain> */
open fun getAllDomains(): List<Domain> {
return domainRepository.findAll()
}
@@ -59,7 +59,7 @@ open class ErrorCatalogDBService(
* This is a getAllDomainsByApplication method to retrieve all the Domain that belong to an application in Error Catalog Database
*
* @return List<Domain> list of the domains
- </Domain> */
+ </Domain> */
open fun getAllDomainsByApplication(applicationId: String): List<Domain> {
return domainRepository.findAllByApplicationId(applicationId)
}
@@ -68,7 +68,7 @@ open class ErrorCatalogDBService(
* This is a getAllErrorMessagesByApplication method to retrieve all the Messages that belong to an application in Error Catalog Database
*
* @return MutableMap<String, ErrorCode> list of the abstractErrorModel
- </Domain> */
+ </Domain> */
open fun getAllErrorMessagesByApplication(applicationId: String): MutableMap<String, ErrorMessageModel> {
val domains = domainRepository.findAllByApplicationId(applicationId)
val errorMessages = mutableMapOf<String, ErrorMessageModel>()
@@ -93,6 +93,7 @@ open class ErrorCatalogDBService(
}
companion object {
+
private const val MESSAGE_KEY_SEPARATOR = "."
}
}
diff --git a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogExceptionHandler.kt b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogExceptionHandler.kt
index 258209f71..161b6b8e4 100644
--- a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogExceptionHandler.kt
+++ b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogExceptionHandler.kt
@@ -39,40 +39,50 @@ abstract class ErrorCatalogExceptionHandler(private val errorCatalogService: Err
@ExceptionHandler
fun errorCatalogException(e: ServerWebInputException): ResponseEntity<ErrorPayload> {
- val error = ErrorCatalogException(HttpErrorCodes.code(ErrorCatalogCodes.REQUEST_NOT_FOUND),
- e.errorMessageOrDefault(), e.errorCauseOrDefault())
+ val error = ErrorCatalogException(
+ HttpErrorCodes.code(ErrorCatalogCodes.REQUEST_NOT_FOUND),
+ e.errorMessageOrDefault(), e.errorCauseOrDefault()
+ )
val errorPayload = ErrorPayload(error.code, error.name, error.errorMessageOrDefault())
return errorPayload.toResponseEntity()
}
@ExceptionHandler
fun errorCatalogException(e: IncorrectResultSizeDataAccessException): ResponseEntity<ErrorPayload> {
- val error = ErrorCatalogException(HttpErrorCodes.code(ErrorCatalogCodes.DUPLICATE_DATA),
- e.errorMessageOrDefault(), e.errorCauseOrDefault())
+ val error = ErrorCatalogException(
+ HttpErrorCodes.code(ErrorCatalogCodes.DUPLICATE_DATA),
+ e.errorMessageOrDefault(), e.errorCauseOrDefault()
+ )
val errorPayload = ErrorPayload(error.code, error.name, error.errorMessageOrDefault())
return errorPayload.toResponseEntity()
}
@ExceptionHandler
fun errorCatalogException(e: EmptyResultDataAccessException): ResponseEntity<ErrorPayload> {
- val error = ErrorCatalogException(HttpErrorCodes.code(ErrorCatalogCodes.RESOURCE_NOT_FOUND),
- e.errorMessageOrDefault(), e.errorCauseOrDefault())
+ val error = ErrorCatalogException(
+ HttpErrorCodes.code(ErrorCatalogCodes.RESOURCE_NOT_FOUND),
+ e.errorMessageOrDefault(), e.errorCauseOrDefault()
+ )
val errorPayload = ErrorPayload(error.code, error.name, error.errorMessageOrDefault())
return errorPayload.toResponseEntity()
}
@ExceptionHandler
fun errorCatalogException(e: JpaObjectRetrievalFailureException): ResponseEntity<ErrorPayload> {
- val error = ErrorCatalogException(HttpErrorCodes.code(ErrorCatalogCodes.RESOURCE_NOT_FOUND),
- e.errorMessageOrDefault(), e.errorCauseOrDefault())
+ val error = ErrorCatalogException(
+ HttpErrorCodes.code(ErrorCatalogCodes.RESOURCE_NOT_FOUND),
+ e.errorMessageOrDefault(), e.errorCauseOrDefault()
+ )
val errorPayload = ErrorPayload(error.code, error.name, error.errorMessageOrDefault())
return errorPayload.toResponseEntity()
}
@ExceptionHandler
fun errorCatalogException(e: Exception): ResponseEntity<ErrorPayload> {
- val error = ErrorCatalogException(HttpErrorCodes.code(ErrorCatalogCodes.GENERIC_FAILURE),
- e.errorMessageOrDefault(), e.errorCauseOrDefault())
+ val error = ErrorCatalogException(
+ HttpErrorCodes.code(ErrorCatalogCodes.GENERIC_FAILURE),
+ e.errorMessageOrDefault(), e.errorCauseOrDefault()
+ )
val errorPayload = ErrorPayload(error.code, error.name, error.errorMessageOrDefault())
return errorPayload.toResponseEntity()
}
diff --git a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogLoadService.kt b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogLoadService.kt
index df13724c6..bcde35029 100644
--- a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogLoadService.kt
+++ b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogLoadService.kt
@@ -100,7 +100,7 @@ open class ErrorCatalogLoadDBService(
havingValue = ErrorMessageLibConstants.ERROR_CATALOG_TYPE_PROPERTIES
)
open class ErrorCatalogLoadPropertyService(private var errorCatalogProperties: ErrorCatalogProperties) :
- ErrorCatalogLoadService {
+ ErrorCatalogLoadService {
private val propertyFileName = ErrorMessageLibConstants.ERROR_CATALOG_PROPERTIES_FILENAME
private lateinit var propertyFile: File
@@ -134,11 +134,15 @@ open class ErrorCatalogLoadPropertyService(private var errorCatalogProperties: E
inputStream = propertyFile.inputStream()
props.load(inputStream)
} catch (e: FileNotFoundException) {
- log.error("Application ID: ${errorCatalogProperties.applicationId} > Property File '$propertyFileName' " +
- "not found in the application directory.")
+ log.error(
+ "Application ID: ${errorCatalogProperties.applicationId} > Property File '$propertyFileName' " +
+ "not found in the application directory."
+ )
} catch (e: IOException) {
- log.error("Application ID: ${errorCatalogProperties.applicationId} > Fail to load property file " +
- "'$propertyFileName' for message errors.")
+ log.error(
+ "Application ID: ${errorCatalogProperties.applicationId} > Fail to load property file " +
+ "'$propertyFileName' for message errors."
+ )
} finally {
inputStream?.close()
}
diff --git a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogService.kt b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogService.kt
index 21fd51b2f..298daa6fc 100644
--- a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogService.kt
+++ b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogService.kt
@@ -18,6 +18,7 @@
package org.onap.ccsdk.cds.error.catalog.services
import kotlinx.coroutines.runBlocking
+import org.apache.commons.lang3.exception.ExceptionUtils
import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalog
import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogException
import org.onap.ccsdk.cds.error.catalog.core.ErrorMessageLibConstants
@@ -25,7 +26,6 @@ import org.onap.ccsdk.cds.error.catalog.core.ErrorPayload
import org.onap.ccsdk.cds.error.catalog.core.GrpcErrorCodes
import org.onap.ccsdk.cds.error.catalog.core.HttpErrorCodes
import org.onap.ccsdk.cds.error.catalog.core.utils.ErrorCatalogUtils
-import org.apache.commons.lang3.exception.ExceptionUtils
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
import org.springframework.stereotype.Service
import javax.annotation.PostConstruct
@@ -78,11 +78,11 @@ open class ErrorCatalogService(private var errorCatalogLoadService: ErrorCatalog
}
return ErrorCatalog(
- errorCatalogException.name,
- errorCatalogException.domain,
- errorCode,
- action,
- errorCause
+ errorCatalogException.name,
+ errorCatalogException.domain,
+ errorCode,
+ action,
+ errorCause
)
}
diff --git a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/domain/Domain.kt b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/domain/Domain.kt
index 7ade1c2a2..7216c0585 100755
--- a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/domain/Domain.kt
+++ b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/domain/Domain.kt
@@ -17,18 +17,18 @@
package org.onap.ccsdk.cds.error.catalog.services.domain
import java.io.Serializable
+import java.util.UUID
import javax.persistence.CascadeType
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.FetchType
import javax.persistence.Id
+import javax.persistence.JoinColumn
+import javax.persistence.JoinTable
import javax.persistence.Lob
import javax.persistence.ManyToMany
import javax.persistence.Table
import javax.persistence.UniqueConstraint
-import java.util.UUID
-import javax.persistence.JoinTable
-import javax.persistence.JoinColumn
/**
* Provide ErrorCode Entity
@@ -40,6 +40,7 @@ import javax.persistence.JoinColumn
@Entity
@Table(name = "ERROR_DOMAINS", uniqueConstraints = [UniqueConstraint(columnNames = ["name", "application_id"])])
class Domain : Serializable {
+
@Id
var id: String = UUID.randomUUID().toString()
@@ -71,6 +72,7 @@ class Domain : Serializable {
}
companion object {
+
private const val serialVersionUID = 1L
}
}
diff --git a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/domain/ErrorMessageModel.kt b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/domain/ErrorMessageModel.kt
index a4e92af48..f2556e6c1 100644
--- a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/domain/ErrorMessageModel.kt
+++ b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/domain/ErrorMessageModel.kt
@@ -56,6 +56,7 @@ class ErrorMessageModel : Serializable {
val domains: MutableSet<Domain> = mutableSetOf()
companion object {
+
private const val serialVersionUID = 1L
}