DMAAP-MR - Merge MR repos
[dmaap/messagerouter/messageservice.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 /**
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
30  *
31  */
32 //@XmlRootElement
33 public class ErrorResponse {
34         
35         private int httpStatusCode;
36         private int mrErrorCode;
37     private String errorMessage;
38     private String helpURL;
39     private String statusTs;
40     private String topic;
41     private String publisherId;
42     private String publisherIp;
43     private String subscriberId;
44     private String subscriberIp;
45         
46
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) {
51                 super();
52                 this.httpStatusCode = httpStatusCode;
53                 this.mrErrorCode = mrErrorCode;
54                 this.errorMessage = errorMessage;
55                 this.helpURL = "http://onap.readthedocs.io";
56                 this.statusTs = statusTs;
57                 this.topic = topic;
58                 this.publisherId = publisherId;
59                 this.publisherIp = publisherIp;
60                 this.subscriberId = subscriberId;
61                 this.subscriberIp = subscriberIp;
62         }
63
64         public ErrorResponse(int httpStatusCode, int mrErrorCode,
65                         String errorMessage) {
66                 super();
67                 this.httpStatusCode = httpStatusCode;
68                 this.mrErrorCode = mrErrorCode;
69                 this.errorMessage = errorMessage;
70                 this.helpURL = "http://onap.readthedocs.io";
71                 
72         }
73         
74         public int getHttpStatusCode() {
75                 return httpStatusCode;
76         }
77
78         public void setHttpStatusCode(int httpStatusCode) {
79                 this.httpStatusCode = httpStatusCode;
80         }
81         
82         public int getMrErrorCode() {
83                 return mrErrorCode;
84         }
85
86
87         public void setMrErrorCode(int mrErrorCode) {
88                 this.mrErrorCode = mrErrorCode;
89         }
90
91         
92         public String getErrorMessage() {
93                 return errorMessage;
94         }
95
96         public void setErrorMessage(String errorMessage) {
97                 this.errorMessage = errorMessage;
98         }
99
100         public String getHelpURL() {
101                 return helpURL;
102         }
103
104         public void setHelpURL(String helpURL) {
105                 this.helpURL = helpURL;
106         }
107
108         @Override
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+"\"}";
116         }
117         
118         public String getErrMapperStr1() {
119                 return "ErrorResponse [httpStatusCode=" + httpStatusCode + ", mrErrorCode=" + mrErrorCode + ", errorMessage="
120                                 + errorMessage + ", helpURL=" + helpURL + "]";
121         }
122
123         
124         
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());
131                 return o;
132         }
133         
134     
135         
136 }