2 * ===============================LICENSE_START======================================
\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
11 * http://www.apache.org/licenses/LICENSE-2.0
\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
21 package org.openecomp.dcae.apod.analytics.cdap.tca.validator;
\r
23 import org.openecomp.dcae.apod.analytics.cdap.common.validation.CDAPAppSettingsValidator;
\r
24 import org.openecomp.dcae.apod.analytics.cdap.tca.settings.TCAAppPreferences;
\r
25 import org.openecomp.dcae.apod.analytics.common.validation.GenericValidationResponse;
\r
27 import static org.openecomp.dcae.apod.analytics.cdap.common.utils.ValidationUtils.isEmpty;
\r
31 * @author Rajiv Singla . Creation Date: 11/3/2016.
\r
33 public class TCAPreferencesValidator implements CDAPAppSettingsValidator<TCAAppPreferences,
\r
34 GenericValidationResponse<TCAAppPreferences>> {
\r
36 private static final long serialVersionUID = 1L;
\r
39 public GenericValidationResponse<TCAAppPreferences> validateAppSettings(TCAAppPreferences appPreferences) {
\r
41 final GenericValidationResponse<TCAAppPreferences> validationResponse = new GenericValidationResponse<>();
\r
43 // subscriber validations
\r
44 final String subscriberHostName = appPreferences.getSubscriberHostName();
\r
45 if (isEmpty(subscriberHostName)) {
\r
46 validationResponse.addErrorMessage("subscriberHostName", "Subscriber host name must be present");
\r
48 final String subscriberTopicName = appPreferences.getSubscriberTopicName();
\r
49 if (isEmpty(subscriberTopicName)) {
\r
50 validationResponse.addErrorMessage("subscriberTopicName", "Subscriber topic name must be present");
\r
53 // publisher validations
\r
54 final String publisherHostName = appPreferences.getPublisherHostName();
\r
55 if (isEmpty(publisherHostName)) {
\r
56 validationResponse.addErrorMessage("publisherHostName", "Publisher host name must be present");
\r
58 final String publisherTopicName = appPreferences.getPublisherTopicName();
\r
59 if (isEmpty(publisherTopicName)) {
\r
60 validationResponse.addErrorMessage("publisherTopicName", "Publisher topic name must be present");
\r
63 final Boolean enableAAIEnrichment = appPreferences.getEnableAAIEnrichment();
\r
65 // if aai enrichment is enabled then do some aai validations
\r
66 if (enableAAIEnrichment) {
\r
67 final String aaiEnrichmentHost = appPreferences.getAaiEnrichmentHost();
\r
68 if (isEmpty(aaiEnrichmentHost)) {
\r
69 validationResponse.addErrorMessage("aaiEnrichmentHost", "AAI Enrichment Host must be present");
\r
71 final String aaiVMEnrichmentAPIPath = appPreferences.getAaiVMEnrichmentAPIPath();
\r
72 if (isEmpty(aaiVMEnrichmentAPIPath)) {
\r
73 validationResponse.addErrorMessage("aaiVMEnrichmentAPIPath", "AAI VM Enrichment path must be present");
\r
75 final String aaiVNFEnrichmentAPIPath = appPreferences.getAaiVNFEnrichmentAPIPath();
\r
76 if (isEmpty(aaiVNFEnrichmentAPIPath)) {
\r
77 validationResponse.addErrorMessage("aaiVNFEnrichmentAPIPath", "AAI VNF Enrichment path must be " +
\r
82 return validationResponse;
\r