jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r773455 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/api/ src/java/org/apache/wiki/content/ src/java/org/apache/wiki/parser/ src/java/org/apache/wiki/plugin/ src/java/org/apache/wiki/search/ src/java/...
Date Mon, 11 May 2009 03:04:58 GMT
Author: ajaquith
Date: Mon May 11 03:04:57 2009
New Revision: 773455

URL: http://svn.apache.org/viewvc?rev=773455&view=rev
Log:
Reviewed and partially applied the remainder of Greg Kable's patches [JSPWIKI-528]. The changes
I made to ComtentManager, WikiEngine and several plugins go further than those specified in
the patch, and eliminate the wrapping/unwrapping in AbstractFilteredPlugin.filterCollection.
Notable changes include use of Lists in preference to SortedSets, plus the use of Collections.sort().
To do this, WikiPage now extends Comparable<WikiPage>, as does JCRWikiPage. To allow
pages to be returned efficiently in a specified order, ContentManager now has a method getAllPages(String,Comparator<WikiPage>).

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/PageManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java
    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/api/WikiPage.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.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/search/SearchManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=773455&r1=773454&r2=773455&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Mon May 11 03:04:57 2009
@@ -1,3 +1,17 @@
+2009-05-10  Andrew Jaquith <ajaquith AT apache DOT org>
+
+        * 3.0.0-svn-115
+
+        * Reviewed and partially applied the remainder of Greg Kable's patches
+        [JSPWIKI-528]. The changes to ComtentManager, WikiEngine and several
+        plugins go further than those specified in the patch, and eliminate the
+        wrapping/unwrapping in AbstractFilteredPlugin.filterCollection. Notable
+        changes include use of Lists in preference to SortedSets, plus the use
+        of Collections.sort(). To do this, WikiPage now extends
+        Comparable<WikiPage>, as does JCRWikiPage. To allow pages to be
+        returned efficiently in a specified order, ContentManager now has a
+        method getAllPages(String,Comparator<WikiPage>).
+
 2009-05-10  Janne Jalkanen <jalkanen@apache.org>
 
         * Priha 0.1.16 to address some encoding issues with our unit

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java?rev=773455&r1=773454&r2=773455&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java Mon May 11 03:04:57
2009
@@ -48,8 +48,7 @@
 //        need to figure out the metadata lifecycle.
 
 public class JCRWikiPage
-    implements Cloneable,
-               Comparable<Object>, WikiPage, Attachment
+    implements Cloneable, WikiPage, Attachment, Comparable<WikiPage>
 {
     private static final long serialVersionUID = 1L;
 
@@ -437,20 +436,17 @@
         return p;
     }
     
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.WikiPage#compareTo(java.lang.Object)
      */
-    public int compareTo( Object o )
+    public int compareTo( WikiPage o )
     {
-        int res = 0;
-        if( o instanceof WikiPage )
-        {
-            WikiPage c = (WikiPage)o;
+        WikiPage c = (WikiPage)o;
         
-            res = this.getName().compareTo(c.getName());
-            
-            if( res == 0 ) res = this.getVersion()-c.getVersion();
-        }
+        int res = this.getName().compareTo(c.getName());
+        
+        if( res == 0 ) res = this.getVersion()-c.getVersion();
             
         return res;
     }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/PageManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/PageManager.java?rev=773455&r1=773454&r2=773455&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/PageManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/PageManager.java Mon May 11 03:04:57
2009
@@ -129,7 +129,7 @@
      *  @return A Collection of WikiPage objects.
      *  @throws ProviderException If the backend has problems.
      */
