IDEMPIERE-2565 - found transaction not rolled back when initial client setup was failing with an exception

This commit is contained in:
Carlos Ruiz 2015-04-08 10:15:57 -05:00
parent da2fd9fffb
commit 267fe358df
2 changed files with 30 additions and 26 deletions

View File

@ -257,34 +257,38 @@ public class InitialClientSetup extends SvrProcess
// Process
MSetup ms = new MSetup(Env.getCtx(), WINDOW_THIS_PROCESS);
try {
if (! ms.createClient(p_ClientName, p_OrgValue, p_OrgName, p_AdminUserName, p_NormalUserName
, p_Phone, p_Phone2, p_Fax, p_EMail, p_TaxID, p_AdminUserEmail, p_NormalUserEmail)) {
ms.rollback();
throw new AdempiereException("Create client failed");
}
addLog(ms.getInfo());
if (! ms.createClient(p_ClientName, p_OrgValue, p_OrgName, p_AdminUserName, p_NormalUserName
, p_Phone, p_Phone2, p_Fax, p_EMail, p_TaxID, p_AdminUserEmail, p_NormalUserEmail)) {
// Generate Accounting
MCurrency currency = MCurrency.get(getCtx(), p_C_Currency_ID);
KeyNamePair currency_kp = new KeyNamePair(p_C_Currency_ID, currency.getDescription());
if (!ms.createAccounting(currency_kp,
p_IsUseProductDimension, p_IsUseBPDimension, p_IsUseProjectDimension, p_IsUseCampaignDimension, p_IsUseSalesRegionDimension, p_IsUseActivityDimension,
coaFile, p_UseDefaultCoA, p_InactivateDefaults)) {
ms.rollback();
throw new AdempiereException("@AccountSetupError@");
}
// Generate Entities
if (!ms.createEntities(p_C_Country_ID, p_CityName, p_C_Region_ID, p_C_Currency_ID, p_Postal, p_Address1)) {
ms.rollback();
throw new AdempiereException("@AccountSetupError@");
}
addLog(ms.getInfo());
// Create Print Documents
PrintUtil.setupPrintForm(ms.getAD_Client_ID());
} catch (Exception e) {
ms.rollback();
throw new AdempiereException("Create client failed");
throw e;
}
addLog(ms.getInfo());
// Generate Accounting
MCurrency currency = MCurrency.get(getCtx(), p_C_Currency_ID);
KeyNamePair currency_kp = new KeyNamePair(p_C_Currency_ID, currency.getDescription());
if (!ms.createAccounting(currency_kp,
p_IsUseProductDimension, p_IsUseBPDimension, p_IsUseProjectDimension, p_IsUseCampaignDimension, p_IsUseSalesRegionDimension, p_IsUseActivityDimension,
coaFile, p_UseDefaultCoA, p_InactivateDefaults)) {
ms.rollback();
throw new AdempiereException("@AccountSetupError@");
}
// Generate Entities
if (!ms.createEntities(p_C_Country_ID, p_CityName, p_C_Region_ID, p_C_Currency_ID, p_Postal, p_Address1)) {
ms.rollback();
throw new AdempiereException("@AccountSetupError@");
}
addLog(ms.getInfo());
// Create Print Documents
PrintUtil.setupPrintForm(ms.getAD_Client_ID());
return "@OK@";
}

View File

@ -465,7 +465,7 @@ public class MLocation extends X_C_Location implements Comparator<Object>
if (c == null)
return "CountryNotFound";
boolean local = getC_Country_ID() == MCountry.getDefault(getCtx()).getC_Country_ID();
boolean local = MCountry.getDefault(getCtx()) != null && getC_Country_ID() == MCountry.getDefault(getCtx()).getC_Country_ID();
String inStr = local ? c.getDisplaySequenceLocal() : c.getDisplaySequence();
StringBuilder outStr = new StringBuilder();