IDEMPIERE-37 Make iDempiere safer using saveEx instead of save / found and fix more cases using save - or ignoring the error of save

This commit is contained in:
Carlos Ruiz 2017-03-31 18:29:53 +02:00
parent df7de8087a
commit 55e074dc5e
34 changed files with 77 additions and 82 deletions

View File

@ -232,7 +232,7 @@ public class DunningPrint extends SvrProcess
if (printed)
{
entry.setProcessed (true);
entry.save ();
entry.saveEx();
}
} // for all dunning letters

View File

@ -609,7 +609,7 @@ public class ImportInvoice extends SvrProcess
imp.setAD_User_ID (user.getAD_User_ID ());
}
}
imp.save ();
imp.saveEx();
} // for all new BPartners
//
}

View File

@ -610,7 +610,7 @@ public class ImportOrder extends SvrProcess
imp.setAD_User_ID (user.getAD_User_ID ());
}
}
imp.save ();
imp.saveEx();
} // for all new BPartners
//
}

View File

@ -161,7 +161,7 @@ public class ProjectGenPO extends SvrProcess
}
order.setClientOrg (projectLine.getAD_Client_ID (), AD_Org_ID);
order.setBPartner (bp);
order.save ();
order.saveEx();
// optionally save for consolidation
if (m_ConsolidateDocument)
m_pos.add(order);

View File

@ -258,7 +258,7 @@ public class TableCreateColumns extends SvrProcess
element.setName(uuidColumn);
element.setPrintName(uuidColumn);
}
element.save ();
element.saveEx();
}
column.setColumnName (element.getColumnName ());
column.setName (element.getName ());

View File

@ -67,7 +67,7 @@ public class RequestEventHandler extends AbstractEventHandler implements Managed
MNote note = new MNote(Env.getCtx(), AD_Message_ID, eventData.getTo().getAD_User_ID(),
X_R_Request.Table_ID, eventData.getRequestID(),
eventData.getSubject(), eventData.getMessage(), null);
note.save();
note.saveEx();
}
}
else if (topic.equals(IEventTopics.PO_BEFORE_NEW) || topic.equals(IEventTopics.PO_BEFORE_CHANGE)
@ -390,7 +390,7 @@ public class RequestEventHandler extends AbstractEventHandler implements Managed
MNote note = new MNote(r.getCtx(), AD_Message_ID, AD_User_ID,
X_R_Request.Table_ID, r.getR_Request_ID(),
subject, message.toString(), r.get_TrxName());
note.save();
note.saveEx();
}
}
}

View File

@ -108,7 +108,7 @@ public class ProductPriceValidator implements ModelValidator {
{
pp1.setPrices(priceList, priceStd, priceLimit);
pp1.setIsActive(isActive);
pp1.save(po.get_TrxName());
pp1.saveEx(po.get_TrxName());
}
}
else if (type == TYPE_AFTER_DELETE)

View File

@ -52,7 +52,7 @@ public class TemplateValidate extends SvrProcess
{
MTemplate thisTemplate = new MTemplate(getCtx (), getRecord_ID (), get_TrxName ());
thisTemplate.setIsValid (true);
thisTemplate.save ();
thisTemplate.saveEx();
return null;
}

View File

@ -184,7 +184,7 @@ public class WebProjectDeploy extends SvrProcess
thisHandler.cleanContainer(cc.get_ID());
// Reset Modified flag...
stage.setIsModified(false);
stage.save(stage.get_TrxName());
stage.saveEx(stage.get_TrxName());
}
if (child.isSummary())
copyStage (child, path + stage.getRelativeURL() + "/");

View File

@ -277,7 +277,7 @@ public class AttachmentFileSystem implements IAttachmentStore {
}
}
attach.m_items.remove(index);
attach.save(); // must save here as the operation cannot be rolled back on filesystem
attach.saveEx(); // must save here as the operation cannot be rolled back on filesystem
if (log.isLoggable(Level.CONFIG)) log.config("Index=" + index + " - NewSize=" + attach.m_items.size());
return true;
}

View File

@ -127,7 +127,7 @@ public class MCalendar extends X_C_Calendar
if (get_ID() == 0)
return null;
MYear year = new MYear (this);
if (year.save())
year.saveEx();
year.createStdPeriods(locale);
//
return year;

View File

@ -94,7 +94,7 @@ public class MCash extends X_C_Cash implements DocAction
// Create New Journal
retValue = new MCash (cb, dateAcct);
retValue.save(trxName);
retValue.saveEx(trxName);
return retValue;
} // get

