[SDC-29] Amdocs OnBoard 1707 initial commit.
[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 public class ErrorCodeAndMessage {
31
32   /**
33    * the HTTP status code.
34    */
35   private Response.Status status;
36
37   /**
38    * Error code no. if available.
39    */
40   private String errorCode;
41
42   /**
43    * the error message to be displayed.
44    */
45   private String message;
46
47   public ErrorCodeAndMessage() {
48   }
49
50   /**
51    * Instantiates a new Error code and message.
52    *
53    * @param status    the status
54    * @param errorCode the error code
55    */
56   public ErrorCodeAndMessage(Response.Status status, ErrorCode errorCode) {
57     this.status = status;
58     this.message = errorCode.message();
59     this.errorCode = errorCode.id();
60   }
61
62
63   public Response.Status getStatus() {
64     return status;
65   }
66
67   public void setStatus(Response.Status status) {
68     this.status = status;
69   }
70
71   public String getErrorCode() {
72     return errorCode;
73   }
74
75   public void setErrorCode(String errorCode) {
76     this.errorCode = errorCode;
77   }
78
79   public String getMessage() {
80     return message;
81   }
82
83   public void setMessage(String message) {
84     this.message = message;
85   }
86
87 }