Update css file name in conf.py
[multicloud/framework.git] / artifactbroker / plugins / reception-plugins / src / main / java / org / onap / policy / distribution / reception / handling / sdc / SdcReceptionHandlerConfigurationParameterGroup.java
1 /*-
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.distribution.reception.handling.sdc;
22
23 import java.util.List;
24
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;
29
30 /**
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.
33  */
34 public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHandlerConfigurationParameterGroup {
35
36     private String asdcAddress;
37     private List<String> messageBusAddress;
38     private String user;
39     private String password;
40     private int pollingInterval;
41     private int pollingTimeout;
42     private int retryDelay;
43     private String consumerId;
44     private List<String> artifactTypes;
45     private String consumerGroup;
46     private String environmentName;
47     private String keyStorePath;
48     private String keyStorePassword;
49     private boolean activeServerTlsAuth;
50     private boolean isFilterInEmptyResources;
51     private boolean isUseHttpsWithDmaap;
52
53     /**
54      * The constructor for instantiating {@link SdcReceptionHandlerConfigurationParameterGroup} class.
55      *
56      * @param builder the SDC configuration builder
57      */
58     public SdcReceptionHandlerConfigurationParameterGroup(
59             final SdcReceptionHandlerConfigurationParameterBuilder builder) {
60         asdcAddress = builder.getAsdcAddress();
61         messageBusAddress = builder.getMessageBusAddress();
62         user = builder.getUser();
63         password = builder.getPassword();
64         pollingInterval = builder.getPollingInterval();
65         pollingTimeout = builder.getPollingTimeout();
66         retryDelay = builder.getRetryDelay();
67         consumerId = builder.getConsumerId();
68         artifactTypes = builder.getArtifactTypes();
69         consumerGroup = builder.getConsumerGroup();
70         environmentName = builder.getEnvironmentName();
71         keyStorePath = builder.getKeystorePath();
72         keyStorePassword = builder.getKeystorePassword();
73         activeServerTlsAuth = builder.isActiveserverTlsAuth();
74         isFilterInEmptyResources = builder.isFilterinEmptyResources();
75         isUseHttpsWithDmaap = builder.getIsUseHttpsWithDmaap();
76
77     }
78
79     public String getAsdcAddress() {
80         return asdcAddress;
81     }
82
83     public List<String> getMessageBusAddress() {
84         return messageBusAddress;
85     }
86
87     public String getUser() {
88         return user;
89     }
90
91     public String getPassword() {
92         return password;
93     }
94
95     public int getPollingInterval() {
96         return pollingInterval;
97     }
98
99     public int getPollingTimeout() {
100         return pollingTimeout;
101     }
102
103     public int getRetryDelay() {
104         return retryDelay;
105     }
106
107     public String getConsumerId() {
108         return consumerId;
109     }
110
111     public List<String> getArtifactTypes() {
112         return artifactTypes;
113     }
114
115     public String getConsumerGroup() {
116         return consumerGroup;
117     }
118
119     public String getEnvironmentName() {
120         return environmentName;
121     }
122
123     public String getKeyStorePassword() {
124         return keyStorePassword;
125     }
126
127     public boolean isActiveServerTlsAuth() {
128         return activeServerTlsAuth;
129     }
130
131     public String getKeyStorePath() {
132         return keyStorePath;
133     }
134
135     public boolean isFilterInEmptyResources() {
136         return isFilterInEmptyResources;
137     }
138
139     public boolean isUseHttpsWithDmaap() {
140         return isUseHttpsWithDmaap;
141     }
142
143     /**
144      * {@inheritDoc}.
145      */
146     @Override
147     public GroupValidationResult validate() {
148         final GroupValidationResult validationResult = new GroupValidationResult(this);
149         validateStringElement(validationResult, asdcAddress, "asdcAddress");
150         validateStringElement(validationResult, user, "user");
151         validateStringElement(validationResult, consumerId, "consumerId");
152         validateStringElement(validationResult, consumerGroup, "consumerGroup");
153         validateStringElement(validationResult, keyStorePath, "keyStorePath");
154         validateStringElement(validationResult, keyStorePassword, "keyStorePassword");
155         validateIntElement(validationResult, pollingInterval, "pollingInterval");
156         validateIntElement(validationResult, pollingTimeout, "pollingTimeout");
157         validateIntElement(validationResult, retryDelay, "retryDelay");
158         validateStringListElement(validationResult, messageBusAddress, "messageBusAddress");
159         validateStringListElement(validationResult, artifactTypes, "artifactTypes");
160         return validationResult;
161     }
162
163     /**
164      * Validate the integer Element.
165      *
166      * @param validationResult the result object
167      * @param element the element to validate
168      * @param elementName the element name for error message
169      */
170     private void validateIntElement(final GroupValidationResult validationResult, final int element,
171             final String elementName) {
172         if (!ParameterValidationUtils.validateIntParameter(element)) {
173             validationResult.setResult(elementName, ValidationStatus.INVALID,
174                     elementName + " must be a positive integer");
175         }
176     }
177
178     /**
179      * Validate the String List Element.
180      *
181      * @param validationResult the result object
182      * @param element the element to validate
183      * @param elementName the element name for error message
184      */
185     private void validateStringListElement(final GroupValidationResult validationResult, final List<String> element,
186             final String elementName) {
187         for (final String temp : element) {
188             if (!ParameterValidationUtils.validateStringParameter(temp)) {
189                 validationResult.setResult(elementName, ValidationStatus.INVALID,
190                         "the string of " + elementName + "must be a non-blank string");
191             }
192         }
193     }
194
195     /**
196      * Validate the string element.
197      *
198      * @param validationResult the result object
199      * @param element the element to validate
200      * @param elementName the element name for error message
201      */
202     private void validateStringElement(final GroupValidationResult validationResult, final String element,
203             final String elementName) {
204         if (!ParameterValidationUtils.validateStringParameter(element)) {
205             validationResult.setResult(elementName, ValidationStatus.INVALID,
206                     elementName + " must be a non-blank string");
207         }
208     }
209 }
210