svn commit: r535539 - in /ofbiz/branches/release4.0/framework/webtools/webapp/webtools: WEB-INF/actions/entity/xmldsdump.bsh entity/xmldsdump.ftl entity/xmldsrawdump.jsp

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r535539 - in /ofbiz/branches/release4.0/framework/webtools/webapp/webtools: WEB-INF/actions/entity/xmldsdump.bsh entity/xmldsdump.ftl entity/xmldsrawdump.jsp

hansbak-2
Author: hansbak
Date: Sat May  5 08:40:38 2007
New Revision: 535539

URL: http://svn.apache.org/viewvc?view=rev&rev=535539
Log:
jira OFBIZ-960 xml export is now working, Patch from Scott Gray

Modified:
    ofbiz/branches/release4.0/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh
    ofbiz/branches/release4.0/framework/webtools/webapp/webtools/entity/xmldsdump.ftl
    ofbiz/branches/release4.0/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp

Modified: ofbiz/branches/release4.0/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh?view=diff&rev=535539&r1=535538&r2=535539
==============================================================================
--- ofbiz/branches/release4.0/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh (original)
+++ ofbiz/branches/release4.0/framework/webtools/webapp/webtools/WEB-INF/actions/entity/xmldsdump.bsh Sat May  5 08:40:38 2007
@@ -166,6 +166,7 @@
 }
 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 @@
 } 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);

Modified: ofbiz/branches/release4.0/framework/webtools/webapp/webtools/entity/xmldsdump.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/framework/webtools/webapp/webtools/entity/xmldsdump.ftl?view=diff&rev=535539&r1=535538&r2=535539
==============================================================================
--- ofbiz/branches/release4.0/framework/webtools/webapp/webtools/entity/xmldsdump.ftl (original)
+++ ofbiz/branches/release4.0/framework/webtools/webapp/webtools/entity/xmldsdump.ftl Sat May  5 08:40:38 2007
@@ -16,7 +16,17 @@
 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 @@
 <#else>
     <div>You do not have permission to use this page (ENTITY_MAINT needed)</div>
 </#if>
+</#if>
\ No newline at end of file

Modified: ofbiz/branches/release4.0/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp?view=diff&rev=535539&r1=535538&r2=535539
==============================================================================
--- ofbiz/branches/release4.0/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp (original)
+++ ofbiz/branches/release4.0/framework/webtools/webapp/webtools/entity/xmldsrawdump.jsp Sat May  5 08:40:38 2007
@@ -15,7 +15,7 @@
 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 @@
 
             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>");
           }