From 562283fe48cc767bde5db138c979247174d4ff4c Mon Sep 17 00:00:00 2001 From: Nicolas Micoud <58596990+nmicoud@users.noreply.github.com> Date: Sat, 2 Sep 2023 16:38:13 +0200 Subject: [PATCH] IDEMPIERE-5760: Manage mail.smtp.timeout using SysConfig (#1982) https://idempiere.atlassian.net/browse/IDEMPIERE-5760 https://github.com/idempiere/idempiere/pull/1883 + changes requested by Carlos (migration script) --- migration/iD10/oracle/202308280920_IDEMPIERE-5760.sql | 10 ++++++++++ .../iD10/postgresql/202308280920_IDEMPIERE-5760.sql | 7 +++++++ .../src/org/compiere/model/MSysConfig.java | 3 ++- org.adempiere.base/src/org/compiere/util/EMail.java | 6 +++--- 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 migration/iD10/oracle/202308280920_IDEMPIERE-5760.sql create mode 100644 migration/iD10/postgresql/202308280920_IDEMPIERE-5760.sql diff --git a/migration/iD10/oracle/202308280920_IDEMPIERE-5760.sql b/migration/iD10/oracle/202308280920_IDEMPIERE-5760.sql new file mode 100644 index 0000000000..6257f2c0bb --- /dev/null +++ b/migration/iD10/oracle/202308280920_IDEMPIERE-5760.sql @@ -0,0 +1,10 @@ +-- IDEMPIERE-5760 +SELECT register_migration_script('202308280920_IDEMPIERE-5760.sql') FROM dual; + +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Aug 28, 2023, 9:20:09 AM CEST +INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200233,0,0,TO_TIMESTAMP('2023-08-28 09:20:09','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2023-08-28 09:20:09','YYYY-MM-DD HH24:MI:SS'),10,10,'Y','MAIL_SMTP_TIMEOUT','20000','Timeout in milliseconds to send an email','D','C','66c84808-15eb-4f26-ad23-25d9ea0d96fc') +; + diff --git a/migration/iD10/postgresql/202308280920_IDEMPIERE-5760.sql b/migration/iD10/postgresql/202308280920_IDEMPIERE-5760.sql new file mode 100644 index 0000000000..e4f0f38eaf --- /dev/null +++ b/migration/iD10/postgresql/202308280920_IDEMPIERE-5760.sql @@ -0,0 +1,7 @@ +-- IDEMPIERE-5760 +SELECT register_migration_script('202308280920_IDEMPIERE-5760.sql') FROM dual; + +-- Aug 28, 2023, 9:20:09 AM CEST +INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200233,0,0,TO_TIMESTAMP('2023-08-28 09:20:09','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2023-08-28 09:20:09','YYYY-MM-DD HH24:MI:SS'),10,10,'Y','MAIL_SMTP_TIMEOUT','20000','Timeout in milliseconds to send an email','D','C','66c84808-15eb-4f26-ad23-25d9ea0d96fc') +; + diff --git a/org.adempiere.base/src/org/compiere/model/MSysConfig.java b/org.adempiere.base/src/org/compiere/model/MSysConfig.java index 5540c8fda7..36814c5350 100644 --- a/org.adempiere.base/src/org/compiere/model/MSysConfig.java +++ b/org.adempiere.base/src/org/compiere/model/MSysConfig.java @@ -44,7 +44,7 @@ public class MSysConfig extends X_AD_SysConfig /** * */ - private static final long serialVersionUID = 4924291305767860669L; + private static final long serialVersionUID = -2055659961699848343L; public static final String AD_CHANGELOG_SAVE_UUID = "AD_CHANGELOG_SAVE_UUID"; public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION"; @@ -137,6 +137,7 @@ public class MSysConfig extends X_AD_SysConfig public static final String MAIL_SEND_BCC_TO_ADDRESS = "MAIL_SEND_BCC_TO_ADDRESS"; public static final String MAIL_SEND_BCC_TO_FROM = "MAIL_SEND_BCC_TO_FROM"; public static final String MAIL_SEND_CREDENTIALS = "MAIL_SEND_CREDENTIALS"; + public static final String MAIL_SMTP_TIMEOUT = "MAIL_SMTP_TIMEOUT"; public static final String MAX_ACTIVITIES_IN_LIST = "MAX_ACTIVITIES_IN_LIST"; public static final String MAX_RESULTS_PER_SEARCH_IN_DOCUMENT_CONTROLLER = "MAX_RESULTS_PER_SEARCH_IN_DOCUMENT_CONTROLLER"; public static final String MAX_ROWS_IN_TABLE_COMBOLIST = "MAX_ROWS_IN_TABLE_COMBOLIST"; diff --git a/org.adempiere.base/src/org/compiere/util/EMail.java b/org.adempiere.base/src/org/compiere/util/EMail.java index 6538d8771c..89f91b3282 100644 --- a/org.adempiere.base/src/org/compiere/util/EMail.java +++ b/org.adempiere.base/src/org/compiere/util/EMail.java @@ -74,7 +74,7 @@ public final class EMail implements Serializable /** * */ - private static final long serialVersionUID = 5355436165040508855L; + private static final long serialVersionUID = -8982983766981221312L; //use in server bean public final static String HTML_MAIL_MARKER = "ContentType=text/html;"; @@ -305,8 +305,8 @@ public final class EMail implements Serializable props.put("mail.store.protocol", "smtp"); props.put("mail.transport.protocol", "smtp"); props.put("mail.host", m_smtpHost); - //Timeout for sending the email defaulted to 20 seconds - props.put("mail.smtp.timeout", 20000); + //Timeout for sending the email defaulted to 20 seconds if not defined in a SysConfig Key + props.put("mail.smtp.timeout", MSysConfig.getIntValue(MSysConfig.MAIL_SMTP_TIMEOUT, 20000, Env.getAD_Client_ID(m_ctx))); if (CLogMgt.isLevelFinest()) props.put("mail.debug", "true");