update the package name
[dmaap/messagerouter/msgrtr.git] / src / main / java / org / onap / dmaap / dmf / mr / exception / ErrorResponse.java
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  org.onap.dmaap
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
11 *  
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=========================================================
18  *  
19  *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
20  *  
21  *******************************************************************************/
22 package org.onap.dmaap.dmf.mr.exception;
23 import org.json.JSONObject;
24 /**
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
29  *
30  */
31 //@XmlRootElement
32 public class ErrorResponse {
33         
34         private int httpStatusCode;
35         private int mrErrorCode;
36     private String errorMessage;
37     private String helpURL;
38     private String statusTs;
39     private String topic;
40     private String publisherId;
41     private String publisherIp;
42     private String subscriberId;
43     private String subscriberIp;
44         
45
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) {
50                 super();
51                 this.httpStatusCode = httpStatusCode;
52                 this.mrErrorCode = mrErrorCode;
53                 this.errorMessage = errorMessage;
54                 this.helpURL = "http://onap.readthedocs.io";
55                 this.statusTs = statusTs;
56                 this.topic = topic;
57                 this.publisherId = publisherId;
58                 this.publisherIp = publisherIp;
59                 this.subscriberId = subscriberId;
60                 this.subscriberIp = subscriberIp;
61         }
62
63         public ErrorResponse(int httpStatusCode, int mrErrorCode,
64                         String errorMessage) {
65                 super();
66                 this.httpStatusCode = httpStatusCode;
67                 this.mrErrorCode = mrErrorCode;
68                 this.errorMessage = errorMessage;
69                 this.helpURL = "http://onap.readthedocs.io";
70                 
71         }
72         
73         public int getHttpStatusCode() {
74                 return httpStatusCode;
75         }
76
77         public void setHttpStatusCode(int httpStatusCode) {
78                 this.httpStatusCode = httpStatusCode;
79         }
80         
81         public int getMrErrorCode() {
82                 return mrErrorCode;
83         }
84
85
86         public void setMrErrorCode(int mrErrorCode) {
87                 this.mrErrorCode = mrErrorCode;
88         }
89
90         
91         public String getErrorMessage() {
92                 return errorMessage;
93         }
94
95         public void setErrorMessage(String errorMessage) {
96                 this.errorMessage = errorMessage;
97         }
98
99         public String getHelpURL() {
100                 return helpURL;
101         }
102
103         public void setHelpURL(String helpURL) {
104                 this.helpURL = helpURL;
105         }
106
107         @Override
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+"\"}";
115         }
116         
117         public String getErrMapperStr1() {
118                 return "ErrorResponse [httpStatusCode=" + httpStatusCode + ", mrErrorCode=" + mrErrorCode + ", errorMessage="
119                                 + errorMessage + ", helpURL=" + helpURL + "]";
120         }
121
122         
123         
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());
130                 return o;
131         }
132         
133     
134         
135 }