2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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 * ===================================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
24 package org.onap.clamp.clds.model.prop;
26 import com.fasterxml.jackson.databind.JsonNode;
28 import java.util.List;
29 import java.util.logging.Logger;
32 * Parse policyConfigurations from Policy json properties.
34 * Example json: "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]}],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":["vf3RtPi"]}]]}]
36 public class PolicyItem {
37 private static final Logger logger = Logger.getLogger(Policy.class.getName());
39 private final String id;
40 private final String recipe;
41 private final int maxRetries;
42 private final int retryTimeLimit;
43 private final String parentPolicy;
44 private final List<String> parentPolicyConditions;
47 * Parse Policy given json node.
51 public PolicyItem(JsonNode node) {
52 id = ModelElement.getValueByName(node, "_id");
53 recipe = ModelElement.getValueByName(node, "recipe");
54 maxRetries = ModelElement.getIntValueByName(node, "maxRetries");
55 retryTimeLimit = ModelElement.getIntValueByName(node, "retryTimeLimit");
56 parentPolicy = ModelElement.getValueByName(node, "parentPolicy");
57 parentPolicyConditions = ModelElement.getValuesByName(node, "parentPolicyConditions");
64 public String getId() {
71 public String getRecipe() {
76 * @return the maxRetries
78 public int getMaxRetries() {
83 * @return the retryTimeLimit
85 public int getRetryTimeLimit() {
86 return retryTimeLimit;
90 * @return the parentPolicy
92 public String getParentPolicy() {
97 * @return the parentPolicyConditions
99 public List<String> getParentPolicyConditions() {
100 return parentPolicyConditions;