IDEMPIERE-4639 simplify calls using saveCrossTenantSafeEx when possible (#2073)
* IDEMPIERE-4639 simplify calls using saveCrossTenantSafeEx when possible * - integrate patch from Heng Sin
This commit is contained in:
parent
e83bb49935
commit
ef9ecb3490
|
@ -229,12 +229,7 @@ public class MRecentItem extends X_AD_RecentItem implements ImmutablePOSupport
|
|||
ri.setAD_Role_ID(AD_Role_ID);
|
||||
ri.setAD_Window_ID(AD_Window_ID);
|
||||
ri.setAD_Tab_ID(AD_Tab_ID);
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
ri.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
ri.saveCrossTenantSafeEx();
|
||||
} else {
|
||||
if ( ric.getAD_Role_ID() != AD_Role_ID
|
||||
|| ric.getAD_Window_ID() != AD_Window_ID
|
||||
|
@ -243,12 +238,7 @@ public class MRecentItem extends X_AD_RecentItem implements ImmutablePOSupport
|
|||
ri.setAD_Role_ID(AD_Role_ID);
|
||||
ri.setAD_Window_ID(AD_Window_ID);
|
||||
ri.setAD_Tab_ID(AD_Tab_ID);
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
ri.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
ri.saveCrossTenantSafeEx();
|
||||
} else {
|
||||
DB.executeUpdateEx("UPDATE AD_RecentItem SET Updated=getDate() WHERE AD_RecentItem_ID=?", new Object[] {ric.getAD_RecentItem_ID()}, null);
|
||||
}
|
||||
|
|
|
@ -117,12 +117,7 @@ public class MShippingTransaction extends X_M_ShippingTransaction
|
|||
msg.append(getErrorMessage());
|
||||
msg.append("\nAction: " + getAction());
|
||||
history.setTextMsg(msg.toString());
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
history.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
history.saveCrossTenantSafeEx();
|
||||
|
||||
setProcessed(processed);
|
||||
return processed;
|
||||
|
|
|
@ -76,12 +76,7 @@ public class MSystem extends X_AD_System
|
|||
//
|
||||
if (!Ini.isClient() && system.setInfo())
|
||||
{
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
system.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
system.saveCrossTenantSafeEx();
|
||||
}
|
||||
s_system.put(0, new MSystem(Env.getCtx(), system));
|
||||
return system;
|
||||
|
|
|
@ -2592,10 +2592,13 @@ public abstract class PO
|
|||
* @see #saveEx(String)
|
||||
*/
|
||||
public void saveCrossTenantSafeEx() {
|
||||
boolean crossTenantSet = isSafeCrossTenant.get();
|
||||
try {
|
||||
if (!crossTenantSet)
|
||||
PO.setCrossTenantSafe();
|
||||
saveEx();
|
||||
} finally {
|
||||
if (!crossTenantSet)
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
}
|
||||
|
@ -2751,10 +2754,13 @@ public abstract class PO
|
|||
* @see #saveEx(String)
|
||||
*/
|
||||
public void saveCrossTenantSafeEx(String trxName) {
|
||||
boolean crossTenantSet = isSafeCrossTenant.get();
|
||||
try {
|
||||
if (!crossTenantSet)
|
||||
PO.setCrossTenantSafe();
|
||||
saveEx(trxName);
|
||||
} finally {
|
||||
if (!crossTenantSet)
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ import javax.print.attribute.DocAttributeSet;
|
|||
import org.adempiere.base.Core;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.PrintInfo;
|
||||
import org.compiere.print.ArchiveEngine;
|
||||
import org.compiere.print.CPaper;
|
||||
|
@ -1671,13 +1670,8 @@ public class LayoutEngine implements Pageable, Printable, Doc
|
|||
if (item.is_Immutable())
|
||||
item = new MPrintFormatItem(item);
|
||||
item.setIsSuppressNull(true); // display size will be set to 0 in TableElement
|
||||
try {
|
||||
//this can be tenant or system print format
|
||||
PO.setCrossTenantSafe();
|
||||
item.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
item.saveCrossTenantSafeEx();
|
||||
CacheMgt.get().reset(MPrintFormat.Table_Name, format.get_ID());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import java.util.logging.Level;
|
|||
|
||||
import org.compiere.model.MMFARegisteredDevice;
|
||||
import org.compiere.model.MProcessPara;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
|
@ -89,12 +88,7 @@ public class MFARevokeDevice extends SvrProcess {
|
|||
.list();
|
||||
for (MMFARegisteredDevice rd : rds) {
|
||||
rd.setIsActive(false);
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
rd.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
rd.saveCrossTenantSafeEx();
|
||||
}
|
||||
|
||||
return "@OK@";
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.logging.Level;
|
|||
|
||||
import org.compiere.model.MMFARegistration;
|
||||
import org.compiere.model.MProcessPara;
|
||||
import org.compiere.model.PO;
|
||||
|
||||
/**
|
||||
* IDEMPIERE-4782
|
||||
|
@ -69,12 +68,7 @@ public class MFAUnregister extends SvrProcess {
|
|||
MMFARegistration reg = new MMFARegistration(getCtx(), p_MFA_Registration_ID, get_TrxName());
|
||||
reg.setIsActive(false);
|
||||
reg.setMFAUnregisteredAt(new Timestamp(System.currentTimeMillis()));
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
reg.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
reg.saveCrossTenantSafeEx();
|
||||
|
||||
return "@OK@";
|
||||
}
|
||||
|
|
|
@ -217,12 +217,7 @@ public class MWFActivity extends X_AD_WF_Activity implements Runnable
|
|||
setEndWaitTime(new Timestamp(limitMS + System.currentTimeMillis()));
|
||||
// Responsible
|
||||
setResponsible(process);
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
saveCrossTenantSafeEx();
|
||||
//
|
||||
m_audit = new MWFEventAudit(this);
|
||||
m_audit.setAD_Org_ID(getAD_Org_ID());//Add by Hideaki Hagiwara
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.compiere.model.MMFAMethod;
|
|||
import org.compiere.model.MMFARegistration;
|
||||
import org.compiere.model.MMailText;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.EMail;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
@ -274,12 +273,7 @@ public class EMailMechanism implements IMFAMechanism {
|
|||
* @param reg
|
||||
*/
|
||||
private void saveRegistration(MMFARegistration reg) {
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
reg.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
reg.saveCrossTenantSafeEx();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.compiere.model.MMFAMethod;
|
|||
import org.compiere.model.MMFARegistration;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
|
@ -249,12 +248,7 @@ public class TOTPMechanism implements IMFAMechanism {
|
|||
* @param reg
|
||||
*/
|
||||
private void saveRegistration(MMFARegistration reg) {
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
reg.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
reg.saveCrossTenantSafeEx();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.adempiere.webui.window.Dialog;
|
|||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.MTreeFavoriteNode;
|
||||
import org.compiere.model.MTreeNode;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
@ -407,13 +406,8 @@ public class ADTreeFavoriteOnDropListener implements EventListener<Event>
|
|||
{
|
||||
favNode.setParent_ID(parentTNode.getNode_ID());
|
||||
favNode.setSeqNo(seqNo);
|
||||
try {
|
||||
//For service users, needs to persist data in system tenant
|
||||
PO.setCrossTenantSafe();
|
||||
favNode.save();
|
||||
}finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
favNode.saveCrossTenantSafeEx();
|
||||
}
|
||||
} // updateTFNParentAndSeqNo
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ import org.compiere.model.MMFARegisteredDevice;
|
|||
import org.compiere.model.MMFARegistration;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.model.MUser;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.SystemProperties;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -393,12 +392,7 @@ public class ValidateMFAPanel extends Window implements EventListener<Event> {
|
|||
long daysExpire = MSysConfig.getIntValue(MSysConfig.MFA_REGISTERED_DEVICE_EXPIRATION_DAYS, 30, Env.getAD_Client_ID(m_ctx));
|
||||
rd.setExpiration(new Timestamp(System.currentTimeMillis() + (daysExpire * 86400000L)));
|
||||
// TODO: rd.setHelp -> add information about the browser, device and IP address (fingerprint)
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
rd.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
rd.saveCrossTenantSafeEx();
|
||||
}
|
||||
Env.setContext(m_ctx, Env.MFA_Registration_ID, registrationId);
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.adempiere.webui.util.ZKUpdateUtil;
|
|||
import org.compiere.model.MField;
|
||||
import org.compiere.model.MFieldSuggestion;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
|
@ -174,12 +173,7 @@ public class WFieldSuggestion extends Window implements EventListener<Event> {
|
|||
suggestion.setIsApproved(false);
|
||||
suggestion.setIsUpdateBaseLanguage(false);
|
||||
suggestion.setProcessed(false);
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
suggestion.saveEx();
|
||||
}finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
suggestion.saveCrossTenantSafeEx();
|
||||
Dialog.info(0, Msg.getMsg(Env.getCtx(),"Your suggestions have been submitted for review"));
|
||||
this.detach();
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ import org.compiere.model.MPayment;
|
|||
import org.compiere.model.MPaymentProcessor;
|
||||
import org.compiere.model.MProduct;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.SystemIDs;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
|
@ -312,12 +311,7 @@ public class PaymentFormTest extends AbstractTestCase {
|
|||
try {
|
||||
payProcessorClass = mpp.getPayProcessorClass();
|
||||
mpp.setPayProcessorClass("org.compiere.model.PP_Dummy");
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
mpp.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
mpp.saveCrossTenantSafeEx();
|
||||
boolean ok = form.saveChangesInTrx(getTrxName());
|
||||
assertTrue(ok, "Save failed: " + form.getProcessMessage());
|
||||
assertNotNull(form.getPayment(), "Payment not created");
|
||||
|
@ -325,12 +319,7 @@ public class PaymentFormTest extends AbstractTestCase {
|
|||
assertEquals(order.getGrandTotal().setScale(2, RoundingMode.HALF_EVEN), form.getPayment().getPayAmt().setScale(2, RoundingMode.HALF_EVEN), "Wrong Payment Document Amount");
|
||||
} finally {
|
||||
mpp.setPayProcessorClass(payProcessorClass);
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
mpp.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
mpp.saveCrossTenantSafeEx();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.compiere.model.MBankStatement;
|
|||
import org.compiere.model.MBankStatementLine;
|
||||
import org.compiere.model.MPayment;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
|
@ -99,12 +98,7 @@ public class BankStatementTest extends AbstractTestCase {
|
|||
MSysConfig sysConfig = query.setOrderBy("AD_Client_ID Desc").setParameters(MSysConfig.ALLOW_REVERSAL_OF_RECONCILED_PAYMENT, getAD_Client_ID()).first();
|
||||
if (!sysConfig.getValue().equals("Y")) {
|
||||
sysConfig.setValue("Y");
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
sysConfig.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
sysConfig.saveCrossTenantSafeEx();
|
||||
CacheMgt.get().reset();
|
||||
} else {
|
||||
sysConfig = null;
|
||||
|
@ -165,12 +159,7 @@ public class BankStatementTest extends AbstractTestCase {
|
|||
} finally {
|
||||
if (sysConfig != null) {
|
||||
sysConfig.setValue("N");
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
sysConfig.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
sysConfig.saveCrossTenantSafeEx();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,12 +173,7 @@ public class BankStatementTest extends AbstractTestCase {
|
|||
MSysConfig sysConfig = query.setOrderBy("AD_Client_ID Desc").setParameters(MSysConfig.ALLOW_REVERSAL_OF_RECONCILED_PAYMENT, getAD_Client_ID()).first();
|
||||
if (!sysConfig.getValue().equals("N")) {
|
||||
sysConfig.setValue("N");
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
sysConfig.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
sysConfig.saveCrossTenantSafeEx();
|
||||
CacheMgt.get().reset();
|
||||
} else {
|
||||
sysConfig = null;
|
||||
|
@ -249,12 +233,7 @@ public class BankStatementTest extends AbstractTestCase {
|
|||
} finally {
|
||||
if (sysConfig != null) {
|
||||
sysConfig.setValue("Y");
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
sysConfig.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
sysConfig.saveCrossTenantSafeEx();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.compiere.model.MClientInfo;
|
|||
import org.compiere.model.MOrgInfo;
|
||||
import org.compiere.model.MSchedule;
|
||||
import org.compiere.model.MScheduler;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CacheMgt;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Util;
|
||||
|
@ -69,12 +68,7 @@ public class MSchedulerTest extends AbstractTestCase {
|
|||
schedule.setScheduleType(MSchedule.SCHEDULETYPE_CronSchedulingPattern);
|
||||
schedule.setIsSystemSchedule(false);
|
||||
schedule.setCronPattern("0 17 * * *");
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
schedule.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
schedule.saveCrossTenantSafeEx();
|
||||
|
||||
//get jvm timezone
|
||||
//this test assume jvm and db server is using the same default time zone
|
||||
|
|
|
@ -31,7 +31,6 @@ import java.math.RoundingMode;
|
|||
|
||||
import org.compiere.model.MUOM;
|
||||
import org.compiere.model.MUOMConversion;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CacheMgt;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -61,12 +60,7 @@ public class MUOMConversionTest extends AbstractTestCase {
|
|||
conv1.setC_UOM_To_ID(DictionaryIDs.C_UOM.HOUR.id);
|
||||
conv1.setMultiplyRate(new BigDecimal("1.15"));
|
||||
conv1.setDivideRate(BigDecimal.ZERO);
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
conv1.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
conv1.saveCrossTenantSafeEx();
|
||||
|
||||
MUOMConversion conv2 = null;
|
||||
MUOMConversion conv3 = null;
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.compiere.model.MColumn;
|
|||
import org.compiere.model.MStyle;
|
||||
import org.compiere.model.MStyleLine;
|
||||
import org.compiere.model.MTest;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CacheMgt;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Trx;
|
||||
|
@ -62,12 +61,7 @@ public class ModelForeignKeyTest extends AbstractTestCase {
|
|||
// set model cascade on Test.Record_ID
|
||||
MColumn col_test_record_id = new MColumn(ctx, MColumn.getColumn_ID(MTest.Table_Name, MTest.COLUMNNAME_Record_ID), trxName);
|
||||
col_test_record_id.setFKConstraintType(MColumn.FKCONSTRAINTTYPE_ModelCascade);
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
col_test_record_id.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
col_test_record_id.saveCrossTenantSafeEx();
|
||||
|
||||
MTest test1 = new MTest(ctx, 0, trxName);
|
||||
test1.setName("Test 1");
|
||||
|
@ -93,12 +87,7 @@ public class ModelForeignKeyTest extends AbstractTestCase {
|
|||
// set model cascade on Test.Record_ID
|
||||
MColumn col_test_record_id = new MColumn(ctx, MColumn.getColumn_ID(MTest.Table_Name, MTest.COLUMNNAME_Record_ID), trxName);
|
||||
col_test_record_id.setFKConstraintType(MColumn.FKCONSTRAINTTYPE_ModelSetNull);
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
col_test_record_id.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
col_test_record_id.saveCrossTenantSafeEx();
|
||||
CacheMgt.get().reset();
|
||||
|
||||
MTest test1 = new MTest(ctx, 0, trxName);
|
||||
|
@ -125,12 +114,7 @@ public class ModelForeignKeyTest extends AbstractTestCase {
|
|||
// set model cascade on Test.Record_ID
|
||||
MColumn col_test_record_id = new MColumn(ctx, MColumn.getColumn_ID(MTest.Table_Name, MTest.COLUMNNAME_Record_ID), trxName);
|
||||
col_test_record_id.setFKConstraintType(MColumn.FKCONSTRAINTTYPE_ModelNoAction_ForbidDeletion);
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
col_test_record_id.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
col_test_record_id.saveCrossTenantSafeEx();
|
||||
CacheMgt.get().reset();
|
||||
|
||||
MTest test1 = new MTest(ctx, 0, trxName);
|
||||
|
@ -184,12 +168,7 @@ public class ModelForeignKeyTest extends AbstractTestCase {
|
|||
// set model cascade on Test.Record_ID
|
||||
MColumn col_styleline_style = new MColumn(ctx, MColumn.getColumn_ID(MStyleLine.Table_Name, MStyleLine.COLUMNNAME_AD_Style_ID), trxName);
|
||||
col_styleline_style.setFKConstraintType(MColumn.FKCONSTRAINTTYPE_ModelCascade);
|
||||
try {
|
||||
PO.setCrossTenantSafe();
|
||||
col_styleline_style.saveEx();
|
||||
} finally {
|
||||
PO.clearCrossTenantSafe();
|
||||
}
|
||||
col_styleline_style.saveCrossTenantSafeEx();
|
||||
CacheMgt.get().reset();
|
||||
|
||||
MStyle style = new MStyle(ctx, 0, trxName);
|
||||
|
|
Loading…
Reference in New Issue