Second part of onap rename
[appc.git] / appc-adapters / appc-ansible-adapter / appc-ansible-adapter-bundle / src / main / java / org / onap / appc / adapter / ansible / model / AnsibleResultCodes.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.adapter.ansible.model;
26
27
28 import java.util.*;
29
30 /**
31  * enum of the various codes that APP-C uses to resolve different
32  *  status of response from Ansible Server
33  **/
34
35 public enum AnsibleResultCodes{
36
37     SUCCESS(400),
38     KEYSTORE_EXCEPTION(622),
39     CERTIFICATE_ERROR(610),
40     IO_EXCEPTION (611),
41     HOST_UNKNOWN(625),
42     USER_UNAUTHORIZED(613),
43     UNKNOWN_EXCEPTION(699),
44     SSL_EXCEPTION(697),
45     INVALID_PAYLOAD(698),
46     INVALID_RESPONSE(601),
47     PENDING(100),
48     REJECTED(101),
49     FINAL_SUCCESS(200),
50     REQ_FAILURE(401),
51     MESSAGE(1),
52     CODE(0),
53     INITRESPONSE(0),
54     FINALRESPONSE(1); 
55     
56     private final Set<Integer> InitCodes = new HashSet<Integer>(Arrays.asList(100, 101));
57     private final Set<Integer> FinalCodes = new HashSet<Integer>(Arrays.asList(200, 500));
58     private final ArrayList<Set<Integer>>CodeSets = new ArrayList<Set<Integer>>(Arrays.asList(InitCodes, FinalCodes));
59     
60     private  final Set<String> MessageSet = new HashSet<String>(Arrays.asList("PENDING", "FINISHED", "TERMINATED"));
61
62     private final int value;
63     
64     AnsibleResultCodes(int value){
65         this.value = value;
66     };
67
68
69     public int getValue(){
70         return this.value;
71     }
72
73
74     public boolean checkValidCode(int Type, int Code){
75         Set<Integer>CodeSet = CodeSets.get(Type);
76         if (CodeSet.contains(Code)){
77             return true;
78         }
79         else{
80             return false;
81         }
82     }
83
84
85     public String getValidCodes(int Type){
86         Set<Integer>CodeSet = CodeSets.get(Type);
87         
88         Iterator iter = CodeSet.iterator();
89         String ValidCodes = "[ ";
90         while(iter.hasNext()){
91             ValidCodes = ValidCodes +  iter.next().toString() + ",";
92         }
93
94         ValidCodes = ValidCodes + "]";
95         return ValidCodes;
96     }
97
98
99     public boolean checkValidMessage(String Message){
100         if (MessageSet.contains(Message)){
101             return true;
102         }
103         else{
104             return false;
105         }
106     }
107
108
109
110     public String getValidMessages(){
111         Iterator iter = MessageSet.iterator();
112         String ValidMessage = "[ ";
113         while(iter.hasNext()){
114             ValidMessage = ValidMessage +  iter.next() + ",";
115         }
116
117         ValidMessage = ValidMessage + "]";
118         return ValidMessage;
119     }
120
121
122 };