Author: jonesde
Date: Tue Mar 6 12:27:36 2007
New Revision: 515285
URL: http://svn.apache.org/viewvc?view=rev&rev=515285
Log:
Changed EntityDataAssert to throw exceptions so that calling method has more
control over it
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataAssert.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/FieldObject.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataAssert.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataAssert.java?view=diff&rev=515285&r1=515284&r2=515285
==============================================================================
---
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataAssert.java
(original)
+++
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataAssert.java
Tue Mar 6 12:27:36 2007
@@ -18,15 +18,20 @@
*******************************************************************************/
package org.ofbiz.entity.util;
+import java.io.IOException;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericPK;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.model.ModelEntity;
+import org.xml.sax.SAXException;
/**
* Some utility routines for loading seed data.
@@ -36,7 +41,7 @@
public static final String module = EntityDataAssert.class.getName();
- public static int assertData(URL dataUrl, GenericDelegator delegator, List
errorMessages) {
+ public static int assertData(URL dataUrl, GenericDelegator delegator, List
errorMessages) throws GenericEntityException, SAXException,
ParserConfigurationException, IOException {
int rowsChecked = 0;
if (dataUrl == null) {
@@ -86,10 +91,12 @@
rowsChecked++;
}
- } catch (Exception e) {
+ } catch (GenericEntityException e) {
String xmlError = "Error checking/asserting XML Resource \"" +
dataUrl.toExternalForm() + "\"; Error was: " + e.getMessage();
- errorMessages.add(xmlError);
Debug.logError(e, xmlError, module);
+ // instead of adding this as a message, throw the real exception;
then caller has more control
+ //errorMessages.add(xmlError);
+ throw e;
}
return rowsChecked;
Modified:
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/FieldObject.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/FieldObject.java?view=diff&rev=515285&r1=515284&r2=515285
==============================================================================
---
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/FieldObject.java
(original)
+++
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/FieldObject.java
Tue Mar 6 12:27:36 2007
@@ -64,7 +64,7 @@
if (!mapAcsr.isEmpty()) {
Map fromMap = (Map) mapAcsr.get(methodContext);
- if (fromMap == null) {
+ if (fromMap == null) {
Debug.logWarning("Map not found with name " + mapAcsr + ", not
getting Object value, returning null.", module);
return null;
}
Modified:
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java?view=diff&rev=515285&r1=515284&r2=515285
==============================================================================
---
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java
(original)
+++
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java
Tue Mar 6 12:27:36 2007
@@ -18,15 +18,19 @@
*******************************************************************************/
package org.ofbiz.minilang.method.entityops;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.ofbiz.base.location.FlexibleLocation;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.util.EntityDataAssert;
import org.ofbiz.entity.util.EntitySaxReader;
import org.ofbiz.minilang.SimpleMethod;
@@ -34,6 +38,7 @@
import org.ofbiz.minilang.method.MethodContext;
import org.ofbiz.minilang.method.MethodOperation;
import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
/**
* Uses the delegator to find entity values by a primary key
@@ -93,7 +98,13 @@
if ("assert".equals(mode)) {
// load the XML file, read in one element at a time and check it
against the database
- EntityDataAssert.assertData(dataUrl, delegator, messages);
+ try {
+ EntityDataAssert.assertData(dataUrl, delegator, messages);
+ } catch (Exception e) {
+ String xmlError = "Error checking/asserting XML Resource \"" +
dataUrl.toExternalForm() + "\"; Error was: " + e.getMessage();
+ //Debug.logError(e, xmlError, module);
+ messages.add(xmlError);
+ }
} else {
// again, default to load
try {