Upgrade Java 17 in xacml-pdp
[policy/xacml-pdp.git] / main / src / main / java / org / onap / policy / pdpx / main / startstop / XacmlPdpRestServer.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
4  * Modifications Copyright (C) 2023 Nordix Foundation.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.pdpx.main.startstop;
23
24 import jakarta.servlet.Filter;
25 import java.util.List;
26 import java.util.Properties;
27 import org.onap.policy.common.endpoints.http.server.JsonExceptionMapper;
28 import org.onap.policy.common.endpoints.http.server.RestServer;
29 import org.onap.policy.common.endpoints.http.server.YamlExceptionMapper;
30 import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
31 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
32 import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
33 import org.onap.policy.common.gson.GsonMessageBodyHandler;
34 import org.onap.policy.pdpx.main.rest.serialization.XacmlJsonExceptionMapper;
35 import org.onap.policy.pdpx.main.rest.serialization.XacmlJsonMessageBodyHandler;
36 import org.onap.policy.pdpx.main.rest.serialization.XacmlXmlExceptionMapper;
37 import org.onap.policy.pdpx.main.rest.serialization.XacmlXmlMessageBodyHandler;
38
39 /**
40  * Class to manage life cycle of a rest server that is particularly used by xacml pdp.
41  *
42  * @author Chenfei Gao (cgao@research.att.com)
43  */
44 public class XacmlPdpRestServer extends RestServer {
45
46     /**
47      * Constructs the object.
48      *
49      * @param restServerParameters the rest server parameters
50      * @param filters class of object to use to filter requests, or {@code null}
51      * @param jaxrsProviders classes providing the services
52      */
53     public XacmlPdpRestServer(final RestServerParameters restServerParameters,
54             List<Class<? extends Filter>> filters, List<Class<?>> jaxrsProviders) {
55
56         super(restServerParameters, filters, jaxrsProviders);
57     }
58
59     @Override
60     protected Properties getServerProperties(RestServerParameters restServerParameters, String names) {
61
62         final var props = super.getServerProperties(restServerParameters, names);
63         final String svcpfx =
64                         PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + restServerParameters.getName();
65
66         props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER,
67                 String.join(",", GsonMessageBodyHandler.class.getName(), YamlMessageBodyHandler.class.getName(),
68                                 JsonExceptionMapper.class.getName(), YamlExceptionMapper.class.getName(),
69                                 XacmlJsonMessageBodyHandler.class.getName(), XacmlJsonExceptionMapper.class.getName(),
70                                 XacmlXmlMessageBodyHandler.class.getName(), XacmlXmlExceptionMapper.class.getName()));
71         return props;
72     }
73 }