jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mets...@apache.org
Subject svn commit: r1418640 - in /incubator/jspwiki/trunk: ChangeLog src/org/apache/wiki/Release.java src/org/apache/wiki/WikiEngine.java src/org/apache/wiki/event/WikiPageRenameEvent.java src/org/apache/wiki/plugin/PageViewPlugin.java
Date Sat, 08 Dec 2012 10:44:44 GMT
Author: metskem
Date: Sat Dec  8 10:44:42 2012
New Revision: 1418640

URL: http://svn.apache.org/viewvc?rev=1418640&view=rev
Log:
2012-12-08  Harry Metske <metskem@apache.org>

       * 2.9.1-svn-4
       
       * fixed JSPWIKI-754 Have PageViewPlugin work with page renames (thanks to Glen Mazza)

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/src/org/apache/wiki/WikiEngine.java
    incubator/jspwiki/trunk/src/org/apache/wiki/event/WikiPageRenameEvent.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=1418640&r1=1418639&r2=1418640&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sat Dec  8 10:44:42 2012
@@ -1,3 +1,9 @@
+2012-12-08  Harry Metske <metskem@apache.org>
+
+       * 2.9.1-svn-4
+       
+       * fixed JSPWIKI-754 Have PageViewPlugin work with page renames (thanks to Glen Mazza)
+       
 2012-12-06  Juan Pablo Santos (juanpablo AT apache DOT org)
 
        * 2.9.1-svn-3

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=1418640&r1=1418639&r2=1418640&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/Release.java Sat Dec  8 10:44:42 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         = "3";
+    public static final String     BUILD         = "4";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/org/apache/wiki/WikiEngine.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/WikiEngine.java?rev=1418640&r1=1418639&r2=1418640&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/WikiEngine.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/WikiEngine.java Sat Dec  8 10:44:42 2012
@@ -49,6 +49,7 @@ import org.apache.wiki.event.WikiEngineE
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
+import org.apache.wiki.event.WikiPageRenameEvent;
 import org.apache.wiki.filters.FilterException;
 import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.i18n.InternationalizationManager;
@@ -2278,7 +2279,9 @@ public class WikiEngine
                               boolean changeReferrers)
         throws WikiException
     {
-        return m_pageRenamer.renamePage(context, renameFrom, renameTo, changeReferrers);
+        String newPageName = m_pageRenamer.renamePage(context, renameFrom, renameTo, changeReferrers);
+        firePageRenameEvent(renameFrom, newPageName);
+        return newPageName;
     }
 
     /**
@@ -2425,6 +2428,19 @@ public class WikiEngine
     }
 
     /**
+     * Fires a WikiPageRenameEvent to all registered listeners.
+     * @param oldName the former page name
+     * @param newName the new page name
+     */
+    protected final void firePageRenameEvent(String oldName, String newName )
+    {
+        if ( WikiEventManager.isListening(this) )
+        {
+            WikiEventManager.fireEvent(this,new WikiPageRenameEvent(this,oldName,newName));
+        }
+    }
+
+    /**
      * Adds an attribute to the engine for the duration of this engine.  The
      * value is not persisted.
      *

Modified: incubator/jspwiki/trunk/src/org/apache/wiki/event/WikiPageRenameEvent.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/event/WikiPageRenameEvent.java?rev=1418640&r1=1418639&r2=1418640&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/event/WikiPageRenameEvent.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/event/WikiPageRenameEvent.java Sat Dec  8
10:44:42 2012
@@ -86,7 +86,7 @@ public class WikiPageRenameEvent extends
      */
     public static boolean isValidType( int type )
     {
-        return type >= PAGE_LOCK && type <= PAGE_RENAMED;
+        return type == PAGE_RENAMED;
     }
 
 

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=1418640&r1=1418639&r2=1418640&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java Sat Dec  8 10:44:42
2012
@@ -43,6 +43,7 @@ import org.apache.wiki.event.WikiEngineE
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiPageEvent;
+import org.apache.wiki.event.WikiPageRenameEvent;
 import org.apache.wiki.plugin.InitializablePlugin;
 import org.apache.wiki.plugin.PluginException;
 import org.apache.wiki.plugin.PluginManager;
@@ -289,6 +290,17 @@ public class PageViewPlugin extends Abst
                     handleShutdown();
                 }
             } 
+            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;
+            }
             else if( (event instanceof WikiPageEvent) && (event.getType() == WikiPageEvent.PAGE_DELETED)
)
             {
                  String pageName = ((WikiPageEvent) event).getPageName();
@@ -406,6 +418,13 @@ public class PageViewPlugin extends Abst
                     else if( PARAM_COUNT.equals( show ) )
                     {
                         // show page count
+                        if( counter == null )
+                        {
+                            counter = new Counter();
+                            m_counters.put( pagename, counter );
+                            m_storage.setProperty( pagename, counter.toString() );
+                            m_dirty = true;
+                        }
                         result = counter.toString();
 
                     }



Mime
View raw message