Author: metskem
Date: Sat May  9 16:39:43 2009
New Revision: 773248

URL: http://svn.apache.org/viewvc?rev=773248&view=rev
Log:
 3.0.0-svn-114

        * JSPWIKI-528, applied Greg's patches jspwiki-528-Weblog.patch and 
           jspwiki-528-workflow.Step.patch.
           
        * minor javadoc in ContentManager
        
        * fixed PluginManagerTest

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/WeblogPlugin.java
    
incubator/jspwiki/trunk/src/java/org/apache/wiki/util/PageTimeComparator.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/workflow/AbstractStep.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/workflow/Step.java
    
incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
    
incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/PluginManagerTest.java
    
incubator/jspwiki/trunk/tests/java/org/apache/wiki/workflow/SimpleDecisionTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/workflow/TaskTest.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=773248&r1=773247&r2=773248&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sat May  9 16:39:43 2009
@@ -1,3 +1,14 @@
+2009-05-09  Harry Metske <[email protected]>
+
+        * 3.0.0-svn-114
+
+        * JSPWIKI-528, applied Greg's patches jspwiki-528-Weblog.patch and 
+           jspwiki-528-workflow.Step.patch.
+           
+        * minor javadoc in ContentManager
+        
+        * fixed PluginManagerTest
+
 2009-05-07  Andrew Jaquith <ajaquith AT apache DOT org>
 
         * 3.0.0-svn-113
@@ -798,7 +809,7 @@
 
         * 3.0.0-svn-45
         
-        * JSPWIKI-466 - FileSystemProviderTest rücksichtslos empties 
java.io.tmpdir
+        * JSPWIKI-466 - FileSystemProviderTest r�cksichtslos empties 
java.io.tmpdir
         
 2009-01-03  Harry Metske <[email protected]>
 

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=773248&r1=773247&r2=773248&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Sat May  9 
16:39:43 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "113";
+    public static final String     BUILD         = "114";
     
     /**
      *  This is the generic version string you should use

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=773248&r1=773247&r2=773248&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 
Sat May  9 16:39:43 2009
@@ -770,7 +770,7 @@
      *  representing the page must exist, and it must also have been
      *  previously saved (that is, not "new").
      *  
-     *  Unlike {...@link WikiEngine#pageExists(String}, this method does not
+     *  Unlike {...@link WikiEngine#pageExists(String)}, this method does not
      *  resolve the supplied path by calling {...@link 
WikiEngine#getFinalPageName(WikiPath)}. 
      *  
      *  @param wikiPath  the {...@link WikiPath} to check for

Modified: 
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/WeblogPlugin.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/WeblogPlugin.java?rev=773248&r1=773247&r2=773248&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/WeblogPlugin.java 
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/WeblogPlugin.java 
Sat May  9 16:39:43 2009
@@ -42,6 +42,7 @@
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.preferences.Preferences.TimeFormat;
 import org.apache.wiki.providers.ProviderException;
+import org.apache.wiki.util.PageTimeComparator;
 import org.apache.wiki.util.TextUtil;
 
 
@@ -261,13 +262,11 @@
 
         try
         {
-            List<WikiPage> blogEntries = findBlogEntries( 
engine.getContentManager(),
+            SortedSet<WikiPage> blogEntries = findBlogEntriesSorted( 
engine.getContentManager(),
                                                           weblogName,
                                                           startTime.getTime(),
                                                           stopTime.getTime() );
 
-            Collections.sort( blogEntries, new PageDateComparator() );
-
             sb.append("<div class=\"weblog\">\n");
             
             for( Iterator i = blogEntries.iterator(); i.hasNext() && 
maxEntries-- > 0 ; )
@@ -428,15 +427,54 @@
      *  @param baseName The basename (e.g. "Main" if you want 
"Main_blogentry_xxxx")
      *  @param start The date which is the first to be considered
      *  @param end   The end date which is the last to be considered
-     *  @return a list of pages with their FIRST revisions.
+     *  @return an unordered list of pages with their FIRST revisions.
      *  @throws ProviderException If something goes wrong
      */
     public List<WikiPage> findBlogEntries( ContentManager mgr,
                                  String baseName, Date start, Date end )
         throws ProviderException
     {
+        return (List<WikiPage>)findBlogEntries( new ArrayList<WikiPage>(), 
mgr, baseName, start, end );
+    }
+
+    /**
+     *  Attempts to locate all pages that correspond to the
+     *  blog entry pattern.  Will only consider the days on the dates; not the 
hours and minutes.
+     *
+     *  @param mgr A ContentManager which is used to get the pages
+     *  @param baseName The basename (e.g. "Main" if you want 
"Main_blogentry_xxxx")
+     *  @param start The date which is the first to be considered
+     *  @param end   The end date which is the last to be considered
+     *  @return a SortedSet of pages with their FIRST revisions in reverse 
date order (i.e. newest first).
+     *  @throws ProviderException If something goes wrong
+     */
+    public SortedSet<WikiPage> findBlogEntriesSorted( ContentManager mgr,
+                                 String baseName, Date start, Date end )
+        throws ProviderException
+    {
+        return (SortedSet<WikiPage>)findBlogEntries( new 
TreeSet<WikiPage>(PageTimeComparator.DEFAULT_PAGETIME_COMPARATOR), mgr, 
baseName, start, end );
+    }
+
+    /**
+     *  Attempts to locate all pages that correspond to the
+     *  blog entry pattern.  Will only consider the days on the dates; not the 
hours and minutes.
+     *  
+     *  Ordering of the resulting pages is determined by the passed in result 
collection.
+     *
+     *  @param result the Collection to be filled with the resulting WikiPages
+     *  @param mgr A ContentManager which is used to get the pages
+     *  @param baseName The basename (e.g. "Main" if you want 
"Main_blogentry_xxxx")
+     *  @param start The date which is the first to be considered
+     *  @param end   The end date which is the last to be considered
+     *  @return the passed Collection now filled with pages with their FIRST 
revisions.
+     *  @throws ProviderException If something goes wrong
+     */
+    public Collection<WikiPage> findBlogEntries( Collection<WikiPage> result, 
ContentManager mgr,
+                                 String baseName, Date start, Date end )
+        throws ProviderException
+    {
+        result.clear();
         Collection<WikiPage> everyone = mgr.getAllPages( null );
-        ArrayList<WikiPage> result = new ArrayList<WikiPage>();
 
         baseName = makeEntryPage( baseName );
         SimpleDateFormat fmt = new SimpleDateFormat(DEFAULT_DATEFORMAT);
@@ -490,22 +528,6 @@
         return result;
     }
 
