2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
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 * ===================================================================
24 package org.onap.clamp.clds.model.properties;
26 import com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
29 import com.google.gson.JsonElement;
30 import com.google.gson.JsonObject;
31 import java.io.IOException;
32 import java.util.ArrayList;
33 import java.util.Iterator;
34 import java.util.List;
35 import java.util.Map.Entry;
38 * Parse Policy json properties.
40 * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[
41 * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{
42 * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{
43 * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]}
44 * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]
45 * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]
46 * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]}
47 * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]}
48 * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"
49 * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[
50 * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[
53 public class Policy extends AbstractModelElement {
54 protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class);
55 protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
57 private List<PolicyChain> policyChains;
59 private static final String TYPE_POLICY = "policy";
62 * Parse Policy given json node.
64 * @param modelProp The model properties.
65 * @param modelBpmn The model bpmn
66 * @param modelJson The model json
67 * @throws IOException The IO Exception
69 public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonObject modelJson) throws IOException {
70 super(TYPE_POLICY, modelProp, modelBpmn, modelJson);
73 if (modelElementJsonNode != null) {
74 Iterator<Entry<String, JsonElement>> itr = modelElementJsonNode.getAsJsonObject().entrySet().iterator();
75 policyChains = new ArrayList<>();
76 while (itr.hasNext()) {
77 policyChains.add(new PolicyChain(itr.next().getValue()));
83 * Get the policy chains.
84 * @return the policyChains
86 public List<PolicyChain> getPolicyChains() {
90 public static final String getType() {