Merge "Add debugging of REST call"
[policy/drools-applications.git] / controlloop / common / model-impl / appclcm / src / main / java / org / onap / policy / appclcm / LcmResponseCode.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * appclcm
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. Intellectual Property. All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.appclcm;
23
24 import java.io.Serializable;
25 import org.onap.policy.appclcm.util.StatusCodeEnum;
26
27 public class LcmResponseCode implements Serializable {
28
29     /* These fields define the key to the response code value. */
30     public static final String ACCEPTED = "ACCEPTED";
31     public static final String ERROR = "ERROR";
32     public static final String REJECT = "REJECT";
33     public static final String SUCCESS = "SUCCESS";
34     public static final String FAILURE = "FAILURE";
35     public static final String PARTIAL_SUCCESS = "PARTIAL SUCCESS";
36     public static final String PARTIAL_FAILURE = "PARTIAL FAILURE";
37     private static final long serialVersionUID = 8189456447227022582L;
38
39     private final Integer code;
40
41     protected LcmResponseCode(final int code) {
42         this.code = code;
43     }
44
45     public int getCode() {
46         return this.code;
47     }
48
49     @Override
50     public String toString() {
51         return Integer.toString(this.code);
52     }
53
54     /**
55      * Translates the code to a string value that represents the meaning of the code.
56      *
57      * @param code the numeric value that is returned by APPC based on success, failure, etc. of the action requested
58      * @return the string value equivalent of the APPC response code
59      */
60     public static String toResponseValue(int code) {
61         StatusCodeEnum statusCodeEnum = StatusCodeEnum.fromStatusCode(code);
62         return (statusCodeEnum != null) ? statusCodeEnum.toString() : null;
63     }
64 }