re base code
[sdc.git] / asdctool / src / main / java / org / openecomp / sdc / asdctool / main / ValidationTool.java
1 package org.openecomp.sdc.asdctool.main;
2
3 import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL;
4 import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
5 import org.openecomp.sdc.asdctool.impl.validator.config.ValidationToolConfiguration;
6 import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
7 import org.openecomp.sdc.be.config.ConfigurationManager;
8 import org.openecomp.sdc.common.api.ConfigurationSource;
9 import org.openecomp.sdc.common.impl.ExternalConfiguration;
10 import org.openecomp.sdc.common.impl.FSConfigurationSource;
11 import org.openecomp.sdc.common.log.wrappers.Logger;
12 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
13
14 /**
15  * Created by chaya on 7/3/2017.
16  */
17 public class ValidationTool {
18
19     private static Logger log = Logger.getLogger(ValidationTool.class.getName());
20
21     public static void main(String[] args) {
22
23         String outputPath = args[0];
24         ValidationConfigManager.setOutputFullFilePath(outputPath);
25         ValidationConfigManager.setCsvReportFilePath(outputPath);
26
27         String appConfigDir = args[1];
28         AnnotationConfigApplicationContext context = initContext(appConfigDir);
29         ValidationToolBL validationToolBL = context.getBean(ValidationToolBL.class);
30
31         log.info("Start Validation Tool");
32         Boolean result = validationToolBL.validateAll();
33         ReportManager.reportEndOfToolRun();
34         if (result) {
35             log.info("Validation finished successfully");
36             System.exit(0);
37         } else {
38             log.info("Validation finished with warnings");
39             System.exit(2);
40         }
41     }
42
43     private static AnnotationConfigApplicationContext initContext(String appConfigDir) {
44         ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
45         ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
46         AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ValidationToolConfiguration.class);
47         return context;
48     }
49 }