2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020-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.match;
26 import java.nio.file.Path;
27 import java.util.Arrays;
28 import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
29 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
30 import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator;
31 import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
32 import org.onap.policy.pdp.xacml.application.common.std.StdMatchableTranslator;
33 import org.onap.policy.pdp.xacml.application.common.std.StdXacmlApplicationServiceProvider;
35 public class MatchPdpApplication extends StdXacmlApplicationServiceProvider {
37 public static final String ONAP_MATCH_BASE_POLICY_TYPE = "onap.policies.Match";
38 public static final String ONAP_MATCH_DERIVED_POLICY_TYPE = "onap.policies.match.";
40 private static final ToscaConceptIdentifier supportedPolicy = new ToscaConceptIdentifier(
41 ONAP_MATCH_BASE_POLICY_TYPE, "1.0.0");
43 private StdMatchableTranslator translator = new StdMatchableTranslator();
48 public MatchPdpApplication() {
51 applicationName = "match";
52 actions = Arrays.asList("match");
53 supportedPolicyTypes.add(supportedPolicy);
57 public void initialize(Path pathForData, BusTopicParams policyApiParameters)
58 throws XacmlApplicationException {
60 // Store our API parameters and path for translator so it
61 // can go get Policy Types
63 this.translator.setPathForData(pathForData);
64 this.translator.setApiRestParameters(policyApiParameters);
66 // Let our super class do its thing
68 super.initialize(pathForData, policyApiParameters);
72 public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
73 return policyTypeId.getName().startsWith(ONAP_MATCH_DERIVED_POLICY_TYPE);
77 protected ToscaPolicyTranslator getTranslator(String type) {