2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 Nordix Foundation.
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.clamp.controlloop.participant.dcae.main.parameters;
23 import javax.validation.constraints.NotBlank;
25 import org.apache.commons.lang3.StringUtils;
26 import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters;
27 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
28 import org.onap.policy.common.parameters.BeanValidationResult;
29 import org.onap.policy.common.parameters.ParameterGroupImpl;
30 import org.onap.policy.common.parameters.ValidationStatus;
31 import org.onap.policy.common.parameters.annotations.NotNull;
32 import org.onap.policy.common.parameters.annotations.Valid;
33 import org.onap.policy.models.provider.PolicyModelsProviderParameters;
36 * Class to hold all parameters needed for the participant dcae.
42 public class ParticipantDcaeParameters extends ParameterGroupImpl {
44 private RestServerParameters clampClientParameters;
47 private RestServerParameters consulClientParameters;
49 private ParticipantIntermediaryParameters intermediaryParameters;
50 private PolicyModelsProviderParameters databaseProviderParameters;
53 * Create the participant dcae parameter group.
55 * @param name the parameter group name
57 public ParticipantDcaeParameters(final String name) {
65 public BeanValidationResult validate() {
66 BeanValidationResult result = super.validate();
67 if (result.isValid()) {
68 result.addResult(checkMissingMandatoryParams(clampClientParameters));
69 result.addResult(checkMissingMandatoryParams(consulClientParameters));
74 private BeanValidationResult checkMissingMandatoryParams(RestServerParameters clientParameters) {
75 BeanValidationResult result = new BeanValidationResult(clientParameters.getName(), clientParameters);
76 if (StringUtils.isBlank(clientParameters.getHost())) {
77 result.addResult("Host", clientParameters.getHost(), ValidationStatus.INVALID, "is blank");
79 if (StringUtils.isBlank(clientParameters.getName())) {
80 result.addResult("Name", clientParameters.getName(), ValidationStatus.INVALID, "is blank");
82 if (StringUtils.isBlank(clientParameters.getPassword())) {
83 result.addResult("Password", clientParameters.getPassword(), ValidationStatus.INVALID, "is blank");
85 if (StringUtils.isBlank(clientParameters.getUserName())) {
86 result.addResult("UserName", clientParameters.getUserName(), ValidationStatus.INVALID, "is blank");
88 if (clientParameters.getPort() <= 0 || clientParameters.getPort() >= 65535) {
89 result.addResult("Port", clientParameters.getPort(), ValidationStatus.INVALID, "is not valid");