2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
4 * Modifications Copyright (C) 2019 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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.pdpx.main.parameters;
25 import org.apache.commons.lang3.StringUtils;
26 import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
27 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
28 import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
29 import org.onap.policy.common.parameters.BeanValidationResult;
30 import org.onap.policy.common.parameters.ParameterGroupImpl;
31 import org.onap.policy.common.parameters.ValidationStatus;
32 import org.onap.policy.common.parameters.annotations.NotBlank;
33 import org.onap.policy.common.parameters.annotations.NotNull;
34 import org.onap.policy.common.parameters.annotations.Valid;
35 import org.onap.policy.models.base.Validated;
38 * Class to hold all parameters needed for xacml pdp component.
44 public class XacmlPdpParameterGroup extends ParameterGroupImpl {
45 private static final String PARAM_POLICY_API = "policyApiParameters";
47 private String pdpGroup;
48 private String pdpType;
50 private RestServerParameters restServerParameters;
52 private BusTopicParams policyApiParameters;
54 private TopicParameterGroup topicParameterGroup;
55 private String applicationPath;
58 * Create the xacml pdp parameter group.
60 * @param name the parameter group name
61 * @param pdpGroup the pdp group name
63 public XacmlPdpParameterGroup(final String name, final String pdpGroup, final String pdpType,
64 final RestServerParameters restServerParameters, final BusTopicParams policyApiParameters,
65 final TopicParameterGroup topicParameterGroup, final String applicationPath) {
67 this.pdpGroup = pdpGroup;
68 this.pdpType = pdpType;
69 this.restServerParameters = restServerParameters;
70 this.policyApiParameters = policyApiParameters;
71 this.topicParameterGroup = topicParameterGroup;
72 this.applicationPath = applicationPath;
76 * Validate the parameter group.
78 * @return the result of the validation
81 public BeanValidationResult validate() {
82 final BeanValidationResult validationResult = super.validate();
84 if (policyApiParameters != null && StringUtils.isBlank(policyApiParameters.getHostname())) {
85 var sub = new BeanValidationResult(PARAM_POLICY_API, policyApiParameters);
86 sub.addResult("hostname", policyApiParameters.getHostname(), ValidationStatus.INVALID, Validated.IS_NULL);
87 validationResult.addResult(sub);
90 return validationResult;