Sonar Critical Fix
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-tca / src / main / java / org / onap / dcae / apod / analytics / cdap / tca / validator / TCAAppConfigValidator.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *   You may obtain a copy of the License at
10  *
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *  ============================LICENSE_END===========================================
19  */
20
21 package org.onap.dcae.apod.analytics.cdap.tca.validator;
22
23 import org.onap.dcae.apod.analytics.cdap.common.validation.CDAPAppSettingsValidator;
24 import org.onap.dcae.apod.analytics.cdap.tca.settings.TCAAppConfig;
25 import org.onap.dcae.apod.analytics.common.validation.GenericValidationResponse;
26
27 import static org.onap.dcae.apod.analytics.cdap.common.utils.ValidationUtils.isEmpty;
28
29 /**
30  *  <p>
31  *      TCA App Config Validator validates any TCA App Config parameter values
32  *  </p>
33  *
34  * @author Rajiv Singla . Creation Date: 10/24/2016.
35  */
36 public class TCAAppConfigValidator implements CDAPAppSettingsValidator<TCAAppConfig,
37         GenericValidationResponse<TCAAppConfig>> {
38
39     private static final long serialVersionUID = 1L;
40
41     @Override
42     public GenericValidationResponse<TCAAppConfig> validateAppSettings(TCAAppConfig tcaAppConfig) {
43
44         final GenericValidationResponse<TCAAppConfig> validationResponse = new GenericValidationResponse<>();
45
46         if (isEmpty(tcaAppConfig.getTcaSubscriberOutputStreamName())) {
47             validationResponse.addErrorMessage("tcaSubscriberOutputStreamName",
48                     "tcaSubscriberOutputStreamName must be present");
49         }
50
51         if (isEmpty(tcaAppConfig.getTcaVESMessageStatusTableName())) {
52             validationResponse.addErrorMessage("tcaVESMessageStatusTableName",
53                     "tcaVESMessageStatusTableName must be present");
54         }
55         if (isEmpty(tcaAppConfig.getTcaVESAlertsTableName())) {
56             validationResponse.addErrorMessage("tcaVESAlertsTableName",
57                     "tcaVESAlertsTableName must be present");
58         }
59
60         return validationResponse;
61     }
62 }