From 32a312a8751df387f95fcb6365913e3033d74628 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 8 Feb 2022 03:58:03 +0100 Subject: [PATCH] IDEMPIERE-5174 Disable System User (#1170) Database Error when query/ReQuery in info window "Info System Element" as System User --- .../oracle/202202072157_IDEMPIERE-5174.sql | 35 +++++ .../202202072157_IDEMPIERE-5174.sql | 32 ++++ org.adempiere.base/src/org/compiere/Base.java | 139 ------------------ .../src/org/compiere/install/Translation.java | 30 ---- .../src/org/compiere/util/Login.java | 9 +- .../theme/default/zul/login/login-info.zul | 6 - 6 files changed, 72 insertions(+), 179 deletions(-) create mode 100644 migration/iD10/oracle/202202072157_IDEMPIERE-5174.sql create mode 100644 migration/iD10/postgresql/202202072157_IDEMPIERE-5174.sql delete mode 100644 org.adempiere.base/src/org/compiere/Base.java diff --git a/migration/iD10/oracle/202202072157_IDEMPIERE-5174.sql b/migration/iD10/oracle/202202072157_IDEMPIERE-5174.sql new file mode 100644 index 0000000000..e5161c571d --- /dev/null +++ b/migration/iD10/oracle/202202072157_IDEMPIERE-5174.sql @@ -0,0 +1,35 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-5174 Deactivate System user +-- Feb 7, 2022, 9:52:47 PM CET +UPDATE AD_User SET IsActive='N',Password=NULL,Updated=TO_DATE('2022-02-07 21:52:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_User_ID=0 AND IsActive='Y' +; + +-- Feb 7, 2022, 9:52:55 PM CET +UPDATE AD_User_Roles SET IsActive='N',Updated=TO_DATE('2022-02-07 21:52:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Role_ID=0 AND AD_User_ID=0 AND IsActive='Y' +; + +-- Feb 7, 2022, 10:49:09 PM CET +UPDATE AD_SchedulerRecipient SET AD_User_ID=100,Updated=TO_DATE('2022-02-07 22:49:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_User_ID=0 +; + +-- Feb 7, 2022, 10:59:05 PM CET +UPDATE AD_AlertProcessor SET Supervisor_ID=100,Updated=TO_DATE('2022-02-07 22:59:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE Supervisor_ID=0 +; + +-- Feb 7, 2022, 10:59:05 PM CET +UPDATE AD_LdapProcessor SET Supervisor_ID=100,Updated=TO_DATE('2022-02-07 22:59:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE Supervisor_ID=0 +; + +-- Feb 7, 2022, 10:59:05 PM CET +UPDATE AD_Scheduler SET Supervisor_ID=100,Updated=TO_DATE('2022-02-07 22:59:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE Supervisor_ID=0 +; + +-- Feb 7, 2022, 10:59:05 PM CET +UPDATE AD_WorkflowProcessor SET Supervisor_ID=100,Updated=TO_DATE('2022-02-07 22:59:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE Supervisor_ID=0 +; + +SELECT register_migration_script('202202072157_IDEMPIERE-5174.sql') FROM dual +; + diff --git a/migration/iD10/postgresql/202202072157_IDEMPIERE-5174.sql b/migration/iD10/postgresql/202202072157_IDEMPIERE-5174.sql new file mode 100644 index 0000000000..04b96f6762 --- /dev/null +++ b/migration/iD10/postgresql/202202072157_IDEMPIERE-5174.sql @@ -0,0 +1,32 @@ +-- IDEMPIERE-5174 Deactivate System user +-- Feb 7, 2022, 9:52:47 PM CET +UPDATE AD_User SET IsActive='N',Password=NULL,Updated=TO_TIMESTAMP('2022-02-07 21:52:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_User_ID=0 AND IsActive='Y' +; + +-- Feb 7, 2022, 9:52:55 PM CET +UPDATE AD_User_Roles SET IsActive='N',Updated=TO_TIMESTAMP('2022-02-07 21:52:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Role_ID=0 AND AD_User_ID=0 AND IsActive='Y' +; + +-- Feb 7, 2022, 10:49:09 PM CET +UPDATE AD_SchedulerRecipient SET AD_User_ID=100,Updated=TO_TIMESTAMP('2022-02-07 22:49:09','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_User_ID=0 +; + +-- Feb 7, 2022, 10:59:05 PM CET +UPDATE AD_AlertProcessor SET Supervisor_ID=100,Updated=TO_TIMESTAMP('2022-02-07 22:59:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE Supervisor_ID=0 +; + +-- Feb 7, 2022, 10:59:05 PM CET +UPDATE AD_LdapProcessor SET Supervisor_ID=100,Updated=TO_TIMESTAMP('2022-02-07 22:59:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE Supervisor_ID=0 +; + +-- Feb 7, 2022, 10:59:05 PM CET +UPDATE AD_Scheduler SET Supervisor_ID=100,Updated=TO_TIMESTAMP('2022-02-07 22:59:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE Supervisor_ID=0 +; + +-- Feb 7, 2022, 10:59:05 PM CET +UPDATE AD_WorkflowProcessor SET Supervisor_ID=100,Updated=TO_TIMESTAMP('2022-02-07 22:59:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE Supervisor_ID=0 +; + +SELECT register_migration_script('202202072157_IDEMPIERE-5174.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/Base.java b/org.adempiere.base/src/org/compiere/Base.java deleted file mode 100644 index 9c08b4e593..0000000000 --- a/org.adempiere.base/src/org/compiere/Base.java +++ /dev/null @@ -1,139 +0,0 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ -package org.compiere; - -import static org.compiere.model.SystemIDs.WINDOW_WINDOW_TAB_FIELD; - -import java.util.Properties; - -import org.compiere.model.GridWindow; -import org.compiere.model.GridWindowVO; -import org.compiere.model.MConversionRate; -import org.compiere.model.MUOMConversion; -import org.compiere.util.Env; -import org.compiere.util.Login; - -/** - * Base Library Test Classes mainly for Optimize it - * - * @author Jorg Janke - * @version $Id: Base.java,v 1.5 2006/09/21 20:44:54 jjanke Exp $ - */ -class Base -{ - /** - * Base Test - */ - public static void test() - { - System.out.println("** Before Init **"); //$NON-NLS-1$ - getMemoryUsed(); - Properties ctx = Login.initTest(false); - // - System.gc(); // cleanup Init - // - System.out.println("** Before Creation **"); - long start = getMemoryUsed(); - - // ******************************************************************* - - // Table=100, Shipper=142, Window=102, Reference=101 - int AD_Window_ID = WINDOW_WINDOW_TAB_FIELD; - long startTime = System.currentTimeMillis(); - GridWindowVO vo = GridWindowVO.create(Env.getCtx(), 1, AD_Window_ID); - GridWindow w = new GridWindow(vo); - long endDef = System.currentTimeMillis(); - System.out.println("Load Definition Time in ms = " + String.valueOf(endDef-startTime)); - - w.query(); - long endData = System.currentTimeMillis(); - System.out.println("Load Data Time in ms = " + String.valueOf(endData-startTime)); - w.loadCompete(); - long endDataComplete = System.currentTimeMillis(); - System.out.println("Load Data Complete Time in ms = " + String.valueOf(endDataComplete-startTime)); - w.getTab(0).navigate(0); - - // ******************************************************************* -// sleep(); - - System.out.println("** Before Dispose **"); - getMemoryUsed(); - w.dispose(); -// sleep(); - // - System.out.println("** Before GC **"); - getMemoryUsed(); - w = null; - System.gc(); - System.out.println("** After GC **"); - getMemoryUsed(); - System.gc(); - - System.out.println("** Final **"); - long complete = System.currentTimeMillis(); - System.out.println("Complete Time in ms = " + String.valueOf(complete-startTime)); - long end = getMemoryUsed(); - System.out.println("Memory increase in kB = End-Start=" + String.valueOf((end-start)/1024)); - listThreads(); - // - System.out.println("API Test"); - System.out.println("64.72=" + MConversionRate.convert(ctx, Env.ONEHUNDRED, 116, 100,0,0)); - System.out.println("0.647169=" + MConversionRate.getRate(116, 100, null, 0,0,0)); - System.out.println("12.5=" + MUOMConversion.convert(101, 102, Env.ONEHUNDRED, true)); - - } // Base - - /** - * Get Used Memory in bytes - * @return memory used - */ - private static long getMemoryUsed() - { - long free = Runtime.getRuntime().freeMemory(); - long total = Runtime.getRuntime().totalMemory(); - long used = total - free; - // - System.out.println("Memory used in kB = Total(" - + String.valueOf(total/1024) + ")-Free(" - + String.valueOf(free/1024) + ") = " + String.valueOf(used/1024)); - System.out.println("Active Threads=" + Thread.activeCount()); - return used; - } // getMemoryUsed - - /** - * List Threads - */ - private static void listThreads() - { - Thread[] list = new Thread[Thread.activeCount()]; - for (int i = 0; i < list.length; i++) - { - if (list[i] != null) - System.out.println("Thread " + i + " - " + list[i].toString()); - } - } // listThreads - - /** - * Start - * @param args ignored - */ - public static void main(String[] args) - { - Base.test(); - Env.exitEnv(0); - } // main -} // Base diff --git a/org.adempiere.base/src/org/compiere/install/Translation.java b/org.adempiere.base/src/org/compiere/install/Translation.java index 99f55c9dbd..16ee2fdb5b 100644 --- a/org.adempiere.base/src/org/compiere/install/Translation.java +++ b/org.adempiere.base/src/org/compiere/install/Translation.java @@ -52,7 +52,6 @@ import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Language; -import org.compiere.util.Login; import org.compiere.util.Msg; import org.compiere.util.Util; import org.eclipse.equinox.app.IApplication; @@ -589,33 +588,4 @@ public class Translation implements IApplication // IApplication implementation method - (only start method used) } - /************************************************************************** - * Batch Interface - * @param args directory AD_Language import/export - */ - public static void main (String[] args) - { - if (args.length != 3) - { - System.out.println("format : java Translation directory AD_Language import|export"); - System.out.println("example: java Translation /Adempiere/data/de_DE de_DE import"); - System.out.println("example: java Translation /Adempiere/data/fr_FR fr_FR export"); - System.exit(1); - } - // - Login.initTest (false); - String directory = args[0]; - String AD_Language = args[1]; - String mode = args[2]; - - Translation trl = new Translation(Env.getCtx()); - String msg = trl.validateLanguage (AD_Language); - if (msg.length() > 0) - System.err.println(msg); - else - trl.process (directory, AD_Language, mode); - - System.exit(0); - } // main - } // Translation diff --git a/org.adempiere.base/src/org/compiere/util/Login.java b/org.adempiere.base/src/org/compiere/util/Login.java index 64c50d3e69..d440bf22f2 100644 --- a/org.adempiere.base/src/org/compiere/util/Login.java +++ b/org.adempiere.base/src/org/compiere/util/Login.java @@ -82,6 +82,7 @@ public class Login * @param isClient client session * @return Context */ + @Deprecated public static Properties initTest (boolean isClient) { // logger.entering("Env", "initTest"); @@ -91,7 +92,7 @@ public class Login Properties ctx = Env.getCtx(); Login login = new Login(ctx); KeyNamePair[] roles = login.getRoles(CConnection.get(), - "System", "System", true); + "SuperUser", "System", true); // load role if (roles != null && roles.length > 0) { @@ -373,9 +374,9 @@ public class Login if (!rs.next()) // no record found if (force) { - Env.setContext(m_ctx, Env.AD_USER_NAME, "System"); - Env.setContext(m_ctx, Env.AD_USER_ID, "0"); - Env.setContext(m_ctx, "#AD_User_Description", "System Forced Login"); + Env.setContext(m_ctx, Env.AD_USER_NAME, "SuperUser"); + Env.setContext(m_ctx, Env.AD_USER_ID, "100"); + Env.setContext(m_ctx, "#AD_User_Description", "SuperUser Forced Login"); Env.setContext(m_ctx, Env.USER_LEVEL, "S "); // Format 'SCO' Env.setContext(m_ctx, "#User_Client", "0"); // Format c1, c2, ... Env.setContext(m_ctx, "#User_Org", "0"); // Format o1, o2, ... diff --git a/org.adempiere.ui.zk/WEB-INF/src/web/theme/default/zul/login/login-info.zul b/org.adempiere.ui.zk/WEB-INF/src/web/theme/default/zul/login/login-info.zul index 927b26d144..ea19cf913d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/web/theme/default/zul/login/login-info.zul +++ b/org.adempiere.ui.zk/WEB-INF/src/web/theme/default/zul/login/login-info.zul @@ -50,12 +50,6 @@ Copyright (C) 2009 Idalica Corporation System - -System -system @ idempiere.com -System - -