diff --git a/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh b/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh index 6ab692b865..f9913f2dca 100644 --- a/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh +++ b/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh @@ -166,6 +166,7 @@ if (UtilValidate.isNotEmpty(entitySyncId)) { } boolean checkAll = "true".equals(request.getParameter("checkAll")); boolean tobrowser = request.getParameter("tobrowser")!=null?true:false; +context.put("tobrowser", tobrowser); EntityExpr entityFromCond = null; EntityExpr entityThruCond = null; @@ -183,6 +184,11 @@ if ((entityFromCond!=null) && (entityThruCond!=null)) { } else if(entityThruCond!=null) { entityDateCond = entityThruCond; } + +ModelReader reader = delegator.getModelReader(); +Collection ec = reader.getEntityNames(); +TreeSet entityNames = new TreeSet(ec); +context.put("entityNames", entityNames); if (tobrowser) { session.setAttribute("xmlrawdump_entitylist", entityName); diff --git a/framework/webtools/webapp/webtools/entity/xmldsdump.ftl b/framework/webtools/webapp/webtools/entity/xmldsdump.ftl index 3ed6be29cf..9d1486245b 100644 --- a/framework/webtools/webapp/webtools/entity/xmldsdump.ftl +++ b/framework/webtools/webapp/webtools/entity/xmldsdump.ftl @@ -16,7 +16,17 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - +<#if tobrowser?exists && tobrowser> +

XML Export from DataSource(s)

+
+

This page can be used to export data from the database. The exported documents will have a root tag of "<entity-engine-xml>".

+
+<#if security.hasPermission("ENTITY_MAINT", session)> + Click Here to Get Data (or save to file) +<#else> +
You do not have permission to use this page (ENTITY_MAINT needed)
+ +<#else> <#macro displayButtonBar>
@@ -112,3 +122,4 @@ under the License. <#else>
You do not have permission to use this page (ENTITY_MAINT needed)
+ \ No newline at end of file diff --git a/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp b/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp index 54721cb8e6..8374594912 100644 --- a/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp +++ b/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp @@ -15,7 +15,7 @@ software distributed under the License is distributed on an KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---%><%@ page import="java.io.*, java.util.*, java.net.*, org.w3c.dom.*, org.ofbiz.security.*, org.ofbiz.entity.*, org.ofbiz.entity.condition.*, org.ofbiz.entity.util.*, org.ofbiz.base.util.*, org.ofbiz.entity.model.*" %><%@ taglib uri="ofbizTags" prefix="ofbiz" %><% +--%><%@ page import="java.io.*, java.util.*, java.net.*, org.w3c.dom.*, org.ofbiz.security.*, org.ofbiz.entity.*, org.ofbiz.entity.condition.*, org.ofbiz.entity.util.*, org.ofbiz.base.util.*, org.ofbiz.entity.model.*, org.ofbiz.entity.transaction.*" %><%@ taglib uri="ofbizTags" prefix="ofbiz" %><% if(security.hasPermission("ENTITY_MAINT", session)) { String[] entityName = (String[]) session.getAttribute("xmlrawdump_entitylist"); session.removeAttribute("xmlrawdump_entitylist"); @@ -51,19 +51,41 @@ under the License. writer.println(""); writer.println(""); - - Iterator i = passedEntityNames.iterator(); - while(i.hasNext()) { - String curEntityName = (String)i.next(); - EntityListIterator values = delegator.findListIteratorByCondition(curEntityName, entityDateCond, null, null); - GenericValue value = null; - while ((value = (GenericValue) values.next()) != null) { - value.writeXmlText(writer, ""); - numberWritten++; + boolean beganTransaction = false; + try { + beganTransaction = TransactionUtil.begin(); + + Iterator i = passedEntityNames.iterator(); + while(i.hasNext()) { + String curEntityName = (String)i.next(); + EntityListIterator values = delegator.findListIteratorByCondition(curEntityName, entityDateCond, null, null); + + GenericValue value = null; + while ((value = (GenericValue) values.next()) != null) { + value.writeXmlText(writer, ""); + numberWritten++; + } + values.close(); } - values.close(); + TransactionUtil.commit(beganTransaction); + } catch (GenericEntityException e) { + String errMsg = "Failure in operation, rolling back transaction"; + String module = "xmldsrawdump.jsp"; + Debug.logError(e, errMsg, module); + try { + // only rollback the transaction if we started one... + TransactionUtil.rollback(beganTransaction, errMsg, e); + } catch (GenericEntityException e2) { + Debug.logError(e2, "Could not rollback transaction: " + e2.toString(), module); + } + // after rolling back, rethrow the exception + throw e; + } finally { + // only commit the transaction if we started one... this will throw an exception if it fails + TransactionUtil.commit(beganTransaction); } + writer.println(""); }