summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/att/dmf/mr/exception
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/att/dmf/mr/exception')
-rw-r--r--src/main/java/com/att/dmf/mr/exception/DMaaPAccessDeniedException.java42
-rw-r--r--src/main/java/com/att/dmf/mr/exception/DMaaPCambriaExceptionMapper.java94
-rw-r--r--src/main/java/com/att/dmf/mr/exception/DMaaPErrorMessages.java248
-rw-r--r--src/main/java/com/att/dmf/mr/exception/DMaaPResponseCode.java93
-rw-r--r--src/main/java/com/att/dmf/mr/exception/DMaaPWebExceptionMapper.java138
-rw-r--r--src/main/java/com/att/dmf/mr/exception/ErrorResponse.java135
6 files changed, 750 insertions, 0 deletions
diff --git a/src/main/java/com/att/dmf/mr/exception/DMaaPAccessDeniedException.java b/src/main/java/com/att/dmf/mr/exception/DMaaPAccessDeniedException.java
new file mode 100644
index 0000000..de66617
--- /dev/null
+++ b/src/main/java/com/att/dmf/mr/exception/DMaaPAccessDeniedException.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
+ *******************************************************************************/
+package com.att.dmf.mr.exception;
+
+import com.att.dmf.mr.CambriaApiException;
+
+public class DMaaPAccessDeniedException extends CambriaApiException{
+
+
+
+ public DMaaPAccessDeniedException(ErrorResponse errRes) {
+ super(errRes);
+
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+
+}
diff --git a/src/main/java/com/att/dmf/mr/exception/DMaaPCambriaExceptionMapper.java b/src/main/java/com/att/dmf/mr/exception/DMaaPCambriaExceptionMapper.java
new file mode 100644
index 0000000..84634a9
--- /dev/null
+++ b/src/main/java/com/att/dmf/mr/exception/DMaaPCambriaExceptionMapper.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
+ *******************************************************************************/
+package com.att.dmf.mr.exception;
+
+import javax.inject.Singleton;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.http.HttpStatus;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.att.dmf.mr.CambriaApiException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+/**
+ * Exception Mapper class to handle
+ * CambriaApiException
+ * @author rajashree.khare
+ *
+ */
+@Provider
+@Singleton
+public class DMaaPCambriaExceptionMapper implements ExceptionMapper<CambriaApiException>{
+
+private ErrorResponse errRes;
+
+//private static final Logger LOGGER = Logger.getLogger(DMaaPCambriaExceptionMapper.class);
+private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DMaaPCambriaExceptionMapper.class);
+
+ @Autowired
+ private DMaaPErrorMessages msgs;
+
+ public DMaaPCambriaExceptionMapper() {
+ super();
+ LOGGER.info("Cambria Exception Mapper Created..");
+ }
+
+ @Override
+ public Response toResponse(CambriaApiException ex) {
+
+ LOGGER.info("Reached Cambria Exception Mapper..");
+
+ /**
+ * Cambria Generic Exception
+ */
+ if(ex instanceof CambriaApiException)
+ {
+
+ errRes = ex.getErrRes();
+ if(errRes!=null) {
+
+ return Response.status(errRes.getHttpStatusCode()).entity(errRes).type(MediaType.APPLICATION_JSON)
+ .build();
+ }
+ else
+ {
+ return Response.status(ex.getStatus()).entity(ex.getMessage()).type(MediaType.APPLICATION_JSON)
+ .build();
+ }
+
+
+ }
+ else
+ {
+ errRes = new ErrorResponse(HttpStatus.SC_EXPECTATION_FAILED, DMaaPResponseCode.SERVER_UNAVAILABLE.getResponseCode(), msgs.getServerUnav());
+ return Response.status(HttpStatus.SC_EXPECTATION_FAILED).entity(errRes).type(MediaType.APPLICATION_JSON).build();
+ }
+
+ }
+
+
+}
diff --git a/src/main/java/com/att/dmf/mr/exception/DMaaPErrorMessages.java b/src/main/java/com/att/dmf/mr/exception/DMaaPErrorMessages.java
new file mode 100644
index 0000000..409aa60
--- /dev/null
+++ b/src/main/java/com/att/dmf/mr/exception/DMaaPErrorMessages.java
@@ -0,0 +1,248 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
+ *******************************************************************************/
+package com.att.dmf.mr.exception;
+
+import javax.annotation.PostConstruct;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.support.SpringBeanAutowiringSupport;
+
+/**
+ * This Class reads the error message properties
+ * from the properties file
+ * @author rajashree.khare
+ *
+ */
+@Component
+public class DMaaPErrorMessages {
+
+
+
+
+ //@Value("${resource.not.found}")
+ private String notFound="The requested resource was not found.Please verify the URL and try again";
+
+// @Value("${server.unavailable}")
+ private String serverUnav="Server is temporarily unavailable or busy.Try again later, or try another server in the cluster.";
+
+// @Value("${http.method.not.allowed}")
+ private String methodNotAllowed="The specified HTTP method is not allowed for the requested resource.Enter a valid HTTP method and try again.";
+
+ //@Value("${incorrect.request.json}")
+ private String badRequest="Incorrect JSON object. Please correct the JSON format and try again.";
+
+// @Value("${network.time.out}")
+ private String nwTimeout="Connection to the DMaaP MR was timed out.Please try again.";
+
+ //@Value("${get.topic.failure}")
+ private String topicsfailure="Failed to retrieve list of all topics.";
+
+ //@Value("${not.permitted.access.1}")
+ private String notPermitted1="Access Denied.User does not have permission to perform";
+
+ //@Value("${not.permitted.access.2}")
+ private String notPermitted2="operation on Topic:";
+
+ //@Value("${get.topic.details.failure}")
+ private String topicDetailsFail="Failed to retrieve details of topic:";
+
+ //@Value("${create.topic.failure}")
+ private String createTopicFail="Failed to create topic:";
+
+ //@Value("${delete.topic.failure}")
+ private String deleteTopicFail="Failed to delete topic:";
+
+ //@Value("${incorrect.json}")
+ private String incorrectJson="Incorrect JSON object.Could not parse JSON. Please correct the JSON format and try again.";
+
+ //@Value("${consume.msg.error}")
+ private String consumeMsgError="Error while reading data from topic.";
+
+ //@Value("${publish.msg.error}")
+ private String publishMsgError="Error while publishing data to topic.";
+
+
+ //@Value("${publish.msg.count}")
+ private String publishMsgCount="Successfully published number of messages :";
+
+
+ //@Value("${authentication.failure}")
+ private String authFailure="Access Denied: Invalid Credentials. Enter a valid MechId and Password and try again.";
+ //@Value("${msg_size_exceeds}")
+ private String msgSizeExceeds="Message size exceeds the default size.";
+
+
+ //@Value("${topic.not.exist}")
+ private String topicNotExist="No such topic exists.";
+
+ public String getMsgSizeExceeds() {
+ return msgSizeExceeds;
+ }
+
+ public void setMsgSizeExceeds(String msgSizeExceeds) {
+ this.msgSizeExceeds = msgSizeExceeds;
+ }
+
+ public String getNotFound() {
+ return notFound;
+ }
+
+ public void setNotFound(String notFound) {
+ this.notFound = notFound;
+ }
+
+ public String getServerUnav() {
+ return serverUnav;
+ }
+
+ public void setServerUnav(String serverUnav) {
+ this.serverUnav = serverUnav;
+ }
+
+ public String getMethodNotAllowed() {
+ return methodNotAllowed;
+ }
+
+ public void setMethodNotAllowed(String methodNotAllowed) {
+ this.methodNotAllowed = methodNotAllowed;
+ }
+
+ public String getBadRequest() {
+ return badRequest;
+ }
+
+ public void setBadRequest(String badRequest) {
+ this.badRequest = badRequest;
+ }
+
+ public String getNwTimeout() {
+ return nwTimeout;
+ }
+
+ public void setNwTimeout(String nwTimeout) {
+ this.nwTimeout = nwTimeout;
+ }
+
+ public String getNotPermitted1() {
+ return notPermitted1;
+ }
+
+ public void setNotPermitted1(String notPermitted1) {
+ this.notPermitted1 = notPermitted1;
+ }
+
+ public String getNotPermitted2() {
+ return notPermitted2;
+ }
+
+ public void setNotPermitted2(String notPermitted2) {
+ this.notPermitted2 = notPermitted2;
+ }
+
+ public String getTopicsfailure() {
+ return topicsfailure;
+ }
+
+ public void setTopicsfailure(String topicsfailure) {
+ this.topicsfailure = topicsfailure;
+ }
+
+ public String getTopicDetailsFail() {
+ return topicDetailsFail;
+ }
+
+ public void setTopicDetailsFail(String topicDetailsFail) {
+ this.topicDetailsFail = topicDetailsFail;
+ }
+
+ public String getCreateTopicFail() {
+ return createTopicFail;
+ }
+
+ public void setCreateTopicFail(String createTopicFail) {
+ this.createTopicFail = createTopicFail;
+ }
+
+ public String getIncorrectJson() {
+ return incorrectJson;
+ }
+
+ public void setIncorrectJson(String incorrectJson) {
+ this.incorrectJson = incorrectJson;
+ }
+
+ public String getDeleteTopicFail() {
+ return deleteTopicFail;
+ }
+
+ public void setDeleteTopicFail(String deleteTopicFail) {
+ this.deleteTopicFail = deleteTopicFail;
+ }
+
+ public String getConsumeMsgError() {
+ return consumeMsgError;
+ }
+
+ public void setConsumeMsgError(String consumeMsgError) {
+ this.consumeMsgError = consumeMsgError;
+ }
+
+ public String getPublishMsgError() {
+ return publishMsgError;
+ }
+
+ public void setPublishMsgError(String publishMsgError) {
+ this.publishMsgError = publishMsgError;
+ }
+
+ public String getPublishMsgCount() {
+ return publishMsgCount;
+ }
+
+ public String getAuthFailure() {
+ return authFailure;
+ }
+
+ public void setAuthFailure(String authFailure) {
+ this.authFailure = authFailure;
+ }
+
+ public void setPublishMsgCount(String publishMsgCount) {
+ this.publishMsgCount = publishMsgCount;
+ }
+
+ public String getTopicNotExist() {
+ return topicNotExist;
+ }
+
+ public void setTopicNotExist(String topicNotExist) {
+ this.topicNotExist = topicNotExist;
+ }
+
+
+ @PostConstruct
+ public void init() {
+ SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
+ }
+
+}
diff --git a/src/main/java/com/att/dmf/mr/exception/DMaaPResponseCode.java b/src/main/java/com/att/dmf/mr/exception/DMaaPResponseCode.java
new file mode 100644
index 0000000..593863a
--- /dev/null
+++ b/src/main/java/com/att/dmf/mr/exception/DMaaPResponseCode.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
+ *******************************************************************************/
+package com.att.dmf.mr.exception;
+
+/**
+ * Define the Error Response Codes for MR
+ * using this enumeration
+ * @author rajashree.khare
+ *
+ */
+public enum DMaaPResponseCode {
+
+
+ /**
+ * GENERIC
+ */
+ RESOURCE_NOT_FOUND(3001),
+ SERVER_UNAVAILABLE(3002),
+ METHOD_NOT_ALLOWED(3003),
+ GENERIC_INTERNAL_ERROR(1004),
+ /**
+ * AAF
+ */
+ INVALID_CREDENTIALS(4001),
+ ACCESS_NOT_PERMITTED(4002),
+ UNABLE_TO_AUTHORIZE(4003),
+ /**
+ * PUBLISH AND SUBSCRIBE
+ */
+ MSG_SIZE_EXCEEDS_BATCH_LIMIT(5001),
+ UNABLE_TO_PUBLISH(5002),
+ INCORRECT_BATCHING_FORMAT(5003),
+ MSG_SIZE_EXCEEDS_MSG_LIMIT(5004),
+ INCORRECT_JSON(5005),
+ CONN_TIMEOUT(5006),
+ PARTIAL_PUBLISH_MSGS(5007),
+ CONSUME_MSG_ERROR(5008),
+ PUBLISH_MSG_ERROR(5009),
+ RETRIEVE_TRANSACTIONS(5010),
+ RETRIEVE_TRANSACTIONS_DETAILS(5011),
+ TOO_MANY_REQUESTS(5012),
+
+ RATE_LIMIT_EXCEED(301),
+
+ /**
+ * TOPICS
+ */
+ GET_TOPICS_FAIL(6001),
+ GET_TOPICS_DETAILS_FAIL(6002),
+ CREATE_TOPIC_FAIL(6003),
+ DELETE_TOPIC_FAIL(6004),
+ GET_PUBLISHERS_BY_TOPIC(6005),
+ GET_CONSUMERS_BY_TOPIC(6006),
+ PERMIT_PUBLISHER_FOR_TOPIC(6007),
+ REVOKE_PUBLISHER_FOR_TOPIC(6008),
+ PERMIT_CONSUMER_FOR_TOPIC(6009),
+ REVOKE_CONSUMER_FOR_TOPIC(6010),
+ GET_CONSUMER_CACHE(6011),
+ DROP_CONSUMER_CACHE(6012),
+ GET_METRICS_ERROR(6013),
+ GET_BLACKLIST(6014),
+ ADD_BLACKLIST(6015),
+ REMOVE_BLACKLIST(6016),
+ TOPIC_NOT_IN_AAF(6017);
+ private int responseCode;
+
+ public int getResponseCode() {
+ return responseCode;
+ }
+ private DMaaPResponseCode (final int code) {
+ responseCode = code;
+ }
+
+}
diff --git a/src/main/java/com/att/dmf/mr/exception/DMaaPWebExceptionMapper.java b/src/main/java/com/att/dmf/mr/exception/DMaaPWebExceptionMapper.java
new file mode 100644
index 0000000..a971c3f
--- /dev/null
+++ b/src/main/java/com/att/dmf/mr/exception/DMaaPWebExceptionMapper.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
+ *******************************************************************************/
+package com.att.dmf.mr.exception;
+
+import javax.inject.Singleton;
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.NotAllowedException;
+import javax.ws.rs.NotAuthorizedException;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.ServiceUnavailableException;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.http.HttpStatus;
+//import org.apache.log-4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+/**
+ * Exception Mapper class to handle
+ * Jersey Exceptions
+ * @author rajashree.khare
+ *
+ */
+@Provider
+@Singleton
+public class DMaaPWebExceptionMapper implements ExceptionMapper<WebApplicationException>{
+
+ //private static final Logger LOGGER = Logger
+ // .getLogger(DMaaPWebExceptionMapper.class);
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(DMaaPWebExceptionMapper.class);
+ private ErrorResponse errRes;
+
+ @Autowired
+ private DMaaPErrorMessages msgs;
+
+ public DMaaPWebExceptionMapper() {
+ super();
+ LOGGER.info("WebException Mapper Created..");
+ }
+
+ @Override
+ public Response toResponse(WebApplicationException ex) {
+
+ LOGGER.info("Reached WebException Mapper");
+
+ /**
+ * Resource Not Found
+ */
+ if(ex instanceof NotFoundException)
+ {
+ errRes = new ErrorResponse(HttpStatus.SC_NOT_FOUND,DMaaPResponseCode.RESOURCE_NOT_FOUND.getResponseCode(),msgs.getNotFound());
+
+ LOGGER.info(errRes.toString());
+
+ return Response.status(errRes.getHttpStatusCode()).entity(errRes).type(MediaType.APPLICATION_JSON)
+ .build();
+
+ }
+
+ if(ex instanceof InternalServerErrorException)
+ {
+ errRes = new ErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,DMaaPResponseCode.SERVER_UNAVAILABLE.getResponseCode(),msgs.getServerUnav());
+
+ LOGGER.info(errRes.toString());
+ return Response.status(errRes.getHttpStatusCode()).entity(errRes).type(MediaType.APPLICATION_JSON)
+ .build();
+
+ }
+
+ if(ex instanceof NotAuthorizedException)
+ {
+ errRes = new ErrorResponse(HttpStatus.SC_UNAUTHORIZED,DMaaPResponseCode.ACCESS_NOT_PERMITTED.getResponseCode(),msgs.getAuthFailure());
+
+ LOGGER.info(errRes.toString());
+ return Response.status(errRes.getHttpStatusCode()).entity(errRes).type(MediaType.APPLICATION_JSON)
+ .build();
+ }
+
+ if(ex instanceof BadRequestException)
+ {
+ errRes = new ErrorResponse(HttpStatus.SC_BAD_REQUEST,DMaaPResponseCode.INCORRECT_JSON.getResponseCode(),msgs.getBadRequest());
+
+ LOGGER.info(errRes.toString());
+ return Response.status(errRes.getHttpStatusCode()).entity(errRes).type(MediaType.APPLICATION_JSON)
+ .build();
+ }
+ if(ex instanceof NotAllowedException)
+ {
+ errRes = new ErrorResponse(HttpStatus.SC_METHOD_NOT_ALLOWED,DMaaPResponseCode.METHOD_NOT_ALLOWED.getResponseCode(),msgs.getMethodNotAllowed());
+
+ LOGGER.info(errRes.toString());
+ return Response.status(errRes.getHttpStatusCode()).entity(errRes).type(MediaType.APPLICATION_JSON)
+ .build();
+ }
+
+ if(ex instanceof ServiceUnavailableException)
+ {
+ errRes = new ErrorResponse(HttpStatus.SC_SERVICE_UNAVAILABLE,DMaaPResponseCode.SERVER_UNAVAILABLE.getResponseCode(),msgs.getServerUnav());
+
+ LOGGER.info(errRes.toString());
+ return Response.status(errRes.getHttpStatusCode()).entity(errRes).type(MediaType.APPLICATION_JSON)
+ .build();
+ }
+
+
+ return Response.serverError().build();
+ }
+
+
+
+
+}
diff --git a/src/main/java/com/att/dmf/mr/exception/ErrorResponse.java b/src/main/java/com/att/dmf/mr/exception/ErrorResponse.java
new file mode 100644
index 0000000..c92cadd
--- /dev/null
+++ b/src/main/java/com/att/dmf/mr/exception/ErrorResponse.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
+ *******************************************************************************/
+package com.att.dmf.mr.exception;
+import org.json.JSONObject;
+/**
+ * Represents the Error Response Object
+ * that is rendered as a JSON object when
+ * an exception or error occurs on MR Rest Service.
+ * @author rajashree.khare
+ *
+ */
+//@XmlRootElement
+public class ErrorResponse {
+
+ private int httpStatusCode;
+ private int mrErrorCode;
+ private String errorMessage;
+ private String helpURL;
+ private String statusTs;
+ private String topic;
+ private String publisherId;
+ private String publisherIp;
+ private String subscriberId;
+ private String subscriberIp;
+
+
+ public ErrorResponse(int httpStatusCode, int mrErrorCode,
+ String errorMessage, String helpURL, String statusTs, String topic,
+ String publisherId, String publisherIp, String subscriberId,
+ String subscriberIp) {
+ super();
+ this.httpStatusCode = httpStatusCode;
+ this.mrErrorCode = mrErrorCode;
+ this.errorMessage = errorMessage;
+ this.helpURL = "http://onap.readthedocs.io";
+ this.statusTs = statusTs;
+ this.topic = topic;
+ this.publisherId = publisherId;
+ this.publisherIp = publisherIp;
+ this.subscriberId = subscriberId;
+ this.subscriberIp = subscriberIp;
+ }
+
+ public ErrorResponse(int httpStatusCode, int mrErrorCode,
+ String errorMessage) {
+ super();
+ this.httpStatusCode = httpStatusCode;
+ this.mrErrorCode = mrErrorCode;
+ this.errorMessage = errorMessage;
+ this.helpURL = "http://onap.readthedocs.io";
+
+ }
+
+ public int getHttpStatusCode() {
+ return httpStatusCode;
+ }
+
+ public void setHttpStatusCode(int httpStatusCode) {
+ this.httpStatusCode = httpStatusCode;
+ }
+
+ public int getMrErrorCode() {
+ return mrErrorCode;
+ }
+
+
+ public void setMrErrorCode(int mrErrorCode) {
+ this.mrErrorCode = mrErrorCode;
+ }
+
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getHelpURL() {
+ return helpURL;
+ }
+
+ public void setHelpURL(String helpURL) {
+ this.helpURL = helpURL;
+ }
+
+ @Override
+ public String toString() {
+ return "ErrorResponse {\"httpStatusCode\":\"" + httpStatusCode
+ + "\", \"mrErrorCode\":\"" + mrErrorCode + "\", \"errorMessage\":\""
+ + errorMessage + "\", \"helpURL\":\"" + helpURL + "\", \"statusTs\":\""+statusTs+"\""
+ + ", \"topicId\":\""+topic+"\", \"publisherId\":\""+publisherId+"\""
+ + ", \"publisherIp\":\""+publisherIp+"\", \"subscriberId\":\""+subscriberId+"\""
+ + ", \"subscriberIp\":\""+subscriberIp+"\"}";
+ }
+
+ public String getErrMapperStr1() {
+ return "ErrorResponse [httpStatusCode=" + httpStatusCode + ", mrErrorCode=" + mrErrorCode + ", errorMessage="
+ + errorMessage + ", helpURL=" + helpURL + "]";
+ }
+
+
+
+ public JSONObject getErrMapperStr() {
+ JSONObject o = new JSONObject();
+ o.put("status", getHttpStatusCode());
+ o.put("mrstatus", getMrErrorCode());
+ o.put("message", getErrorMessage());
+ o.put("helpURL", getHelpURL());
+ return o;
+ }
+
+
+
+}