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 org.onap.dmaap.dmf.mr.exception;
23 import org.json.JSONObject;
26 * Represents the Error Response Object
27 * that is rendered as a JSON object when
28 * an exception or error occurs on MR Rest Service.
29 * @author rajashree.khare
33 public class ErrorResponse {
35 private int httpStatusCode;
36 private int mrErrorCode;
37 private String errorMessage;
38 private String helpURL;
39 private String statusTs;
41 private String publisherId;
42 private String publisherIp;
43 private String subscriberId;
44 private String subscriberIp;
47 public ErrorResponse(int httpStatusCode, int mrErrorCode,
48 String errorMessage, String helpURL, String statusTs, String topic,
49 String publisherId, String publisherIp, String subscriberId,
50 String subscriberIp) {
52 this.httpStatusCode = httpStatusCode;
53 this.mrErrorCode = mrErrorCode;
54 this.errorMessage = errorMessage;
55 this.helpURL = "http://onap.readthedocs.io";
56 this.statusTs = statusTs;
58 this.publisherId = publisherId;
59 this.publisherIp = publisherIp;
60 this.subscriberId = subscriberId;
61 this.subscriberIp = subscriberIp;
64 public ErrorResponse(int httpStatusCode, int mrErrorCode,
65 String errorMessage) {
67 this.httpStatusCode = httpStatusCode;
68 this.mrErrorCode = mrErrorCode;
69 this.errorMessage = errorMessage;
70 this.helpURL = "http://onap.readthedocs.io";
74 public int getHttpStatusCode() {
75 return httpStatusCode;
78 public void setHttpStatusCode(int httpStatusCode) {
79 this.httpStatusCode = httpStatusCode;
82 public int getMrErrorCode() {
87 public void setMrErrorCode(int mrErrorCode) {
88 this.mrErrorCode = mrErrorCode;
92 public String getErrorMessage() {
96 public void setErrorMessage(String errorMessage) {
97 this.errorMessage = errorMessage;
100 public String getHelpURL() {
104 public void setHelpURL(String helpURL) {
105 this.helpURL = helpURL;
109 public String toString() {
110 return "ErrorResponse {\"httpStatusCode\":\"" + httpStatusCode
111 + "\", \"mrErrorCode\":\"" + mrErrorCode + "\", \"errorMessage\":\""
112 + errorMessage + "\", \"helpURL\":\"" + helpURL + "\", \"statusTs\":\""+statusTs+"\""
113 + ", \"topicId\":\""+topic+"\", \"publisherId\":\""+publisherId+"\""
114 + ", \"publisherIp\":\""+publisherIp+"\", \"subscriberId\":\""+subscriberId+"\""
115 + ", \"subscriberIp\":\""+subscriberIp+"\"}";
118 public String getErrMapperStr1() {
119 return "ErrorResponse [httpStatusCode=" + httpStatusCode + ", mrErrorCode=" + mrErrorCode + ", errorMessage="
120 + errorMessage + ", helpURL=" + helpURL + "]";
125 public JSONObject getErrMapperStr() {
126 JSONObject o = new JSONObject();
127 o.put("status", getHttpStatusCode());
128 o.put("mrstatus", getMrErrorCode());
129 o.put("message", getErrorMessage());
130 o.put("helpURL", getHelpURL());