IDEMPIERE-5567 Fix NPE when AD_RecentItem.Record_UU is null (#2172)
- this can happen for example when a recent item record doesn't have or doesn't manage UUID
This commit is contained in:
parent
ab576027f7
commit
18146a57a6
|
@ -172,17 +172,18 @@ public class MRecentItem extends X_AD_RecentItem implements ImmutablePOSupport
|
||||||
* Get Recent Item from Cache using table+recordID (immutable)
|
* Get Recent Item from Cache using table+recordID (immutable)
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param AD_Table_ID tableID
|
* @param AD_Table_ID tableID
|
||||||
|
* @param Record_ID record ID
|
||||||
* @param Record_UU record UUID
|
* @param Record_UU record UUID
|
||||||
* @return recent item
|
* @return recent item
|
||||||
*/
|
*/
|
||||||
public static synchronized MRecentItem get (Properties ctx, int AD_Table_ID, String Record_UU, int AD_User_ID)
|
public static synchronized MRecentItem get (Properties ctx, int AD_Table_ID, int Record_ID, String Record_UU, int AD_User_ID)
|
||||||
{
|
{
|
||||||
Iterator<MRecentItem> it = s_cache.values().iterator();
|
Iterator<MRecentItem> it = s_cache.values().iterator();
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
MRecentItem retValue = it.next();
|
MRecentItem retValue = it.next();
|
||||||
if (retValue.getAD_Table_ID() == AD_Table_ID
|
if (retValue.getAD_Table_ID() == AD_Table_ID
|
||||||
&& retValue.getRecord_UU().equals(Record_UU)
|
&& ((retValue.getRecord_UU() != null && retValue.getRecord_UU().equals(Record_UU)) || retValue.getRecord_ID() == Record_ID)
|
||||||
&& retValue.getAD_User_ID() == AD_User_ID
|
&& retValue.getAD_User_ID() == AD_User_ID
|
||||||
&& retValue.getAD_Client_ID() == Env.getAD_Client_ID(ctx)
|
&& retValue.getAD_Client_ID() == Env.getAD_Client_ID(ctx)
|
||||||
&& Env.getAD_Language(ctx).equals(Env.getAD_Language(retValue.getCtx()))
|
&& Env.getAD_Language(ctx).equals(Env.getAD_Language(retValue.getCtx()))
|
||||||
|
@ -192,8 +193,14 @@ public class MRecentItem extends X_AD_RecentItem implements ImmutablePOSupport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
MRecentItem retValue = new Query(ctx, Table_Name, "AD_Table_ID=? AND Record_UU=? AND AD_User_ID=? AND AD_Client_ID=?", null)
|
MRecentItem retValue;
|
||||||
.setParameters(AD_Table_ID, Record_UU, AD_User_ID, Env.getAD_Client_ID(ctx))
|
if (Record_UU != null)
|
||||||
|
retValue = new Query(ctx, Table_Name, "AD_Table_ID=? AND Record_UU=? AND AD_User_ID=? AND AD_Client_ID=?", null)
|
||||||
|
.setParameters(AD_Table_ID, Record_UU, AD_User_ID, Env.getAD_Client_ID(ctx))
|
||||||
|
.first();
|
||||||
|
else
|
||||||
|
retValue = new Query(ctx, Table_Name, "AD_Table_ID=? AND Record_ID=? AND AD_User_ID=? AND AD_Client_ID=?", null)
|
||||||
|
.setParameters(AD_Table_ID, Record_ID, AD_User_ID, Env.getAD_Client_ID(ctx))
|
||||||
.first();
|
.first();
|
||||||
if (retValue != null)
|
if (retValue != null)
|
||||||
{
|
{
|
||||||
|
@ -219,7 +226,7 @@ public class MRecentItem extends X_AD_RecentItem implements ImmutablePOSupport
|
||||||
int maxri = MSysConfig.getIntValue(MSysConfig.RecentItems_MaxSaved, 50, Env.getAD_Client_ID(ctx));
|
int maxri = MSysConfig.getIntValue(MSysConfig.RecentItems_MaxSaved, 50, Env.getAD_Client_ID(ctx));
|
||||||
if (maxri <= 0)
|
if (maxri <= 0)
|
||||||
return;
|
return;
|
||||||
MRecentItem ric = get(ctx, AD_Table_ID, Record_UU, AD_User_ID);
|
MRecentItem ric = get(ctx, AD_Table_ID, Record_ID, Record_UU, AD_User_ID);
|
||||||
if (ric == null) {
|
if (ric == null) {
|
||||||
MRecentItem ri = new MRecentItem(ctx, 0, null);
|
MRecentItem ri = new MRecentItem(ctx, 0, null);
|
||||||
ri.setAD_Table_ID(AD_Table_ID);
|
ri.setAD_Table_ID(AD_Table_ID);
|
||||||
|
@ -281,8 +288,8 @@ public class MRecentItem extends X_AD_RecentItem implements ImmutablePOSupport
|
||||||
* @param Record_UU
|
* @param Record_UU
|
||||||
* @param AD_User_ID
|
* @param AD_User_ID
|
||||||
*/
|
*/
|
||||||
public static void touchUpdatedRecord(Properties ctx, int AD_Table_ID, String Record_UU, int AD_User_ID) {
|
public static void touchUpdatedRecord(Properties ctx, int AD_Table_ID, int Record_ID, String Record_UU, int AD_User_ID) {
|
||||||
MRecentItem ri = get(ctx, AD_Table_ID, Record_UU, AD_User_ID);
|
MRecentItem ri = get(ctx, AD_Table_ID, Record_ID, Record_UU, AD_User_ID);
|
||||||
if (ri != null) {
|
if (ri != null) {
|
||||||
DB.executeUpdateEx("UPDATE AD_RecentItem SET Updated=getDate() WHERE AD_RecentItem_ID=?", new Object[] {ri.getAD_RecentItem_ID()}, null);
|
DB.executeUpdateEx("UPDATE AD_RecentItem SET Updated=getDate() WHERE AD_RecentItem_ID=?", new Object[] {ri.getAD_RecentItem_ID()}, null);
|
||||||
deleteExtraRecentItems(ctx, AD_User_ID);
|
deleteExtraRecentItems(ctx, AD_User_ID);
|
||||||
|
|
|
@ -2269,7 +2269,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
focusToActivePanel();
|
focusToActivePanel();
|
||||||
// IDEMPIERE-1328 - refresh recent item after running a process, i.e. completing a doc that changes documentno
|
// IDEMPIERE-1328 - refresh recent item after running a process, i.e. completing a doc that changes documentno
|
||||||
MRecentItem.touchUpdatedRecord(ctx, adTabbox.getSelectedGridTab().getAD_Table_ID(),
|
MRecentItem.touchUpdatedRecord(ctx, adTabbox.getSelectedGridTab().getAD_Table_ID(),
|
||||||
adTabbox.getSelectedGridTab().getRecord_UU(), Env.getAD_User_ID(ctx));
|
adTabbox.getSelectedGridTab().getRecord_ID(), adTabbox.getSelectedGridTab().getRecord_UU(), Env.getAD_User_ID(ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2877,12 +2877,12 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
||||||
} else {
|
} else {
|
||||||
if (adTabbox.getSelectedIndex() == 0) {
|
if (adTabbox.getSelectedIndex() == 0) {
|
||||||
MRecentItem.touchUpdatedRecord(ctx, adTabbox.getSelectedGridTab().getAD_Table_ID(),
|
MRecentItem.touchUpdatedRecord(ctx, adTabbox.getSelectedGridTab().getAD_Table_ID(),
|
||||||
adTabbox.getSelectedGridTab().getRecord_UU(), Env.getAD_User_ID(ctx));
|
adTabbox.getSelectedGridTab().getRecord_ID(), adTabbox.getSelectedGridTab().getRecord_UU(), Env.getAD_User_ID(ctx));
|
||||||
} else {
|
} else {
|
||||||
GridTab mainTab = getMainTabAbove();
|
GridTab mainTab = getMainTabAbove();
|
||||||
if (mainTab != null) {
|
if (mainTab != null) {
|
||||||
MRecentItem.touchUpdatedRecord(ctx, mainTab.getAD_Table_ID(),
|
MRecentItem.touchUpdatedRecord(ctx, mainTab.getAD_Table_ID(),
|
||||||
mainTab.getRecord_UU(), Env.getAD_User_ID(ctx));
|
mainTab.getRecord_ID(), mainTab.getRecord_UU(), Env.getAD_User_ID(ctx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue