2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Intel. 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.distribution.reception.handling.sdc;
23 import java.util.List;
25 import org.onap.policy.common.parameters.GroupValidationResult;
26 import org.onap.policy.common.parameters.ValidationStatus;
27 import org.onap.policy.common.utils.validation.ParameterValidationUtils;
28 import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigurationParameterGroup;
31 * This class handles reading, parsing and validating of the Policy SDC Service Distribution parameters from Json
32 * format, which strictly adheres to the interface:IConfiguration, defined by SDC SDK.
34 public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHandlerConfigurationParameterGroup {
36 private String asdcAddress;
37 private List<String> messageBusAddress;
39 private String password;
40 private int pollingInterval;
41 private int pollingTimeout;
42 private int retryDelay;
43 private int httpsProxyPort;
44 private int httpProxyPort;
45 private String httpsProxyHost;
46 private String httpProxyHost;
47 private String consumerId;
48 private List<String> artifactTypes;
49 private String consumerGroup;
50 private String environmentName;
51 private String keyStorePath;
52 private String keyStorePassword;
53 private boolean activeServerTlsAuth;
54 private boolean isFilterInEmptyResources;
55 private boolean isUseHttpsWithDmaap;
56 private boolean isUseHttpsWithSDC;
59 * The constructor for instantiating {@link SdcReceptionHandlerConfigurationParameterGroup} class.
61 * @param builder the SDC configuration builder
63 public SdcReceptionHandlerConfigurationParameterGroup(
64 final SdcReceptionHandlerConfigurationParameterBuilder builder) {
65 asdcAddress = builder.getAsdcAddress();
66 messageBusAddress = builder.getMessageBusAddress();
67 user = builder.getUser();
68 password = builder.getPassword();
69 pollingInterval = builder.getPollingInterval();
70 pollingTimeout = builder.getPollingTimeout();
71 retryDelay = builder.getRetryDelay();
72 httpsProxyPort = builder.getHttpsProxyPort();
73 httpsProxyHost = builder.getHttpsProxyHost();
74 httpProxyPort = builder.getHttpProxyPort();
75 httpProxyHost = builder.getHttpProxyHost();
76 consumerId = builder.getConsumerId();
77 artifactTypes = builder.getArtifactTypes();
78 consumerGroup = builder.getConsumerGroup();
79 environmentName = builder.getEnvironmentName();
80 keyStorePath = builder.getKeystorePath();
81 keyStorePassword = builder.getKeystorePassword();
82 activeServerTlsAuth = builder.isActiveserverTlsAuth();
83 isFilterInEmptyResources = builder.isFilterinEmptyResources();
84 isUseHttpsWithDmaap = builder.getIsUseHttpsWithDmaap();
85 isUseHttpsWithSDC = builder.getIsUseHttpsWithSDC();
89 public String getAsdcAddress() {
93 public List<String> getMessageBusAddress() {
94 return messageBusAddress;
97 public String getUser() {
101 public String getPassword() {
105 public int getPollingInterval() {
106 return pollingInterval;
109 public int getPollingTimeout() {
110 return pollingTimeout;
113 public int getRetryDelay() {
117 public String getConsumerId() {
121 public List<String> getArtifactTypes() {
122 return artifactTypes;
125 public String getConsumerGroup() {
126 return consumerGroup;
129 public String getEnvironmentName() {
130 return environmentName;
133 public String getKeyStorePassword() {
134 return keyStorePassword;
137 public boolean isActiveServerTlsAuth() {
138 return activeServerTlsAuth;
141 public String getKeyStorePath() {
145 public boolean isFilterInEmptyResources() {
146 return isFilterInEmptyResources;
149 public boolean isUseHttpsWithDmaap() {
150 return isUseHttpsWithDmaap;
153 public boolean isUseHttpsWithSDC() {
154 return isUseHttpsWithSDC;
157 public int getHttpsProxyPort() {
158 return httpsProxyPort;
161 public String getHttpsProxyHost() {
162 return httpsProxyHost;
165 public int getHttpProxyPort() {
166 return httpProxyPort;
169 public String getHttpProxyHost() {
170 return httpProxyHost;
177 public GroupValidationResult validate() {
178 final GroupValidationResult validationResult = new GroupValidationResult(this);
179 validateStringElement(validationResult, asdcAddress, "asdcAddress");
180 validateStringElement(validationResult, user, "user");
181 validateStringElement(validationResult, consumerId, "consumerId");
182 validateStringElement(validationResult, consumerGroup, "consumerGroup");
183 validateStringElement(validationResult, keyStorePath, "keyStorePath");
184 validateStringElement(validationResult, keyStorePassword, "keyStorePassword");
185 validateIntElement(validationResult, pollingInterval, "pollingInterval");
186 validateIntElement(validationResult, pollingTimeout, "pollingTimeout");
187 validateIntElement(validationResult, retryDelay, "retryDelay");
188 validateStringListElement(validationResult, messageBusAddress, "messageBusAddress");
189 validateStringListElement(validationResult, artifactTypes, "artifactTypes");
190 return validationResult;
194 * Validate the integer Element.
196 * @param validationResult the result object
197 * @param element the element to validate
198 * @param elementName the element name for error message
200 private void validateIntElement(final GroupValidationResult validationResult, final int element,
201 final String elementName) {
202 if (!ParameterValidationUtils.validateIntParameter(element)) {
203 validationResult.setResult(elementName, ValidationStatus.INVALID,
204 elementName + " must be a positive integer");
209 * Validate the String List Element.
211 * @param validationResult the result object
212 * @param element the element to validate
213 * @param elementName the element name for error message
215 private void validateStringListElement(final GroupValidationResult validationResult, final List<String> element,
216 final String elementName) {
217 for (final String temp : element) {
218 if (!ParameterValidationUtils.validateStringParameter(temp)) {
219 validationResult.setResult(elementName, ValidationStatus.INVALID,
220 "the string of " + elementName + "must be a non-blank string");
226 * Validate the string element.
228 * @param validationResult the result object
229 * @param element the element to validate
230 * @param elementName the element name for error message
232 private void validateStringElement(final GroupValidationResult validationResult, final String element,
233 final String elementName) {
234 if (!ParameterValidationUtils.validateStringParameter(element)) {
235 validationResult.setResult(elementName, ValidationStatus.INVALID,
236 elementName + " must be a non-blank string");