summaryrefslogtreecommitdiffstats
path: root/ms/error-catalog
diff options
context:
space:
mode:
Diffstat (limited to 'ms/error-catalog')
-rw-r--r--ms/error-catalog/application/pom.xml10
-rw-r--r--ms/error-catalog/application/pom.xml-n34
-rw-r--r--ms/error-catalog/core/pom.xml22
-rw-r--r--ms/error-catalog/core/pom.xml-n34
-rw-r--r--ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCatalogException.kt20
-rw-r--r--ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorCodes.kt6
-rw-r--r--ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/ErrorLibData.kt10
-rw-r--r--ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/utils/ErrorCatalogUtils.kt (renamed from ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/utils/ErrorCatalogUtils.kt)6
-rw-r--r--ms/error-catalog/pom.xml60
-rw-r--r--ms/error-catalog/pom.xml-n157
-rw-r--r--ms/error-catalog/services/pom.xml37
-rw-r--r--ms/error-catalog/services/pom.xml-n41
-rw-r--r--ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogExceptionHandler.kt48
-rw-r--r--ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogService.kt16
14 files changed, 439 insertions, 62 deletions
diff --git a/ms/error-catalog/application/pom.xml b/ms/error-catalog/application/pom.xml
index c2a09dbdb..e775585ae 100644
--- a/ms/error-catalog/application/pom.xml
+++ b/ms/error-catalog/application/pom.xml
@@ -14,13 +14,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.cds.error.catalog</groupId>
<artifactId>error-catalog</artifactId>
- <version>0.7.1-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>error-catalog-application</artifactId>
@@ -31,4 +32,11 @@
<properties>
<sonar.skip>true</sonar.skip>
</properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.cds.error.catalog</groupId>
+ <artifactId>error-catalog-services</artifactId>
+ </dependency>
+ </dependencies>
</project>
diff --git a/ms/error-catalog/application/pom.xml-n b/ms/error-catalog/application/pom.xml-n
new file mode 100644
index 000000000..4d992718e
--- /dev/null
+++ b/ms/error-catalog/application/pom.xml-n
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2018-2019 AT&T Intellectual Property.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.cds.error.catalog</groupId>
+ <artifactId>error-catalog</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>error-catalog-application</artifactId>
+
+ <name>Error Catalog Application</name>
+ <description>Error Catalog Application</description>
+
+ <properties>
+ <sonar.skip>true</sonar.skip>
+ </properties>
+</project>
diff --git a/ms/error-catalog/core/pom.xml b/ms/error-catalog/core/pom.xml
index 0592112cf..81ad38f00 100644
--- a/ms/error-catalog/core/pom.xml
+++ b/ms/error-catalog/core/pom.xml
@@ -14,13 +14,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.cds.error.catalog</groupId>
<artifactId>error-catalog</artifactId>
- <version>0.7.1-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>error-catalog-core</artifactId>
@@ -31,4 +32,23 @@
<properties>
<sonar.skip>true</sonar.skip>
</properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-kotlin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>javax.persistence-api</artifactId>
+ </dependency>
+ </dependencies>
</project>
diff --git a/ms/error-catalog/core/pom.xml-n b/ms/error-catalog/core/pom.xml-n
new file mode 100644
index 000000000..a3663f2c3
--- /dev/null
+++ b/ms/error-catalog/core/pom.xml-n
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2018-2019 AT&T Intellectual Property.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.cds.error.catalog</groupId>
+ <artifactId>error-catalog</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>error-catalog-core</artifactId>
+
+ <name>Error Catalog Core</name>
+ <description>Error Catalog Core</description>
+
+ <properties>
+ <sonar.skip>true</sonar.skip>
+ </properties>
+</project>
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 032feb62c..348b60ceb 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
@@ -23,6 +23,8 @@ interface ErrorCatalogExceptionFluent<T> {
fun action(action: String): T
fun http(type: String): T
fun grpc(type: String): T
+ fun convertToHttp(): T
+ fun convertToGrpc(): T
fun payloadMessage(message: String): T
fun addErrorPayloadMessage(message: String): T
fun addSubError(errorMessage: ErrorMessage): T
@@ -78,12 +80,30 @@ open class ErrorCatalogException : RuntimeException {
fun <T : ErrorCatalogException> updateHttp(type: String): T {
this.protocol = ErrorMessageLibConstants.ERROR_CATALOG_PROTOCOL_HTTP
+ this.name = type
this.code = HttpErrorCodes.code(type)
return this as T
}
+ fun <T : ErrorCatalogException> inverseToHttp(): T {
+ if (this.protocol != "" && this.protocol == ErrorMessageLibConstants.ERROR_CATALOG_PROTOCOL_GRPC) {
+ this.protocol = ErrorMessageLibConstants.ERROR_CATALOG_PROTOCOL_HTTP
+ this.code = HttpErrorCodes.code(this.name)
+ }
+ return this as T
+ }
+
+ fun <T : ErrorCatalogException> inverseToGrpc(): T {
+ if (this.protocol != "" && this.protocol == ErrorMessageLibConstants.ERROR_CATALOG_PROTOCOL_HTTP) {
+ this.protocol = ErrorMessageLibConstants.ERROR_CATALOG_PROTOCOL_GRPC
+ this.code = GrpcErrorCodes.code(this.name)
+ }
+ return this as T
+ }
+
fun <T : ErrorCatalogException> updateGrpc(type: String): T {
this.protocol = ErrorMessageLibConstants.ERROR_CATALOG_PROTOCOL_GRPC
+ this.name = type
this.code = GrpcErrorCodes.code(type)
return this as T
}
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 86483e3e9..8023d97c8 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
@@ -54,8 +54,7 @@ object HttpErrorCodes {
}
fun code(type: String): Int {
- // FIXME("Return Default Error Code , If missing")
- return store[type]!!
+ return store[type] ?: store[ErrorCatalogCodes.GENERIC_FAILURE]!!
}
}
@@ -82,7 +81,6 @@ object GrpcErrorCodes {
}
fun code(type: String): Int {
- // FIXME("Return Default Error Code , If missing")
- return store[type]!!
+ return store[type] ?: store[ErrorCatalogCodes.GENERIC_FAILURE]!!
}
}
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 2c0772e31..4158cfaf8 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
@@ -20,12 +20,15 @@ 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 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: LocalDateTime = LocalDateTime.now()
+ var timestamp: Date = controllerDate()
var message: String = ""
var debugMessage: String = ""
var logLevel: String = Level.ERROR.name
@@ -68,6 +71,11 @@ open class ErrorPayload {
this.logLevel == errorPayload.logLevel && this.debugMessage == errorPayload.debugMessage &&
this.subErrors == errorPayload.subErrors)
}
+
+ private fun controllerDate(): Date {
+ val localDateTime = LocalDateTime.now(ZoneId.systemDefault())
+ return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant())
+ }
}
/**
diff --git a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/utils/ErrorCatalogUtils.kt b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/utils/ErrorCatalogUtils.kt
index 967d3560c..f13a3604f 100644
--- a/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/utils/ErrorCatalogUtils.kt
+++ b/ms/error-catalog/core/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/core/utils/ErrorCatalogUtils.kt
@@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.ccsdk.cds.error.catalog.services.utils
+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=(.*)"
@@ -31,7 +33,7 @@ object ErrorCatalogUtils {
}
fun Exception.errorCauseOrDefault(): Throwable {
- return this.cause ?: Throwable()
+ return ExceptionUtils.getRootCause(this)
}
fun Exception.errorMessageOrDefault(): String {
diff --git a/ms/error-catalog/pom.xml b/ms/error-catalog/pom.xml
index 8b82d7d75..8356e4d38 100644
--- a/ms/error-catalog/pom.xml
+++ b/ms/error-catalog/pom.xml
@@ -14,13 +14,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.cds</groupId>
<artifactId>ms</artifactId>
- <version>0.7.1-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
@@ -37,17 +38,21 @@
<module>services</module>
</modules>
+ <properties>
+ <error-catalog.version>${project.version}</error-catalog.version>
+ </properties>
+
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.onap.ccsdk.cds.error.catalog</groupId>
<artifactId>error-catalog-core</artifactId>
- <version>${project.version}</version>
+ <version>${error-catalog.version}</version>
</dependency>
<dependency>
<groupId>org.onap.ccsdk.cds.error.catalog</groupId>
<artifactId>error-catalog-services</artifactId>
- <version>${project.version}</version>
+ <version>${error-catalog.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@@ -55,70 +60,29 @@
<!-- Kotlin Dependencies -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-stdlib</artifactId>
+ <artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-stdlib-common</artifactId>
+ <artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-script-util</artifactId>
+ <artifactId>kotlin-stdlib</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-stdlib-jdk8</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlinx</groupId>
- <artifactId>kotlinx-coroutines-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlinx</groupId>
- <artifactId>kotlinx-coroutines-reactor</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.module</groupId>
- <artifactId>jackson-module-kotlin</artifactId>
+ <artifactId>kotlin-stdlib-common</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-compiler-embeddable</artifactId>
</dependency>
<dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-scripting-jvm-host</artifactId>
- <!--Use kotlin-compiler-embeddable as koltin-compiler wrap-->
- <!--guava dependency creating classpath issues at runtime-->
- <exclusions>
- <exclusion>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-compiler</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-webflux</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>javax.persistence-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
- </dependency>
- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>io.projectreactor</groupId>
- <artifactId>reactor-test</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/ms/error-catalog/pom.xml-n b/ms/error-catalog/pom.xml-n
new file mode 100644
index 000000000..319f2f6de
--- /dev/null
+++ b/ms/error-catalog/pom.xml-n
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2018-2019 AT&T Intellectual Property.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.cds</groupId>
+ <artifactId>ms</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <groupId>org.onap.ccsdk.cds.error.catalog</groupId>
+ <artifactId>error-catalog</artifactId>
+ <packaging>pom</packaging>
+
+ <name>Error Catalog Lib</name>
+ <description>Error Catalog Lib for ONAP Components</description>
+
+ <modules>
+ <module>application</module>
+ <module>core</module>
+ <module>services</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.cds.error.catalog</groupId>
+ <artifactId>error-catalog-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.cds.error.catalog</groupId>
+ <artifactId>error-catalog-services</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <!-- Kotlin Dependencies -->
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-script-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-stdlib-jdk8</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-reactor</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.module</groupId>
+ <artifactId>jackson-module-kotlin</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-compiler-embeddable</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-scripting-jvm-host</artifactId>
+ <!--Use kotlin-compiler-embeddable as koltin-compiler wrap-->
+ <!--guava dependency creating classpath issues at runtime-->
+ <exclusions>
+ <exclusion>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-compiler</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>javax.persistence-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-maven-plugin</artifactId>
+ <version>${kotlin.maven.version}</version>
+ <executions>
+ <execution>
+ <id>compile</id>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ <configuration>
+ <sourceDirs>
+ <sourceDir>src/main/kotlin</sourceDir>
+ </sourceDirs>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-compile</id>
+ <goals>
+ <goal>test-compile</goal>
+ </goals>
+ <configuration>
+ <sourceDirs>
+ <sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
+ </sourceDirs>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/ms/error-catalog/services/pom.xml b/ms/error-catalog/services/pom.xml
index a0a1ba9b1..c5e6cb216 100644
--- a/ms/error-catalog/services/pom.xml
+++ b/ms/error-catalog/services/pom.xml
@@ -14,13 +14,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.cds.error.catalog</groupId>
<artifactId>error-catalog</artifactId>
- <version>0.7.1-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>error-catalog-services</artifactId>
@@ -37,5 +38,39 @@
<groupId>org.onap.ccsdk.cds.error.catalog</groupId>
<artifactId>error-catalog-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-scripting-jvm-host</artifactId>
+ <!--Use kotlin-compiler-embeddable as koltin-compiler wrap-->
+ <!--guava dependency creating classpath issues at runtime-->
+ <exclusions>
+ <exclusion>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-compiler</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-reactor</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-script-util</artifactId>
+ </dependency>
+ <!-- Kotlin Dependencies -->
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/ms/error-catalog/services/pom.xml-n b/ms/error-catalog/services/pom.xml-n
new file mode 100644
index 000000000..44f12f7e3
--- /dev/null
+++ b/ms/error-catalog/services/pom.xml-n
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2018-2019 AT&T Intellectual Property.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.cds.error.catalog</groupId>
+ <artifactId>error-catalog</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>error-catalog-services</artifactId>
+
+ <name>Error Catalog Service</name>
+ <description>Error Catalog Service</description>
+
+ <properties>
+ <sonar.skip>true</sonar.skip>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.cds.error.catalog</groupId>
+ <artifactId>error-catalog-core</artifactId>
+ </dependency>
+ </dependencies>
+</project>
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 88e2f4522..258209f71 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
@@ -16,10 +16,18 @@
package org.onap.ccsdk.cds.error.catalog.services
+import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogCodes
import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogException
import org.onap.ccsdk.cds.error.catalog.core.ErrorPayload
+import org.onap.ccsdk.cds.error.catalog.core.HttpErrorCodes
+import org.onap.ccsdk.cds.error.catalog.core.utils.errorCauseOrDefault
+import org.onap.ccsdk.cds.error.catalog.core.utils.errorMessageOrDefault
+import org.springframework.dao.EmptyResultDataAccessException
+import org.springframework.dao.IncorrectResultSizeDataAccessException
import org.springframework.http.ResponseEntity
+import org.springframework.orm.jpa.JpaObjectRetrievalFailureException
import org.springframework.web.bind.annotation.ExceptionHandler
+import org.springframework.web.server.ServerWebInputException
abstract class ErrorCatalogExceptionHandler(private val errorCatalogService: ErrorCatalogService) {
@@ -28,4 +36,44 @@ abstract class ErrorCatalogExceptionHandler(private val errorCatalogService: Err
val errorPayload = errorCatalogService.errorPayload(e)
return errorPayload.toResponseEntity()
}
+
+ @ExceptionHandler
+ fun errorCatalogException(e: ServerWebInputException): ResponseEntity<ErrorPayload> {
+ 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 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 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 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 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/ErrorCatalogService.kt b/ms/error-catalog/services/src/main/kotlin/org/onap/ccsdk/cds/error/catalog/services/ErrorCatalogService.kt
index 91f817133..21fd51b2f 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
@@ -24,7 +24,8 @@ import org.onap.ccsdk.cds.error.catalog.core.ErrorMessageLibConstants
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.services.utils.ErrorCatalogUtils
+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
@@ -40,10 +41,17 @@ open class ErrorCatalogService(private var errorCatalogLoadService: ErrorCatalog
fun errorPayload(errorCatalogException: ErrorCatalogException): ErrorPayload {
val errorCatalog = getErrorCatalog(errorCatalogException)
- val errorPayload = ErrorPayload(errorCatalog.code, errorCatalog.errorId, errorCatalog.getMessage())
- errorPayload.subErrors.addAll(errorCatalogException.errorPayload!!.subErrors)
+ val errorPayload: ErrorPayload
+ if (errorCatalogException.errorPayload == null) {
+ errorPayload = ErrorPayload(errorCatalog.code, errorCatalog.errorId, errorCatalog.getMessage())
+ } else {
+ errorPayload = errorCatalogException.errorPayload!!
+ errorPayload.code = errorCatalog.code
+ errorPayload.message = errorCatalog.getMessage()
+ errorPayload.status = errorCatalog.errorId
+ }
if (errorCatalogException.cause != null) {
- errorPayload.debugMessage = errorCatalogException.cause!!.printStackTrace().toString()
+ errorPayload.debugMessage = ExceptionUtils.getStackTrace(errorCatalogException.cause)
}
return errorPayload
}