Return-Path: Delivered-To: apmail-incubator-jspwiki-commits-archive@minotaur.apache.org Received: (qmail 44031 invoked from network); 8 May 2009 03:41:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 May 2009 03:41:19 -0000 Received: (qmail 95884 invoked by uid 500); 8 May 2009 03:41:19 -0000 Delivered-To: apmail-incubator-jspwiki-commits-archive@incubator.apache.org Received: (qmail 95868 invoked by uid 500); 8 May 2009 03:41:19 -0000 Mailing-List: contact jspwiki-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jspwiki-dev@incubator.apache.org Delivered-To: mailing list jspwiki-commits@incubator.apache.org Received: (qmail 95859 invoked by uid 99); 8 May 2009 03:41:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 May 2009 03:41:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 May 2009 03:41:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A9427238898F; Fri, 8 May 2009 03:40:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r772833 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/content/ src/java/org/apache/wiki/plugin/ tests/java/org/apache/wiki/plugin/ Date: Fri, 08 May 2009 03:40:51 -0000 To: jspwiki-commits@incubator.apache.org From: ajaquith@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090508034052.A9427238898F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ajaquith Date: Fri May 8 03:40:50 2009 New Revision: 772833 URL: http://svn.apache.org/viewvc?rev=772833&view=rev Log: Fixed various plugins that were broken, particularly AbstractFilteredPlugin which did not know now to handle page names without spaces. We treat this as meaning the default space. Minor method signature changes from Collection to List in WikiEngine and ContentManager. Pass rate is now 95.5%, not counting the JCR Property-related file issue noted in build 110. Modified: incubator/jspwiki/trunk/ChangeLog incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/IndexPlugin.java incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/RecentChangesPlugin.java incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferredPagesPlugin.java incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UnusedPagesPlugin.java incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/RecentChangesPluginTest.java incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/ReferredPagesPluginTest.java Modified: incubator/jspwiki/trunk/ChangeLog URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/ChangeLog (original) +++ incubator/jspwiki/trunk/ChangeLog Fri May 8 03:40:50 2009 @@ -1,3 +1,13 @@ +2009-05-07 Andrew Jaquith + + * 3.0.0-svn-113 + + * Fixed various plugins that were broken, particularly AbstractFilteredPlugin + which did not know now to handle page names without spaces. We treat + this as meaning the default space. Minor method signature changes from + Collection to List in WikiEngine and ContentManager. Pass rate is now + 95.5%, not counting the JCR Property-related file issue noted in build 110. + 2009-05-05 Andrew Jaquith * 3.0.0-svn-112 Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original) +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Fri May 8 03:40:50 2009 @@ -77,7 +77,7 @@ *

