From 5e72409c3589f29cd6d128f3f29171fed3a47f3e Mon Sep 17 00:00:00 2001 From: mozhenghua Date: Fri, 3 May 2024 20:03:28 +0800 Subject: [PATCH] exec doInit when in SysInitializeAction context --- docker-compose/docker-compose.yaml | 4 ++-- .../tis/manage/spring/aop/AuthorityCheckAdvice.java | 5 ++++- .../qlangtech/tis/runtime/module/action/BasicModule.java | 2 +- .../tis/runtime/module/action/SysInitializeAction.java | 6 +++++- .../tis/runtime/module/action/TestSysInitializeAction.java | 3 ++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docker-compose/docker-compose.yaml b/docker-compose/docker-compose.yaml index 41ad9f0d1..b5b8908ac 100644 --- a/docker-compose/docker-compose.yaml +++ b/docker-compose/docker-compose.yaml @@ -1,7 +1,7 @@ version: "1" services: flink: - image: registry.cn-hangzhou.aliyuncs.com/tis/flink:4.0.0 + image: registry.cn-hangzhou.aliyuncs.com/tis/flink:4.0.0.36 hostname: flink mem_limit: 2048m cpus: '1.0' @@ -13,7 +13,7 @@ services: depends_on: - tis-console tis-console: - image: registry.cn-hangzhou.aliyuncs.com/tis/tis-console:4.0.0 + image: registry.cn-hangzhou.aliyuncs.com/tis/tis-console:4.0.0.36 hostname: tis-console mem_limit: "1.5G" cpus: '2.5' diff --git a/tis-console/src/main/java/com/qlangtech/tis/manage/spring/aop/AuthorityCheckAdvice.java b/tis-console/src/main/java/com/qlangtech/tis/manage/spring/aop/AuthorityCheckAdvice.java index 5f6d9a10f..9ec092f7d 100644 --- a/tis-console/src/main/java/com/qlangtech/tis/manage/spring/aop/AuthorityCheckAdvice.java +++ b/tis-console/src/main/java/com/qlangtech/tis/manage/spring/aop/AuthorityCheckAdvice.java @@ -22,6 +22,7 @@ import com.opensymphony.xwork2.ActionProxy; import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor; import com.qlangtech.tis.manage.common.IUser; +import com.qlangtech.tis.manage.common.MockContext; import com.qlangtech.tis.manage.common.RunContextGetter; import com.qlangtech.tis.manage.common.UserUtils; import com.qlangtech.tis.manage.common.valve.AjaxValve; @@ -81,7 +82,9 @@ protected String doIntercept(ActionInvocation invocation) throws Exception { return Action.NONE; } else { // 直接进行初始化 - return (action).execute(); + SysInitializeAction initAction = (SysInitializeAction) action; + initAction.doInit(new MockContext()); + return initAction.getReturnCode(); } } diff --git a/tis-console/src/main/java/com/qlangtech/tis/runtime/module/action/BasicModule.java b/tis-console/src/main/java/com/qlangtech/tis/runtime/module/action/BasicModule.java index d98554ff8..ad7ea2726 100644 --- a/tis-console/src/main/java/com/qlangtech/tis/runtime/module/action/BasicModule.java +++ b/tis-console/src/main/java/com/qlangtech/tis/runtime/module/action/BasicModule.java @@ -323,7 +323,7 @@ public static ActionContext getActionContext() { protected String getReturnCode() { - ActionContext actionCtx = ActionContext.getContext(); + // ActionContext actionCtx = ActionContext.getContext(); //ActionProxy proxy = actionCtx.getActionInvocation().getProxy(); // 并且只有screen中的 模块可以设置forward if (this.getRequest().getAttribute(TERMINATOR_FORWARD) != null) { diff --git a/tis-console/src/main/java/com/qlangtech/tis/runtime/module/action/SysInitializeAction.java b/tis-console/src/main/java/com/qlangtech/tis/runtime/module/action/SysInitializeAction.java index ad2a08751..6c6b2d248 100644 --- a/tis-console/src/main/java/com/qlangtech/tis/runtime/module/action/SysInitializeAction.java +++ b/tis-console/src/main/java/com/qlangtech/tis/runtime/module/action/SysInitializeAction.java @@ -101,8 +101,12 @@ public void doInit(Context context) throws Exception { * 取得SQL并且初始化 */ File mysqlInitScript = new File(Config.getDataDir(), "sql/tis_console_mysql.sql"); + this.init(context, true, Config.getDbCfg().dbtype, mysqlInitScript); + } - init(context, true, Config.getDbCfg().dbtype, mysqlInitScript); + @Override + public String getReturnCode() { + return super.getReturnCode(); } /** diff --git a/tis-console/src/test/java/com/qlangtech/tis/runtime/module/action/TestSysInitializeAction.java b/tis-console/src/test/java/com/qlangtech/tis/runtime/module/action/TestSysInitializeAction.java index ce6e9143c..c8a255196 100644 --- a/tis-console/src/test/java/com/qlangtech/tis/runtime/module/action/TestSysInitializeAction.java +++ b/tis-console/src/test/java/com/qlangtech/tis/runtime/module/action/TestSysInitializeAction.java @@ -110,7 +110,8 @@ public void testSystemDBInitializWithDerby() throws Exception { File initialSuccessToken = SysInitializeAction.getSysInitializedTokenFile(); FileUtils.deleteQuietly(initialSuccessToken); SysDBType sysDBType = SysDBType.DERBY; - final String tis_ansible_home = StringUtils.defaultIfEmpty(System.getenv("tis_ansible_home"), "/opt/misc/tis-ansible"); + final String tis_ansible_home + = StringUtils.defaultIfEmpty(System.getenv("tis_ansible_home"), "/opt/misc/tis-ansible"); String[] args = new String[]{tis_ansible_home + "/tis_console_derby.sql", sysDBType.getToken()}; // Config config = this.mock("config", Config.class);