View File

@ -93,7 +93,7 @@ public class MContainer extends X_CM_Container
if (cc == null) // new
cc = new MContainer (stage.getCtx (), 0, stage.get_TrxName ());
cc.setStage (project, stage, path);
cc.save ();
cc.saveEx();
if (!stage.isSummary ())
{
cc.updateElements (project, stage, stage.get_TrxName ());
@ -315,7 +315,7 @@ public class MContainer extends X_CM_Container
// PO.copyValues(new
// X_CM_CStage_Element(project.getCtx(),tableKeys[i],trxName),
// thisContainerElement);
thisContainerElement.save (trxName);
thisContainerElement.saveEx(trxName);
// Remove Container from cache
thisHandler.cleanContainerElement (thisContainerElement
.get_ID ());
@ -391,7 +391,7 @@ public class MContainer extends X_CM_Container
thisContainerTTable.setCM_Container_ID (stage.get_ID ());
PO.copyValues (new X_CM_CStageTTable (project.getCtx (),
tableKeys[i], trxName), thisContainerTTable);
thisContainerTTable.save (trxName);
thisContainerTTable.saveEx(trxName);
}
}
}

View File

@ -295,7 +295,7 @@ public class MDunningRunEntry extends X_C_DunningRunEntry
thisBPartner.setSOCreditStatus (X_C_BPartner.SOCREDITSTATUS_CreditStop);
if (level.isSetPaymentTerm ())
thisBPartner.setC_PaymentTerm_ID (level.getC_PaymentTerm_ID ());
thisBPartner.save ();
thisBPartner.saveEx();
}
}
return true;

View File

@ -132,7 +132,7 @@ public class MInOut extends X_M_InOut implements DocAction
}
// Create Line
if (retValue.get_ID() == 0) // not saved yet
retValue.save(trxName);
retValue.saveEx(trxName);
// Create a line until qty is reached
for (int ll = 0; ll < storages.length; ll++)
{
@ -148,11 +148,11 @@ public class MInOut extends X_M_InOut implements DocAction
.multiply(oLines[i].getQtyEntered())
.divide(oLines[i].getQtyOrdered(), 12, BigDecimal.ROUND_HALF_UP));
line.setC_Project_ID(oLines[i].getC_Project_ID());
line.save(trxName);
line.saveEx(trxName);
// Delivered everything ?
qty = qty.subtract(lineQty);
// storage[ll].changeQtyOnHand(lineQty, !order.isSOTrx()); // Credit Memo not considered
// storage[ll].save(get_TrxName());
// storage[ll].saveEx(get_TrxName());
if (qty.signum() == 0)
break;
}

View File

@ -1581,7 +1581,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
if (bom.getDescription() != null)
newLine.setDescription(bom.getDescription());
newLine.setPrice();
newLine.save(get_TrxName());
newLine.saveEx(get_TrxName());
}
// Convert into Comment Line
@ -2506,8 +2506,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
msgall.toString(),
get_TrxName());
alloc.setAD_Org_ID(getAD_Org_ID());
if (alloc.save())
{
alloc.saveEx();
// Amount
BigDecimal gt = getGrandTotal(true);
if (!isSOTrx())
@ -2527,7 +2526,6 @@ public class MInvoice extends X_C_Invoice implements DocAction
throw new AdempiereException("Failed when processing document - " + alloc.getProcessMsg());
// end added
alloc.saveEx();
}
return reversal;
}

View File

@ -522,7 +522,7 @@ public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProce
access.setR_InterestArea_ID (R_InterestArea_ID);
access.setIsError (error != null);
access.setSummary (info);
access.save ();
access.saveEx();
} // logAccess
@Override

View File

@ -72,7 +72,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
}
MMovementConfirm confirm = new MMovementConfirm (move);
confirm.save(move.get_TrxName());
confirm.saveEx(move.get_TrxName());
MMovementLine[] moveLines = move.getLines(false);
for (int i = 0; i < moveLines.length; i++)
{

View File

@ -1620,7 +1620,7 @@ public class MOrder extends X_C_Order implements DocAction
newLine.setDescription (bomline.getDescription ());
//
newLine.setPrice ();
newLine.save (get_TrxName());
newLine.saveEx(get_TrxName());
}
} */
@ -1633,7 +1633,7 @@ public class MOrder extends X_C_Order implements DocAction
if (bom.getDescription() != null)
newLine.setDescription(bom.getDescription());
newLine.setPrice();
newLine.save(get_TrxName());
newLine.saveEx(get_TrxName());
}
// Convert into Comment Line
@ -1651,7 +1651,7 @@ public class MOrder extends X_C_Order implements DocAction
if (line.getDescription () != null)
description += " " + line.getDescription ();
line.setDescription (description);
line.save (get_TrxName());
line.saveEx(get_TrxName());
} // for all lines with BOM
m_lines = null; // force requery

