details:   /erp/erp/devel/pi/rev/8d81bf71afee
changeset: 4666:8d81bf71afee
user:      Sathiyan Sivaprakasam <sathiyan.sivaprakasam <at> openbravo.com>
date:      Thu Aug 20 17:25:56 2009 +0530
summary:   Fixes Issue 10355: Trigger exception messages on reference data 
import need to be captured in Initial Client Setup process

diffstat:

 src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.java |  16 
+++++++++++++---
 src/org/openbravo/service/db/DataImportService.java          |  17 
++++++++++++++++-
 2 files changed, 29 insertions(+), 4 deletions(-)

diffs (71 lines):

diff -r ee790443abc8 -r 8d81bf71afee 
src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.java
--- a/src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.java      Thu Aug 
20 01:45:19 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/InitialClientSetup.java      Thu Aug 
20 17:25:56 2009 +0530
@@ -388,6 +388,7 @@
           strSummary.append(SALTO_LINEA).append(
               Utility.messageBD(this, strReferenceData, 
vars.getLanguage())).append(SALTO_LINEA);
           isOK = false;
+          strError = strReferenceData;
           return m_info.toString();
         }
       } catch (Exception err) {
@@ -1563,10 +1564,19 @@
           if (myResult.getErrorMessages() != null && 
!myResult.getErrorMessages().equals("")
               && !myResult.getErrorMessages().equals("null")) {
             m_info.append(SALTO_LINEA).append("ERRORS:").append(SALTO_LINEA);
-            
m_info.append(SALTO_LINEA).append(myResult.getErrorMessages()).append(SALTO_LINEA);
+            if 
(myResult.getErrorMessages().startsWith("isBatchUpdateException:")) {
+              String messageKey = myResult.getErrorMessages().substring(
+                  "isBatchUpdateException:".length()).trim();
+              m_info.append(SALTO_LINEA).append(
+                  Utility.translateError(this, vars, vars.getLanguage(), 
messageKey).getMessage())
+                  .append(SALTO_LINEA);
+              strError = strError.append(Utility.translateError(this, vars, 
vars.getLanguage(),
+                  messageKey).getMessage());
+            } else {
+              
m_info.append(SALTO_LINEA).append(myResult.getErrorMessages()).append(SALTO_LINEA);
+              strError = strError.append(myResult.getErrorMessages());
+            }
           }
-          if (myResult.getErrorMessages() != null && 
!myResult.getErrorMessages().equals(""))
-            strError = strError.append(myResult.getErrorMessages());
 
           if (!strError.toString().equals(""))
             return strError.toString();
diff -r ee790443abc8 -r 8d81bf71afee 
src/org/openbravo/service/db/DataImportService.java
--- a/src/org/openbravo/service/db/DataImportService.java       Thu Aug 20 
01:45:19 2009 +0200
+++ b/src/org/openbravo/service/db/DataImportService.java       Thu Aug 20 
17:25:56 2009 +0530
@@ -20,6 +20,7 @@
 package org.openbravo.service.db;
 
 import java.io.Reader;
+import java.sql.BatchUpdateException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -441,10 +442,24 @@
         return ir;
       }
     } catch (final Throwable t) {
+      boolean isBatchUpdateException = false;
+      // We need to capture nested exception of BatchUpdate exception.
+      Throwable cause = t.getCause();
+      if (cause instanceof BatchUpdateException) {
+        BatchUpdateException batchUpdateException = (BatchUpdateException) 
cause;
+        if (batchUpdateException.getNextException() != null) {
+          String errorMessage = 
batchUpdateException.getNextException().getMessage();
+          String messageKey = errorMessage.substring("ERROR:".length()).trim();
+          isBatchUpdateException = true;
+          ir.setErrorMessages("isBatchUpdateException:" + messageKey);
+        }
+      }
       OBDal.getInstance().rollbackAndClose();
       rolledBack = true;
       t.printStackTrace(System.err);
-      ir.setException(t);
+      if (!isBatchUpdateException)
+        ir.setException(t);
+
     } finally {
       if (rolledBack) {
         TriggerHandler.getInstance().clear();

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to