Author: vmassol
Date: 2007-11-26 16:46:57 +0100 (Mon, 26 Nov 2007)
New Revision: 6079

Added:
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6079XWIKI1878Migrator.java
Modified:
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/rcs/XWikiRCSArchive.java
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4340XWIKI883Migrator.java
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4359XWIKI1459Migrator.java
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/XWikiHibernateMigrationManager.java
Log:
XWIKI-1878: "Exception while patching" error


Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/rcs/XWikiRCSArchive.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/rcs/XWikiRCSArchive.java
       2007-11-26 15:07:13 UTC (rev 6078)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/rcs/XWikiRCSArchive.java
       2007-11-26 15:46:57 UTC (rev 6079)
@@ -263,9 +263,10 @@
             result.add(nodeInfo);
             result.add(content);
         }
-        // ensure latest version is full
+        // Ensure that the latest revision is set set to have the full content 
and not a diff.
         if (result.size() > 0) {
-            ((XWikiRCSNodeInfo) result.iterator().next()).setDiff(false);
+            ((XWikiRCSNodeInfo) ((ArrayList) result).get(0)).setDiff(false);
+            ((XWikiRCSNodeContent) ((ArrayList) 
result).get(1)).getPatch().setDiff(false);
         }
         return result;
     }

Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4340XWIKI883Migrator.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4340XWIKI883Migrator.java
       2007-11-26 15:07:13 UTC (rev 6078)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4340XWIKI883Migrator.java
       2007-11-26 15:46:57 UTC (rev 6079)
@@ -1,3 +1,22 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package com.xpn.xwiki.store.migration.hibernate;
 
 import java.util.ArrayList;

Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4359XWIKI1459Migrator.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4359XWIKI1459Migrator.java
      2007-11-26 15:07:13 UTC (rev 6078)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4359XWIKI1459Migrator.java
      2007-11-26 15:46:57 UTC (rev 6079)
@@ -1,3 +1,22 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package com.xpn.xwiki.store.migration.hibernate;
 
 import java.sql.ResultSet;
@@ -50,6 +69,15 @@
     /** [EMAIL PROTECTED] */
     public void migrate(XWikiHibernateMigrationManager manager, final 
XWikiContext context) throws XWikiException
     {
+        migrate(manager, context, LOG);
+    }
+
+    /**
+     * The reason for the logger is to let the R6079XWIKI1878Migrator reuse 
the same code.
+     */
+    protected void migrate(XWikiHibernateMigrationManager manager, final 
XWikiContext context, final Log logger)
+        throws XWikiException
+    {
         // migrate data
         if (manager.getStore(context).executeWrite(context, true, new 
HibernateCallback() {
             public Object doInHibernate(Session session) throws 
HibernateException, XWikiException
@@ -65,8 +93,8 @@
                         return null;
                     }
                     while (rs.next()) {
-                        if (LOG.isInfoEnabled()) {
-                            LOG.info("Updating document [" + rs.getString(3) + 
"]...");
+                        if (logger.isInfoEnabled()) {
+                            logger.info("Updating document [" + 
rs.getString(3) + "]...");
                         }
                         long docId = Long.parseLong(rs.getString(1));
                         String sArchive = rs.getString(2);
@@ -78,7 +106,7 @@
                     }
                     stmt.close();
                 } catch (SQLException e) {
-                    throw new 
XWikiException(XWikiException.MODULE_XWIKI_STORE, 
+                    throw new XWikiException(XWikiException.MODULE_XWIKI_STORE,
                         XWikiException.ERROR_XWIKI_STORE_MIGRATION, getName() 
+ " migration failed", e);
                 }
                 return Boolean.TRUE;

Copied: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6079XWIKI1878Migrator.java
 (from rev 6076, 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R4359XWIKI1459Migrator.java)
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6079XWIKI1878Migrator.java
                              (rev 0)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6079XWIKI1878Migrator.java
      2007-11-26 15:46:57 UTC (rev 6079)
@@ -0,0 +1,82 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.store.migration.hibernate;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.store.migration.XWikiDBVersion;
+
+/**
+ * Migration for XWIKI1878: Fix xwikircs table isdiff data not matching RCS 
state of some revisions (when the state
+ * says "full" the isdiff column in the database should be false).
+ *
+ * Note: This migrator should only be executed if the R4359XWIKI1459 one has 
already been executed (i.e. if the
+ * database is in version < 4360). This is because this current migrator is 
because of a bug in R4359XWIKI1459 which
+ * has now been fixed.  
+ * 
+ * @version $Id: $
+ */
+public class R6079XWIKI1878Migrator extends R4359XWIKI1459Migrator
+{
+    /** logger. */
+    private static final Log LOG = 
LogFactory.getLog(R6079XWIKI1878Migrator.class);
+
+    private int previousVersion;
+
+    public R6079XWIKI1878Migrator(int currentVersionBeforeMigratorsExecute)
+    {
+        this.previousVersion = currentVersionBeforeMigratorsExecute;
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     * @see 
com.xpn.xwiki.store.migration.hibernate.AbstractXWikiHibernateMigrator#getName()
+     */
+    public String getName()
+    {
+        return "R6079XWIKI1878";
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     * @see AbstractXWikiHibernateMigrator#getDescription()
+     */
+    public String getDescription()
+    {
+        return "See http://jira.xwiki.org/jira/browse/XWIKI-1878";;
+    }
+
+    /** [EMAIL PROTECTED] */
+    public XWikiDBVersion getVersion()
+    {
+        return new XWikiDBVersion(6079);
+    }
+
+    /** [EMAIL PROTECTED] */
+    public void migrate(XWikiHibernateMigrationManager manager, final 
XWikiContext context) throws XWikiException
+    {
+        if (this.previousVersion >= 4360) {
+            super.migrate(manager, context, LOG);
+        }
+    }
+}


Property changes on: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/R6079XWIKI1878Migrator.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/XWikiHibernateMigrationManager.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/XWikiHibernateMigrationManager.java
      2007-11-26 15:07:13 UTC (rev 6078)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/migration/hibernate/XWikiHibernateMigrationManager.java
      2007-11-26 15:46:57 UTC (rev 6079)
@@ -79,12 +79,14 @@
         });
     }
     /** [EMAIL PROTECTED] */
-    protected List getAllMigrations(XWikiContext context) {
+    protected List getAllMigrations(XWikiContext context) throws XWikiException
+    {
         List result = new ArrayList();
         // TODO: how to register migrations?
         // 1st way:
         result.add(new R4340XWIKI883Migrator());
         result.add(new R4359XWIKI1459Migrator());
+        result.add(new 
R6079XWIKI1878Migrator(getDBVersion(context).getVersion()));
         // 2nd way - via classloader
         
         return result;

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to