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