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=========================================================
20 package org.onap.policy.distribution.reception.handling.sdc;
21 import java.util.List;
22 import java.io.FileReader;
23 import java.io.IOException;
25 import com.google.gson.Gson;
26 import com.google.gson.GsonBuilder;
28 import org.onap.policy.common.parameters.GroupValidationResult;
29 import org.onap.policy.common.parameters.ParameterConstants;
30 import org.onap.policy.common.parameters.ParameterGroup;
31 import org.onap.policy.common.parameters.ValidationStatus;
34 * This class handles reading, parsing and validating of the Policy SDC Service Distribution parameters from Json
35 * format, which strictly adheres to the interface:IConfiguration, defined by SDC SDK.
37 public class PSSDConfigurationParametersGroup implements ParameterGroup {
38 //Policy SDC Service Distribution specified field.
41 //Interface of IConfiguration item
42 private String asdcAddress;
43 private List<String> messageBusAddress;
45 private String password;
46 private int pollingInterval;
47 private int pollingTimeout;
48 private String consumerId;
49 private List<String> artifactTypes;
50 private String consumerGroup;
51 private String environmentName;
52 private String keystorePath;
53 private String keystorePassword;
54 private boolean activeserverTlsAuth;
55 private boolean isFilterinEmptyResources;
56 private Boolean isUseHttpsWithDmaap;
58 public String getAsdcAddress(){
62 public List<String> getMsgBusAddress(){
63 return messageBusAddress;
66 public String getUser() {
70 public String getPassword() {
74 public int getPollingInterval() {
75 return pollingInterval;
78 public int getPollingTimeout() {
79 return pollingTimeout;
82 public String getConsumerID() {
86 public List<String> getArtifactTypes(){
90 public String getConsumerGroup() {
94 public String getEnvironmentName() {
95 return environmentName;
98 public String getKeyStorePassword() {
99 return keystorePassword;
102 public String getKeyStorePath() {
106 public boolean activateServerTLSAuth() {
107 return activeserverTlsAuth;
110 public boolean isFilterInEmptyResources() {
111 return isFilterinEmptyResources;
114 public Boolean isUseHttpsWithDmaap() {
115 return isUseHttpsWithDmaap;
119 public String toString() {
120 return "name =" + name +",TestParameters:[asdcAddress = " + asdcAddress + ", messageBusAddress = " + messageBusAddress +
121 ", user = "+ user + "]";
125 public String getName() {
130 public GroupValidationResult validate() {
131 GroupValidationResult validationResult = new GroupValidationResult(this);
133 if (name == null || name.trim().length() == 0) {
134 validationResult.setResult("name", ValidationStatus.INVALID, "name must be a non-blank string");
137 if (asdcAddress == null || asdcAddress.trim().length() == 0) {
138 validationResult.setResult("asdcAddress", ValidationStatus.INVALID, "asdcAddress must be a non-blank string");
141 if (user == null || user.trim().length() == 0) {
142 validationResult.setResult("user", ValidationStatus.INVALID, "user must be a non-blank string");
145 if (consumerId == null || consumerId.trim().length() == 0) {
146 validationResult.setResult("consumerId", ValidationStatus.INVALID, "consumerId must be a non-blank string");
149 if (consumerGroup == null || consumerGroup.trim().length() == 0) {
150 validationResult.setResult("consumerGroup", ValidationStatus.INVALID, "consumerGroup must be a non-blank string");
153 if (keystorePath == null || keystorePath.trim().length() == 0) {
154 validationResult.setResult("keystorePath", ValidationStatus.INVALID, "keystorePath must be a non-blank string");
157 if (keystorePassword == null || keystorePassword.trim().length() == 0) {
158 validationResult.setResult("keystorePassword", ValidationStatus.INVALID, "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(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(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;