fixed bug 27222: NPE in WebServices when trying to delete a non-existing record
authorAsier Lostalé <asier.lostale@openbravo.com>
Tue, 29 Jul 2014 08:34:51 +0200
changeset 24130 6f9569492c59
parent 24129 d49455df9b18
child 24131 5366618a2141
fixed bug 27222: NPE in WebServices when trying to delete a non-existing record

Throwing OBException in this case so HTTP 500 response is kept
src/org/openbravo/service/rest/DalWebService.java
--- a/src/org/openbravo/service/rest/DalWebService.java	Mon Jul 28 12:33:08 2014 +0200
+++ b/src/org/openbravo/service/rest/DalWebService.java	Tue Jul 29 08:34:51 2014 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008-2013 Openbravo SLU
+ * All portions are Copyright (C) 2008-2014 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -395,6 +395,9 @@
       final String entityName = segments[0];
       final String id = segments[1];
       final BaseOBObject result = OBDal.getInstance().get(entityName, id);
+      if (result == null) {
+        throw new OBException("Not found record for deletion: entity " + entityName + ", id " + id);
+      }
       final String resIdentifier = result.getIdentifier();
       OBDal.getInstance().remove(result);
       OBDal.getInstance().commitAndClose();