Change RestServerParameters to BusTopicParams
[policy/xacml-pdp.git] / applications / match / src / main / java / org / onap / policy / xacml / pdp / application / match / MatchPdpApplication.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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  *
20  * SPDX-License-Identifier: Apache-2.0
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.policy.xacml.pdp.application.match;
25
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;
34
35 public class MatchPdpApplication extends StdXacmlApplicationServiceProvider {
36
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.";
39
40     private static final ToscaConceptIdentifier supportedPolicy = new ToscaConceptIdentifier(
41             ONAP_MATCH_BASE_POLICY_TYPE, "1.0.0");
42
43     private StdMatchableTranslator translator = new StdMatchableTranslator();
44
45     /**
46      * Constructor.
47      */
48     public MatchPdpApplication() {
49         super();
50
51         applicationName = "match";
52         actions = Arrays.asList("match");
53         supportedPolicyTypes.add(supportedPolicy);
54     }
55
56     @Override
57     public void initialize(Path pathForData, BusTopicParams policyApiParameters)
58             throws XacmlApplicationException {
59         //
60         // Store our API parameters and path for translator so it
61         // can go get Policy Types
62         //
63         this.translator.setPathForData(pathForData);
64         this.translator.setApiRestParameters(policyApiParameters);
65         //
66         // Let our super class do its thing
67         //
68         super.initialize(pathForData, policyApiParameters);
69     }
70
71     @Override
72     public boolean canSupportPolicyType(ToscaConceptIdentifier policyTypeId) {
73         return policyTypeId.getName().startsWith(ONAP_MATCH_DERIVED_POLICY_TYPE);
74     }
75
76     @Override
77     protected ToscaPolicyTranslator getTranslator(String type) {
78         return translator;
79     }
80
81 }