2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.xacml.pdp.application.guard;
25 import com.google.common.collect.Lists;
27 import java.nio.file.Path;
28 import java.util.Arrays;
29 import java.util.HashMap;
30 import java.util.List;
33 import org.json.JSONObject;
34 import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
39 * This class implements the onap.policies.controlloop.Guard policy implementations.
41 * @author pameladragosh
44 public class GuardPdpApplication implements XacmlApplicationServiceProvider {
46 private static final Logger LOGGER = LoggerFactory.getLogger(GuardPdpApplication.class);
47 private static final String STRING_VERSION100 = "1.0.0";
48 private Map<String, String> supportedPolicyTypes = new HashMap<>();
49 private Path pathForData;
54 public GuardPdpApplication() {
55 this.supportedPolicyTypes.put("onap.policies.controlloop.guard.FrequencyLimiter", STRING_VERSION100);
56 this.supportedPolicyTypes.put("onap.policies.controlloop.guard.MinMax", STRING_VERSION100);
60 public String applicationName() {
61 return "Guard Application";
65 public List<String> actionDecisionsSupported() {
66 return Arrays.asList("guard");
70 public void initialize(Path pathForData) {
74 this.pathForData = pathForData;
75 LOGGER.debug("New Path is {}", this.pathForData.toAbsolutePath());
79 public List<String> supportedPolicyTypes() {
80 return Lists.newArrayList(supportedPolicyTypes.keySet());
84 public boolean canSupportPolicyType(String policyType, String policyTypeVersion) {
86 // For the time being, restrict this if the version isn't known.
87 // Could be too difficult to support changing of versions dynamically.
89 if (! this.supportedPolicyTypes.containsKey(policyType)) {
93 // Must match version exactly
95 return this.supportedPolicyTypes.get(policyType).equals(policyTypeVersion);
99 public void loadPolicies(Map<String, Object> toscaPolicies) {
103 public JSONObject makeDecision(JSONObject jsonSchema) {