Author: ajaquith
Date: Sun Apr 19 22:20:32 2009
New Revision: 766531

URL: http://svn.apache.org/viewvc?rev=766531&view=rev
Log:
Fixed bug in WikiEngine.getFinalPageName() that was causing page lookups to 
fail horribly. Made PageNameResolver implementations consistent in terms of how 
they treat page variants that are not found.

Modified:
    incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java
    
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/EnglishPluralsPageNameResolver.java
    
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageNameResolver.java

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=766531&r1=766530&r2=766531&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java Sun Apr 19 
22:20:32 2009
@@ -2556,7 +2556,9 @@
     }
     
     /**
-     *  Resolves a page name as per the installed PageNameResolvers.
+     *  Resolves a wiki path, trying all resolution algorithms as specified by 
the
+     *  {...@link PageNameResolver} classes. If the path resolves to a 
different
+     *  path, that path is returned. Otherwise, <code>null</code> is returned.
      *  
      *  @param page the page name.
      *  @return The rewritten page name.  May also return null in case there
@@ -2564,12 +2566,23 @@
      */
     public final WikiPath getFinalPageName( WikiPath page ) throws 
ProviderException
     {
+        // If the original name resolves, return it
+        if ( getContentManager().pageExists( page  ) )
+        {
+            return page;
+        }
+
+        // Otherwise try resolving it
         for( PageNameResolver resolver : m_nameResolvers )
         {
-            page = resolver.resolve( page );
+            WikiPath resolvedPath = resolver.resolve( page );
+            if ( resolvedPath != null )
+            {
+                return resolvedPath;
+            }
         }
         
-        return page;
+        return null;
     }
 
 }

Modified: 
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/EnglishPluralsPageNameResolver.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/EnglishPluralsPageNameResolver.java?rev=766531&r1=766530&r2=766531&view=diff
==============================================================================
--- 
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/EnglishPluralsPageNameResolver.java
 (original)
+++ 
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/EnglishPluralsPageNameResolver.java
 Sun Apr 19 22:20:32 2009
@@ -26,7 +26,7 @@
 
 /**
  *  A resolver for English language plurals (matches "PageName" to "PageNames" 
and
- *  vice versa).  If the page does not exist, returns the requested name.
+ *  vice versa).  If the page does not exist, returns <code>null</code>.
  */
 public class EnglishPluralsPageNameResolver extends PageNameResolver
 {
@@ -71,7 +71,7 @@
                 return alternativeName;
         }
         
-        return name;
+        return null;
     }
 
 }

Modified: 
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageNameResolver.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageNameResolver.java?rev=766531&r1=766530&r2=766531&view=diff
==============================================================================
--- 
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageNameResolver.java 
(original)
+++ 
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageNameResolver.java 
Sun Apr 19 22:20:32 2009
@@ -44,7 +44,9 @@
     }   
 
     /**
-     *  Resolves the page name to another page.
+     *  Resolves the page name to another page. If the page can be resolved to 
another
+     *  page name, this method returns that name. If it cannot be resolved, 
this
+     *  method returns <code>null</code>.
      *  
      *  @param name The name to check for
      *  @return A new name that you should getPage() on.


Reply via email to