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.event.comm.bus.internal.BusTopicParams;
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 static final String MSG_IS_BLANK = "is blank";
47 private BusTopicParams clampClientParameters;
50 private BusTopicParams consulClientParameters;
52 private ParticipantIntermediaryParameters intermediaryParameters;
53 private PolicyModelsProviderParameters databaseProviderParameters;
56 * Create the participant dcae parameter group.
58 * @param name the parameter group name
60 public ParticipantDcaeParameters(final String name) {
68 public BeanValidationResult validate() {
69 BeanValidationResult result = super.validate();
70 if (result.isValid()) {
71 result.addResult(checkMissingMandatoryParams(clampClientParameters));
72 result.addResult(checkMissingMandatoryParams(consulClientParameters));
77 private BeanValidationResult checkMissingMandatoryParams(BusTopicParams clientParameters) {
78 BeanValidationResult result = new BeanValidationResult(clientParameters.getClientName(), clientParameters);
79 if (clientParameters.isHostnameInvalid()) {
80 result.addResult("Host", clientParameters.getHostname(), ValidationStatus.INVALID, MSG_IS_BLANK);
82 if (clientParameters.isClientNameInvalid()) {
83 result.addResult("Name", clientParameters.getClientName(), ValidationStatus.INVALID, MSG_IS_BLANK);
85 if (StringUtils.isBlank(clientParameters.getPassword())) {
86 result.addResult("Password", clientParameters.getPassword(), ValidationStatus.INVALID, MSG_IS_BLANK);
88 if (StringUtils.isBlank(clientParameters.getUserName())) {
89 result.addResult("UserName", clientParameters.getUserName(), ValidationStatus.INVALID, MSG_IS_BLANK);
91 if (clientParameters.isPortInvalid()) {
92 result.addResult("Port", clientParameters.getPort(), ValidationStatus.INVALID, "is not valid");