fixing warnings from checkstyle in common-app-api
[sdc.git] / common-app-api / src / main / java / org / openecomp / sdc / common / api / ResponseInfo.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 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  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.common.api;
22
23 import com.fasterxml.jackson.core.JsonProcessingException;
24 import com.fasterxml.jackson.databind.ObjectMapper;
25
26 public class ResponseInfo {
27
28     public enum ResponseStatusEnum {
29         SUCCESS("success"), LOGIN_FAILED("loginFailed"), INTERNAL_ERROR("internalError"), MISSING_HEADERS("required headers are missing"), TIMEOUT("timeout"), PARSING_ERROR("parsingFailed");
30
31         private String statusDescription;
32
33         ResponseStatusEnum(String status) {
34             this.statusDescription = status;
35         }
36
37         public String getStatusDescription() {
38             return statusDescription;
39         }
40     }
41
42     private ResponseStatusEnum applicativeStatus;
43     private String description;
44
45     public ResponseInfo(ResponseStatusEnum applicativeStatus, String description) {
46         super();
47         this.applicativeStatus = applicativeStatus;
48         this.description = description;
49     }
50
51     public ResponseInfo(ResponseStatusEnum applicativeStatus) {
52         super();
53         this.applicativeStatus = applicativeStatus;
54     }
55
56     public ResponseStatusEnum getApplicativeStatus() {
57         return applicativeStatus;
58     }
59
60     public void setApplicativeStatus(ResponseStatusEnum applicativeStatus) {
61         this.applicativeStatus = applicativeStatus;
62     }
63
64     public String getDescription() {
65         return description;
66     }
67
68     public void setDescription(String description) {
69         this.description = description;
70     }
71
72     @Override
73     public String toString() {
74         ObjectMapper mapper = new ObjectMapper();
75         String tostring = super.toString();
76         try {
77             tostring = mapper.writeValueAsString(this);
78         } catch (JsonProcessingException e) {
79
80         }
81         return tostring;
82     }
83 }