-    public Collection<WikiPage> getAllPages()
+    public List<WikiPage> getAllPages()
         throws ProviderException
     {
         return m_engine.getContentManager().getAllPages(null);

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java?rev=773455&r1=773454&r2=773455&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java Mon May 11 03:04:57
2009
@@ -1054,7 +1054,7 @@
         }
         if ( highChar )
         {
-            Thread.currentThread().dumpStack();
+            Thread.dumpStack();
         }
     }
 

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=773455&r1=773454&r2=773455&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Mon May 11 03:04:57 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "114";
+    public static final String     BUILD         = "115";
     
     /**
      *  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=773455&r1=773454&r2=773455&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java Mon May 11 03:04:57 2009
@@ -1059,35 +1059,35 @@
     }
 
     /**
-     *  Returns a collection of all supported InterWiki links.
+     *  Returns an unordered list of all supported InterWiki links.
      *
-     *  @return A Collection of Strings.
+     *  @return An unordered list of Strings.
      */
     @SuppressWarnings("unchecked")
-    public Collection<String> getAllInterWikiLinks()
+    public List<String> getAllInterWikiLinks()
     {
-        Vector<String> v = new Vector<String>();
+        List<String> links = new ArrayList<String>();
 
-        for( Enumeration i = m_properties.propertyNames(); i.hasMoreElements(); )
+        for( Enumeration e = m_properties.propertyNames(); e.hasMoreElements(); )
         {
-            String prop = (String) i.nextElement();
+            String prop = (String) e.nextElement();
 
             if( prop.startsWith( PROP_INTERWIKIREF ) )
             {
-                v.add( prop.substring( prop.lastIndexOf(".")+1 ) );
+                links.add( prop.substring( prop.lastIndexOf(".")+1 ) );
             }
         }
 
-        return v;
+        return links;
     }
 
     /**
-     *  Returns a collection of all image types that get inlined.
+     *  Returns an unordered  list of all image types that get inlined.
      *
-     *  @return A Collection of Strings with a regexp pattern.
+     *  @return An unordered list of Strings with a regexp pattern.
      */
 
-    public Collection<String> getAllInlinedImagePatterns()
+    public List<String> getAllInlinedImagePatterns()
     {
         return JSPWikiMarkupParser.getImagePatterns( this );
     }
@@ -1789,13 +1789,13 @@
     }
 
     /**
-     *  Returns a List 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 List of WikiPage objects
+     *  @param space The wiki space for which you want to get
+     *  recent changes
+     *  @return a list of wiki pages, sorted
      */
     // FIXME: Should really get a Date object and do proper comparisons.
     //        This is terribly wasteful.
@@ -1815,26 +1815,24 @@
     }
 
     /**
-     *  Parses an incoming search request, then
-     *  does a search.
-     *  <P>
-     *  The query is dependent on the actual chosen search provider - each one of them has
-     *  a language of its own.
+     *  <p>Searches for objects using the WikiEngine's configured
+     *  search provider. How the query is processed depends on the
+     *  on the search provider; each has its own search syntax .
+     *  The returned list is sorted in order of relevance (i.e., highest
+     *  quality hits first).</p>
      *
-     *  @param query The query string
-     *  @return A Collection of SearchResult objects.
+     *  @param query the query string
+     *  @return A list of SearchResult objects
      *  @throws ProviderException If the searching failed
-     *  @throws IOException       If the searching failed
+     *  @throws IOException If the searching failed
      */
-
     //
     // FIXME: Should also have attributes attached.
     //
-    public Collection<SearchResult> findPages( String query )
+    public List<SearchResult> findPages( String query )
         throws ProviderException, IOException
     {
-        Collection<SearchResult> results = m_searchManager.findPages( query );
-
+        List<SearchResult> results = m_searchManager.findPages( query );
         return results;
     }
 
@@ -1911,16 +1909,15 @@
 
 
     /**
-     *  Returns a Collection of WikiPages containing the
+     *  Returns a list of WikiPages containing the
      *  version history of a page.
      *
      *  @param page Name of the page to look for
-     *  @return an ordered List of WikiPages, each corresponding to a different
+     *  @return an ordered list of WikiPages, each corresponding to a different
      *          revision of the page.
      * @throws ProviderException 
      * @throws PageNotFoundException 
      */
