diff options
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters')
3 files changed, 75 insertions, 13 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestClientParameters.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestClientParameters.java new file mode 100644 index 00000000..5d02e753 --- /dev/null +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestClientParameters.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.common.endpoints.parameters; + +import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.parameters.BeanValidationResult; +import org.onap.policy.common.parameters.ParameterGroup; +import org.onap.policy.common.parameters.ValidationStatus; + +public class RestClientParameters extends BusTopicParams implements ParameterGroup { + + private static final String MSG_IS_BLANK = "is blank"; + + @Override + public String getName() { + return getClientName(); + } + + @Override + public void setName(String name) { + setClientName(name); + } + + @Override + public BeanValidationResult validate() { + var result = new BeanValidationResult(getClientName(), this); + if (isHostnameInvalid()) { + result.addResult("hostname", getHostname(), ValidationStatus.INVALID, MSG_IS_BLANK); + } + if (isClientNameInvalid()) { + result.addResult("clientName", getClientName(), ValidationStatus.INVALID, MSG_IS_BLANK); + } + if (isPortInvalid()) { + result.addResult("port", getPort(), ValidationStatus.INVALID, "is not valid"); + } + return result; + } +} diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestServerParameters.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestServerParameters.java index 85f1f455..9ffe5cb7 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestServerParameters.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestServerParameters.java @@ -1,6 +1,8 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019,2023 Nordix Foundation. + * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +23,6 @@ package org.onap.policy.common.endpoints.parameters; import lombok.Getter; - import org.onap.policy.common.parameters.ParameterGroupImpl; import org.onap.policy.common.parameters.annotations.Min; import org.onap.policy.common.parameters.annotations.NotBlank; @@ -32,10 +33,10 @@ import org.onap.policy.common.parameters.annotations.NotNull; * * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ -@NotNull @NotBlank @Getter public class RestServerParameters extends ParameterGroupImpl { + @NotNull private String host; @Min(value = 1) @@ -44,7 +45,11 @@ public class RestServerParameters extends ParameterGroupImpl { private String userName; private String password; private boolean https; + private boolean sniHostCHeck; private boolean aaf; + private boolean prometheus; + private String servletClass; + private String servletUriPath; public RestServerParameters() { super(RestServerParameters.class.getSimpleName()); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java index 4cd3893d..d63134bc 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2024 Nordix Foundation. + * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import java.util.List; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; -import org.onap.policy.common.parameters.GroupValidationResult; +import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ParameterGroupImpl; import org.onap.policy.common.parameters.ValidationStatus; import org.onap.policy.common.parameters.annotations.NotBlank; @@ -53,20 +53,20 @@ public class TopicParameterGroup extends ParameterGroupImpl { * {@inheritDoc}. */ @Override - public GroupValidationResult validate() { - GroupValidationResult result = super.validate(); + public BeanValidationResult validate() { + BeanValidationResult result = super.validate(); if (result.isValid()) { - StringBuilder errorMsg = new StringBuilder(); + var errorMsg = new StringBuilder(); StringBuilder missingSourceParams = checkMissingMandatoryParams(topicSources); - if (missingSourceParams.length() > 0) { + if (!missingSourceParams.isEmpty()) { errorMsg.append(missingSourceParams.append("missing in topicSources. ")); } StringBuilder missingSinkParams = checkMissingMandatoryParams(topicSinks); - if (missingSinkParams.length() > 0) { + if (!missingSinkParams.isEmpty()) { errorMsg.append(missingSinkParams.append("missing in topicSinks.")); } - if (errorMsg.length() > 0) { + if (!errorMsg.isEmpty()) { errorMsg.insert(0, "Mandatory parameters are missing. "); result.setResult(ValidationStatus.INVALID, errorMsg.toString()); } @@ -75,7 +75,7 @@ public class TopicParameterGroup extends ParameterGroupImpl { } private StringBuilder checkMissingMandatoryParams(List<TopicParameters> topicParametersList) { - StringBuilder missingParams = new StringBuilder(); + var missingParams = new StringBuilder(); for (TopicParameters topicParameters : topicParametersList) { if (StringUtils.isBlank(topicParameters.getTopic())) { missingParams.append("topic, "); |