You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by me...@apache.org on 2012/12/26 12:19:34 UTC

svn commit: r1425880 - in /incubator/jspwiki/trunk: ChangeLog src/org/apache/wiki/Release.java src/org/apache/wiki/content/PageRenamer.java src/org/apache/wiki/plugin/PageViewPlugin.java

Author: metskem
Date: Wed Dec 26 11:19:33 2012
New Revision: 1425880

URL: http://svn.apache.org/viewvc?rev=1425880&view=rev
Log:
2012-12-26  Harry Metske <me...@apache.org>

       * 2.9.1-svn-7
        
       * fixed JSPWIKI-663 (Christmas 2012 patch, thanks to Glen Mazza),
          Rename page - page index still shows attachment with old page name, also patched the 
          WikiPageRenameEvent handling code in PageViewPlugin 
 

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/src/org/apache/wiki/content/PageRenamer.java
    incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=1425880&r1=1425879&r2=1425880&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Wed Dec 26 11:19:33 2012
@@ -1,3 +1,11 @@
+2012-12-26  Harry Metske <me...@apache.org>
+
+       * 2.9.1-svn-7
+        
+       * fixed JSPWIKI-663 (Christmas 2012 patch, thanks to Glen Mazza),
+          Rename page - page index still shows attachment with old page name, also patched the 
+          WikiPageRenameEvent handling code in PageViewPlugin 
+ 
 2012-12-14  Juan Pablo Santos (juanpablo AT apache DOT org)
 
        * 2.9.1-svn-6

Modified: incubator/jspwiki/trunk/src/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/Release.java?rev=1425880&r1=1425879&r2=1425880&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/Release.java Wed Dec 26 11:19:33 2012
@@ -75,7 +75,7 @@ public final class Release
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "6";
+    public static final String     BUILD         = "7";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/org/apache/wiki/content/PageRenamer.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/content/PageRenamer.java?rev=1425880&r1=1425879&r2=1425880&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/content/PageRenamer.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/content/PageRenamer.java Wed Dec 26 11:19:33 2012
@@ -120,13 +120,22 @@ public class PageRenamer
         //  all of the attachments
         //
         
+        //  Remove references to attachments under old name
+        @SuppressWarnings( "unchecked" )
+        Collection<Attachment> attachmentsOldName = engine.getAttachmentManager().listAttachments( fromPage );
+        for (Attachment att:attachmentsOldName)
+        {
+            WikiPage fromAttPage = engine.getPage( att.getName() );
+            engine.getReferenceManager().pageRemoved( fromAttPage );
+        }
+
         engine.getPageManager().getProvider().movePage( renameFrom, renameToClean );
-        
+
         if( engine.getAttachmentManager().attachmentsEnabled() )
         {
             engine.getAttachmentManager().getCurrentProvider().moveAttachmentsForPage( renameFrom, renameToClean );
         }
-
+        
         //
         //  Add a comment to the page notifying what changed.  This adds a new revision
         //  to the repo with no actual change.
@@ -157,14 +166,17 @@ public class PageRenamer
         }
 
         //
-        //  re-index the page 
+        //  re-index the page including its attachments
         //
         engine.getSearchManager().reindexPage(toPage);
         
         @SuppressWarnings( "unchecked" )
-        Collection<Attachment> attachments = engine.getAttachmentManager().listAttachments( toPage );
-        for (Attachment att:attachments)
+        Collection<Attachment> attachmentsNewName = engine.getAttachmentManager().listAttachments( toPage );
+        for (Attachment att:attachmentsNewName)
         {
+            WikiPage toAttPage = engine.getPage( att.getName() );
+            // add reference to attachment under new page name
+            engine.updateReferences( toAttPage );
             engine.getSearchManager().reindexPage(att);
         }
 

Modified: incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java?rev=1425880&r1=1425879&r2=1425880&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java Wed Dec 26 11:19:33 2012
@@ -267,14 +267,17 @@ public class PageViewPlugin extends Abst
             } 
             else if( (event instanceof WikiPageRenameEvent) && (event.getType() == WikiPageRenameEvent.PAGE_RENAMED) )
             {
-                 String oldPageName = ((WikiPageRenameEvent) event).getOldPageName();
-                 String newPageName = ((WikiPageRenameEvent) event).getNewPageName();
-                 m_storage.remove(oldPageName);
-                 Counter oldCounter = m_counters.get( oldPageName );
-                 m_counters.put( newPageName, oldCounter );
-                 m_storage.setProperty( newPageName, oldCounter.toString() );
-                 m_counters.remove(oldPageName);
-                 m_dirty = true;
+                String oldPageName = ((WikiPageRenameEvent) event).getOldPageName();
+                String newPageName = ((WikiPageRenameEvent) event).getNewPageName();
+                Counter oldCounter = m_counters.get(oldPageName);
+                if ( oldCounter != null )
+                {
+                    m_storage.remove(oldPageName);
+                    m_counters.put(newPageName, oldCounter);
+                    m_storage.setProperty(newPageName, oldCounter.toString());
+                    m_counters.remove(oldPageName);
+                    m_dirty = true;
+                }
             }
             else if( (event instanceof WikiPageEvent) && (event.getType() == WikiPageEvent.PAGE_DELETED) )
             {