Skip to content

Commit

Permalink
feat(liquibase-unlocker-tool): added loggin of provided options on Li…
Browse files Browse the repository at this point in the history
…quibase Unlocker Tool startup

Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Dec 19, 2023
1 parent e43701f commit f72ec96
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
package org.eclipse.kapua.extras.liquibaseUnlocker;

import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import org.eclipse.kapua.commons.jpa.JdbcConnectionUrlResolvers;
import org.eclipse.kapua.commons.liquibase.KapuaLiquibaseClient;
import org.eclipse.kapua.commons.setting.system.SystemSetting;
import org.eclipse.kapua.commons.setting.system.SystemSettingKey;
import org.eclipse.kapua.commons.util.log.ConfigurationPrinter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,6 +35,8 @@ public static void main(String[] args) {
LOG.info("Liquibase change log table unlocker tool... STARTING");
try {
{
printConfiguration();

String dbUsername = SYSTEM_SETTING.getString(SystemSettingKey.DB_USERNAME);
String dbPassword = SYSTEM_SETTING.getString(SystemSettingKey.DB_PASSWORD);
String schema = MoreObjects.firstNonNull(
Expand All @@ -49,4 +53,34 @@ public static void main(String[] args) {

LOG.info("Liquibase change log table unlocker tool... DONE!");
}

/**
* Prints the JDBC configuration on startup
*
* @since 2.0.0
*/
protected static void printConfiguration() {
ConfigurationPrinter configurationPrinter =
ConfigurationPrinter.create()
.withLogger(LOG)
.withLogLevel(ConfigurationPrinter.LogLevel.INFO)
.withTitle("Entity Secret Attribute Migration Tool Configuration");

configurationPrinter
.openSection("JDBC Configuration")
.addParameter("Resolver", System.getProperty(SystemSettingKey.DB_JDBC_CONNECTION_URL_RESOLVER.key()))
.addParameter("Driver", System.getProperty(SystemSettingKey.DB_JDBC_DRIVER.key()))
.addParameter("Scheme", System.getProperty(SystemSettingKey.DB_CONNECTION_SCHEME.key()))
.addParameter("Host", System.getProperty(SystemSettingKey.DB_CONNECTION_HOST.key()))
.addParameter("Port", System.getProperty(SystemSettingKey.DB_CONNECTION_PORT.key()))
.addParameter("Database Name", System.getProperty(SystemSettingKey.DB_NAME.key()))
.addParameter("Database Schema", System.getProperty(SystemSettingKey.DB_SCHEMA.key()))
.addParameter("Username", Strings.isNullOrEmpty(System.getProperty(SystemSettingKey.DB_USERNAME.key())) ? "No" : "Yes")
.addParameter("Password", Strings.isNullOrEmpty(System.getProperty(SystemSettingKey.DB_PASSWORD.key())) ? "No" : "Yes")
.addParameter("SSL Enabled", System.getProperty(SystemSettingKey.DB_CONNECTION_USE_SSL.key()))
.addParameter("SSL Enabled Protocols", System.getProperty(SystemSettingKey.DB_CONNECTION_ENABLED_SSL_PROTOCOL_SUITES.key()))
.closeSection();

configurationPrinter.printLog();
}
}

0 comments on commit f72ec96

Please sign in to comment.