Merge remote-tracking branch 'origin/release-7.1'

This commit is contained in:
hengsin 2020-04-06 12:28:46 +08:00
commit c8b8e00202
8 changed files with 89 additions and 39 deletions

View File

@ -0,0 +1,15 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-2869
-- Apr 5, 2020, 6:40:35 PM CEST
UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-04-05 18:40:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6429
;
-- Apr 5, 2020, 6:42:56 PM CEST
UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2020-04-05 18:42:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2291
;
SELECT register_migration_script('202004051844_IDEMPIERE-2869.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- IDEMPIERE-2869
-- Apr 5, 2020, 6:40:35 PM CEST
UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-04-05 18:40:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=6429
;
-- Apr 5, 2020, 6:42:56 PM CEST
UPDATE AD_Field SET IsActive='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-04-05 18:42:56','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=2291
;
SELECT register_migration_script('202004051844_IDEMPIERE-2869.sql') FROM dual
;

View File

@ -18,9 +18,8 @@
package org.adempiere.webui;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@ -61,6 +60,7 @@ import org.zkoss.web.servlet.Servlets;
import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.event.ClientInfoEvent;
import org.zkoss.zk.ui.event.Event;
@ -86,8 +86,6 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
*/
private static final long serialVersionUID = -6725805283410008847L;
private static final String SAVED_CONTEXT = "saved.context";
public static final String APPLICATION_DESKTOP_KEY = "application.desktop";
public static String APP_NAME = null;
@ -139,13 +137,6 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
SessionManager.setSessionApplication(this);
Session session = Executions.getCurrent().getDesktop().getSession();
@SuppressWarnings("unchecked")
Map<String, Object>map = (Map<String, Object>) session.removeAttribute(SAVED_CONTEXT);
if (map != null && !map.isEmpty())
{
onChangeRole(map);
return;
}
Properties ctx = Env.getCtx();
langSession = Env.getContext(ctx, Env.LANGUAGE);
@ -493,14 +484,11 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
}
private void onChangeRole(Map<String, Object> map) {
Locale locale = (Locale) map.get("locale");
Properties properties = (Properties) map.get("context");
private void onChangeRole(Locale locale, Properties context) {
SessionManager.setSessionApplication(this);
loginDesktop = new WLogin(this);
loginDesktop.createPart(this.getPage());
loginDesktop.changeRole(locale, properties);
loginDesktop.changeRole(locale, context);
loginDesktop.getComponent().getRoot().addEventListener(Events.ON_CLIENT_INFO, this);
}
@ -541,28 +529,44 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
Desktop desktop = Executions.getCurrent().getDesktop();
Locale locale = (Locale) desktop.getSession().getAttribute(Attributes.PREFERRED_LOCALE);
HttpServletRequest httpRequest = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
Env.setContext(properties, SessionContextListener.SERVLET_SESSION_ID, httpRequest.getSession().getId());
if (desktop.isServerPushEnabled())
desktop.enableServerPush(false);
logout0();
//stop key listener
if (keyListener != null) {
keyListener.detach();
keyListener = null;
}
//clear context
Env.getCtx().clear();
//invalidate session
httpRequest.getSession(false).invalidate();
desktop.setAttribute(DESKTOP_SESSION_INVALIDATED_ATTR, Boolean.TRUE);
//desktop cleanup
IDesktop appDesktop = getAppDeskop();
if (appDesktop != null)
appDesktop.logout();
//remove all children component
getChildren().clear();
//put saved context into new session
Map<String, Object> map = new HashMap<String, Object>();
map.put("context", properties);
map.put("locale", locale);
//remove all root components except this
Page page = getPage();
page.removeComponents();
this.setPage(page);
//clear session attributes
Enumeration<String> attributes = httpRequest.getSession().getAttributeNames();
while(attributes.hasMoreElements()) {
String attribute = attributes.nextElement();
//need to keep zk's session attributes
if (attribute.contains("zkoss."))
continue;
httpRequest.getSession().removeAttribute(attribute);
}
//logout ad_session
AEnv.logout();
HttpSession newSession = httpRequest.getSession(true);
newSession.setAttribute(SAVED_CONTEXT, map);
properties.setProperty(SessionContextListener.SERVLET_SESSION_ID, newSession.getId());
Executions.getCurrent().sendRedirect("index.zul");
//show change role window and set new context for env and session
onChangeRole(locale, properties);
}
@Override

View File

@ -135,6 +135,11 @@ public class WLogin extends AbstractUIPart
return layout;
}
/**
* Show change role window
* @param locale
* @param properties env context
*/
public void changeRole(Locale locale, Properties properties) {
loginWindow.changeRole(locale, properties);
}

View File

@ -583,8 +583,13 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
}
}
/**
* show UI for change role
* @param ctx env context
*/
public void changeRole(Properties ctx) {
ctxBeforeChangeRole = ctx;
ctxBeforeChangeRole = new Properties();
ctxBeforeChangeRole.putAll(ctx);
int AD_Client_ID = Env.getAD_Client_ID(ctx);
lstClient.setValue(AD_Client_ID);
updateRoleList();

View File

@ -224,12 +224,12 @@ public class UserPanel implements EventListener<Event>, Composer<Component>
{
if (result)
{
Events.echoEvent(ON_DEFER_CHANGE_ROLE, component, null);
Events.postEvent(ON_DEFER_CHANGE_ROLE, component, null);
}
}
});
} else {
Events.echoEvent(ON_DEFER_CHANGE_ROLE, component, null);
Events.postEvent(ON_DEFER_CHANGE_ROLE, component, null);
}
}
else if (preference == event.getTarget())

View File

@ -32,6 +32,7 @@ import org.adempiere.webui.panel.ChangePasswordPanel;
import org.adempiere.webui.panel.LoginPanel;
import org.adempiere.webui.panel.ResetPasswordPanel;
import org.adempiere.webui.panel.RolePanel;
import org.adempiere.webui.session.SessionContextListener;
import org.adempiere.webui.theme.ThemeManager;
import org.compiere.model.MSysConfig;
import org.compiere.model.MUser;
@ -180,9 +181,15 @@ public class LoginWindow extends FWindow implements EventListener<Event>
}
}
/**
* Show change role window
* @param locale
* @param ctx
*/
public void changeRole(Locale locale, Properties ctx)
{
Env.setCtx(ctx);
getDesktop().getSession().setAttribute(SessionContextListener.SESSION_CTX, ctx);
//reload theme preference
PageDefinition pageDefintion = Executions.getCurrent().getPageDefinition(ThemeManager.getThemeResource("preference.zul"));

View File

@ -345,8 +345,10 @@ public class Process {
try
{
processOK = process.processIt(pi, trx, false);
if (trxName == null)
trx.commit();
if (trxName == null && processOK)
trx.commit();
else if (trxName == null && !processOK)
trx.rollback();
}
catch (Throwable t)
{