-
     public List<WikiPage> getVersionHistory( String page ) 
         throws PageNotFoundException, ProviderException
     {

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java?rev=773455&r1=773454&r2=773455&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java Mon May 11 03:04:57
2009
@@ -36,7 +36,7 @@
  *  Simple wrapper class for the Wiki page attributes.  The Wiki page
  *  content is moved around in Strings, though.
  */
-public interface WikiPage
+public interface WikiPage extends Comparable<WikiPage>
 {
     /**
      *  "Summary" is a short summary of the page.  It is a String.
@@ -190,7 +190,7 @@
      *  @param o The object to compare against
      *  @return -1, 0 or 1
      */
-    public int compareTo( Object o );
+    public int compareTo( WikiPage o );
  
     /**
      *  Returns the content of the WikiPage markup as a String.

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=773455&r1=773454&r2=773455&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 Mon May 11
03:04:57 2009
@@ -439,11 +439,10 @@
      *  please see {@link ReferenceManager#findCreated()}, which is probably a lot
      *  faster.  This method may cause repository access.
      *  
-     *  @param space Name of the Wiki space.  May be null, in which case gets all spaces
-     *  @return A Collection of WikiPage objects.
-     *  @throws ProviderException If the backend has problems.
+     *  @param space the name of the wiki space containing the pages to get.  May be
+     *  <code>null</code>, in which case gets all spaces
+     *  @throws ProviderException if the backend has problems.
      */
-   
     public List<WikiPage> getAllPages( String space )
         throws ProviderException
     {
@@ -484,6 +483,30 @@
         
         return results;
     }
+    
+    /**
+     *  Returns all pages in a specified order.  If you need just the page names, 
+     *  please see {@link ReferenceManager#findCreated()}, which is probably a lot
+     *  faster.  This method may cause repository access.
+     *  
+     *  @param space the name of the wiki space containing the pages to get.  May be
+     *  <code>null</code>, in which case gets all spaces
+     *  @param comparator the comparator used for sorting the page collection;
+     *  for example, {@link org.apache.wiki.util.PageTimeComparator}.
+     *  @return a list of WikiPage objects.
+     *  @throws ProviderException if the back-end has problems.
+     */
+    public List<WikiPage> getAllPages( String space, Comparator<WikiPage> comparator
)
+        throws ProviderException
+    {
+        if ( comparator == null )
+        {
+            throw new IllegalArgumentException ( "Comparator cannot be null." );
+        }
+        List<WikiPage> pages = getAllPages( space );
+        Collections.sort( pages, comparator );
+        return pages;
+    }
 
     /**
      *  Returns true, if this Node is the root node of a space.
@@ -1476,7 +1499,7 @@
             {
                 int pagesChanged = 0;
                 // FIXME: This is a hack to make this thing compile, not work.
-                Collection<WikiPage> pages = getAllPages( null );
+                List<WikiPage> pages = getAllPages( null );
                 for ( Iterator<WikiPage> it = pages.iterator(); it.hasNext(); )
                 {
                     WikiPage page = (WikiPage)it.next();

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java?rev=773455&r1=773454&r2=773455&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java Mon May
11 03:04:57 2009
@@ -30,6 +30,7 @@
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
+import javax.jcr.RepositoryException;
 import javax.servlet.http.HttpServletResponse;
 import javax.xml.transform.Result;
 
@@ -52,7 +53,6 @@
 import org.apache.wiki.log.LoggerFactory;
 import org.apache.wiki.plugin.PluginManager;
 import org.apache.wiki.plugin.WikiPlugin;
-import org.apache.wiki.providers.ProviderException;
 import org.apache.wiki.render.CleanTextRenderer;
 import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.util.RegExpUtil;
@@ -403,35 +403,34 @@
 
     /**
      *  Figure out which image suffixes should be inlined.
-     *  @return Collection of Strings with patterns.
+     *  @return a list of Strings with patterns.
      *  
      *  @param engine The WikiEngine from which the patterns are read.
      */
-
     // FIXME: Does not belong here; should be elsewhere
-    public static Collection<String> getImagePatterns( WikiEngine engine )
+    public static List<String> getImagePatterns( WikiEngine engine )
     {
         Properties props    = engine.getWikiProperties();
-        ArrayList<String>  ptrnlist = new ArrayList<String>();
+        ArrayList<String>  patterns = new ArrayList<String>();
 
         for( Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); )
         {
-            String name = (String) e.nextElement();
+            String prop = (String) e.nextElement();
 
-            if( name.startsWith( PROP_INLINEIMAGEPTRN ) )
+            if( prop.startsWith( PROP_INLINEIMAGEPTRN ) )
             {
-                String ptrn = TextUtil.getStringProperty( props, name, null );
+                String pattern = TextUtil.getStringProperty( props, prop, null );
 
-                ptrnlist.add( ptrn );
+                patterns.add( pattern );
             }
         }
 
-        if( ptrnlist.size() == 0 )
+        if( patterns.size() == 0 )
         {
-            ptrnlist.add( DEFAULT_INLINEPATTERN );
+            patterns.add( DEFAULT_INLINEPATTERN );
         }
 
-        return ptrnlist;
+        return patterns;
     }
 
     /**
@@ -1412,14 +1411,14 @@
         try
         {
             acl = m_engine.getAclManager().parseAcl( page, ruleLine );
-            page.save();
+            m_engine.getContentManager().save( page );
             if( log.isDebugEnabled() ) log.debug( acl.toString() );
         }
         catch( WikiSecurityException wse )
         {
             return makeError( wse.getMessage() );
         }
-        catch( ProviderException pe )
+        catch( RepositoryException pe )
         {
             return makeError( "Could not save WikiPage after extracting ACL: " + pe.getMessage()
);
         }

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=773455&r1=773454&r2=773455&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 Mon
May 11 03:04:57 2009
@@ -252,107 +252,156 @@
     }
     
     /**
-     *  Filters a collection according to the include and exclude -parameters.
+     *  Filters a list of same-type objects according to the include and exclude parameters
+     *  supplied to the plugin. The list supplied to this method is filtered
+     *  in-place. That is, it is <em>not</em> defensively copied; items filtered
+     *  are removed from the list.
      *  
-     *  @param items The collection to filter.
-     *  @return A filtered collection.
+     *  @param items the collection to filter
+     *  @return the same collection, with items removed as needed
+     * @throws IllegalArgumentException if the list is composed of objects that
+     * are not WikiPages, WikiPaths, or Strings
      */
     protected <T extends Object> List<T> filterCollection( List<T> items
)
     {
-        ArrayList<T> filteredItems = new ArrayList<T>();
-
-        for( T item : items )
+        Iterator<T> iterator = items.listIterator();
+        while( iterator.hasNext() )
         {
-            String pageName = null;
-            if( item instanceof WikiPage )
-            {
-                pageName = ((WikiPage) item).getPath().toString();
-            }
-            else if ( item instanceof WikiPath )
+            T item = iterator.next();
+            String pageName = getPageName( item );
+
+            // Include it?
+            boolean include = filterItem( pageName );
+
+            if( include )
             {
-                pageName = ((WikiPath) item).toString();
+                // show the page if it's not an attachment, or it's an
+                // attachment and show_attachment=true
+                boolean isAttachment = pageName.contains( "/" );
+                if( isAttachment && !m_showAttachments )
+                {
+                    include = false;
+                }
+                
+                // Update the "high watermark"
+                updateHighWaterMark( pageName );
             }
-            else if ( item instanceof String )
+            
+            // Remove the item from the list if not included
+            if ( !include )
             {
-                pageName = (String) item;
+                iterator.remove();
             }
+        }
 
-            //
-            //  If include parameter exists, then by default we include only those
-            //  pages in it (excluding the ones in the exclude pattern list).
-            //
-            //  include='*' means the same as no include.
-            //
-            boolean includeThis = m_include == null;
+        return items;
+    }
+    
+    /**
+     * Returns the name of a wiki page, wiki path, or String page name.
+     * @param item
+     * @return the page name
+     * @throws IllegalArgumentException if <code>item</code> is
+     * not a WikiPage, WikiPath, or String
+     */
+    private String getPageName( Object item )
+    {
+        if( item instanceof WikiPage )
+        {
+            return ((WikiPage) item).getPath().toString();
+        }
+        else if ( item instanceof WikiPath )
+        {
+            return ((WikiPath) item).toString();
+        }
+        else if ( item instanceof String )
+        {
+            return (String) item;
+        }
+        throw new IllegalArgumentException( "Item must be WikiPage, WikiPath or String."
);
+    }
+   
+    
+    /**
+     * Returns <code>true</code> if an item should be included based on the
+     * settings of the include/exclude filters. If the include parameter exists,
+     * then by default the page is included if it is matches the pattern.
+     * The item will always be included if the include parameter is "*".
+     * After checking the include list, the exclude list is examined. The item is
+     * excluded if it matches the exclude pattern. If the exclude pattern was not
+     * supplied, it is not excluded.
+     * @param pageName the page to filter
+     * @return the result
+     */
+    private boolean filterItem( String pageName )
+    {
+        //
+        //  If include parameter exists, then by default we include only those
+        //  pages in it (excluding the ones in the exclude pattern list).
+        //
+        //  include='*' means the same as no include.
+        //
+        boolean include = m_include == null;
 
-            if( m_include != null && pageName != null )
+        if( m_include != null && pageName != null )
+        {
+            for( int j = 0; j < m_include.length; j++ )
             {
-                for( int j = 0; j < m_include.length; j++ )
+                Matcher matcher = m_include[j].matcher( pageName );
+                if( matcher.matches() )
                 {
-                    Matcher matcher = m_include[j].matcher( pageName );
-                    if( matcher.matches() )
-                    {
-                        includeThis = true;
-                        break;
-                    }
+                    include = true;
+                    break;
                 }
             }
+        }
 
-            if( m_exclude != null && pageName != null )
+        if( m_exclude != null && pageName != null )
+        {
+            for( int j = 0; j < m_exclude.length; j++ )
             {
-                for( int j = 0; j < m_exclude.length; j++ )
+                Matcher matcher = m_exclude[j].matcher( pageName );
+                if( matcher.matches() )
                 {
-                    Matcher matcher = m_exclude[j].matcher( pageName );
-                    if( matcher.matches() )
-                    {
-                        includeThis = false;
-                        break; // The inner loop, continue on the next item
-                    }
+                    include = false;
+                    break; // The inner loop, continue on the next item
                 }
             }
-
-            if( includeThis )
+        }
+        
+        return include;
+    }
+    
+    /**
+     * Updates the internal field that stores the last-modified date of the most recently
+     * changed page.
+     * @param pageName the name of the page to check
+     */
+    private void updateHighWaterMark( String pageName )
+    {
+        WikiPage page = null;
+        if( m_lastModified )
+        {
+            try
             {
-                // show the page if it's not an attachment, or it's and
-                // attachment and show_attachment=true
-                boolean isAttachment = pageName.contains( "/" );
-                if( !isAttachment || (isAttachment && m_showAttachments) )
+                page = m_engine.getPage( pageName );
+
+                Date lastModPage = page.getLastModified();
+                if( log.isDebugEnabled() )
                 {
-                    if( item instanceof WikiPage || item instanceof WikiPath || item instanceof
String )
-                    {
-                        filteredItems.add( item );
-                    }
+                    log.debug( "lastModified Date of page " + pageName + " : " + m_dateLastModified
);
                 }
-                
-                //
-                //  if we want to show the last modified date of the most recently changed
page, we keep a "high watermark" here:
-                WikiPage page = null;
-                if( m_lastModified )
+                if( lastModPage.after( m_dateLastModified ) )
                 {
-                    try
-                    {
-                        page = m_engine.getPage( pageName );
-
-                        Date lastModPage = page.getLastModified();
-                        if( log.isDebugEnabled() )
-                        {
-                            log.debug( "lastModified Date of page " + pageName + " : " +
m_dateLastModified );
-                        }
-                        if( lastModPage.after( m_dateLastModified ) )
-                        {
-                            m_dateLastModified = lastModPage;
-                        }
-                    }
-                    catch( PageNotFoundException e ) {}
-                    catch( ProviderException e )
-                    {
-                        log.debug( "Error while getting page data", e );
-                    }
+                    m_dateLastModified = lastModPage;
                 }
             }
+            catch( PageNotFoundException e ) {}
+            catch( ProviderException e )
+            {
+                log.debug( "Error while getting page data", e );
+            }
         }
-
-        return filteredItems;
     }
 
     /**
@@ -407,50 +456,50 @@
     }
     
     /**
-     *  Makes WikiText from a Collection.
+     *  Makes WikiText markup from a collection of links.
      *
-     *  @param links Collection to make into WikiText.
-     *  @param separator Separator string to use.
-     *  @param numItems How many items to show.
+     *  @param links the collection to make into WikiText.
+     *  @param separator the separator string to use.
+     *  @param maxItems the maximum number of items to show.
      *  @return The WikiText
      */
-    protected String wikitizeCollection( Collection<WikiPath> links, String separator,
int numItems )
+    protected String wikitizeCollection( Collection<WikiPath> links, String separator,
int maxItems )
     {
         if( links == null || links.isEmpty() )
             return "";
 
-        StringBuilder output = new StringBuilder();
+        StringBuilder markup = new StringBuilder();
 
-        Iterator<WikiPath> it     = links.iterator();
+        Iterator<WikiPath> it = links.iterator();
         int      count  = 0;
 
         //
         //  The output will be B Item[1] A S B Item[2] A S B Item[3] A
         //
-        while( it.hasNext() && ( (count < numItems) || ( numItems == ALL_ITEMS
) ) )
+        while( it.hasNext() && ( (count < maxItems) || ( maxItems == ALL_ITEMS
) ) )
         {
-            WikiPath value = it.next();
+            WikiPath link = it.next();
 
             if( count > 0 )
             {
-                output.append( m_after );
-                output.append( m_separator );
+                markup.append( m_after );
+                markup.append( m_separator );
             }
 
-            output.append( m_before );
+            markup.append( m_before );
 
             // Make a Wiki markup link. See TranslatorReader.
-            String page = ContentManager.DEFAULT_SPACE.equals( value.getSpace() ) ? value.getPath()
: value.toString();
-            output.append( "[" + m_engine.beautifyTitle(value) + "|" + page + "]" );
+            String page = ContentManager.DEFAULT_SPACE.equals( link.getSpace() ) ? link.getPath()
: link.toString();
+            markup.append( "[" + m_engine.beautifyTitle( link ) + "|" + page + "]" );
             count++;
         }
 
         //
         //  Output final item - if there have been none, no "after" is printed
         //
-        if( count > 0 ) output.append( m_after );
+        if( count > 0 ) markup.append( m_after );
 
-        return output.toString();
+        return markup.toString();
     }
 
     /**

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=773455&r1=773454&r2=773455&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 Mon May 11 03:04:57
2009
@@ -51,7 +51,6 @@
     {
         super.initialize( context, params );
         
-        List<String> pages;
         div masterDiv = new div();
         masterDiv.setClass( "index" );
         
@@ -61,15 +60,17 @@
         indexDiv.setClass( "header" );
         try
         {
-            pages = listPages( context );
+            List<WikiPage> pages = context.getEngine().getContentManager().getAllPages(
ContentManager.DEFAULT_SPACE  );
+            pages = super.filterCollection( pages );
             Collections.sort( pages );
             
             char initialChar = ' ';
             
             div currentDiv = new div();
             
-            for( String name : pages )
+            for( WikiPage page : pages )
             {
+                String name = page.getName();
                 if( name.charAt( 0 ) != initialChar )
                 {
                     if( initialChar != ' ' ) indexDiv.addElement( " - " );
@@ -118,25 +119,4 @@
         return s;
     }
 
-    /**
-     * Grabs a list of all pages and filters them according to the
-     * include/exclude patterns and showAttachments parameter.
-     * 
-     * @param context
-     * @return A list containing {@link org.apache.wiki.api.WikiPage} Objects
-     * @throws ProviderException
-     */
-    private List<String> listPages( WikiContext context ) throws ProviderException
-    {
-        ArrayList<String> result = new ArrayList<String>();
-        List<WikiPage> pages = context.getEngine().getContentManager().getAllPages(
ContentManager.DEFAULT_SPACE );
-        pages = super.filterCollection( pages );
-
-        for( WikiPage page : pages )
-        {
-            result.add( page.getName() );
-        }
-        return result;
-    }
-
 }

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=773455&r1=773454&r2=773455&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 Mon May
11 03:04:57 2009
@@ -107,7 +107,7 @@
 
         // FIXME: Should really have a since date on the getRecentChanges
         // method.
