details:   /erp/devel/pi/rev/594ab4625cfa
changeset: 8585:594ab4625cfa
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Thu Oct 21 17:50:13 2010 +0200
summary:   fixes issue 14973: DalWebServiceServlet does not report errors which 
occur at commit time

diffstat:

 src-test/org/openbravo/test/webservice/WSUpdateTest.java |  11 +++++++++++
 src/org/openbravo/service/rest/DalWebService.java        |   6 ++++++
 2 files changed, 17 insertions(+), 0 deletions(-)

diffs (58 lines):

diff -r dd5c68a448cf -r 594ab4625cfa 
src-test/org/openbravo/test/webservice/WSUpdateTest.java
--- a/src-test/org/openbravo/test/webservice/WSUpdateTest.java  Thu Oct 21 
17:54:19 2010 +0530
+++ b/src-test/org/openbravo/test/webservice/WSUpdateTest.java  Thu Oct 21 
17:50:13 2010 +0200
@@ -20,6 +20,7 @@
 package org.openbravo.test.webservice;
 
 import java.io.FileNotFoundException;
+import java.net.HttpURLConnection;
 
 import org.apache.log4j.Logger;
 import org.openbravo.base.provider.OBProvider;
@@ -199,6 +200,16 @@
   }
 
   /**
+   * Tests issue 14973 https://issues.openbravo.com/view.php?id=14973 
DalWebServiceServlet does not
+   * report errors which occur at commit time
+   */
+  public void test14973() throws Exception {
+    final HttpURLConnection hc = createConnection("/ws/dal/Product/1000004", 
"DELETE");
+    hc.connect();
+    assertEquals(500, hc.getResponseCode());
+  }
+
+  /**
    * Add a new city using the wrong HTTP method.
    * 
    * @throws Exception
diff -r dd5c68a448cf -r 594ab4625cfa 
src/org/openbravo/service/rest/DalWebService.java
--- a/src/org/openbravo/service/rest/DalWebService.java Thu Oct 21 17:54:19 
2010 +0530
+++ b/src/org/openbravo/service/rest/DalWebService.java Thu Oct 21 17:50:13 
2010 +0200
@@ -276,6 +276,7 @@
       final BaseOBObject result = OBDal.getInstance().get(entityName, id);
       final String resIdentifier = result.getIdentifier();
       OBDal.getInstance().remove(result);
+      OBDal.getInstance().commitAndClose();
 
       final String resultXml = 
WebServiceUtil.getInstance().createResultXMLWithLogWarning(
           "Action performed successfully", "Removed business object " + 
resIdentifier, null);
@@ -311,6 +312,8 @@
 
         Object o = obq.deleteQuery().executeUpdate();
 
+        OBDal.getInstance().commitAndClose();
+
         final String resultXml = 
WebServiceUtil.getInstance().createResultXMLWithLogWarning(
             "Action performed successfully", "Removed business objects " + o, 
null);
         response.setContentType("text/xml;charset=UTF-8");
@@ -347,6 +350,9 @@
       HttpServletResponse response, ChangeAction changeAction) {
     response.setContentType("text/xml;charset=UTF-8");
     final String resultXml = doChangeActionXML(path, request, response, 
changeAction);
+
+    OBDal.getInstance().commitAndClose();
+
     try {
       final Writer w = response.getWriter();
       w.write(resultXml);

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to