aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/dcae/restapi/ApiException.java
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2020-08-13 07:35:53 +0200
committerZebek Bogumil <bogumil.zebek@nokia.com>2020-08-13 07:35:53 +0200
commitf1ea637a60bace906db5619d71a914ad601e9478 (patch)
tree47775211190c8a152b4349edd335767472f44cb2 /src/main/java/org/onap/dcae/restapi/ApiException.java
parentf6260a26de44a9338ca998626a93c0d0fa56abc3 (diff)
StndDefined event routing
- Update WS error response - Update DPO configuration Change-Id: Id4eb5ea50af6d55c839047c4f39b9f99487e95de Issue-ID: DCAEGEN2-1771 Signed-off-by: Zebek Bogumil <bogumil.zebek@nokia.com>
Diffstat (limited to 'src/main/java/org/onap/dcae/restapi/ApiException.java')
-rw-r--r--src/main/java/org/onap/dcae/restapi/ApiException.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/org/onap/dcae/restapi/ApiException.java b/src/main/java/org/onap/dcae/restapi/ApiException.java
index 255999a6..9ea02076 100644
--- a/src/main/java/org/onap/dcae/restapi/ApiException.java
+++ b/src/main/java/org/onap/dcae/restapi/ApiException.java
@@ -22,6 +22,9 @@ package org.onap.dcae.restapi;
import com.google.common.base.CaseFormat;
import org.json.JSONObject;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author Pawel Szalapski (pawel.szalapski@nokia.com)
*/
@@ -32,19 +35,25 @@ public enum ApiException {
INVALID_CONTENT_TYPE(ExceptionType.SERVICE_EXCEPTION, "SVC0002", "Bad Parameter (Incorrect request Content-Type)", 400),
UNAUTHORIZED_USER(ExceptionType.POLICY_EXCEPTION, "POL2000", "Unauthorized user", 401),
INVALID_CUSTOM_HEADER(ExceptionType.SERVICE_EXCEPTION, "SVC0002", "Bad Parameter (Incorrect request api version)", 400),
- MISSING_NAMESPACE_PARAMETER(ExceptionType.SERVICE_EXCEPTION, "SVC2006", "Mandatory input attribute event.commonEventHeader.stndDefinedNamespace is missing from request", 400),
- EMPTY_NAMESPACE_PARAMETER(ExceptionType.SERVICE_EXCEPTION, "SVC2006", "Mandatory input attribute event.commonEventHeader.stndDefinedNamespace is empty in request", 400),
+ MISSING_NAMESPACE_PARAMETER(ExceptionType.SERVICE_EXCEPTION, "SVC2006", "Mandatory input %1 %2 is missing from request", List.of("attribute", "event.commonEventHeader.stndDefinedNamespace"), 400),
+ EMPTY_NAMESPACE_PARAMETER(ExceptionType.SERVICE_EXCEPTION, "SVC2006", "Mandatory input %1 %2 is empty in request", List.of("attribute", "event.commonEventHeader.stndDefinedNamespace"), 400),
NO_SERVER_RESOURCES(ExceptionType.SERVICE_EXCEPTION, "SVC1000", "No server resources (internal processing queue full)", 503);
public final int httpStatusCode;
private final ExceptionType type;
private final String code;
private final String details;
+ private final List<String> variables;
ApiException(ExceptionType type, String code, String details, int httpStatusCode) {
+ this(type, code, details, new ArrayList<>(), httpStatusCode);
+ }
+
+ ApiException(ExceptionType type, String code, String details, List<String> variables, int httpStatusCode) {
this.type = type;
this.code = code;
this.details = details;
+ this.variables = variables;
this.httpStatusCode = httpStatusCode;
}
@@ -52,6 +61,9 @@ public enum ApiException {
JSONObject exceptionTypeNode = new JSONObject();
exceptionTypeNode.put("messageId", code);
exceptionTypeNode.put("text", details);
+ if(!variables.isEmpty()) {
+ exceptionTypeNode.put("variables", variables);
+ }
JSONObject requestErrorNode = new JSONObject();
requestErrorNode.put(type.toString(), exceptionTypeNode);