jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mets...@apache.org
Subject svn commit: r1416167 - in /incubator/jspwiki/trunk: ./ src/org/apache/wiki/ src/org/apache/wiki/plugin/ tests/org/apache/wiki/ tests/org/apache/wiki/plugin/
Date Sun, 02 Dec 2012 12:49:16 GMT
Author: metskem
Date: Sun Dec  2 12:49:14 2012
New Revision: 1416167

URL: http://svn.apache.org/viewvc?rev=1416167&view=rev
Log:
2012-12-02   Harry Metske <metskem@apache.org>
       
       * 2.9.1-svn-1
       
       * fixed JSPWIKI-665 Page View Plugin and page renames and deletions (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/plugin/PageViewPlugin.java
    incubator/jspwiki/trunk/tests/org/apache/wiki/TestEngine.java
    incubator/jspwiki/trunk/tests/org/apache/wiki/plugin/PageViewPluginTest.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=1416167&r1=1416166&r2=1416167&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sun Dec  2 12:49:14 2012
@@ -1,4 +1,10 @@
-2012-11-22  Florian Holeczek (florianh AT apache DOT org)
+2012-12-02   Harry Metske <metskem@apache.org>
+       
+       * 2.9.1-svn-1
+       
+       * fixed JSPWIKI-665 Page View Plugin and page renames and deletions (thanks to Glen
Mazza)
+       
+ 2012-11-22  Florian Holeczek (florianh AT apache DOT org)
 
        * version switch to 2.9.1-svn-0
 

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=1416167&r1=1416166&r2=1416167&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/Release.java Sun Dec  2 12:49:14 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         = "0";
+    public static final String     BUILD         = "1";
     
     /**
      *  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=1416167&r1=1416166&r2=1416167&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/WikiEngine.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/WikiEngine.java Sun Dec  2 12:49:14 2012
@@ -48,6 +48,7 @@ import org.apache.wiki.diff.DifferenceMa
 import org.apache.wiki.event.WikiEngineEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
+import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.filters.FilterException;
 import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.i18n.InternationalizationManager;
@@ -2182,6 +2183,7 @@ public class WikiEngine
                     }
                 }
                 m_pageManager.deletePage( p );
+                firePageEvent( WikiPageEvent.PAGE_DELETED, pageName );
             }
         }
     }
@@ -2411,6 +2413,18 @@ public class WikiEngine
     }
 
     /**
+     * Fires a WikiPageEvent to all registered listeners.
+     * @param type  the event type
+     */
+    protected final void firePageEvent( int type, String pageName )
+    {
+        if ( WikiEventManager.isListening(this) )
+        {
+            WikiEventManager.fireEvent(this,new WikiPageEvent(this,type,pageName));
+        }
+    }
+
+    /**
      * 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/plugin/PageViewPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java?rev=1416167&r1=1416166&r2=1416167&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/plugin/PageViewPlugin.java Sun Dec  2 12:49:14
2012
@@ -42,6 +42,7 @@ import org.apache.wiki.WikiPage;
 import org.apache.wiki.event.WikiEngineEvent;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
+import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.plugin.InitializablePlugin;
 import org.apache.wiki.plugin.PluginException;
 import org.apache.wiki.plugin.PluginManager;
@@ -139,11 +140,9 @@ public class PageViewPlugin extends Abst
         {
             if( c_singleton == null )
             {
-
                 c_singleton = new PageViewManager(  );
-
-                c_singleton.initialize( engine );
             }
+            c_singleton.initialize( engine );
         }
     }
 
@@ -289,6 +288,12 @@ public class PageViewPlugin extends Abst
                     log.info( "Detected wiki engine shutdown" );
                     handleShutdown();
                 }
+            } 
+            else if( (event instanceof WikiPageEvent) && (event.getType() == WikiPageEvent.PAGE_DELETED)
)
+            {
+                 String pageName = ((WikiPageEvent) event).getPageName();
+                 m_storage.remove(pageName);
+                 m_counters.remove(pageName);
             }
         }
 

Modified: incubator/jspwiki/trunk/tests/org/apache/wiki/TestEngine.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/org/apache/wiki/TestEngine.java?rev=1416167&r1=1416166&r2=1416167&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/org/apache/wiki/TestEngine.java (original)
+++ incubator/jspwiki/trunk/tests/org/apache/wiki/TestEngine.java Sun Dec  2 12:49:14 2012
@@ -36,6 +36,7 @@ import org.apache.wiki.auth.Authenticati
 import org.apache.wiki.auth.SessionMonitor;
 import org.apache.wiki.auth.Users;
 import org.apache.wiki.auth.WikiSecurityException;
+import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.providers.AbstractFileProvider;
 import org.apache.wiki.providers.BasicAttachmentProvider;
 import org.apache.wiki.providers.FileSystemProvider;
@@ -254,6 +255,38 @@ public class TestEngine extends WikiEngi
     }
 
     /**
+     *  Removes a page, but not any auxiliary information.  Works only
+     *  with FileSystemProvider.
+     */
+    public void nonStaticDeleteTestPage( String name )
+    {
+        Properties properties = new Properties();
+
+        try
+        {
+            properties.load( findTestProperties() );
+            String files = properties.getProperty( FileSystemProvider.PROP_PAGEDIR );
+
+            File f = new File( files, mangleName(name)+FileSystemProvider.FILE_EXT );
+
+            f.delete();
+
+            // Remove the property file, too
+            f = new File( files, mangleName(name)+".properties" );
+
+            if( f.exists() )
+                f.delete();
+            
+            deleteAttachments( name );
+            firePageEvent( WikiPageEvent.PAGE_DELETED, name );
+        }
+        catch( Exception e )
+        {
+            log.error("Couldn't delete "+name, e );
+        }
+    }
+
+    /**
      *  Deletes all attachments related to the given page.
      */
     public static void deleteAttachments( String page )

Modified: incubator/jspwiki/trunk/tests/org/apache/wiki/plugin/PageViewPluginTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/org/apache/wiki/plugin/PageViewPluginTest.java?rev=1416167&r1=1416166&r2=1416167&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/org/apache/wiki/plugin/PageViewPluginTest.java (original)
+++ incubator/jspwiki/trunk/tests/org/apache/wiki/plugin/PageViewPluginTest.java Sun Dec 
2 12:49:14 2012
@@ -39,25 +39,9 @@ public class PageViewPluginTest extends 
 
     PluginManager manager;
 
-    /*
-     * Constructor is part of a workaround for execution ordering of the tests
-     */
-    public PageViewPluginTest ( String testName )
-    {
-        super( testName );
-    }
-
-    /*
-     * Second part of the workaround for execution ordering of the tests
-     */
     public static Test suite()
     {
-        TestSuite ts = new TestSuite();
-        ts.addTest( new PageViewPluginTest( "testShowCountsBasic" ) );
-        ts.addTest( new PageViewPluginTest( "testShowCountsExclude" ) );
-        ts.addTest( new PageViewPluginTest( "testShowCountsSorted" ) );
-        ts.addTest( new PageViewPluginTest( "testShowCountEntries" ) );
-        return ts;
+        return new TestSuite( PageViewPluginTest.class );
     }
 
     public void setUp() throws Exception
@@ -75,9 +59,9 @@ public class PageViewPluginTest extends 
 
     public void tearDown()
     {
-        TestEngine.deleteTestPage( "TestPage01" );
-        TestEngine.deleteTestPage( "TestPage02" );
-        TestEngine.deleteTestPage( "PageViews" );
+        testEngine.nonStaticDeleteTestPage( "TestPage01" );
+        testEngine.nonStaticDeleteTestPage( "TestPage02" );
+        testEngine.nonStaticDeleteTestPage( "PageViews" );
         TestEngine.emptyWorkDir();
     }
 
@@ -137,7 +121,7 @@ public class PageViewPluginTest extends 
         // this page should not have been shown:
         assertFalse( result.contains( "Test Page Excluded" ) );
 
-        TestEngine.deleteTestPage( "TestPageExcluded" );
+        testEngine.nonStaticDeleteTestPage( "TestPageExcluded" );
     }
 
     public void testShowCountsSorted() throws Exception
@@ -205,8 +189,8 @@ public class PageViewPluginTest extends 
 
         assertFalse( result.contains( "Test Page 04" ) );
         
-        TestEngine.deleteTestPage( "TestPage03" );
-        TestEngine.deleteTestPage( "TestPage04" );
+        testEngine.nonStaticDeleteTestPage( "TestPage03" );
+        testEngine.nonStaticDeleteTestPage( "TestPage04" );
     }
 
 }



Mime
View raw message