You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2007/03/01 08:32:20 UTC
svn commit: r513211 - in /ofbiz/trunk/framework/webtools:
src/org/ofbiz/webtools/WebToolsServices.java
webapp/webtools/includes/header.ftl
webapp/webtools/templates/main_template.jsp
Author: jonesde
Date: Wed Feb 28 23:32:20 2007
New Revision: 513211
URL: http://svn.apache.org/viewvc?view=rev&rev=513211
Log:
Applied patch from Andrew Sykes, and tested and improved by Jacques and Chris Howe and Adrian Crum; Jira #OFBIZ-757
Modified:
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java
ofbiz/trunk/framework/webtools/webapp/webtools/includes/header.ftl
ofbiz/trunk/framework/webtools/webapp/webtools/templates/main_template.jsp
Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java?view=diff&rev=513211&r1=513210&r2=513211
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java Wed Feb 28 23:32:20 2007
@@ -211,7 +211,7 @@
LocalDispatcher dispatcher = dctx.getDispatcher();
- List messages = new ArrayList();
+ List messages = FastList.newInstance();
String path = (String)context.get("path");
String mostlyInserts = (String)context.get("mostlyInserts");
@@ -233,71 +233,71 @@
long pauseLong = filePause != null ? filePause.longValue() : 0;
File baseDir = new File(path);
+ Map parseEntityXmlFileArgs = UtilMisc.toMap("mostlyInserts", mostlyInserts,
+ "createDummyFks", createDummyFks,
+ "maintainTimeStamps", maintainTimeStamps,
+ "txTimeout", txTimeout,
+ "userLogin", userLogin);
+
if (baseDir.isDirectory() && baseDir.canRead()) {
File[] fileArray = baseDir.listFiles();
- ArrayList files = new ArrayList(fileArray.length);
+ FastList files = FastList.newInstance();
for (int a=0; a<fileArray.length; a++){
if (fileArray[a].getName().toUpperCase().endsWith("XML")) {
files.add(fileArray[a]);
}
- }
- boolean importedOne = false;
- int fileListMarkedSize = files.size();
- int passes = 0;
- for (int a=0; a<files.size(); a++){
- // Infinite loop defense
- if (a == fileListMarkedSize) {
- passes++;
- fileListMarkedSize = files.size();
- messages.add("Pass " + passes + " complete");
- // This means we've done a pass
- if ( false == importedOne ) {
- // We've failed to make any imports
- messages.add("Dropping out as we failed to make any imports on the last pass");
- a = files.size();
- continue;
- }
- importedOne = false;
- }
- File curFile = (File)files.get(a);
- try{
- URL url = curFile.toURI().toURL();
- Map inputMap = UtilMisc.toMap("url", url,
- "mostlyInserts", mostlyInserts,
- "createDummyFks", createDummyFks,
- "maintainTimeStamps", maintainTimeStamps,
- "txTimeout", txTimeout,
- "userLogin", userLogin);
- Map outputMap = dispatcher.runSync("parseEntityXmlFile", inputMap);
- Long numberRead = (Long)outputMap.get("rowProcessed");
-
- messages.add("Got " + numberRead.longValue() + " entities from " + curFile);
-
- importedOne = true;
- if (deleteFiles) {
- curFile.delete();
- }
- } catch (Exception ex){
- messages.add("Error trying to read from " + curFile + ": " + ex);
- if (ex.toString().indexOf("referential integrity violation") > -1 ||
- ex.toString().indexOf("Integrity constraint violation") > -1){
- //It didn't work because object it depends on are still
- //missing from the DB. Retry later.
- //
- //FIXME: Of course this is a potential infinite loop.
- messages.add("Looks like referential integrity violation, will retry");
- files.add(curFile);
- }
- }
- // pause in between files
- if (pauseLong > 0) {
- Debug.log("Pausing for [" + pauseLong + "] seconds - " + UtilDateTime.nowTimestamp());
+ }
+
+ int passes=0;
+ int initialListSize = files.size();
+ int lastUnprocessedFilesCount = 0;
+ FastList unprocessedFiles = FastList.newInstance();
+ while (files.size()>0 &&
+ files.size() != lastUnprocessedFilesCount) {
+ lastUnprocessedFilesCount = files.size();
+ unprocessedFiles = FastList.newInstance();
+ Iterator filesItr = files.iterator();
+ while (filesItr.hasNext()) {
+ File f = (File) filesItr.next();
try {
- Thread.sleep((pauseLong * 1000));
- } catch(InterruptedException ie) {
- Debug.log("Pause finished - " + UtilDateTime.nowTimestamp());
+ URL furl = f.toURI().toURL();
+ parseEntityXmlFileArgs.put("url", furl);
+ Map outputMap = dispatcher.runSync("parseEntityXmlFile", parseEntityXmlFileArgs);
+ Long numberRead = (Long) outputMap.get("rowProcessed");
+ messages.add("Got " + numberRead.longValue() + " entities from " + f);
+ if (deleteFiles) {
+ messages.add("Deleting " + f);
+ f.delete();
+ }
+ } catch(Exception e) {
+ unprocessedFiles.add(f);
+ messages.add("Failed " + f + " adding to retry list for next pass");
+ }
+ // pause in between files
+ if (pauseLong > 0) {
+ Debug.log("Pausing for [" + pauseLong + "] seconds - " + UtilDateTime.nowTimestamp());
+ try {
+ Thread.sleep((pauseLong * 1000));
+ } catch(InterruptedException ie) {
+ Debug.log("Pause finished - " + UtilDateTime.nowTimestamp());
+ }
}
}
+ files = unprocessedFiles;
+ passes++;
+ messages.add("Pass " + passes + " complete");
+ Debug.logInfo("Pass " + passes + " complete", module);
+ }
+ lastUnprocessedFilesCount=unprocessedFiles.size();
+ messages.add("---------------------------------------");
+ messages.add("Succeeded: " + (initialListSize-lastUnprocessedFilesCount) + " of " + initialListSize);
+ messages.add("Failed: " + lastUnprocessedFilesCount + " of " + initialListSize);
+ messages.add("---------------------------------------");
+ messages.add("Failed Files:");
+ Iterator unprocessedFilesItr = unprocessedFiles.iterator();
+ while (unprocessedFilesItr.hasNext()) {
+ File file = (File) unprocessedFilesItr.next();
+ messages.add("" + file);
}
} else {
messages.add("path not found or can't be read");
Modified: ofbiz/trunk/framework/webtools/webapp/webtools/includes/header.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/includes/header.ftl?view=diff&rev=513211&r1=513210&r2=513211
==============================================================================
--- ofbiz/trunk/framework/webtools/webapp/webtools/includes/header.ftl (original)
+++ ofbiz/trunk/framework/webtools/webapp/webtools/includes/header.ftl Wed Feb 28 23:32:20 2007
@@ -1,4 +1,4 @@
-<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<#--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -25,14 +25,14 @@
<#if (requestAttributes.person)?exists><#assign person = requestAttributes.person></#if>
<#if (requestAttributes.partyGroup)?exists><#assign partyGroup = requestAttributes.partyGroup></#if>
-<html>
+<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>${layoutSettings.companyName}: <#if (page.titleProperty)?has_content>${uiLabelMap[page.titleProperty]}<#else>${(page.title)?if_exists}</#if></title>
<script language="javascript" src="<@o...@ofbizContentUrl>" type="text/javascript"></script>
<script language="javascript" src="<@o...@ofbizContentUrl>" type="text/javascript"></script>
<script language="javascript" src="<@o...@ofbizContentUrl>" type="text/javascript"></script>
- <link rel="stylesheet" href="<@o...@ofbizContentUrl>" type="text/css">
+ <link rel="stylesheet" href="<@o...@ofbizContentUrl>" type="text/css"/>
</head>
<body>
Modified: ofbiz/trunk/framework/webtools/webapp/webtools/templates/main_template.jsp
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/templates/main_template.jsp?view=diff&rev=513211&r1=513210&r2=513211
==============================================================================
--- ofbiz/trunk/framework/webtools/webapp/webtools/templates/main_template.jsp (original)
+++ ofbiz/trunk/framework/webtools/webapp/webtools/templates/main_template.jsp Wed Feb 28 23:32:20 2007
@@ -16,7 +16,6 @@
specific language governing permissions and limitations
under the License.
--%>
-<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ include file="/includes/envsetup.jsp" %>
<%@ taglib uri='ofbizTags' prefix='ofbiz' %>
<%@ taglib uri='regions' prefix='region' %>