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; package org.adempiere.webui;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.HashMap; import java.util.Enumeration;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; 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.au.out.AuScript;
import org.zkoss.zk.ui.Desktop; import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.Session; import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.event.ClientInfoEvent; import org.zkoss.zk.ui.event.ClientInfoEvent;
import org.zkoss.zk.ui.event.Event; 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 long serialVersionUID = -6725805283410008847L;
private static final String SAVED_CONTEXT = "saved.context";
public static final String APPLICATION_DESKTOP_KEY = "application.desktop"; public static final String APPLICATION_DESKTOP_KEY = "application.desktop";
public static String APP_NAME = null; public static String APP_NAME = null;
@ -139,13 +137,6 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
SessionManager.setSessionApplication(this); SessionManager.setSessionApplication(this);
Session session = Executions.getCurrent().getDesktop().getSession(); 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(); Properties ctx = Env.getCtx();
langSession = Env.getContext(ctx, Env.LANGUAGE); 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) { private void onChangeRole(Locale locale, Properties context) {
Locale locale = (Locale) map.get("locale");
Properties properties = (Properties) map.get("context");
SessionManager.setSessionApplication(this); SessionManager.setSessionApplication(this);
loginDesktop = new WLogin(this); loginDesktop = new WLogin(this);
loginDesktop.createPart(this.getPage()); loginDesktop.createPart(this.getPage());
loginDesktop.changeRole(locale, properties); loginDesktop.changeRole(locale, context);
loginDesktop.getComponent().getRoot().addEventListener(Events.ON_CLIENT_INFO, this); 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(); Desktop desktop = Executions.getCurrent().getDesktop();
Locale locale = (Locale) desktop.getSession().getAttribute(Attributes.PREFERRED_LOCALE); Locale locale = (Locale) desktop.getSession().getAttribute(Attributes.PREFERRED_LOCALE);
HttpServletRequest httpRequest = (HttpServletRequest) Executions.getCurrent().getNativeRequest(); HttpServletRequest httpRequest = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
Env.setContext(properties, SessionContextListener.SERVLET_SESSION_ID, httpRequest.getSession().getId());
if (desktop.isServerPushEnabled()) //stop key listener
desktop.enableServerPush(false); if (keyListener != null) {
logout0(); keyListener.detach();
keyListener = null;
}
//clear context //desktop cleanup
Env.getCtx().clear(); IDesktop appDesktop = getAppDeskop();
if (appDesktop != null)
//invalidate session appDesktop.logout();
httpRequest.getSession(false).invalidate();
desktop.setAttribute(DESKTOP_SESSION_INVALIDATED_ATTR, Boolean.TRUE); //remove all children component
getChildren().clear();
//put saved context into new session //remove all root components except this
Map<String, Object> map = new HashMap<String, Object>(); Page page = getPage();
map.put("context", properties); page.removeComponents();
map.put("locale", locale); 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); //show change role window and set new context for env and session
newSession.setAttribute(SAVED_CONTEXT, map); onChangeRole(locale, properties);
properties.setProperty(SessionContextListener.SERVLET_SESSION_ID, newSession.getId());
Executions.getCurrent().sendRedirect("index.zul");
} }
@Override @Override

View File

@ -135,6 +135,11 @@ public class WLogin extends AbstractUIPart
return layout; return layout;
} }
/**
* Show change role window
* @param locale
* @param properties env context
*/
public void changeRole(Locale locale, Properties properties) { public void changeRole(Locale locale, Properties properties) {
loginWindow.changeRole(locale, 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) { public void changeRole(Properties ctx) {
ctxBeforeChangeRole = ctx; ctxBeforeChangeRole = new Properties();
ctxBeforeChangeRole.putAll(ctx);
int AD_Client_ID = Env.getAD_Client_ID(ctx); int AD_Client_ID = Env.getAD_Client_ID(ctx);
lstClient.setValue(AD_Client_ID); lstClient.setValue(AD_Client_ID);
updateRoleList(); updateRoleList();

View File

@ -224,12 +224,12 @@ public class UserPanel implements EventListener<Event>, Composer<Component>
{ {
if (result) if (result)
{ {
Events.echoEvent(ON_DEFER_CHANGE_ROLE, component, null); Events.postEvent(ON_DEFER_CHANGE_ROLE, component, null);
} }
} }
}); });
} else { } else {
Events.echoEvent(ON_DEFER_CHANGE_ROLE, component, null); Events.postEvent(ON_DEFER_CHANGE_ROLE, component, null);
} }
} }
else if (preference == event.getTarget()) 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.LoginPanel;
import org.adempiere.webui.panel.ResetPasswordPanel; import org.adempiere.webui.panel.ResetPasswordPanel;
import org.adempiere.webui.panel.RolePanel; import org.adempiere.webui.panel.RolePanel;
import org.adempiere.webui.session.SessionContextListener;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.compiere.model.MSysConfig; import org.compiere.model.MSysConfig;
import org.compiere.model.MUser; 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) public void changeRole(Locale locale, Properties ctx)
{ {
Env.setCtx(ctx); Env.setCtx(ctx);
getDesktop().getSession().setAttribute(SessionContextListener.SESSION_CTX, ctx);
//reload theme preference //reload theme preference
PageDefinition pageDefintion = Executions.getCurrent().getPageDefinition(ThemeManager.getThemeResource("preference.zul")); PageDefinition pageDefintion = Executions.getCurrent().getPageDefinition(ThemeManager.getThemeResource("preference.zul"));

View File

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