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