equal
deleted
inserted
replaced
23 import java.io.BufferedReader; |
23 import java.io.BufferedReader; |
24 import java.io.InputStreamReader; |
24 import java.io.InputStreamReader; |
25 import java.io.PrintStream; |
25 import java.io.PrintStream; |
26 import java.sql.SQLException; |
26 import java.sql.SQLException; |
27 import java.util.EnumSet; |
27 import java.util.EnumSet; |
|
28 import java.util.List; |
28 import java.util.logging.Level; |
29 import java.util.logging.Level; |
29 import java.util.logging.Logger; |
30 import java.util.logging.Logger; |
30 |
31 |
31 /** |
32 /** |
32 * Displays info like help, version etc. |
33 * Displays info like help, version etc. |
42 public InfoLister(PrintStream out, ConfigurationProvider configurationProvider) { |
43 public InfoLister(PrintStream out, ConfigurationProvider configurationProvider) { |
43 this.out = out; |
44 this.out = out; |
44 this.configurationProvider = configurationProvider; |
45 this.configurationProvider = configurationProvider; |
45 } |
46 } |
46 |
47 |
47 public void showInfo(CLIOptions options) { |
48 public void showInfo(CLIOptions options) throws ConfigurationException { |
48 EnumSet<CLIOptions.INFO_TYPE> infoTypes = options.getShowInfo(); |
49 EnumSet<CLIOptions.INFO_TYPE> infoTypes = options.getShowInfo(); |
49 for (CLIOptions.INFO_TYPE infoType : infoTypes) { |
50 for (CLIOptions.INFO_TYPE infoType : infoTypes) { |
50 switch (infoType) { |
51 switch (infoType) { |
51 /** |
52 /** |
52 * TODO: implement show info |
53 * TODO: implement show info |
65 break; |
66 break; |
66 case VERSION: |
67 case VERSION: |
67 printResource(Constants.VERSION_FILE); |
68 printResource(Constants.VERSION_FILE); |
68 break; |
69 break; |
69 case DATABASES: |
70 case DATABASES: |
70 println("TODO: list databases"); |
71 final List<DatabaseDefinition> configuredDatabases = configurationProvider.getConfiguration().getDatabases(); |
|
72 if (configuredDatabases.isEmpty()) { |
|
73 log.log(Level.WARNING, "No databases are configured."); |
|
74 } else { |
|
75 for (DatabaseDefinition dd : configuredDatabases) { |
|
76 log.log(Level.INFO, "Configured database: {0}", dd.getName()); |
|
77 } |
|
78 } |
71 break; |
79 break; |
72 case CONNECTION: |
80 case CONNECTION: |
73 boolean connectionTestResult = false; |
81 boolean connectionTestResult = false; |
74 String dbName = options.getDatabaseNameToTest(); |
82 String dbName = options.getDatabaseNameToTest(); |
75 log.log(Level.FINE, "Testing connection to database: {0}", dbName); |
83 log.log(Level.FINE, "Testing connection to database: {0}", dbName); |