2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Amdocs
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.openecomp.appc.adapter.ansible.model;
29 * enum of the various codes that APP-C uses to resolve different
30 * status of response from Ansible Server
33 public enum AnsibleResultCodes{
36 KEYSTORE_EXCEPTION(622),
37 CERTIFICATE_ERROR(610),
40 USER_UNAUTHORIZED(613),
41 UNKNOWN_EXCEPTION(699),
44 INVALID_RESPONSE(601),
54 private final Set<Integer> InitCodes = new HashSet<Integer>(Arrays.asList(100, 101));
55 private final Set<Integer> FinalCodes = new HashSet<Integer>(Arrays.asList(200, 500));
56 private final ArrayList<Set<Integer>>CodeSets = new ArrayList<Set<Integer>>(Arrays.asList(InitCodes, FinalCodes));
58 private final Set<String> MessageSet = new HashSet<String>(Arrays.asList("PENDING", "FINISHED", "TERMINATED"));
60 private final int value;
62 AnsibleResultCodes(int value){
67 public int getValue(){
72 public boolean checkValidCode(int Type, int Code){
73 Set<Integer>CodeSet = CodeSets.get(Type);
74 if (CodeSet.contains(Code)){
83 public String getValidCodes(int Type){
84 Set<Integer>CodeSet = CodeSets.get(Type);
86 Iterator iter = CodeSet.iterator();
87 String ValidCodes = "[ ";
88 while(iter.hasNext()){
89 ValidCodes = ValidCodes + iter.next().toString() + ",";
92 ValidCodes = ValidCodes + "]";
97 public boolean checkValidMessage(String Message){
98 if (MessageSet.contains(Message)){
108 public String getValidMessages(){
109 Iterator iter = MessageSet.iterator();
110 String ValidMessage = "[ ";
111 while(iter.hasNext()){
112 ValidMessage = ValidMessage + iter.next() + ",";
115 ValidMessage = ValidMessage + "]";