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;
28 import com.fasterxml.jackson.databind.JsonNode;
30 import java.util.List;
33 * Parse policyConfigurations from Policy json properties.
36 * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[
37 * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{
38 * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{
39 * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]}
40 * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]
41 * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]
42 * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]}
43 * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]}
44 * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"
45 * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[
46 * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[
47 * "vf3RtPi"]},{"name":
48 * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}]
50 public class PolicyItem implements Cloneable {
52 protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyItem.class);
53 protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
55 private String recipe;
56 private int maxRetries;
57 private int retryTimeLimit;
58 private String parentPolicy;
59 private List<String> parentPolicyConditions;
61 private String targetResourceId;
64 * Parse Policy given json node.
68 public PolicyItem(JsonNode node) {
69 id = AbstractModelElement.getValueByName(node, "_id");
70 recipe = AbstractModelElement.getValueByName(node, "recipe");
71 maxRetries = AbstractModelElement.getIntValueByName(node, "maxRetries");
72 retryTimeLimit = AbstractModelElement.getIntValueByName(node, "retryTimeLimit");
73 parentPolicy = AbstractModelElement.getValueByName(node, "parentPolicy");
74 parentPolicyConditions = AbstractModelElement.getValuesByName(node, "parentPolicyConditions");
75 targetResourceId = AbstractModelElement.getValueByName(node, "targetResourceId");
76 if (targetResourceId != null && targetResourceId.isEmpty()) {
77 this.setTargetResourceId(null);
84 public String getId() {
91 public String getRecipe() {
98 public void setId(String id) {
105 public void setRecipe(String recipe) {
106 this.recipe = recipe;
110 * @set the parentPolicy
112 public void setParentPolicy(String parentPolicy) {
113 this.parentPolicy = parentPolicy;
117 * @set the maxRetries
119 public void setMaxRetries(int maxRetries) {
120 this.maxRetries = maxRetries;
124 * @set the retryTimeLimit
126 public void setRetryTimeLimit(int retryTimeLimit) {
127 this.retryTimeLimit = retryTimeLimit;
131 * @set the parentPolicyConditions
133 public void setParentPolicyConditions(List<String> parentPolicyConditions) {
134 this.parentPolicyConditions = parentPolicyConditions;
138 * @return the maxRetries
140 public int getMaxRetries() {
145 * @return the retryTimeLimit
147 public int getRetryTimeLimit() {
148 return retryTimeLimit;
152 * @return the parentPolicy
154 public String getParentPolicy() {
159 * @return the parentPolicyConditions
161 public List<String> getParentPolicyConditions() {
162 return parentPolicyConditions;
168 public String getActor() {
175 public void setActor(String actor) {
179 public String getTargetResourceId() {
180 return targetResourceId;
183 public void setTargetResourceId(String targetResourceId) {
184 this.targetResourceId = targetResourceId;
188 public Object clone() throws CloneNotSupportedException {
189 return super.clone();