2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.adapter.ansible.model;
31 * enum of the various codes that APP-C uses to resolve different
32 * status of response from Ansible Server
35 public enum AnsibleResultCodes{
38 KEYSTORE_EXCEPTION(622),
39 CERTIFICATE_ERROR(610),
42 USER_UNAUTHORIZED(613),
43 UNKNOWN_EXCEPTION(699),
46 INVALID_RESPONSE(601),
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));
60 private final Set<String> MessageSet = new HashSet<String>(Arrays.asList("PENDING", "FINISHED", "TERMINATED"));
62 private final int value;
64 AnsibleResultCodes(int value){
69 public int getValue(){
74 public boolean checkValidCode(int Type, int Code){
75 Set<Integer>CodeSet = CodeSets.get(Type);
76 if (CodeSet.contains(Code)){
85 public String getValidCodes(int Type){
86 Set<Integer>CodeSet = CodeSets.get(Type);
88 Iterator iter = CodeSet.iterator();
89 String ValidCodes = "[ ";
90 while(iter.hasNext()){
91 ValidCodes = ValidCodes + iter.next().toString() + ",";
94 ValidCodes = ValidCodes + "]";
99 public boolean checkValidMessage(String Message){
100 if (MessageSet.contains(Message)){
110 public String getValidMessages(){
111 Iterator iter = MessageSet.iterator();
112 String ValidMessage = "[ ";
113 while(iter.hasNext()){
114 ValidMessage = ValidMessage + iter.next() + ",";
117 ValidMessage = ValidMessage + "]";