From fbbdbbbee07f553f1d577511663d170586118c49 Mon Sep 17 00:00:00 2001 From: SteDev2 Date: Wed, 24 Jan 2024 21:40:46 +0100 Subject: [PATCH 1/4] Add showSql properties for develop mode --- .../it/infn/mw/iam/config/IamProperties.java | 10 +++++++++ .../java/it/infn/mw/iam/config/JpaConfig.java | 21 +++++++++++-------- .../src/main/resources/application.yml | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/iam-login-service/src/main/java/it/infn/mw/iam/config/IamProperties.java b/iam-login-service/src/main/java/it/infn/mw/iam/config/IamProperties.java index a6793d664..3893e4c4d 100644 --- a/iam-login-service/src/main/java/it/infn/mw/iam/config/IamProperties.java +++ b/iam-login-service/src/main/java/it/infn/mw/iam/config/IamProperties.java @@ -517,6 +517,8 @@ public void setLocation(String location) { private boolean enableScopeAuthz = true; + private boolean showSql = false; + private LocalResources localResources = new LocalResources(); private Logo logo = new Logo(); @@ -615,6 +617,14 @@ public void setEnableScopeAuthz(boolean enableScopeAuthz) { this.enableScopeAuthz = enableScopeAuthz; } + public boolean isShowSql() { + return showSql; + } + + public void setShowSql(boolean showSql) { + this.showSql = showSql; + } + public LoginButtonProperties getLoginButton() { return loginButton; } diff --git a/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java b/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java index 696b69365..a0f4fba99 100644 --- a/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java +++ b/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java @@ -36,6 +36,7 @@ import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.jta.JtaTransactionManager; +import it.infn.mw.iam.config.IamProperties; @Configuration @EnableTransactionManagement @@ -43,10 +44,12 @@ public class JpaConfig extends JpaBaseConfiguration { public static final String ECLIPSELINK_LOGGING_LEVEL = "eclipselink.logging.level"; public static final String ECLIPSELINK_LOGGING_LEVEL_SQL = "eclipselink.logging.level.sql"; + public final IamProperties iamProperties; protected JpaConfig(DataSource dataSource, JpaProperties properties, - ObjectProvider jtaTransactionManager) { + ObjectProvider jtaTransactionManager, IamProperties iamProperties) { super(dataSource, properties, jtaTransactionManager); + this.iamProperties = iamProperties; } @Autowired @@ -68,18 +71,18 @@ protected Map getVendorProperties() { map.put(ECLIPSELINK_LOGGING_LEVEL_SQL, "OFF"); map.put("eclipselink.cache.shared.default", "false"); - if (System.getProperty("iam.show_sql") != null) { - map.put(ECLIPSELINK_LOGGING_LEVEL, "FINE"); + if (iamProperties.isShowSql()) { + map.put(ECLIPSELINK_LOGGING_LEVEL, "INFO"); map.put(ECLIPSELINK_LOGGING_LEVEL_SQL, "FINE"); map.put("eclipselink.logging.parameters", "true"); } - if (System.getProperty("iam.generate-ddl-sql-script") != null) { - map.put(ECLIPSELINK_LOGGING_LEVEL, "FINE"); - map.put("eclipselink.ddl-generation.output-mode", "sql-script"); - map.put("eclipselink.ddl-generation", "create-tables"); - map.put("eclipselink.create-ddl-jdbc-file-name", "ddl.sql"); - } + // if (System.getProperty("iam.generate-ddl-sql-script") != null) { + // map.put(ECLIPSELINK_LOGGING_LEVEL, "FINE"); + // map.put("eclipselink.ddl-generation.output-mode", "sql-script"); + // map.put("eclipselink.ddl-generation", "create-tables"); + // map.put("eclipselink.create-ddl-jdbc-file-name", "ddl.sql"); + // } return map; diff --git a/iam-login-service/src/main/resources/application.yml b/iam-login-service/src/main/resources/application.yml index 9fb2907f1..7827d245b 100644 --- a/iam-login-service/src/main/resources/application.yml +++ b/iam-login-service/src/main/resources/application.yml @@ -91,11 +91,11 @@ spring: pathmatch: matching-strategy: "ant-path-matcher" iam: - host: ${IAM_HOST:localhost} baseUrl: ${IAM_BASE_URL:http://${iam.host}:8080} issuer: ${IAM_ISSUER:http://${iam.host}:8080} topbarTitle: ${IAM_TOPBAR_TITLE:INDIGO IAM for ${iam.organisation.name}} + showSql: ${IAM_DATABASE_SHOW_SQL:true} jwk: keystore-location: ${IAM_KEY_STORE_LOCATION:classpath:keystore.jwks} From 48eeb011c3adb4a6fc084cd3d63f91a309160f6f Mon Sep 17 00:00:00 2001 From: SteDev2 Date: Wed, 24 Jan 2024 22:08:46 +0100 Subject: [PATCH 2/4] Restore commented lines --- .../main/java/it/infn/mw/iam/config/JpaConfig.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java b/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java index a0f4fba99..421074b77 100644 --- a/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java +++ b/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java @@ -36,7 +36,6 @@ import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.jta.JtaTransactionManager; -import it.infn.mw.iam.config.IamProperties; @Configuration @EnableTransactionManagement @@ -77,12 +76,12 @@ protected Map getVendorProperties() { map.put("eclipselink.logging.parameters", "true"); } - // if (System.getProperty("iam.generate-ddl-sql-script") != null) { - // map.put(ECLIPSELINK_LOGGING_LEVEL, "FINE"); - // map.put("eclipselink.ddl-generation.output-mode", "sql-script"); - // map.put("eclipselink.ddl-generation", "create-tables"); - // map.put("eclipselink.create-ddl-jdbc-file-name", "ddl.sql"); - // } + if (System.getProperty("iam.generate-ddl-sql-script") != null) { + map.put(ECLIPSELINK_LOGGING_LEVEL, "FINE"); + map.put("eclipselink.ddl-generation.output-mode", "sql-script"); + map.put("eclipselink.ddl-generation", "create-tables"); + map.put("eclipselink.create-ddl-jdbc-file-name", "ddl.sql"); + } return map; From e04b096060b29b2e57fefb76c922491d5f6f0873 Mon Sep 17 00:00:00 2001 From: SteDev2 Date: Thu, 25 Jan 2024 11:11:43 +0100 Subject: [PATCH 3/4] Set the default showSql property to false --- iam-login-service/src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iam-login-service/src/main/resources/application.yml b/iam-login-service/src/main/resources/application.yml index 7827d245b..bc7d27d18 100644 --- a/iam-login-service/src/main/resources/application.yml +++ b/iam-login-service/src/main/resources/application.yml @@ -95,7 +95,7 @@ iam: baseUrl: ${IAM_BASE_URL:http://${iam.host}:8080} issuer: ${IAM_ISSUER:http://${iam.host}:8080} topbarTitle: ${IAM_TOPBAR_TITLE:INDIGO IAM for ${iam.organisation.name}} - showSql: ${IAM_DATABASE_SHOW_SQL:true} + showSql: ${IAM_DATABASE_SHOW_SQL:false} jwk: keystore-location: ${IAM_KEY_STORE_LOCATION:classpath:keystore.jwks} From 8e2c437e386915a2acedc27a389a327b39a408b9 Mon Sep 17 00:00:00 2001 From: SteDev2 Date: Thu, 25 Jan 2024 11:13:25 +0100 Subject: [PATCH 4/4] Fix typo --- .../src/main/java/it/infn/mw/iam/config/JpaConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java b/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java index 421074b77..9d8c26a4f 100644 --- a/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java +++ b/iam-login-service/src/main/java/it/infn/mw/iam/config/JpaConfig.java @@ -71,7 +71,7 @@ protected Map getVendorProperties() { map.put("eclipselink.cache.shared.default", "false"); if (iamProperties.isShowSql()) { - map.put(ECLIPSELINK_LOGGING_LEVEL, "INFO"); + map.put(ECLIPSELINK_LOGGING_LEVEL, "FINE"); map.put(ECLIPSELINK_LOGGING_LEVEL_SQL, "FINE"); map.put("eclipselink.logging.parameters", "true"); }