From e17794b434fe11d895013976deb874ac8828fbfc Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 16 Feb 2009 05:29:09 +0000 Subject: [PATCH] Fix some of [2604454] - 2Pack errors - NPE - Raise exceptions on some failure conditions Pending to implement old functionality in trunk (assign name, key1name and key2name) --- base/src/org/adempiere/pipo/AbstractElementHandler.java | 6 +++--- base/src/org/adempiere/pipo/handler/DataElementHandler.java | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/base/src/org/adempiere/pipo/AbstractElementHandler.java b/base/src/org/adempiere/pipo/AbstractElementHandler.java index e24fadb22d..c3e45ef329 100644 --- a/base/src/org/adempiere/pipo/AbstractElementHandler.java +++ b/base/src/org/adempiere/pipo/AbstractElementHandler.java @@ -258,10 +258,10 @@ public abstract class AbstractElementHandler implements ElementHandler { int idDetail = DB.getSQLValue(getTrxName(ctx),sqlD.toString())+1; if (referenceID == 10 || referenceID == 14 || referenceID == 34 || referenceID == 17) - if (from.get_Value(i)!= null) + if (from != null && from.get_Value(i)!= null) colValue = from.get_Value(i).toString().replaceAll("'","''"); else if (referenceID == 20|| referenceID == 28) - if (from.get_Value(i)!= null) + if (from != null && from.get_Value(i)!= null) colValue = from.get_Value(i).toString().replaceAll("'","''"); else ;//Ignore @@ -281,7 +281,7 @@ public abstract class AbstractElementHandler implements ElementHandler { .append( ", " + tableID ) .append( ", " + (columnID == -1 ? "null" : columnID) ) .append( ", " + (referenceID == -1 ? "null" : referenceID) ) - .append( ", '" + (colValue != null ? colValue : from.get_Value(i)) ) + .append( ", '" + (colValue != null ? colValue : (from != null ? from.get_Value(i) : "null")) ) .append( "')"); int no = DB.executeUpdate (sqlB.toString(), getTrxName(ctx)); diff --git a/base/src/org/adempiere/pipo/handler/DataElementHandler.java b/base/src/org/adempiere/pipo/handler/DataElementHandler.java index a824354edf..974d2d2e78 100644 --- a/base/src/org/adempiere/pipo/handler/DataElementHandler.java +++ b/base/src/org/adempiere/pipo/handler/DataElementHandler.java @@ -162,6 +162,8 @@ public class DataElementHandler extends AbstractElementHandler { int id = get_ID(ctx, d_tablename, nameAttribute); genericPO = table.getPO(id, getTrxName(ctx)); if (id > 0){ + if (genericPO == null || genericPO.get_ID() != id) + throw new SAXException("id not found"); AD_Backup_ID = copyRecord(ctx,d_tablename,genericPO); objectStatus = "Update"; }