Author: jalkanen
Date: Thu Nov 26 22:24:28 2009
New Revision: 884713

URL: http://svn.apache.org/viewvc?rev=884713&view=rev
Log:
Oops, checkin() was checking in pages with the same page version all the time.

Modified:
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java

Modified: 
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java?rev=884713&r1=884712&r2=884713&view=diff
==============================================================================
--- 
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java 
(original)
+++ 
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java 
Thu Nov 26 22:24:28 2009
@@ -405,6 +405,7 @@
      *  
      *  @param page
      *  @throws RepositoryException 
+     *  @throws ItemExistsException If the version already exists.
      */
     private void checkin( String path, int currentVersion ) throws 
RepositoryException
     {
@@ -429,7 +430,14 @@
                 versions = nd.getNode( WIKI_VERSIONS );
             }
             
-            Node newVersion = versions.addNode( Integer.toString( 
currentVersion ) );
+            String versionName = Integer.toString( currentVersion );
+            
+            if( versions.hasNode( versionName ) )
+            {
+                throw new ItemExistsException("Version already exists: 
"+currentVersion+". This is a JSPWiki internal error, please report!");
+            }
+            
+            Node newVersion = versions.addNode( versionName );
             
             newVersion.addMixin( "mix:referenceable" );
             
@@ -492,7 +500,9 @@
 
         int version = page.getVersion();
         
-        nd.setProperty( JCRWikiPage.ATTR_VERSION, version+1 );
+        version++; // New version is always one newer.
+        
+        nd.setProperty( JCRWikiPage.ATTR_VERSION, version );
         
         if( !nd.hasProperty( JCRWikiPage.ATTR_CREATED ) )
         {
@@ -1453,7 +1463,8 @@
         }
         page.setAttribute( WikiPage.CHANGENOTE, fromPage.toString() + " ==> " 
+ toPage.toString() );
         page.setAuthor( context.getCurrentUser().getName() );
-
+        page.setAttribute( JCRWikiPage.ATTR_TITLE, renameTo );
+        
         // Tell everyone we moved the page
         fireEvent( ContentEvent.NODE_RENAMED, toPage.toString(), 
fromPage.toString(), Boolean.valueOf( changeReferrers ) );
         


Reply via email to