From 1efe7a4ac51a6c1a34cd1e0b429f2ea9b4e2a32b Mon Sep 17 00:00:00 2001 From: Zuhri Utama Date: Mon, 18 Sep 2023 19:44:21 +0700 Subject: [PATCH] IDEMPIERE-4697 : temporary filename "adempiere_" (#2000) * IDEMPIERE-4697 : get temp filename based on config "TEMP_FILENAME" if exists * IDEMPIERE-4697 : temporary filename "adempiere_" * IDEMPIERE-4697 : set default value and change from adempiere to idempiere --- migration/iD11/oracle/202309171225_IDEMPIERE-4697.sql | 9 +++++++++ .../iD11/postgresql/202309171225_IDEMPIERE-4697.sql | 6 ++++++ .../src/org/compiere/model/MSysConfig.java | 1 + .../src/org/adempiere/webui/editor/WFilenameEditor.java | 4 +++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 migration/iD11/oracle/202309171225_IDEMPIERE-4697.sql create mode 100644 migration/iD11/postgresql/202309171225_IDEMPIERE-4697.sql diff --git a/migration/iD11/oracle/202309171225_IDEMPIERE-4697.sql b/migration/iD11/oracle/202309171225_IDEMPIERE-4697.sql new file mode 100644 index 0000000000..1b62cd9727 --- /dev/null +++ b/migration/iD11/oracle/202309171225_IDEMPIERE-4697.sql @@ -0,0 +1,9 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Sep 17, 2023, 12:25:48 PM WIB +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 (200234,0,0,TO_TIMESTAMP('2023-09-17 12:25:47','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2023-09-17 12:25:47','YYYY-MM-DD HH24:MI:SS'),10,10,'Y','UPLOAD_TEMP_FILENAME_PREFIX','idempiere_','Prefix temporary filename for uploaded media','D','C','ecc709a7-8c32-4637-861f-9606a9de9751') +; + +-- IDEMPIERE-4697 +SELECT register_migration_script('202309171225_IDEMPIERE-4697.sql') FROM dual; diff --git a/migration/iD11/postgresql/202309171225_IDEMPIERE-4697.sql b/migration/iD11/postgresql/202309171225_IDEMPIERE-4697.sql new file mode 100644 index 0000000000..5fd45b4e14 --- /dev/null +++ b/migration/iD11/postgresql/202309171225_IDEMPIERE-4697.sql @@ -0,0 +1,6 @@ +-- Sep 17, 2023, 12:25:48 PM WIB +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 (200234,0,0,TO_TIMESTAMP('2023-09-17 12:25:47','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2023-09-17 12:25:47','YYYY-MM-DD HH24:MI:SS'),10,10,'Y','UPLOAD_TEMP_FILENAME_PREFIX','idempiere_','Prefix temporary filename for uploaded media','D','C','ecc709a7-8c32-4637-861f-9606a9de9751') +; + +-- IDEMPIERE-4697 +SELECT register_migration_script('202309171225_IDEMPIERE-4697.sql') FROM dual; diff --git a/org.adempiere.base/src/org/compiere/model/MSysConfig.java b/org.adempiere.base/src/org/compiere/model/MSysConfig.java index 36814c5350..29b19eeba9 100644 --- a/org.adempiere.base/src/org/compiere/model/MSysConfig.java +++ b/org.adempiere.base/src/org/compiere/model/MSysConfig.java @@ -182,6 +182,7 @@ public class MSysConfig extends X_AD_SysConfig public static final String TRX_AUTOSET_DISPLAY_NAME = "TRX_AUTOSET_DISPLAY_NAME"; public static final String TWOPACK_COMMIT_DDL = "2PACK_COMMIT_DDL"; public static final String TWOPACK_HANDLE_TRANSLATIONS = "2PACK_HANDLE_TRANSLATIONS"; + public static final String UPLOAD_TEMP_FILENAME_PREFIX = "UPLOAD_TEMP_FILENAME_PREFIX"; public static final String USE_EMAIL_FOR_LOGIN = "USE_EMAIL_FOR_LOGIN"; public static final String USE_ESC_FOR_TAB_CLOSING = "USE_ESC_FOR_TAB_CLOSING"; public static final String USER_LOCKING_MAX_ACCOUNT_LOCK_MINUTES = "USER_LOCKING_MAX_ACCOUNT_LOCK_MINUTES"; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java index 428c6027d3..761cef4d87 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java @@ -26,8 +26,10 @@ import org.adempiere.webui.component.FilenameBox; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.theme.ThemeManager; import org.compiere.model.GridField; +import org.compiere.model.MSysConfig; import org.compiere.util.CLogger; import org.compiere.util.DisplayType; +import org.compiere.util.Env; import org.zkoss.util.media.Media; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; @@ -171,7 +173,7 @@ public class WFilenameEditor extends WEditor String fileName = null; try { - File tempFile = File.createTempFile("adempiere_", "_"+file.getName()); + File tempFile = File.createTempFile(MSysConfig.getValue(MSysConfig.UPLOAD_TEMP_FILENAME_PREFIX, "idempiere", Env.getAD_Client_ID(Env.getCtx())), "_"+file.getName()); fileName = tempFile.getAbsolutePath(); fos = new FileOutputStream(tempFile);