Roberto Sánchez
2014-02-24 fcf951f23acc8160a4433892cd15680d247fe126
src/main/java/net/curisit/securis/License.java
....@@ -1,5 +1,9 @@
11 package net.curisit.securis;
22
3
+import java.io.File;
4
+
5
+import net.curisit.securis.utils.Params;
6
+
37 import org.apache.commons.cli.CommandLine;
48 import org.apache.commons.cli.CommandLineParser;
59 import org.apache.commons.cli.HelpFormatter;
....@@ -12,10 +16,47 @@
1216
1317 public class License {
1418
19
+ static {
20
+ // BasicConfigurator.configure(new ConsoleAppender());
21
+ // PropertyConfigurator.configure("/log4j.xml");
22
+ // LogManager.getRootLogger().
23
+ }
24
+
1525 private static final Logger log = LoggerFactory.getLogger(License.class);
1626
1727 public static void main(String[] args) {
28
+ log.info("Tool init");
29
+ checkConfigFile();
1830 CommandLine cmd = getCommandLine(args);
31
+
32
+ try {
33
+ if (cmd.hasOption('g')) {
34
+ String filename = cmd.getOptionValue("rfile");
35
+ if (filename == null)
36
+ filename = "./license.req";
37
+ LicenseManager.getInstance().createRequestFile(new File(filename));
38
+ System.exit(0);
39
+ }
40
+
41
+ } catch (SeCurisException e) {
42
+ log.error("The command generated an error: {}", e.toString());
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Checks that config file exists and contains mandatory parameters
48
+ */
49
+ private static void checkConfigFile() {
50
+ String appCode = Params.get(Params.KEYS.APPLICATION_CODE);
51
+ if (appCode == null) {
52
+ log.error("Manadatory parameter {} is not set in config file", Params.KEYS.APPLICATION_CODE);
53
+ System.exit(-3);
54
+ }
55
+ String customerCode = Params.get(Params.KEYS.CUSTOMER_CODE);
56
+ if (customerCode == null) {
57
+ log.error("Manadatory parameter {} is not set in config file", Params.KEYS.CUSTOMER_CODE);
58
+ System.exit(-4);
59
+ }
1960 }
2061
2162 private static CommandLine getCommandLine(String[] args) {