details:   /erp/devel/int/rev/05c4b6abd4d3
changeset: 7090:05c4b6abd4d3
user:      Gorka Ion Damián <gorkaion.damian <at> openbravo.com>
date:      Mon Apr 19 19:21:26 2010 +0200
summary:   Fixed issue 13042.Fixed exception management of the method.

diffstat:

 src/org/openbravo/erpCommon/ad_actionButton/InvoicePaymentMonitor.java |   3 +
 src/org/openbravo/erpCommon/ad_process/PaymentMonitor.java             |   3 +-
 src/org/openbravo/erpCommon/ad_process/PaymentMonitorProcess.java      |  21 
++-
 src/org/openbravo/erpCommon/utility/PropertyException.java             |  46 
++++++++++
 src/org/openbravo/erpCommon/utility/Utility.java                       |  24 
+++-
 5 files changed, 80 insertions(+), 17 deletions(-)

diffs (169 lines):

diff -r df1dfe427bc7 -r 05c4b6abd4d3 
src/org/openbravo/erpCommon/ad_actionButton/InvoicePaymentMonitor.java
--- a/src/org/openbravo/erpCommon/ad_actionButton/InvoicePaymentMonitor.java    
Mon Apr 19 14:03:58 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_actionButton/InvoicePaymentMonitor.java    
Mon Apr 19 19:21:26 2010 +0200
@@ -31,6 +31,7 @@
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.ad_process.PaymentMonitor;
 import org.openbravo.erpCommon.utility.OBError;
+import org.openbravo.erpCommon.utility.PropertyException;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.common.invoice.Invoice;
 import org.openbravo.xmlEngine.XmlDocument;
@@ -90,6 +91,8 @@
       myError = new OBError();
       myError.setType("Success");
       myError.setTitle(Utility.messageBD(this, "Success", vars.getLanguage()));
+    } catch (PropertyException e) {
+      myError = Utility.translateError(this, vars, vars.getLanguage(), 
e.getMessage());
     } catch (Exception e) {
       log4j.error("Rollback in transaction", e);
       myError = Utility.translateError(this, vars, vars.getLanguage(), 
e.getMessage());
diff -r df1dfe427bc7 -r 05c4b6abd4d3 
src/org/openbravo/erpCommon/ad_process/PaymentMonitor.java
--- a/src/org/openbravo/erpCommon/ad_process/PaymentMonitor.java        Mon Apr 
19 14:03:58 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/PaymentMonitor.java        Mon Apr 
19 19:21:26 2010 +0200
@@ -17,6 +17,7 @@
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBQuery;
 import org.openbravo.erpCommon.ad_forms.AcctServer;
+import org.openbravo.erpCommon.utility.PropertyException;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.common.invoice.Invoice;
 import org.openbravo.model.financialmgmt.payment.DebtPayment;
@@ -28,7 +29,7 @@
   /**
    * Updates payment monitor information
    */
-  public static void updateInvoice(Invoice invoice) {
+  public static void updateInvoice(Invoice invoice) throws PropertyException {
     // Don't update the payment monitor information if there is an installed 
extension module that
     // manages it.
     if (Utility.getPropertyValue("PaymentMonitor", 
invoice.getClient().getId(), invoice
diff -r df1dfe427bc7 -r 05c4b6abd4d3 
src/org/openbravo/erpCommon/ad_process/PaymentMonitorProcess.java
--- a/src/org/openbravo/erpCommon/ad_process/PaymentMonitorProcess.java Mon Apr 
19 14:03:58 2010 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/PaymentMonitorProcess.java Mon Apr 
19 19:21:26 2010 +0200
@@ -6,6 +6,7 @@
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBQuery;
+import org.openbravo.erpCommon.utility.PropertyException;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.common.invoice.Invoice;
 import org.openbravo.scheduling.ProcessBundle;
@@ -22,14 +23,19 @@
     logger = bundle.getLogger();
     // Don't update the payment monitor information if there is an installed 
extension module that
     // manages it.
-    if (Utility.getPropertyValue("PaymentMonitor", 
bundle.getContext().getClient(), bundle
-        .getContext().getOrganization()) != null) {
-      logger
-          .log("There is an extension module installed managing the Payment 
Monitor information.\n");
-      logger.log("Core's background process is not executed.\n");
+    try {
+      if (Utility.getPropertyValue("PaymentMonitor", 
bundle.getContext().getClient(), bundle
+          .getContext().getOrganization()) != null) {
+        logger
+            .log("There is an extension module installed managing the Payment 
Monitor information.\n");
+        logger.log("Core's background process is not executed.\n");
+        return;
+      } else
+        logger.log("Starting Update Paid Amount for Invoices Background 
Process.\n");
+    } catch (PropertyException e) {
+      logger.log("PropertyException, there is a conflict for PaymentMonitor 
property\n");
       return;
-    } else
-      logger.log("Starting Update Paid Amount for Invoices Background 
Process.\n");
+    }
     try {
       int counter = 0;
       String whereClause = " as inv where inv.totalPaid <> 
inv.grandTotalAmount and inv.processed=true";
@@ -61,5 +67,4 @@
     }
 
   }
-
 }
\ No newline at end of file
diff -r df1dfe427bc7 -r 05c4b6abd4d3 
src/org/openbravo/erpCommon/utility/PropertyException.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/utility/PropertyException.java        Mon Apr 
19 19:21:26 2010 +0200
@@ -0,0 +1,46 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2010 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.erpCommon.utility;
+
+/**
+ * Exception class used for exceptions related with the Configuration 
Properties.
+ * 
+ * @author gorkaion
+ * 
+ */
+public class PropertyException extends Exception {
+  private static final long serialVersionUID = 1L;
+
+  public PropertyException() {
+    super();
+  }
+
+  public PropertyException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public PropertyException(String message) {
+    super(message);
+  }
+
+  public PropertyException(Throwable cause) {
+    super(cause);
+  }
+
+}
diff -r df1dfe427bc7 -r 05c4b6abd4d3 
src/org/openbravo/erpCommon/utility/Utility.java
--- a/src/org/openbravo/erpCommon/utility/Utility.java  Mon Apr 19 14:03:58 
2010 +0200
+++ b/src/org/openbravo/erpCommon/utility/Utility.java  Mon Apr 19 19:21:26 
2010 +0200
@@ -2516,14 +2516,22 @@
    * @return String containing the value of the property in case that exists a 
module implementing
    *         the property. If the value is null returns '-'. Returns null if 
there isn't any module
    *         implementing the property.
+   * @throws PropertyException
+   *           Throws a PropertyException when the StoredProcedure throws an 
exception, for example
+   *           on conflicting property values.
    */
-  public static String getPropertyValue(String strProperty, String 
strClientId, String strOrgId) {
-    final List<Object> parameters = new ArrayList<Object>();
-    parameters.add(strProperty);
-    parameters.add(strClientId);
-    parameters.add(strOrgId);
-    return (String) 
CallStoredProcedure.getInstance().call("AD_GET_PROPERTY_VALUE", parameters,
-        null);
+  public static String getPropertyValue(String strProperty, String 
strClientId, String strOrgId)
+      throws PropertyException {
+    try {
+      final List<Object> parameters = new ArrayList<Object>();
+      parameters.add(strProperty);
+      parameters.add(strClientId);
+      parameters.add(strOrgId);
+      return (String) 
CallStoredProcedure.getInstance().call("AD_GET_PROPERTY_VALUE", parameters,
+          null);
+    } catch (Exception e) {
+      log4j.error(e.getMessage(), e);
+      throw new PropertyException(strProperty + " @PropertyConflict@");
+    }
   }
-
 }

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to