2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2021 Nordix Foundation.
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.
20 * SPDX-License-Identifier: Apache-2.0
21 * ============LICENSE_END=========================================================
24 package org.onap.policy.xacml.pdp.application.guard;
26 import java.util.Arrays;
27 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
28 import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
29 import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
34 * This class implements the onap.policies.controlloop.Guard policy implementations.
36 * @author pameladragosh
39 public class GuardPdpApplication extends StdXacmlApplicationServiceProvider {
40 private static final Logger LOGGER = LoggerFactory.getLogger(GuardPdpApplication.class);
41 protected static final String STRING_VERSION100 = "1.0.0";
43 private GuardTranslator guardTranslator = new GuardTranslator();
44 private CoordinationGuardTranslator coordinationTranslator = new CoordinationGuardTranslator();
50 public GuardPdpApplication() {
53 applicationName = "guard";
54 actions = Arrays.asList("guard");
56 this.supportedPolicyTypes.add(new ToscaConceptIdentifier(
57 GuardTranslator.POLICYTYPE_FREQUENCY,
59 this.supportedPolicyTypes.add(new ToscaConceptIdentifier(
60 GuardTranslator.POLICYTYPE_MINMAX,
62 this.supportedPolicyTypes.add(new ToscaConceptIdentifier(
63 GuardTranslator.POLICYTYPE_BLACKLIST,
65 this.supportedPolicyTypes.add(new ToscaConceptIdentifier(
66 GuardTranslator.POLICYTYPE_FILTER,
68 this.supportedPolicyTypes.add(new ToscaConceptIdentifier(
69 "onap.policies.controlloop.guard.coordination.FirstBlocksSecond",
74 public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
76 // For the time being, restrict this if the version isn't known.
77 // Could be too difficult to support changing of versions dynamically.
79 for (ToscaConceptIdentifier supported : this.supportedPolicyTypes) {
80 if (policyTypeId.equals(supported)) {
88 protected ToscaPolicyTranslator getTranslator(String type) {
89 LOGGER.debug("Policy type {}", type);
90 if (type.contains("coordination")) {
91 LOGGER.debug("returning coordinationTranslator");
92 return coordinationTranslator;
94 LOGGER.debug("returning guardTranslator");
95 return guardTranslator;