View File

@ -93,7 +93,7 @@ public class MPackage extends X_M_Package
} // lines
retValue.setBoxCount(1);
retValue.save();
retValue.saveEx();
return retValue;
} // create

View File

@ -248,7 +248,7 @@ public class MPaymentTerm extends X_C_PaymentTerm
for (int i = 0; i < m_schedule.length; i++)
{
ips = new MInvoicePaySchedule (invoice, m_schedule[i]);
ips.save(invoice.get_TrxName());
ips.saveEx(invoice.get_TrxName());
if (log.isLoggable(Level.FINE)) log.fine(ips.toString());
remainder = remainder.subtract(ips.getDueAmt());
} // for all schedules
@ -256,7 +256,7 @@ public class MPaymentTerm extends X_C_PaymentTerm
if (remainder.compareTo(Env.ZERO) != 0 && ips != null)
{
ips.setDueAmt(ips.getDueAmt().add(remainder));
ips.save(invoice.get_TrxName());
ips.saveEx(invoice.get_TrxName());
if (log.isLoggable(Level.FINE)) log.fine("Remainder=" + remainder + " - " + ips);
}
@ -357,7 +357,7 @@ public class MPaymentTerm extends X_C_PaymentTerm
for (int i = 0; i < m_schedule.length; i++)
{
ops = new MOrderPaySchedule (order, m_schedule[i]);
ops.save(order.get_TrxName());
ops.saveEx(order.get_TrxName());
if (log.isLoggable(Level.FINE)) log.fine(ops.toString());
remainder = remainder.subtract(ops.getDueAmt());
} // for all schedules
@ -365,7 +365,7 @@ public class MPaymentTerm extends X_C_PaymentTerm
if (remainder.compareTo(Env.ZERO) != 0 && ops != null)
{
ops.setDueAmt(ops.getDueAmt().add(remainder));
ops.save(order.get_TrxName());
ops.saveEx(order.get_TrxName());
if (log.isLoggable(Level.FINE)) log.fine("Remainder=" + remainder + " - " + ops);
}

View File

@ -741,7 +741,7 @@ public class MPeriod extends X_C_Period
if (baseTypes.contains(DocBaseType))
continue;
MPeriodControl pc = new MPeriodControl(this, DocBaseType);
if (pc.save())
pc.saveEx();
count++;
baseTypes.add (DocBaseType);
}

View File

@ -358,15 +358,13 @@ public class MProject extends X_C_Project
toPhase.setC_Project_ID (getC_Project_ID ());
toPhase.setC_Order_ID (0);
toPhase.setIsComplete (false);
if (toPhase.save ())
{
toPhase.saveEx();
count++;
taskCount += toPhase.copyTasksFrom (fromPhases[i]);
//BF 3067850 - monhate
lineCount += toPhase.copyLinesFrom(fromPhases[i]);
}
}
}
if (fromPhases.length != count)
log.warning("Count difference - Project=" + fromPhases.length + " <> Saved=" + count);

View File

@ -159,7 +159,7 @@ public class MProjectPhase extends X_C_ProjectPhase
PO.copyValues (fromLines[i], toLine, getAD_Client_ID (), getAD_Org_ID ());
toLine.setC_Project_ID(getC_Project_ID ());
toLine.setC_ProjectPhase_ID (getC_ProjectPhase_ID ());
if (toLine.save ())
toLine.saveEx();
count++;
}
if (fromLines.length != count)
@ -209,13 +209,12 @@ public class MProjectPhase extends X_C_ProjectPhase
MProjectTask toTask = new MProjectTask (getCtx (), 0, get_TrxName());
PO.copyValues (fromTasks[i], toTask, getAD_Client_ID (), getAD_Org_ID ());
toTask.setC_ProjectPhase_ID (getC_ProjectPhase_ID ());
if (toTask.save ()){
toTask.saveEx();
count++;
//BF 3067850 - monhate
countLine += toTask.copyLinesFrom(fromTasks[i]);
}
}
}
if (fromTasks.length != count)
log.warning("Count difference - ProjectPhase=" + fromTasks.length + " <> Saved=" + count);

