patch from Scott Gray to fix the xml dump problem of jira OFBIZ-960, thank you Scott

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@535463 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hans Bakker
2007-05-05 06:49:20 +00:00
parent 63ead57a0e
commit cbffc42c69
3 changed files with 51 additions and 12 deletions
@@ -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);
@@ -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>
<h1>XML Export from DataSource(s)</h1>
<br />
<p>This page can be used to export data from the database. The exported documents will have a root tag of "&lt;entity-engine-xml&gt;".</p>
<hr/>
<#if security.hasPermission("ENTITY_MAINT", session)>
<a href="<@ofbizUrl>xmldsrawdump</@ofbizUrl>" class="buttontext" target="_blank">Click Here to Get Data (or save to file)</a>
<#else>
<div>You do not have permission to use this page (ENTITY_MAINT needed)</div>
</#if>
<#else>
<#macro displayButtonBar>
<div class="button-bar">
<input type="submit" value="Export"/>
@@ -112,3 +122,4 @@ under the License.
<#else>
<div>You do not have permission to use this page (ENTITY_MAINT needed)</div>
</#if>
</#if>
@@ -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" %><jsp:useBean id="security" type="org.ofbiz.security.Security" scope="request" /><jsp:useBean id="delegator" type="org.ofbiz.entity.GenericDelegator" scope="request" /><%
--%><%@ 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" %><jsp:useBean id="security" type="org.ofbiz.security.Security" scope="request" /><jsp:useBean id="delegator" type="org.ofbiz.entity.GenericDelegator" scope="request" /><%
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("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
writer.println("<entity-engine-xml>");
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("</entity-engine-xml>");
}