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.ParameterGroup;
27 import org.onap.policy.common.parameters.ValidationStatus;
30 * This class handles reading, parsing and validating of the Policy SDC Service Distribution parameters from Json
31 * format, which strictly adheres to the interface:IConfiguration, defined by SDC SDK.
33 public class PSSDConfigurationParametersGroup implements ParameterGroup {
34 // Policy SDC Service Distribution specified field.
37 // Interface of IConfiguration item
38 private String asdcAddress;
39 private List<String> messageBusAddress;
41 private String password;
42 private int pollingInterval;
43 private int pollingTimeout;
44 private String consumerId;
45 private List<String> artifactTypes;
46 private String consumerGroup;
47 private String environmentName;
48 private String keystorePath;
49 private String keystorePassword;
50 private boolean activeserverTlsAuth;
51 private boolean isFilterinEmptyResources;
52 private Boolean isUseHttpsWithDmaap;
54 public String getAsdcAddress() {
58 public List<String> getMsgBusAddress() {
59 return messageBusAddress;
62 public String getUser() {
66 public String getPassword() {
70 public int getPollingInterval() {
71 return pollingInterval;
74 public int getPollingTimeout() {
75 return pollingTimeout;
78 public String getConsumerID() {
82 public List<String> getArtifactTypes() {
86 public String getConsumerGroup() {
90 public String getEnvironmentName() {
91 return environmentName;
94 public String getKeyStorePassword() {
95 return keystorePassword;
98 public String getKeyStorePath() {
102 public boolean activateServerTLSAuth() {
103 return activeserverTlsAuth;
106 public boolean isFilterInEmptyResources() {
107 return isFilterinEmptyResources;
110 public Boolean isUseHttpsWithDmaap() {
111 return isUseHttpsWithDmaap;
115 public String toString() {
116 return "name =" + name + ",TestParameters:[asdcAddress = " + asdcAddress + ", messageBusAddress = "
117 + messageBusAddress + ", user = " + user + "]";
121 public String getName() {
126 public GroupValidationResult validate() {
127 final GroupValidationResult validationResult = new GroupValidationResult(this);
129 if (name == null || name.trim().length() == 0) {
130 validationResult.setResult("name", ValidationStatus.INVALID, "name must be a non-blank string");
133 if (asdcAddress == null || asdcAddress.trim().length() == 0) {
134 validationResult.setResult("asdcAddress", ValidationStatus.INVALID,
135 "asdcAddress must be a non-blank string");
138 if (user == null || user.trim().length() == 0) {
139 validationResult.setResult("user", ValidationStatus.INVALID, "user must be a non-blank string");
142 if (consumerId == null || consumerId.trim().length() == 0) {
143 validationResult.setResult("consumerId", ValidationStatus.INVALID, "consumerId must be a non-blank string");
146 if (consumerGroup == null || consumerGroup.trim().length() == 0) {
147 validationResult.setResult("consumerGroup", ValidationStatus.INVALID,
148 "consumerGroup must be a non-blank string");
151 if (keystorePath == null || keystorePath.trim().length() == 0) {
152 validationResult.setResult("keystorePath", ValidationStatus.INVALID,
153 "keystorePath must be a non-blank string");
156 if (keystorePassword == null || keystorePassword.trim().length() == 0) {
157 validationResult.setResult("keystorePassword", ValidationStatus.INVALID,
158 "keystorePassword must be a non-blank string");
161 if (messageBusAddress == null) {
162 validationResult.setResult("messageBusAddress", ValidationStatus.INVALID,
163 "messageBusAddress must be a list of non-blank string");
165 for (final String temp : messageBusAddress) {
166 if (temp.trim().length() == 0) {
167 validationResult.setResult("messageBusAddress", ValidationStatus.INVALID,
168 "the string of messageBusAddress must be a non-blank string");
173 if (artifactTypes == null) {
174 validationResult.setResult("artifactTypes", ValidationStatus.INVALID,
175 "artifactTypes must be a list of non-blank string");
177 for (final String temp : artifactTypes) {
178 if (temp.trim().length() == 0) {
179 validationResult.setResult("artifactTypes", ValidationStatus.INVALID,
180 "the string of artifactTypes must be a non-blank string");
185 if (pollingInterval <= 0) {
186 validationResult.setResult("pollingInterval", ValidationStatus.INVALID,
187 "pollingInterval must be a positive integer");
190 if (pollingTimeout <= 0) {
191 validationResult.setResult("pollingTimeout", ValidationStatus.INVALID,
192 "pollingTimeout must be a positive integer");
195 return validationResult;