aboutsummaryrefslogtreecommitdiffstats
path: root/common-app-api/src/main/java/org/openecomp/sdc/exception
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/exception')
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java172
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentException.java18
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteReferencedObjectException.java12
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/FunctionalException.java21
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/IndexingServiceException.java20
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/InvalidArgumentException.java18
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/NotFoundException.java18
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/OkResponseInfo.java10
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/PolicyException.java14
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/ResponseFormat.java322
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/ServiceException.java14
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/TechnicalException.java19
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/exception/VersionConflictException.java12
13 files changed, 341 insertions, 329 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java
index 7fac9f33fa..75315a06cc 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.exception;
import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.openecomp.sdc.common.util.GeneralUtility;
import java.util.Arrays;
import java.util.Formatter;
@@ -30,87 +31,94 @@ import java.util.regex.Pattern;
public abstract class AbstractSdncException {
- private String messageId;
-
- private String text;
-
- private String[] variables;
-
- private static Logger log = Logger.getLogger(AbstractSdncException.class.getName());
-
- private static final Pattern ERROR_PARAM_PATTERN = Pattern.compile("%\\d");
-
- public AbstractSdncException() {
- }
-
- public AbstractSdncException(String messageId, String text, String[] variables) {
- super();
- this.messageId = messageId;
- this.text = text;
- this.variables = validateParameters(messageId, text, variables);
- }
-
- private String[] validateParameters(String messageId, String text, String[] variables) {
- String[] res = null;
- Matcher m = ERROR_PARAM_PATTERN.matcher(text);
- int expectedParamsNum = 0;
- while (m.find()) {
- expectedParamsNum += 1;
- }
- int actualParamsNum = (variables != null) ? variables.length : 0;
- if (actualParamsNum < expectedParamsNum) {
- log.warn(EcompLoggerErrorCode.UNKNOWN_ERROR, "", "",
- "Received less parameters than expected for error with messageId {}, expected: {}, actual: {}. Missing parameters are padded with null values.",
- messageId, expectedParamsNum, actualParamsNum);
- } else if (actualParamsNum > expectedParamsNum) {
- log.warn(EcompLoggerErrorCode.UNKNOWN_ERROR, "", "", "",
- "Received more parameters than expected for error with messageId {}, expected: {}, actual: {}. Extra parameters are ignored.",
- messageId, expectedParamsNum, actualParamsNum);
- }
- if (variables != null) {
- res = Arrays.copyOf(variables, expectedParamsNum);
- }
-
- return res;
- }
-
- public String getMessageId() {
- return this.messageId;
- }
-
- public String getText() {
- return text;
- }
-
- public String[] getVariables() {
- return variables;
- }
-
- public void setMessageId(String messageId) {
- this.messageId = messageId;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public void setVariables(String[] variables) {
- this.variables = variables;
- }
-
- public String getFormattedErrorMessage() {
- String res;
- if (variables != null && variables.length > 0) {
- Formatter formatter = new Formatter();
- try {
- res = formatter.format(this.text.replaceAll("%\\d", "%s"), (Object[]) this.variables).toString();
- } finally {
- formatter.close();
- }
- } else {
- res = this.text;
- }
- return res;
- }
+ private String messageId;
+
+ private String text;
+
+ private final String ecompRequestId;
+
+ private String[] variables;
+
+ private static Logger log = Logger.getLogger(AbstractSdncException.class.getName());
+
+ private final static Pattern ERROR_PARAM_PATTERN = Pattern.compile("%\\d");
+
+ public AbstractSdncException() {
+ this.ecompRequestId = GeneralUtility.getEcompRequestId();
+ }
+
+ public AbstractSdncException(String messageId, String text, String[] variables) {
+ this();
+ this.messageId = messageId;
+ this.text = text;
+ this.variables = validateParameters(messageId, text, variables);
+ }
+
+ private String[] validateParameters(String messageId, String text, String[] variables) {
+ String[] res = null;
+ Matcher m = ERROR_PARAM_PATTERN.matcher(text);
+ int expectedParamsNum = 0;
+ while (m.find()) {
+ expectedParamsNum += 1;
+ }
+ int actualParamsNum = (variables != null) ? variables.length : 0;
+ if (actualParamsNum < expectedParamsNum) {
+ log.warn(EcompLoggerErrorCode.UNKNOWN_ERROR,"","",
+ "Received less parameters than expected for error with messageId {}, expected: {}, actual: {}. Missing parameters are padded with null values.",
+ messageId, expectedParamsNum, actualParamsNum);
+ } else if (actualParamsNum > expectedParamsNum) {
+ log.warn(EcompLoggerErrorCode.UNKNOWN_ERROR,"","","",
+ "Received more parameters than expected for error with messageId {}, expected: {}, actual: {}. Extra parameters are ignored.",
+ messageId, expectedParamsNum, actualParamsNum);
+ }
+ if (variables != null) {
+ res = Arrays.copyOf(variables, expectedParamsNum);
+ }
+
+ return res;
+ }
+
+ public String getMessageId() {
+ return messageId;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public String getEcompRequestId() {
+ return ecompRequestId;
+ }
+
+ public String[] getVariables() {
+ return variables;
+ }
+
+ public void setMessageId(String messageId) {
+ this.messageId = messageId;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public void setVariables(String[] variables) {
+ this.variables = variables;
+ }
+
+ public String getFormattedErrorMessage() {
+ String res;
+ if (variables != null && variables.length > 0) {
+ Formatter formatter = new Formatter();
+ try {
+ res = formatter.format(this.text.replaceAll("%\\d", "%s"), (Object[]) this.variables).toString();
+ } finally {
+ formatter.close();
+ }
+ } else {
+ res = this.text;
+ }
+ return res;
+ }
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentException.java
index b9de46640a..ec33b69d82 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentException.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentException.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,13 +22,13 @@ package org.openecomp.sdc.exception;
public class DeleteLastApplicationEnvironmentException extends TechnicalException {
- private static final long serialVersionUID = -5192834855057177252L;
+ private static final long serialVersionUID = -5192834855057177252L;
- public DeleteLastApplicationEnvironmentException(String message, Throwable cause) {
- super(message, cause);
- }
+ public DeleteLastApplicationEnvironmentException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public DeleteLastApplicationEnvironmentException(String message) {
- super(message);
- }
+ public DeleteLastApplicationEnvironmentException(String message) {
+ super(message);
+ }
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteReferencedObjectException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteReferencedObjectException.java
index 28c0d99538..6957e960c3 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteReferencedObjectException.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/DeleteReferencedObjectException.java
@@ -7,9 +7,9 @@
* 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.
@@ -27,9 +27,9 @@ package org.openecomp.sdc.exception;
* @author Minh Khang VU
*/
public class DeleteReferencedObjectException extends TechnicalException {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public DeleteReferencedObjectException(String message) {
- super(message);
- }
+ public DeleteReferencedObjectException(String message) {
+ super(message);
+ }
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/FunctionalException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/FunctionalException.java
index 8989feb2ef..5bf67484d5 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/FunctionalException.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/FunctionalException.java
@@ -7,9 +7,9 @@
* 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.
@@ -23,18 +23,19 @@ package org.openecomp.sdc.exception;
/**
* All functional exception which is related to user input must go here. It's a
* checked exception to force error handling and checking.
- *
+ *
* @author mkv
+ *
*/
public class FunctionalException extends Exception {
- private static final long serialVersionUID = 6712845685798792493L;
+ private static final long serialVersionUID = 6712845685798792493L;
- public FunctionalException(String message, Throwable cause) {
- super(message, cause);
- }
+ public FunctionalException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public FunctionalException(String message) {
- super(message);
- }
+ public FunctionalException(String message) {
+ super(message);
+ }
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/IndexingServiceException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/IndexingServiceException.java
index 0e505ff7ff..d8b8518919 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/IndexingServiceException.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/IndexingServiceException.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,18 +22,18 @@ package org.openecomp.sdc.exception;
/**
* All errors happened while trying to access to index service
- *
+ *
* @author mkv
*/
public class IndexingServiceException extends TechnicalException {
- private static final long serialVersionUID = 8644422735660389058L;
+ private static final long serialVersionUID = 8644422735660389058L;
- public IndexingServiceException(String message, Throwable cause) {
- super(message, cause);
- }
+ public IndexingServiceException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public IndexingServiceException(String message) {
- super(message);
- }
+ public IndexingServiceException(String message) {
+ super(message);
+ }
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/InvalidArgumentException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/InvalidArgumentException.java
index 6de09fd594..ef6cd659e4 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/InvalidArgumentException.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/InvalidArgumentException.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,13 +21,13 @@
package org.openecomp.sdc.exception;
public class InvalidArgumentException extends TechnicalException {
- private static final long serialVersionUID = 931646037604062840L;
+ private static final long serialVersionUID = 931646037604062840L;
- public InvalidArgumentException(String message, Throwable cause) {
- super(message, cause);
- }
+ public InvalidArgumentException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public InvalidArgumentException(String message) {
- super(message);
- }
+ public InvalidArgumentException(String message) {
+ super(message);
+ }
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/NotFoundException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/NotFoundException.java
index 6f4d41c582..988325ff3e 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/NotFoundException.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/NotFoundException.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,14 +22,14 @@ package org.openecomp.sdc.exception;
public class NotFoundException extends TechnicalException {
- private static final long serialVersionUID = -5838741067731786413L;
+ private static final long serialVersionUID = -5838741067731786413L;
- public NotFoundException(String message, Throwable cause) {
- super(message, cause);
- }
+ public NotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public NotFoundException(String message) {
- super(message);
- }
+ public NotFoundException(String message) {
+ super(message);
+ }
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/OkResponseInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/OkResponseInfo.java
index 2c5da89eef..78405e0eb1 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/OkResponseInfo.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/OkResponseInfo.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,7 +22,7 @@ package org.openecomp.sdc.exception;
public class OkResponseInfo extends AbstractSdncException {
- public OkResponseInfo(String messageId, String text, String[] variables) {
- super(messageId, text, variables);
- }
+ public OkResponseInfo(String messageId, String text, String[] variables) {
+ super(messageId, text, variables);
+ }
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/PolicyException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/PolicyException.java
index c557bccad3..8c5c8609b6 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/PolicyException.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/PolicyException.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,10 +22,10 @@ package org.openecomp.sdc.exception;
public class PolicyException extends AbstractSdncException {
- public PolicyException(String messageId, String text, String[] variables) {
- super(messageId, text, variables);
- }
+ public PolicyException(String messageId, String text, String[] variables) {
+ super(messageId, text, variables);
+ }
- public PolicyException() {
- }
+ public PolicyException() {
+ }
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/ResponseFormat.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/ResponseFormat.java
index 59d30d5180..109164d07d 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/ResponseFormat.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/ResponseFormat.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,169 +22,171 @@ package org.openecomp.sdc.exception;
/**
* Nested POJOs to express required JSON format of the error
- *
+ *
* { "requestError": { "serviceException": { "messageId": "", "text": "",
* "variables": [] } } }
- *
+ *
+ *
* @author paharoni
+ *
*/
public class ResponseFormat {
- private int status;
- private RequestErrorWrapper requestErrorWrapper;
-
- public ResponseFormat() {
- super();
- }
-
- public ResponseFormat(int status) {
- super();
- this.status = status;
- }
-
- public void setStatus(int status) {
- this.status = status;
- }
-
- public Integer getStatus() {
- return status;
- }
-
- public RequestErrorWrapper getRequestError() {
- return requestErrorWrapper;
- }
-
- public void setRequestError(RequestErrorWrapper requestErrorWrapper) {
- this.requestErrorWrapper = requestErrorWrapper;
- }
-
- public void setPolicyException(PolicyException policyException) {
- this.requestErrorWrapper = new RequestErrorWrapper(new RequestError());
- requestErrorWrapper.setPolicyException(policyException);
- }
-
- public void setServiceException(ServiceException serviceException) {
- this.requestErrorWrapper = new RequestErrorWrapper(new RequestError());
- requestErrorWrapper.setServiceException(serviceException);
- }
-
- public void setOkResponseInfo(OkResponseInfo okResponseInfo) {
- this.requestErrorWrapper = new RequestErrorWrapper(new RequestError());
- requestErrorWrapper.setOkResponseInfo(okResponseInfo);
- }
-
- public String getFormattedMessage() {
- if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
- return this.requestErrorWrapper.requestError.okResponseInfo.getFormattedErrorMessage();
- }
- if (this.requestErrorWrapper.requestError.serviceException != null) {
- return this.requestErrorWrapper.requestError.serviceException.getFormattedErrorMessage();
- }
- return this.requestErrorWrapper.requestError.policyException.getFormattedErrorMessage();
- }
-
- public String getText() {
- if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
- return this.requestErrorWrapper.requestError.okResponseInfo.getText();
- }
- if (this.requestErrorWrapper.requestError.serviceException != null) {
- return this.requestErrorWrapper.requestError.serviceException.getText();
- }
- return this.requestErrorWrapper.requestError.policyException.getText();
- }
-
- public String[] getVariables() {
- if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
- return this.requestErrorWrapper.requestError.okResponseInfo.getVariables();
- }
- if (this.requestErrorWrapper.requestError.serviceException != null) {
- return this.requestErrorWrapper.requestError.serviceException.getVariables();
- }
- return this.requestErrorWrapper.requestError.policyException.getVariables();
- }
-
- public String getMessageId() {
- if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
- return this.requestErrorWrapper.requestError.okResponseInfo.getMessageId();
- }
- if (this.requestErrorWrapper.requestError.serviceException != null) {
- return this.requestErrorWrapper.requestError.serviceException.getMessageId();
- }
- return this.requestErrorWrapper.requestError.policyException.getMessageId();
- }
-
- public class RequestErrorWrapper {
- private RequestError requestError;
-
- public RequestErrorWrapper() {
- this.requestError = new RequestError();
- }
-
- public RequestErrorWrapper(RequestError requestError) {
- this.requestError = requestError;
- }
-
- public RequestError getRequestError() {
- return requestError;
- }
-
- public void setRequestError(RequestError requestError) {
- this.requestError = requestError;
- }
-
- public void setPolicyException(PolicyException policyException) {
- requestError.setPolicyException(policyException);
- }
-
- public void setServiceException(ServiceException serviceException) {
- requestError.setServiceException(serviceException);
- }
-
- public void setOkResponseInfo(OkResponseInfo okResponseInfo) {
- requestError.setOkResponseInfo(okResponseInfo);
- }
- }
-
- public class RequestError {
- @SuppressWarnings("unused")
- private PolicyException policyException;
- @SuppressWarnings("unused")
- private ServiceException serviceException;
- @SuppressWarnings("unused")
- private OkResponseInfo okResponseInfo;
-
- public RequestError() {
- }
-
- public PolicyException getPolicyException() {
- return policyException;
- }
-
- public ServiceException getServiceException() {
- return serviceException;
- }
-
- public OkResponseInfo getOkResponseInfo() {
- return okResponseInfo;
- }
-
- public void setPolicyException(PolicyException policyException) {
- this.policyException = policyException;
- }
-
- public void setServiceException(ServiceException serviceException) {
- this.serviceException = serviceException;
- }
-
- public void setOkResponseInfo(OkResponseInfo okResponseInfo) {
- this.okResponseInfo = okResponseInfo;
- }
- }
-
- @Override
- public String toString() {
- return "ResponseFormat[" + "status=" + status + ", requestErrorWrapper=" + requestErrorWrapper + ']';
- }
-
+ private int status;
+ private RequestErrorWrapper requestErrorWrapper;
+
+ public ResponseFormat() {
+ super();
+ }
+
+ public ResponseFormat(int status) {
+ super();
+ this.status = status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public Integer getStatus() {
+ return status;
+ }
+
+ public RequestErrorWrapper getRequestError() {
+ return requestErrorWrapper;
+ }
+
+ public void setRequestError(RequestErrorWrapper requestErrorWrapper) {
+ this.requestErrorWrapper = requestErrorWrapper;
+ }
+
+ public void setPolicyException(PolicyException policyException) {
+ this.requestErrorWrapper = new RequestErrorWrapper(new RequestError());
+ requestErrorWrapper.setPolicyException(policyException);
+ }
+
+ public void setServiceException(ServiceException serviceException) {
+ this.requestErrorWrapper = new RequestErrorWrapper(new RequestError());
+ requestErrorWrapper.setServiceException(serviceException);
+ }
+
+ public void setOkResponseInfo(OkResponseInfo okResponseInfo) {
+ this.requestErrorWrapper = new RequestErrorWrapper(new RequestError());
+ requestErrorWrapper.setOkResponseInfo(okResponseInfo);
+ }
+
+ public String getFormattedMessage() {
+ if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
+ return this.requestErrorWrapper.requestError.okResponseInfo.getFormattedErrorMessage();
+ }
+ if (this.requestErrorWrapper.requestError.serviceException != null) {
+ return this.requestErrorWrapper.requestError.serviceException.getFormattedErrorMessage();
+ }
+ return this.requestErrorWrapper.requestError.policyException.getFormattedErrorMessage();
+ }
+
+ public String getText() {
+ if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
+ return this.requestErrorWrapper.requestError.okResponseInfo.getText();
+ }
+ if (this.requestErrorWrapper.requestError.serviceException != null) {
+ return this.requestErrorWrapper.requestError.serviceException.getText();
+ }
+ return this.requestErrorWrapper.requestError.policyException.getText();
+ }
+
+ public String[] getVariables() {
+ if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
+ return this.requestErrorWrapper.requestError.okResponseInfo.getVariables();
+ }
+ if (this.requestErrorWrapper.requestError.serviceException != null) {
+ return this.requestErrorWrapper.requestError.serviceException.getVariables();
+ }
+ return this.requestErrorWrapper.requestError.policyException.getVariables();
+ }
+
+ public String getMessageId() {
+ if (this.requestErrorWrapper.requestError.okResponseInfo != null) {
+ return this.requestErrorWrapper.requestError.okResponseInfo.getMessageId();
+ }
+ if (this.requestErrorWrapper.requestError.serviceException != null) {
+ return this.requestErrorWrapper.requestError.serviceException.getMessageId();
+ }
+ return this.requestErrorWrapper.requestError.policyException.getMessageId();
+ }
+
+ public class RequestErrorWrapper {
+ private RequestError requestError;
+
+ public RequestErrorWrapper() {
+ this.requestError = new RequestError();
+ }
+
+ public RequestErrorWrapper(RequestError requestError) {
+ this.requestError = requestError;
+ }
+
+ public RequestError getRequestError() {
+ return requestError;
+ }
+
+ public void setRequestError(RequestError requestError) {
+ this.requestError = requestError;
+ }
+
+ public void setPolicyException(PolicyException policyException) {
+ requestError.setPolicyException(policyException);
+ }
+
+ public void setServiceException(ServiceException serviceException) {
+ requestError.setServiceException(serviceException);
+ }
+
+ public void setOkResponseInfo(OkResponseInfo okResponseInfo) {
+ requestError.setOkResponseInfo(okResponseInfo);
+ }
+ }
+
+ public class RequestError {
+ @SuppressWarnings("unused")
+ private PolicyException policyException;
+ @SuppressWarnings("unused")
+ private ServiceException serviceException;
+ @SuppressWarnings("unused")
+ private OkResponseInfo okResponseInfo;
+
+ public RequestError() {
+ }
+
+ public PolicyException getPolicyException() {
+ return policyException;
+ }
+
+ public ServiceException getServiceException() {
+ return serviceException;
+ }
+
+ public OkResponseInfo getOkResponseInfo() {
+ return okResponseInfo;
+ }
+
+ public void setPolicyException(PolicyException policyException) {
+ this.policyException = policyException;
+ }
+
+ public void setServiceException(ServiceException serviceException) {
+ this.serviceException = serviceException;
+ }
+
+ public void setOkResponseInfo(OkResponseInfo okResponseInfo) {
+ this.okResponseInfo = okResponseInfo;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "ResponseFormat[" + "status=" + status + ", requestErrorWrapper=" + requestErrorWrapper + ']';
+ }
+
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/ServiceException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/ServiceException.java
index 4bf3b2ba44..3aae180517 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/ServiceException.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/ServiceException.java
@@ -7,9 +7,9 @@
* 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.
@@ -22,11 +22,11 @@ package org.openecomp.sdc.exception;
public class ServiceException extends AbstractSdncException {
- public ServiceException(String messageId, String text, String[] variables) {
- super(messageId, text, variables);
- }
+ public ServiceException(String messageId, String text, String[] variables) {
+ super(messageId, text, variables);
+ }
- public ServiceException() {
- }
+ public ServiceException() {
+ }
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/TechnicalException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/TechnicalException.java
index 3262a685fa..96ef2f3159 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/TechnicalException.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/TechnicalException.java
@@ -7,9 +7,9 @@
* 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.
@@ -24,16 +24,17 @@ package org.openecomp.sdc.exception;
* Base class for all Alien technical exception
*
* @author mkv
+ *
*/
public abstract class TechnicalException extends RuntimeException {
- private static final long serialVersionUID = -9152473183025390161L;
+ private static final long serialVersionUID = -9152473183025390161L;
- public TechnicalException(String message, Throwable cause) {
- super(message, cause);
- }
+ public TechnicalException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public TechnicalException(String message) {
- super(message);
- }
+ public TechnicalException(String message) {
+ super(message);
+ }
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/VersionConflictException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/VersionConflictException.java
index ba0457a16c..a998d6393e 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/exception/VersionConflictException.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/VersionConflictException.java
@@ -7,9 +7,9 @@
* 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.
@@ -25,9 +25,9 @@ package org.openecomp.sdc.exception;
* manner for users
*/
public class VersionConflictException extends TechnicalException {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public VersionConflictException(String message, Throwable cause) {
- super(message, cause);
- }
+ public VersionConflictException(String message, Throwable cause) {
+ super(message, cause);
+ }
}