-        List<WikiPage>   changes = engine.getRecentChanges(context.getPage().getWiki());
+        List<WikiPage>   changes = engine.getRecentChanges( context.getPage().getWiki()
);
         super.initialize( context, params );
         changes = super.filterCollection( changes );
 

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=773455&r1=773454&r2=773455&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 Mon May
11 03:04:57 2009
@@ -184,20 +184,15 @@
         handleLinks( context, pages, ++depth, path );
     }
 
-    private void handleLinks(WikiContext context,List<WikiPath> links, int depth, WikiPath
path ) throws ProviderException, PageNotFoundException
+    private void handleLinks(WikiContext context, List<WikiPath> links, int depth,
WikiPath path ) throws ProviderException, PageNotFoundException
     {
         boolean isUL = false;
-        HashSet<WikiPath> uniqueLinks = new HashSet<WikiPath>();  // skip multiple
links to same page
-        uniqueLinks.add( path );
+        links.add( path );
 
         if( m_formatSort ) Collections.sort(links);
 
         for( WikiPath link : links )
         {
-            if( uniqueLinks.contains( link ) ) continue; // skip multiple links to same page
-            
-            uniqueLinks.add( link );
-
             if( !m_engine.pageExists( link.toString() ) ) continue; // hide links to non
existing pages
 
             if( m_exists.contains( link ) )

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=773455&r1=773454&r2=773455&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 Mon
May 11 03:04:57 2009
@@ -21,6 +21,7 @@
 package org.apache.wiki.plugin;
 
 import java.text.MessageFormat;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.ResourceBundle;
@@ -112,6 +113,7 @@
             if( links != null && links.size() > 0 )
             {
                 links = filterCollection( links );
+                Collections.sort( links );
                 wikitext = wikitizeCollection( links , m_separator, items );
 
                 result.append( makeHTML( context, wikitext ) );

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java?rev=773455&r1=773454&r2=773455&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java Mon May 11
03:04:57 2009
@@ -302,17 +302,17 @@
      *  Sends a search to the current search provider. The query is is whatever native format
      *  the query engine wants to use.
      *
-     * @param query The query.  Null is safe, and is interpreted as an empty query.
+     * @param query the query string. A value of <code>null</code> is treated
+     * as an zero-length query string.
      * @return A collection of WikiPages that matched.
      * @throws ProviderException If the provider fails and a search cannot be completed.
      * @throws IOException If something else goes wrong.
      */
-    public Collection<SearchResult> findPages( String query )
+    public List<SearchResult> findPages( String query )
         throws ProviderException, IOException
     {
         if( query == null ) query = "";
-        Collection<SearchResult> c = m_searchProvider.findPages( query );
-
+        List<SearchResult> c = m_searchProvider.findPages( query );
         return c;
     }
 

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java?rev=773455&r1=773454&r2=773455&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java Mon May
11 03:04:57 2009
@@ -42,7 +42,6 @@
 import org.apache.wiki.plugin.WeblogEntryPlugin;
 import org.apache.wiki.plugin.WeblogPlugin;
 import org.apache.wiki.providers.ProviderException;
-import org.apache.wiki.util.PageTimeComparator;
 import org.apache.xmlrpc.XmlRpcException;
 
 
@@ -370,7 +369,7 @@
 
             att.setContent( new ByteArrayInputStream( data ) );
             
-            att.save();
+            engine.getContentManager().save( att );
 
             url = engine.getURL( WikiContext.ATTACH, att.getName(), null, true );
         }



Mime
View raw message