[SDC] Onboarding 1710 rebase.
[sdc.git] / openecomp-be / backend / openecomp-sdc-vendor-software-product-manager / src / main / java / org / openecomp / sdc / vendorsoftwareproduct / types / ValidationResponse.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 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.openecomp.sdc.vendorsoftwareproduct.types;
22
23 import org.apache.commons.collections4.CollectionUtils;
24 import org.apache.commons.collections4.MapUtils;
25 import org.openecomp.sdc.common.errors.ErrorCode;
26 import org.openecomp.sdc.datatypes.error.ErrorMessage;
27 import org.openecomp.sdc.logging.api.Logger;
28 import org.openecomp.sdc.logging.api.LoggerFactory;
29 import org.openecomp.sdc.logging.types.LoggerServiceName;
30 import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
31
32 import java.util.Collection;
33 import java.util.List;
34 import java.util.Map;
35
36 public class ValidationResponse {
37   protected static Logger logger = (Logger) LoggerFactory.getLogger(ValidationResponse.class);
38   private boolean valid = true;
39   private Collection<ErrorCode> vspErrors;
40   private Collection<ErrorCode> licensingDataErrors;
41   private Map<String, List<ErrorMessage>> uploadDataErrors;
42   private Map<String, List<ErrorMessage>> compilationErrors;
43   private QuestionnaireValidationResult questionnaireValidationResult;
44   private ComponentValidationResult componentValidationResult;
45   private DeploymentFlavorValidationResult deploymentFlavorValidationResult;
46
47
48   public boolean isValid() {
49     return valid;
50   }
51
52   public Collection<ErrorCode> getVspErrors() {
53     return vspErrors;
54   }
55
56   /**
57    * Sets vsp errors.
58    *
59    * @param vspErrors         the vsp errors
60    * @param serviceName       the service name
61    * @param targetServiceName the target service name
62    */
63   public void setVspErrors(Collection<ErrorCode> vspErrors, LoggerServiceName serviceName,
64                            String targetServiceName) {
65     this.vspErrors = vspErrors;
66     if (CollectionUtils.isNotEmpty(vspErrors)) {
67       valid = false;
68     }
69
70     VendorSoftwareProductUtils.setErrorsIntoLogger(vspErrors, serviceName, targetServiceName);
71   }
72
73
74   public Collection<ErrorCode> getLicensingDataErrors() {
75     return licensingDataErrors;
76   }
77
78   /**
79    * Sets licensing data errors.
80    *
81    * @param licensingDataErrors the licensing data errors
82    */
83   public void setLicensingDataErrors(Collection<ErrorCode> licensingDataErrors) {
84     this.licensingDataErrors = licensingDataErrors;
85     if (CollectionUtils.isNotEmpty(licensingDataErrors)) {
86       valid = false;
87     }
88   }
89
90   public Map<String, List<ErrorMessage>> getUploadDataErrors() {
91     return uploadDataErrors;
92   }
93
94   /**
95    * Sets upload data errors.
96    *
97    * @param uploadDataErrors  the upload data errors
98    * @param serviceName       the service name
99    * @param targetServiceName the target service name
100    */
101   public void setUploadDataErrors(Map<String, List<ErrorMessage>> uploadDataErrors,
102                                   LoggerServiceName serviceName, String targetServiceName) {
103     this.uploadDataErrors = uploadDataErrors;
104     if (MapUtils.isNotEmpty(uploadDataErrors)) {
105       valid = false;
106     }
107
108     VendorSoftwareProductUtils
109         .setErrorsIntoLogger(uploadDataErrors, serviceName, targetServiceName);
110   }
111
112   public Map<String, List<ErrorMessage>> getCompilationErrors() {
113     return compilationErrors;
114   }
115
116   /**
117    * Sets compilation errors.
118    *
119    * @param compilationErrors the compilation errors
120    * @param serviceName       the service name
121    * @param targetServiceName the target service name
122    */
123   public void setCompilationErrors(Map<String, List<ErrorMessage>> compilationErrors,
124                                    LoggerServiceName serviceName, String targetServiceName) {
125     this.compilationErrors = compilationErrors;
126     if (MapUtils.isNotEmpty(compilationErrors)) {
127       valid = false;
128     }
129
130     VendorSoftwareProductUtils
131         .setErrorsIntoLogger(uploadDataErrors, serviceName, targetServiceName);
132   }
133
134   public QuestionnaireValidationResult getQuestionnaireValidationResult() {
135     return questionnaireValidationResult;
136   }
137
138   /**
139    * Sets questionnaire validation result.
140    *
141    * @param questionnaireValidationResult the questionnaire validation result
142    */
143   public void setQuestionnaireValidationResult(
144       QuestionnaireValidationResult questionnaireValidationResult) {
145     this.questionnaireValidationResult = questionnaireValidationResult;
146     if (questionnaireValidationResult != null && !questionnaireValidationResult.isValid()) {
147       valid = false;
148     }
149   }
150
151
152   public ComponentValidationResult getComponentValidationResult() {
153     return componentValidationResult;
154   }
155
156   /**
157    * Sets Component validation result.
158    *
159    * @param componentValidationResult the Component validation result
160    */
161   public void setComponentValidationResult(
162       ComponentValidationResult componentValidationResult) {
163     this.componentValidationResult = componentValidationResult;
164     if (componentValidationResult != null && !componentValidationResult.isValid()) {
165       valid = false;
166     }
167   }
168
169
170   public DeploymentFlavorValidationResult getDeploymentFlavorValidationResult() {
171     return deploymentFlavorValidationResult;
172   }
173
174   /**
175    * Sets Deployment validation result.
176    *
177    * @param deploymentFlavorValidationResult the Deployment validation result
178    */
179   public void setDeploymentFlavorValidationResult(
180       DeploymentFlavorValidationResult deploymentFlavorValidationResult) {
181     this.deploymentFlavorValidationResult = deploymentFlavorValidationResult;
182     if (deploymentFlavorValidationResult != null && !deploymentFlavorValidationResult.isValid()) {
183       valid = false;
184     }
185   }
186
187
188 }