View File

@ -134,7 +134,7 @@ public class MProjectTask extends X_C_ProjectTask
toLine.setC_Project_ID(getC_Project_ID(false));
toLine.setC_ProjectPhase_ID (getC_ProjectPhase_ID ());
toLine.setC_ProjectTask_ID(getC_ProjectTask_ID ());
if (toLine.save ())
toLine.saveEx();
count++;
}
if (fromLines.length != count)

View File

@ -466,7 +466,7 @@ public class WebLogin
thisBPBankAccount.setA_Name (WebUtil.getParamOrNull (m_request, "A_Name"));
thisBPBankAccount.setAccountNo (WebUtil.getParamOrNull (m_request, "AccountNo"));
thisBPBankAccount.setRoutingNo (WebUtil.getParamOrNull (m_request, "RoutingNo"));
thisBPBankAccount.save ();
thisBPBankAccount.saveEx();
}
else
log.log(Level.WARNING, "Unknown request='" + m_mode + "'");

View File

@ -488,7 +488,7 @@ public class WebUser
// save Location ***************************************
if (log.isLoggable(Level.FINE)) log.fine("LOC=" + m_loc);
m_loc.save ();
m_loc.saveEx();
// save BP Location ***************************************
if (m_bpl.getC_BPartner_ID () != m_bp.getC_BPartner_ID())

View File

@ -253,7 +253,7 @@ public class ImportFixedAsset extends SvrProcess
if (!bpl.save ())
continue;
}
ifa.save ();
ifa.saveEx();
} // for all new BPartners
rs.close ();
pstmt.close ();
@ -311,7 +311,7 @@ public class ImportFixedAsset extends SvrProcess
}
ifa.setM_Product_ID (product.getM_Product_ID());
ifa.save ();
ifa.saveEx();
} // for all new Products
rs.close ();
pstmt.close ();

View File

@ -746,7 +746,7 @@ public class VPAttributeDialog extends CDialog
// New Instance
if (m_changed || m_masi.getM_AttributeSetInstance_ID() == 0)
{
m_masi.save ();
m_masi.saveEx();
m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID ();
m_M_AttributeSetInstanceName = m_masi.getDescription();
}
@ -789,7 +789,7 @@ public class VPAttributeDialog extends CDialog
if (m_changed)
{
m_masi.setDescription ();
m_masi.save ();
m_masi.saveEx();
}
m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID ();
m_M_AttributeSetInstanceName = m_masi.getDescription();

View File

@ -245,7 +245,7 @@ public class DunningPrint extends SvrProcess
if (printed)
{
entry.setProcessed (true);
entry.save ();
entry.saveEx();
}
} // for all dunning letters

View File

@ -979,7 +979,7 @@ public class WPAttributeDialog extends Window implements EventListener<Event>
// New Instance
if (m_changed || m_masi.getM_AttributeSetInstance_ID() == 0)
{
m_masi.save ();
m_masi.saveEx();
m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID ();
m_M_AttributeSetInstanceName = m_masi.getDescription();
}
@ -1026,7 +1026,7 @@ public class WPAttributeDialog extends Window implements EventListener<Event>
if (m_changed)
{
m_masi.setDescription ();
m_masi.save ();
m_masi.saveEx();
}
m_M_AttributeSetInstance_ID = m_masi.getM_AttributeSetInstance_ID ();
m_M_AttributeSetInstanceName = m_masi.getDescription();

View File

@ -810,7 +810,7 @@ public class Allocation
}
MBPartner bpartner = new MBPartner(Env.getCtx(), m_C_BPartner_ID, trxName);
bpartner.setTotalOpenBalance();
bpartner.save();
bpartner.saveEx();
paymentList.clear();
amountList.clear();

View File

@ -323,7 +323,7 @@ public class AssetServlet extends HttpServlet
if (msg.length () > 120)
msg = msg.substring (0, 119);
ad.setDeliveryConfirmation (msg);
ad.save ();
ad.saveEx();
// asset.saveEx(); not delivered
}
catch (Exception ex1)

View File

@ -294,7 +294,7 @@ public class PaymentServlet extends HttpServlet
{
if (log.isLoggable(Level.FINE)) log.fine(payment.getErrorMessage());
String errMsg = payment.getErrorMessage();
payment.save ();
payment.saveEx();
payment.setErrorMessage(errMsg);
request.getSession().setAttribute(WebSessionCtx.HDR_MESSAGE, errMsg);
//