IDEMPIERE-2756 Background threads losing context when user log out - fix validation / integrate fix from hengsin: Improve handling of context lost ( due to user close browser ) exception for document workflow.
This commit is contained in:
parent
6522a64289
commit
8e193dad3d
|
@ -916,7 +916,25 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
processMsg = e.getMessage();
|
processMsg = e.getMessage();
|
||||||
setTextMsg(processMsg);
|
setTextMsg(processMsg);
|
||||||
// addTextMsg(e); // do not add the exception text
|
// addTextMsg(e); // do not add the exception text
|
||||||
|
boolean contextLost = false;
|
||||||
|
if (e instanceof AdempiereException && "Context lost".equals(e.getMessage()))
|
||||||
|
{
|
||||||
|
contextLost = true;
|
||||||
|
m_docStatus = DocAction.STATUS_Invalid;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (contextLost)
|
||||||
|
{
|
||||||
|
Env.getCtx().setProperty("#AD_Client_ID", (m_po != null ? Integer.toString(m_po.getAD_Client_ID()) : "0") );
|
||||||
|
m_state = new StateEngine(WFSTATE_Running);
|
||||||
|
setProcessed(true);
|
||||||
|
setWFState (StateEngine.STATE_Aborted);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
setWFState (StateEngine.STATE_Terminated); // unlocks
|
setWFState (StateEngine.STATE_Terminated); // unlocks
|
||||||
|
}
|
||||||
|
|
||||||
// Set Document Status
|
// Set Document Status
|
||||||
if (m_po != null && m_po instanceof DocAction && m_docStatus != null)
|
if (m_po != null && m_po instanceof DocAction && m_docStatus != null)
|
||||||
{
|
{
|
||||||
|
@ -930,6 +948,10 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
||||||
m_process.setProcessMsg(this.getTextMsg());
|
m_process.setProcessMsg(this.getTextMsg());
|
||||||
m_process.saveEx();
|
m_process.saveEx();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
if (contextLost)
|
||||||
|
Env.getCtx().remove("#AD_Client_ID");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -461,6 +461,8 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI
|
||||||
m_locked = false;
|
m_locked = false;
|
||||||
|
|
||||||
if (Executions.getCurrent() == null)
|
if (Executions.getCurrent() == null)
|
||||||
|
{
|
||||||
|
if (getDesktop() != null)
|
||||||
{
|
{
|
||||||
Executions.schedule(getDesktop(), new EventListener<Event>()
|
Executions.schedule(getDesktop(), new EventListener<Event>()
|
||||||
{
|
{
|
||||||
|
@ -469,6 +471,7 @@ public abstract class AbstractProcessDialog extends Window implements IProcessUI
|
||||||
doUnlockUI();
|
doUnlockUI();
|
||||||
}
|
}
|
||||||
}, new Event("onUnLockUI"));
|
}, new Event("onUnLockUI"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
doUnlockUI();
|
doUnlockUI();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue