d04fca6aa9f61c77bb8f3a4ade039da6b0b6f35f
[policy/xacml-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.xacml.pdp.application.naming;
24
25 import java.nio.file.Path;
26 import java.util.Arrays;
27 import java.util.List;
28 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
29 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
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 NamingPdpApplication extends StdXacmlApplicationServiceProvider {
36
37     private static final ToscaPolicyTypeIdentifier supportedPolicy = new ToscaPolicyTypeIdentifier(
38             "onap.policies.Naming", "1.0.0");
39
40     private StdMatchableTranslator translator = new StdMatchableTranslator();
41
42     @Override
43     public String applicationName() {
44         return "naming";
45     }
46
47     @Override
48     public List<String> actionDecisionsSupported() {
49         return Arrays.asList("naming");
50     }
51
52     @Override
53     public void initialize(Path pathForData, RestServerParameters policyApiParameters)
54             throws XacmlApplicationException {
55         //
56         // Store our API parameters and path for translator so it
57         // can go get Policy Types
58         //
59         this.translator.setPathForData(pathForData);
60         this.translator.setApiRestParameters(policyApiParameters);
61         //
62         // Let our super class do its thing
63         //
64         super.initialize(pathForData, policyApiParameters);
65     }
66
67     @Override
68     public synchronized List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
69         return Arrays.asList(supportedPolicy);
70     }
71
72     @Override
73     public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
74         return supportedPolicy.equals(policyTypeId);
75     }
76
77     @Override
78     protected ToscaPolicyTranslator getTranslator(String type) {
79         //
80         // Return translator
81         //
82         return translator;
83     }
84 }