push addional code
[sdc.git] / openecomp-be / lib / openecomp-common-lib / src / main / java / org / openecomp / sdc / common / errors / ErrorCodeAndMessage.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.errors;
22
23
24 import javax.ws.rs.core.Response;
25
26 /**
27  * This class represents an error object to be returned in failed REST instead of just returning one
28  * of HTTP fail statuses.
29  *
30  */
31 public class ErrorCodeAndMessage {
32
33   /**
34    * the HTTP status code.
35    */
36   private Response.Status status;
37
38   /**
39    * Error code no. if available.
40    */
41   private String errorCode;
42
43   /**
44    * the error message to be displayed.
45    */
46   private String message;
47
48   public ErrorCodeAndMessage() {
49   }
50
51   /**
52    * Instantiates a new Error code and message.
53    *
54    * @param status    the status
55    * @param errorCode the error code
56    */
57   public ErrorCodeAndMessage(Response.Status status, ErrorCode errorCode) {
58     this.status = status;
59     this.message = errorCode.message();
60     this.errorCode = errorCode.id();
61   }
62
63
64   public Response.Status getStatus() {
65     return status;
66   }
67
68   public void setStatus(Response.Status status) {
69     this.status = status;
70   }
71
72   public String getErrorCode() {
73     return errorCode;
74   }
75
76   public void setErrorCode(String errorCode) {
77     this.errorCode = errorCode;
78   }
79
80   public String getMessage() {
81     return message;
82   }
83
84   public void setMessage(String message) {
85     this.message = message;
86   }
87
88 }