* If the build identifier is empty, it is not added. */ - public static final String BUILD = "111"; + public static final String BUILD = "113"; /** * This is the generic version string you should use Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java (original) +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java Fri May 8 03:40:50 2009 @@ -164,6 +164,8 @@ /** If this property is set to false, we don't allow the creation of empty pages */ public static final String PROP_ALLOW_CREATION_OF_EMPTY_PAGES = "jspwiki.allowCreationOfEmptyPages"; + private static final Comparator PAGE_TIME_COMPARATOR = new PageTimeComparator(); + /** Should the user info be saved with the page data as well? */ private boolean m_saveUserInfo = true; @@ -1787,30 +1789,23 @@ } /** - * Returns a Collection of WikiPages, sorted in time + * Returns a List of WikiPages, sorted in time * order of last change (i.e. first object is the most * recently changed). This method also includes attachments. * * @param space The WikiSpace for which you want to have the * Recent Changes for. - * @return Collection of WikiPage objects. In reality, the returned - * collection is a Set, but due to API compatibility reasons, - * we're not changing the signature soon... + * @return List of WikiPage objects */ - // FIXME: Should really get a Date object and do proper comparisons. // This is terribly wasteful. - public Collection getRecentChanges(String space) + public List getRecentChanges(String space) { try { - Collection pages = m_contentManager.getAllPages(space); - - TreeSet sortedPages = new TreeSet( new PageTimeComparator() ); - - sortedPages.addAll( pages ); - - return sortedPages; + List pages = m_contentManager.getAllPages(space); + Collections.sort( pages, PAGE_TIME_COMPARATOR ); + return pages; } catch( ProviderException e ) { 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=772833&r1=772832&r2=772833&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 Fri May 8 03:40:50 2009 @@ -444,10 +444,10 @@ * @throws ProviderException If the backend has problems. */ - public Collection getAllPages( String space ) + public List getAllPages( String space ) throws ProviderException { - Set result = new TreeSet(); + List results = new ArrayList(); try { Session session = m_sessionManager.getSession(); @@ -465,7 +465,11 @@ // Hack to make sure we don't add the space root node. if( !isSpaceRoot(n) ) { - result.add( new JCRWikiPage( getEngine(), n ) ); + WikiPage page = new JCRWikiPage( getEngine(), n ); + if ( !results.contains( page ) ) + { + results.add( page ); + } } } } @@ -478,7 +482,7 @@ throw new ProviderException("getAllPages()",e); } - return result; + return results; } /** Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java (original) +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java Fri May 8 03:40:50 2009 @@ -32,6 +32,7 @@ import org.apache.wiki.WikiEngine; import org.apache.wiki.api.PluginException; import org.apache.wiki.api.WikiPage; +import org.apache.wiki.content.ContentManager; import org.apache.wiki.content.PageNotFoundException; import org.apache.wiki.content.WikiPath; import org.apache.wiki.log.Logger; @@ -110,8 +111,8 @@ protected String m_separator = ""; // null not blank protected String m_after = "\\\\"; - protected Pattern[] m_exclude; - protected Pattern[] m_include; + protected Pattern[] m_exclude = new Pattern[]{ Pattern.compile( "^$" )}; + protected Pattern[] m_include = new Pattern[]{ Pattern.compile( ".*" )}; protected boolean m_showAttachments = true; protected String m_show = "pages"; @@ -179,8 +180,9 @@ for( int i = 0; i < ptrns.length; i++ ) { + String pattern = sanitizePattern( ptrns[i] ); m_exclude[i] = Pattern - .compile( RegExpUtil.globToPerl5( ptrns[i].toCharArray(), + .compile( RegExpUtil.globToPerl5( pattern.toCharArray(), RegExpUtil.DEFAULT_MASK ) ); } } @@ -205,8 +207,9 @@ for( int i = 0; i < ptrns.length; i++ ) { + String pattern = sanitizePattern( ptrns[i] ); m_include[i] = Pattern - .compile( RegExpUtil.globToPerl5( ptrns[i].toCharArray(), + .compile( RegExpUtil.globToPerl5( pattern.toCharArray(), RegExpUtil.DEFAULT_MASK ) ); } } @@ -254,7 +257,7 @@ * @param items The collection to filter. * @return A filtered collection. */ - protected Collection filterCollection( Collection items ) + protected List filterCollection( List items ) { ArrayList filteredItems = new ArrayList(); @@ -263,7 +266,7 @@ String pageName = null; if( item instanceof WikiPage ) { - pageName = ((WikiPage) item).getName(); + pageName = ((WikiPage) item).getPath().toString(); } else if ( item instanceof WikiPath ) { @@ -353,6 +356,57 @@ } /** + * Sanitizes a user-supplied include/exclude pattern. + * If all characters before the first colon are letters, + * numbers or spaces, we need to prepend the + * default wiki space for backwards compatibility. + * @param pattern the pattern + * @return the sanitized pattern + */ + protected static String sanitizePattern( String pattern ) + { + boolean hasSpace = false; + boolean nameIsPrefix = false; + for ( int i = 0; i < pattern.length(); i++ ) + { + char ch = pattern.charAt( i ); + if ( ch ==32 || + ( ch >=48 && ch <= 57 ) || + ( ch >=65 && ch <= 90 ) || + ( ch >=97 && ch <= 122 ) ) + { + nameIsPrefix = true; + } + else if ( i > 0 && nameIsPrefix && ch == ':' ) + { + // Make sure we add in an escape char (\) in front of the colon + if ( pattern.charAt( i - 1 ) == '\\' ) + { + hasSpace = true; + break; + } + else + { + pattern = pattern.substring( 0, i ) + pattern.substring( i, pattern.length() ); + hasSpace = true; + break; + } + } + else if ( nameIsPrefix ) + { + hasSpace = false; + break; + } + else + { + break; + } + } + + return ( nameIsPrefix && !hasSpace ) ? ContentManager.DEFAULT_SPACE + ":" + pattern : pattern; + } + + /** * Makes WikiText from a Collection. * * @param links Collection to make into WikiText. @@ -386,7 +440,8 @@ output.append( m_before ); // Make a Wiki markup link. See TranslatorReader. - output.append( "[" + m_engine.beautifyTitle(value) + "|" + value + "]" ); + String page = ContentManager.DEFAULT_SPACE.equals( value.getSpace() ) ? value.getPath() : value.toString(); + output.append( "[" + m_engine.beautifyTitle(value) + "|" + page + "]" ); count++; } Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/IndexPlugin.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/IndexPlugin.java?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/IndexPlugin.java (original) +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/IndexPlugin.java Fri May 8 03:40:50 2009 @@ -129,7 +129,7 @@ private List listPages( WikiContext context ) throws ProviderException { ArrayList result = new ArrayList(); - Collection pages = context.getEngine().getContentManager().getAllPages( ContentManager.DEFAULT_SPACE ); + List pages = context.getEngine().getContentManager().getAllPages( ContentManager.DEFAULT_SPACE ); pages = super.filterCollection( pages ); for( WikiPage page : pages ) Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/RecentChangesPlugin.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/RecentChangesPlugin.java?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/RecentChangesPlugin.java (original) +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/RecentChangesPlugin.java Fri May 8 03:40:50 2009 @@ -107,7 +107,7 @@ // FIXME: Should really have a since date on the getRecentChanges // method. - Collection changes = engine.getRecentChanges(context.getPage().getWiki()); + List changes = engine.getRecentChanges(context.getPage().getWiki()); super.initialize( context, params ); changes = super.filterCollection( changes ); @@ -127,7 +127,7 @@ { Date lastmod = pageref.getLastModified(); - if( lastmod.before( sincedate.getTime() ) ) + if( lastmod == null || lastmod.before( sincedate.getTime() ) ) { break; } Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferredPagesPlugin.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferredPagesPlugin.java?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferredPagesPlugin.java (original) +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferredPagesPlugin.java Fri May 8 03:40:50 2009 @@ -21,11 +21,14 @@ package org.apache.wiki.plugin; import java.util.*; +import java.util.regex.Pattern; import org.apache.wiki.*; import org.apache.wiki.api.PluginException; import org.apache.wiki.api.WikiPage; +import org.apache.wiki.content.ContentManager; import org.apache.wiki.content.PageNotFoundException; +import org.apache.wiki.content.WikiPath; import org.apache.wiki.log.Logger; import org.apache.wiki.log.LoggerFactory; import org.apache.wiki.providers.ProviderException; @@ -52,7 +55,7 @@ private static Logger log = LoggerFactory.getLogger( ReferredPagesPlugin.class ); private WikiEngine m_engine; private int m_depth; - private HashSet m_exists = new HashSet(); + private HashSet m_exists = new HashSet(); private StringBuilder m_result = new StringBuilder(1024); private boolean m_formatCompact = true; private boolean m_formatSort = false; @@ -96,11 +99,8 @@ m_depth = TextUtil.parseIntParameter( (String)params.get( PARAM_DEPTH ), MIN_DEPTH ); if( m_depth > MAX_DEPTH ) m_depth = MAX_DEPTH; - String includePattern = (String) params.get(PARAM_INCLUDE); - if( includePattern == null ) includePattern = ".*"; - - String excludePattern = (String) params.get(PARAM_EXCLUDE); - if( excludePattern == null ) excludePattern = "^$"; + String includePattern = filterString( m_include ); + String excludePattern = filterString( m_exclude ); log.debug( "Fetching referred pages for "+ rootname + " with a depth of "+ m_depth + @@ -116,11 +116,13 @@ "] format["+(m_formatCompact ? "compact" : "full") + (m_formatSort ? " sort" : "") + "]"; + WikiPath root = WikiPath.valueOf( rootname ); + String rootString = ContentManager.DEFAULT_SPACE.equals( root.getSpace() ) ? root.getPath() : root.toString(); m_result.append("