-    /**
-     *  Reverse comparison.
-     */
-    private static class PageDateComparator implements Comparator<WikiPage>
-    {
-        public int compare( WikiPage page1, WikiPage page2 )
-        {
-            if( page1 == null || page2 == null )
-            {
-                return 0;
-            }
-
-            return page2.getLastModified().compareTo( page1.getLastModified() 
);
-        }
-    }
-
     /** 
      *  Mark us as being a real weblog. 
      *  {...@inheritdoc}

Modified: 
incubator/jspwiki/trunk/src/java/org/apache/wiki/util/PageTimeComparator.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/util/PageTimeComparator.java?rev=773248&r1=773247&r2=773248&view=diff
==============================================================================
--- 
incubator/jspwiki/trunk/src/java/org/apache/wiki/util/PageTimeComparator.java 
(original)
+++ 
incubator/jspwiki/trunk/src/java/org/apache/wiki/util/PageTimeComparator.java 
Sat May  9 16:39:43 2009
@@ -27,17 +27,12 @@
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
 
-
 /**
- *  Compares the lastModified date of its arguments.  Both o1 and o2 MUST
- *  be WikiPage objects, or else you will receive a ClassCastException.
+ *  Compares the lastModified date of two WikiPages.
  *  <p>
  *  If the lastModified date is the same, then the next key is the page name.
  *  If the page name is also equal, then returns 0 for equality.
  */
-// FIXME: Does not implement equals().
-// FIXME3.0: move to util package
-
 public class PageTimeComparator
     implements Comparator<WikiPage>, Serializable
 {
@@ -45,6 +40,9 @@
 
     static Logger log = LoggerFactory.getLogger( PageTimeComparator.class ); 
 
+    // A special singleton instance for quick access
+    public static final Comparator<WikiPage> DEFAULT_PAGETIME_COMPARATOR = new 
PageTimeComparator();
+
     /**
      *  {...@inheritdoc}
      */
@@ -80,4 +78,21 @@
 
         return timecomparison;
     }
+    
+    /**
+     *  {...@inheritdoc}
+     */
+    public boolean equals(Object o)
+    {
+        // Nothing to compare.  All PageTimeComparators are equal.
+        return (o instanceof PageTimeComparator);
+    }
+    
+    /**
+     *  {...@inheritdoc}
+     */
+    public int hashcode()
+    {
+        return 864420504;
+    }
 }

Modified: 
incubator/jspwiki/trunk/src/java/org/apache/wiki/workflow/AbstractStep.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/workflow/AbstractStep.java?rev=773248&r1=773247&r2=773248&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/workflow/AbstractStep.java 
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/workflow/AbstractStep.java 
Sat May  9 16:39:43 2009
@@ -112,10 +112,10 @@
     /**
      * {...@inheritdoc}
      */
