Author: vmassol
Date: 2007-11-15 16:06:56 +0100 (Thu, 15 Nov 2007)
New Revision: 5887
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocumentArchive.java
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/AbstractXWikiMigrationManager.java
Log:
XWIKI-1851: Storage migration fails when migrating from XE 1.1.2 to XE 1.2.x
+ improved logging
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocumentArchive.java
===================================================================
---
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocumentArchive.java
2007-11-15 14:35:14 UTC (rev 5886)
+++
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocumentArchive.java
2007-11-15 15:06:56 UTC (rev 5887)
@@ -33,6 +33,8 @@
import org.suigeneris.jrcs.rcs.Version;
import org.suigeneris.jrcs.util.ToString;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
@@ -49,6 +51,9 @@
*/
public class XWikiDocumentArchive
{
+ /** logger. */
+ private static final Log LOG =
LogFactory.getLog(XWikiDocumentArchive.class);
+
/** =docId. */
private long id;
/** SortedMap from Version to XWikiRCSNodeInfo. */
@@ -189,19 +194,28 @@
for (Iterator it = nodes.iterator(); it.hasNext();) {
XWikiRCSNodeInfo nodeInfo = (XWikiRCSNodeInfo) it.next();
XWikiRCSNodeContent nodeContent = (XWikiRCSNodeContent)
it.next();
- // if archive is old. (there is no author, comment, date
fields in archive nodes)
+
+ // If the archive node is old there is no author, comment and
date fields so we set them using the
+ // ones from a XWikiDocment object that we construct using the
archive content.
if (nodeInfo.getAuthor() == null ||
nodeInfo.getAuthor().indexOf('.') < 0) {
Version ver = nodeInfo.getVersion();
String xml = archive.getRevisionAsString(ver);
- XWikiDocument doc = new XWikiDocument();
- // Some time in the past there was a bug in XWiki where
version were starting at 1.2. When this
- // happens the returned xml has a value of "\n". Thus we
simply skip it.
- if (xml.length()>1) {
+
+ try {
+ XWikiDocument doc = new XWikiDocument();
doc.fromXML(xml);
// set this fields from old document
nodeInfo.setAuthor(doc.getAuthor());
nodeInfo.setComment(doc.getComment());
nodeInfo.setDate(doc.getDate());
+ } catch (Exception e) {
+ // Two potential known errors:
+ // 1) Revision 1.1 doesn't exist. Some time in the
past there was a bug in XWiki where version
+ // were starting at 1.2. When this happens the
returned xml has a value of "\n".
+ // 2) A Class property with an invalid XML name was
created.
+ // See http://jira.xwiki.org/jira/browse/XWIKI-1855
+ LOG.warn("Error in revision [" + ver.toString() + "]:
[" + e.getMessage()
+ + "]. Ignoring non-fatal error.");
}
}
Modified:
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/AbstractXWikiMigrationManager.java
===================================================================
---
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/AbstractXWikiMigrationManager.java
2007-11-15 14:35:14 UTC (rev 5886)
+++
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/AbstractXWikiMigrationManager.java
2007-11-15 15:06:56 UTC (rev 5887)
@@ -78,9 +78,6 @@
public void startMigrations(XWikiContext context) throws XWikiException
{
XWikiDBVersion curversion = getDBVersion(context);
- if (LOG.isInfoEnabled()) {
- LOG.info("Current storage version = [" + curversion.toString() +
"]");
- }
try {
Collection neededMigrations = getNeededMigrations(context);
startMigrations(neededMigrations, context);
@@ -125,10 +122,15 @@
Collection neededMigrationsAsCollection = neededMigrations.values();
if (LOG.isInfoEnabled()) {
- LOG.info("List of migrations that will be executed:");
- for (Iterator it = neededMigrationsAsCollection.iterator();
it.hasNext();) {
- XWikiMigratorInterface migrator = (XWikiMigratorInterface)
it.next();
- LOG.info(" " + migrator.getName() + " - " +
migrator.getDescription());
+ if (!neededMigrations.isEmpty()) {
+ LOG.info("Current storage version = [" + curversion.toString()
+ "]");
+ LOG.info("List of migrations that will be executed:");
+ for (Iterator it = neededMigrationsAsCollection.iterator();
it.hasNext();) {
+ XWikiMigratorInterface migrator = (XWikiMigratorInterface)
it.next();
+ LOG.info(" " + migrator.getName() + " - " +
migrator.getDescription());
+ }
+ } else {
+ LOG.info("No storage migration required since current version
is [" + curversion.toString() + "]");
}
}
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications