1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 *******************************************************************************/
22 package com.att.dmf.mr.exception;
23 import org.json.JSONObject;
25 * Represents the Error Response Object
26 * that is rendered as a JSON object when
27 * an exception or error occurs on MR Rest Service.
28 * @author rajashree.khare
32 public class ErrorResponse {
34 private int httpStatusCode;
35 private int mrErrorCode;
36 private String errorMessage;
37 private String helpURL;
38 private String statusTs;
40 private String publisherId;
41 private String publisherIp;
42 private String subscriberId;
43 private String subscriberIp;
46 public ErrorResponse(int httpStatusCode, int mrErrorCode,
47 String errorMessage, String helpURL, String statusTs, String topic,
48 String publisherId, String publisherIp, String subscriberId,
49 String subscriberIp) {
51 this.httpStatusCode = httpStatusCode;
52 this.mrErrorCode = mrErrorCode;
53 this.errorMessage = errorMessage;
54 this.helpURL = "http://onap.readthedocs.io";
55 this.statusTs = statusTs;
57 this.publisherId = publisherId;
58 this.publisherIp = publisherIp;
59 this.subscriberId = subscriberId;
60 this.subscriberIp = subscriberIp;
63 public ErrorResponse(int httpStatusCode, int mrErrorCode,
64 String errorMessage) {
66 this.httpStatusCode = httpStatusCode;
67 this.mrErrorCode = mrErrorCode;
68 this.errorMessage = errorMessage;
69 this.helpURL = "http://onap.readthedocs.io";
73 public int getHttpStatusCode() {
74 return httpStatusCode;
77 public void setHttpStatusCode(int httpStatusCode) {
78 this.httpStatusCode = httpStatusCode;
81 public int getMrErrorCode() {
86 public void setMrErrorCode(int mrErrorCode) {
87 this.mrErrorCode = mrErrorCode;
91 public String getErrorMessage() {
95 public void setErrorMessage(String errorMessage) {
96 this.errorMessage = errorMessage;
99 public String getHelpURL() {
103 public void setHelpURL(String helpURL) {
104 this.helpURL = helpURL;
108 public String toString() {
109 return "ErrorResponse {\"httpStatusCode\":\"" + httpStatusCode
110 + "\", \"mrErrorCode\":\"" + mrErrorCode + "\", \"errorMessage\":\""
111 + errorMessage + "\", \"helpURL\":\"" + helpURL + "\", \"statusTs\":\""+statusTs+"\""
112 + ", \"topicId\":\""+topic+"\", \"publisherId\":\""+publisherId+"\""
113 + ", \"publisherIp\":\""+publisherIp+"\", \"subscriberId\":\""+subscriberId+"\""
114 + ", \"subscriberIp\":\""+subscriberIp+"\"}";
117 public String getErrMapperStr1() {
118 return "ErrorResponse [httpStatusCode=" + httpStatusCode + ", mrErrorCode=" + mrErrorCode + ", errorMessage="
119 + errorMessage + ", helpURL=" + helpURL + "]";
124 public JSONObject getErrMapperStr() {
125 JSONObject o = new JSONObject();
126 o.put("status", getHttpStatusCode());
127 o.put("mrstatus", getMrErrorCode());
128 o.put("message", getErrorMessage());
129 o.put("helpURL", getHelpURL());