-    public final Collection<Outcome> getAvailableOutcomes()
+    public final Set<Outcome> getAvailableOutcomes()
     {
         Set<Outcome> outcomes = m_successors.keySet();
-        return Collections.unmodifiableCollection( outcomes );
+        return Collections.unmodifiableSet( outcomes );
     }
 
     /**

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/workflow/Step.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/workflow/Step.java?rev=773248&r1=773247&r2=773248&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/workflow/Step.java 
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/workflow/Step.java Sat May 
 9 16:39:43 2009
@@ -22,9 +22,9 @@
 
 import java.io.Serializable;
 import java.security.Principal;
-import java.util.Collection;
 import java.util.Date;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.wiki.api.WikiException;
 
@@ -89,7 +89,7 @@
      * 
      * @return the set of outcomes
      */
-    public Collection<Outcome> getAvailableOutcomes();
+    public Set<Outcome> getAvailableOutcomes();
 
     /**
      * Returns a List of error strings generated by this Step. If this Step

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=773248&r1=773247&r2=773248&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 
Sat May  9 16:39:43 2009
@@ -246,13 +246,11 @@
 
             WeblogPlugin plugin = new WeblogPlugin();
 
-            List<WikiPage> changed = 
plugin.findBlogEntries(m_context.getEngine().getContentManager(), 
+            SortedSet<WikiPage> changed = 
plugin.findBlogEntriesSorted(m_context.getEngine().getContentManager(), 
                                                             blogid,
                                                             new Date(0L),
                                                             new Date());
 
-            Collections.sort( changed, new PageTimeComparator() );
-
             int items = 0;
             for( Iterator i = changed.iterator(); i.hasNext() && items < 
numberOfPosts; items++ )
             {

Modified: 
incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/PluginManagerTest.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/PluginManagerTest.java?rev=773248&r1=773247&r2=773248&view=diff
==============================================================================
--- 
incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/PluginManagerTest.java
 (original)
+++ 
incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/PluginManagerTest.java
 Sat May  9 16:39:43 2009
@@ -218,7 +218,7 @@
     {
         engine.saveText(context, "[{SamplePlugin render=true}]");
 
-        engine.getHTML( "Testpage" );
+        engine.getHTML( "TestPage" );
 
         assertTrue( SamplePlugin.c_rendered );
     }

Modified: 
incubator/jspwiki/trunk/tests/java/org/apache/wiki/workflow/SimpleDecisionTest.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/workflow/SimpleDecisionTest.java?rev=773248&r1=773247&r2=773248&view=diff
==============================================================================
--- 
incubator/jspwiki/trunk/tests/java/org/apache/wiki/workflow/SimpleDecisionTest.java
 (original)
+++ 
incubator/jspwiki/trunk/tests/java/org/apache/wiki/workflow/SimpleDecisionTest.java
 Sat May  9 16:39:43 2009
@@ -20,8 +20,8 @@
  */
 package org.apache.wiki.workflow;
 
-import java.util.Collection;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.auth.WikiPrincipal;
@@ -111,7 +111,7 @@
 
     public void testAvailableOutcomes()
     {
-        Collection<Outcome> outcomes = m_decision.getAvailableOutcomes();
+        Set<Outcome> outcomes = m_decision.getAvailableOutcomes();
         assertTrue(outcomes.contains(Outcome.DECISION_APPROVE));
         assertTrue(outcomes.contains(Outcome.DECISION_DENY));
         assertFalse(outcomes.contains(Outcome.DECISION_HOLD));

Modified: 
incubator/jspwiki/trunk/tests/java/org/apache/wiki/workflow/TaskTest.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/workflow/TaskTest.java?rev=773248&r1=773247&r2=773248&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/workflow/TaskTest.java 
(original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/workflow/TaskTest.java 
Sat May  9 16:39:43 2009
@@ -20,8 +20,8 @@
  */
 package org.apache.wiki.workflow;
 
-import java.util.Collection;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.auth.WikiPrincipal;
@@ -116,7 +116,7 @@
 
     public void testAvailableOutcomes()
     {
-        Collection<Outcome> outcomes = m_task.getAvailableOutcomes();
+        Set<Outcome> outcomes = m_task.getAvailableOutcomes();
         assertFalse(outcomes.contains(Outcome.DECISION_APPROVE));
         assertFalse(outcomes.contains(Outcome.DECISION_DENY));
         assertFalse(outcomes.contains(Outcome.DECISION_HOLD));


Reply via email to