\n"); m_result.append("" + rootname + "\n"); - m_exists.add(rootname); + "\">" + rootString + "\n"); + m_exists.add(WikiPath.valueOf( rootname ) ); // pre compile all needed patterns // glob compiler : * is 0..n instance of any char -- more convenient as input @@ -130,7 +132,7 @@ // go get all referred links try { - getReferredPages(context,rootname, 0); + getReferredPages( context, WikiPath.valueOf( rootname ), 0); } catch(Exception e) { @@ -143,6 +145,19 @@ return m_result.toString() ; } + private String filterString( Pattern[] patterns ) + { + StringBuilder s = new StringBuilder(); + for ( int i = 0; i < patterns.length; i++ ) + { + s.append( patterns[i].pattern() ); + if ( i < patterns.length - 1 ) + { + s.append( ',' ); + } + } + return s.toString(); + } /** * Retrieves a list of all referred pages. Is called recursively @@ -151,46 +166,39 @@ * @throws ProviderException */ @SuppressWarnings("unchecked") - private void getReferredPages( WikiContext context, String pagename, int depth ) throws ProviderException, PageNotFoundException + private void getReferredPages( WikiContext context, WikiPath path, int depth ) throws ProviderException, PageNotFoundException { if( depth >= m_depth ) return; // end of recursion - if( pagename == null ) return; - if( !m_engine.pageExists(pagename) ) return; + if( path == null ) return; + + if( !m_engine.pageExists( path.toString() ) ) return; ReferenceManager mgr = m_engine.getReferenceManager(); - Collection pages = mgr.findRefersTo( pagename ); - if( pages != null ) + List pages = mgr.getRefersTo( path ); + if( pages != null && pages.size() > 0 ) { pages = super.filterCollection( pages ); } - handleLinks( context, pages, ++depth, pagename ); + handleLinks( context, pages, ++depth, path ); } - private void handleLinks(WikiContext context,Collection links, int depth, String pagename) throws ProviderException, PageNotFoundException + private void handleLinks(WikiContext context,List links, int depth, WikiPath path ) throws ProviderException, PageNotFoundException { boolean isUL = false; - HashSet localLinkSet = new HashSet(); // needed to skip multiple - // links to the same page - localLinkSet.add(pagename); - - ArrayList allLinks = new ArrayList(); + HashSet uniqueLinks = new HashSet(); // skip multiple links to same page + uniqueLinks.add( path ); - if( links != null ) - allLinks.addAll( links ); + if( m_formatSort ) Collections.sort(links); - if( m_formatSort ) Collections.sort(allLinks); - - for( String link : allLinks ) + for( WikiPath link : links ) { - if( localLinkSet.contains( link ) ) continue; // skip multiple - // links to the same - // page - localLinkSet.add( link ); + if( uniqueLinks.contains( link ) ) continue; // skip multiple links to same page + + uniqueLinks.add( link ); - if( !m_engine.pageExists( link ) ) continue; // hide links to non - // existing pages + if( !m_engine.pageExists( link.toString() ) ) continue; // hide links to non existing pages if( m_exists.contains( link ) ) { @@ -203,9 +211,7 @@ m_result.append("
  • " + link + "
  • \n"); - getReferredPages( context, link, depth ); // added recursive - // call - on general - // request + getReferredPages( context, link, depth ); // recursive } } else @@ -215,9 +221,9 @@ isUL = true; m_result.append("
      \n"); } - String href = context.getURL(WikiContext.VIEW,link); - m_result.append("
    • "+link+"
    • \n" ); - + String href = context.getURL(WikiContext.VIEW,link.toString()); + String linkString = ContentManager.DEFAULT_SPACE.equals( link.getSpace() ) ? link.getPath() : link.toString(); + m_result.append("
    • "+linkString+"
    • \n" ); m_exists.add( link ); getReferredPages( context, link, depth ); Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java (original) +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java Fri May 8 03:40:50 2009 @@ -21,7 +21,7 @@ package org.apache.wiki.plugin; import java.text.MessageFormat; -import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.ResourceBundle; @@ -93,7 +93,7 @@ { WikiPage page = context.getEngine().getPage( pageName ); - Collection links = refmgr.getReferredBy( page.getPath() ); + List links = refmgr.getReferredBy( page.getPath() ); String wikitext = ""; super.initialize( context, params ); Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java (original) +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java Fri May 8 03:40:50 2009 @@ -20,9 +20,7 @@ */ package org.apache.wiki.plugin; -import java.util.Collection; -import java.util.Map; -import java.util.TreeSet; +import java.util.*; import javax.jcr.RepositoryException; @@ -51,7 +49,7 @@ throws PluginException { ReferenceManager refmgr = context.getEngine().getReferenceManager(); - Collection links; + List links; try { links = refmgr.findUncreated(); @@ -64,11 +62,8 @@ super.initialize( context, params ); - TreeSet sortedSet = new TreeSet(); - links = filterCollection( links ); - - sortedSet.addAll( links ); + Collections.sort( links ); String wikitext = null; @@ -85,7 +80,7 @@ } else { - wikitext = wikitizeCollection(sortedSet, m_separator, ALL_ITEMS); + wikitext = wikitizeCollection(links, m_separator, ALL_ITEMS); } return makeHTML( context, wikitext ); Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UnusedPagesPlugin.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UnusedPagesPlugin.java?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UnusedPagesPlugin.java (original) +++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UnusedPagesPlugin.java Fri May 8 03:40:50 2009 @@ -20,10 +20,7 @@ */ package org.apache.wiki.plugin; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.TreeSet; +import java.util.*; import javax.jcr.RepositoryException; @@ -60,7 +57,7 @@ throws PluginException { ReferenceManager refmgr = context.getEngine().getReferenceManager(); - Collection links; + List links; try { links = refmgr.findUnreferenced(); @@ -91,11 +88,8 @@ super.initialize( context, params ); - TreeSet sortedSet = new TreeSet(); - links = filterCollection( links ); - - sortedSet.addAll( links ); + Collections.sort( links ); String wikitext = null; @@ -109,7 +103,7 @@ } else { - wikitext = wikitizeCollection(sortedSet, m_separator, ALL_ITEMS); + wikitext = wikitizeCollection( links, m_separator, ALL_ITEMS ); } return makeHTML( context, wikitext ); } Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/RecentChangesPluginTest.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/RecentChangesPluginTest.java?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/RecentChangesPluginTest.java (original) +++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/RecentChangesPluginTest.java Fri May 8 03:40:50 2009 @@ -94,7 +94,7 @@ * * @throws Exception */ - public void testParmInClude() throws Exception + public void testParmInclude() throws Exception { context = engine.getWikiContextFactory().newViewContext( null, null, engine.getPage( "TestPage02" ) ); @@ -113,7 +113,7 @@ * * @throws Exception */ - public void testParmExClude() throws Exception + public void testParmExclude() throws Exception { context = engine.getWikiContextFactory().newViewContext( null, null, engine.getPage( "TestPage03" ) ); Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/ReferredPagesPluginTest.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/ReferredPagesPluginTest.java?rev=772833&r1=772832&r2=772833&view=diff ============================================================================== --- incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/ReferredPagesPluginTest.java (original) +++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/ReferredPagesPluginTest.java Fri May 8 03:40:50 2009 @@ -88,7 +88,7 @@ String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.ReferredPagesPlugin}" ); assertEquals( - "\n", + "\n", res ); } @@ -105,26 +105,35 @@ String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.ReferredPagesPlugin page=IPointToSomeoneElseToo}" ); assertEquals( - "\n", + "\n", res ); } /** - * Test with the include parameter + * Test with the include parameter (with and without the space name) * * @throws Exception */ - public void testReferredPageParmInClude() throws Exception + public void testReferredPageParmInclude() throws Exception { context = engine.getWikiContextFactory().newViewContext( null, null, engine.getPage( "IPointToTwoPages" ) ); + String expected = "\n"; String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.ReferredPagesPlugin include='SomeBodyPointsToMe*'}" ); - - assertEquals( - "\n", - res ); - + assertEquals( expected, res ); + + res = manager.execute( context, + "{INSERT org.apache.wiki.plugin.ReferredPagesPlugin include='Main:SomeBodyPointsToMe*'}" ); + assertEquals( expected, res ); + } + + public void testSanitizePattern() + { + assertEquals( "Main:Foo", AbstractFilteredPlugin.sanitizePattern( "Foo" ) ); + assertEquals( "Main:Foo*", AbstractFilteredPlugin.sanitizePattern( "Foo*" ) ); + assertEquals( "Test:Foo", AbstractFilteredPlugin.sanitizePattern( "Test:Foo" ) ); + assertEquals( ".*?Foo", AbstractFilteredPlugin.sanitizePattern( ".*?Foo" ) ); } public static Test suite()