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 2010/12/12 13:24:50 UTC
svn commit: r1044803 - in /incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH:
ChangeLog src/com/ecyrd/jspwiki/Release.java
src/com/ecyrd/jspwiki/content/PageRenamer.java
Author: metskem
Date: Sun Dec 12 12:24:50 2010
New Revision: 1044803
URL: http://svn.apache.org/viewvc?rev=1044803&view=rev
Log:
* 2.8.5-svn-4 * JSPWIKI-671: WikiPageRenameEvent not fired during page rename.
Modified:
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/PageRenamer.java
Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog?rev=1044803&r1=1044802&r2=1044803&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog Sun Dec 12 12:24:50 2010
@@ -1,3 +1,9 @@
+2010-12-12 Harry Metske <me...@apache.org>
+
+ * 2.8.5-svn-4
+
+ * JSPWIKI-671: WikiPageRenameEvent not fired during page rename.
+
2010-12-05 Dirk Frederickx <br...@apache.org>
* v2.8.5-svn-3
Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java?rev=1044803&r1=1044802&r2=1044803&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java Sun Dec 12 12:24:50 2010
@@ -77,7 +77,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/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/PageRenamer.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/PageRenamer.java?rev=1044803&r1=1044802&r2=1044803&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/PageRenamer.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/content/PageRenamer.java Sun Dec 12 12:24:50 2010
@@ -30,6 +30,8 @@ import org.apache.log4j.Logger;
import com.ecyrd.jspwiki.*;
import com.ecyrd.jspwiki.attachment.Attachment;
+import com.ecyrd.jspwiki.event.WikiEventManager;
+import com.ecyrd.jspwiki.event.WikiPageRenameEvent;
import com.ecyrd.jspwiki.parser.JSPWikiMarkupParser;
import com.ecyrd.jspwiki.parser.MarkupParser;
import com.ecyrd.jspwiki.providers.ProviderException;
@@ -58,10 +60,10 @@ public class PageRenamer
* @return The final new name (in case it had to be modified)
* @throws WikiException If the page cannot be renamed.
*/
- public String renamePage( WikiContext context,
- String renameFrom,
- String renameTo,
- boolean changeReferrers )
+ public String renamePage(final WikiContext context,
+ final String renameFrom,
+ final String renameTo,
+ final boolean changeReferrers )
throws WikiException
{
//
@@ -80,9 +82,9 @@ public class PageRenamer
// Clean up the "to" -name so that it does not contain anything illegal
//
- renameTo = MarkupParser.cleanLink( renameTo.trim() );
+ String renameToClean = MarkupParser.cleanLink( renameTo.trim() );
- if( renameTo.equals(renameFrom) )
+ if( renameToClean.equals(renameFrom) )
{
throw new WikiException( "You cannot rename the page to itself" );
}
@@ -98,11 +100,11 @@ public class PageRenamer
throw new WikiException("No such page "+renameFrom);
}
- WikiPage toPage = engine.getPage( renameTo );
+ WikiPage toPage = engine.getPage( renameToClean );
if( toPage != null )
{
- throw new WikiException("Page already exists "+renameTo);
+ throw new WikiException( "Page already exists " + renameToClean );
}
//
@@ -120,11 +122,11 @@ public class PageRenamer
// all of the attachments
//
- engine.getPageManager().getProvider().movePage( renameFrom, renameTo );
+ engine.getPageManager().getProvider().movePage( renameFrom, renameToClean );
if( engine.getAttachmentManager().attachmentsEnabled() )
{
- engine.getAttachmentManager().getCurrentProvider().moveAttachmentsForPage( renameFrom, renameTo );
+ engine.getAttachmentManager().getCurrentProvider().moveAttachmentsForPage( renameFrom, renameToClean );
}
//
@@ -132,7 +134,7 @@ public class PageRenamer
// to the repo with no actual change.
//
- toPage = engine.getPage( renameTo );
+ toPage = engine.getPage( renameToClean );
if( toPage == null ) throw new InternalWikiException("Rename seems to have failed for some strange reason - please check logs!");
@@ -161,17 +163,20 @@ public class PageRenamer
//
engine.getSearchManager().reindexPage(toPage);
+ @SuppressWarnings( "unchecked" )
Collection<Attachment> attachments = engine.getAttachmentManager().listAttachments( toPage );
for (Attachment att:attachments)
{
engine.getSearchManager().reindexPage(att);
}
+ // Currently not used internally by JSPWiki itself, but you can use it for something else.
+ WikiEventManager.fireEvent( this, new WikiPageRenameEvent( this, renameFrom, renameToClean ) );
//
// Done, return the new name.
//
- return renameTo;
+ return renameToClean;
}
/**
@@ -182,7 +187,6 @@ public class PageRenamer
* @param fromPage The old page
* @param toPage The new page
*/
- @SuppressWarnings("unchecked")
private void updateReferrers( WikiContext context, WikiPage fromPage, WikiPage toPage, Set<String>referrers )
{
WikiEngine engine = context.getEngine();
@@ -233,15 +237,18 @@ public class PageRenamer
{
Set<String> referrers = new TreeSet<String>();
+ @SuppressWarnings( "unchecked" )
Collection<String> r = engine.getReferenceManager().findReferrers( fromPage.getName() );
if( r != null ) referrers.addAll( r );
try
{
+ @SuppressWarnings( "unchecked" )
Collection<Attachment> attachments = engine.getAttachmentManager().listAttachments( fromPage );
for( Attachment att : attachments )
{
+ @SuppressWarnings( "unchecked" )
Collection<String> c = engine.getReferenceManager().findReferrers(att.getName());
if( c != null ) referrers.addAll(c);