You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2009/03/17 03:34:30 UTC

svn commit: r755091 [1/2] - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/action/ src/java/org/apache/wiki/attachment/ src/java/org/apache/wiki/content/ src/java/org/apache/wiki/filters/ src/java/org/apache/wiki/par...

Author: ajaquith
Date: Tue Mar 17 02:34:29 2009
New Revision: 755091

URL: http://svn.apache.org/viewvc?rev=755091&view=rev
Log:
PageNotFoundExceptions are now caught and thrown just about everywhere they should be, plus or minus whatever errors I made in the (very fast) process of refactoring. Generally speaking: all method signatures that find and return WikiPages *and* whose page/attachment parameters are Strings now throw PageNotFoundExceptions.

Modified:
    incubator/jspwiki/trunk/ChangeLog
    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/action/DeleteActionBean.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentServlet.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageNotFoundException.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageRenamer.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/filters/FilterManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Image.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/InsertPage.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/WeblogPlugin.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/rss/RSSGenerator.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/search/BasicSearchProvider.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/search/LuceneSearchProvider.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchMatcher.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/CheckVersionTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/HistoryIteratorTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertPageTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkToParentTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkToTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/NoSuchPageTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PageExistsTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ParentPageNameTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PermissionTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/HandlerInfo.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiInterceptor.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageTypeConverter.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiRuntimeConfiguration.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/util/PriorityList.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/RPCHandler.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/TestEngine.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/WikiEngineTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/WikiContextFactoryTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/IndexPluginTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/TableOfContentsTest.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Tue Mar 17 02:34:29 2009
@@ -1,3 +1,24 @@
+2009-03-26  Andrew Jaquith <ajaquith AT apache DOT org>
+
+        * 3.0.0-svn-84
+
+        * PageNotFoundExceptions are now caught and thrown just
+        about everywhere they should be, plus or minus whatever
+        errors I made in the (very fast) process of refactoring.
+        Generally speaking: all method signatures that find and
+        return WikiPages *and* whose page/attachment parameters
+        are Strings now throw PageNotFoundExceptions.
+
+        * Stripes jar upgraded to r1.5.1.
+
+        * Many changes to EditActionBean and JSPs. Initial checkin
+        of SpamProtect annotation and matching JSP tag. This will
+        be refined in future checkins. NO unit tests yet.
+        
+        * JCRWikiPage.equals() is no longer commented out. The lack
+        of a functioning equals() method was hosing LOTS of unit
+        tests.
+
 2009-03-15  Janne Jalkanen <ja...@apache.org>
 
         * 3.0.0-svn-83

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=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/PageManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/PageManager.java Tue Mar 17 02:34:29 2009
@@ -27,6 +27,7 @@
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.content.ContentManager;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.content.WikiName;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
@@ -139,10 +140,11 @@
      *  @param pageName The name of the page to fetch.
      *  @param version The version to find
      *  @return The page content as a raw string
+     *  @throws PageNotFoundException if the wiki page cannot be found
      *  @throws ProviderException If the backend has issues.
      */
     public String getPageText( String pageName, int version )
-        throws ProviderException
+        throws PageNotFoundException, ProviderException
     {
         WikiPage p = m_engine.getContentManager().getPage( WikiName.valueOf( pageName ), version );
         
@@ -172,13 +174,16 @@
     public void putPageText( WikiPage page, String content )
         throws ProviderException
     {
-        WikiPage p = m_engine.getContentManager().getPage( page.getQualifiedName() );
-        
-        if( p == null )
+        WikiPage p;
+        try
+        {
+            p = m_engine.getContentManager().getPage( page.getQualifiedName() );
+        }
+        catch( PageNotFoundException e )
+        {
             p = m_engine.getContentManager().addPage( page.getQualifiedName(), ContentManager.JSPWIKI_CONTENT_TYPE );
-            
+        }
         p.setContent(content);
-        
         p.save();
     }
 
@@ -238,11 +243,12 @@
      *  @param pageName  The name of the page
      *  @param version   A version number
      *  @return          A WikiPage object, or null, if the page does not exist
+     *  @throws PageNotFoundException if the wiki page cannot be found
      *  @throws ProviderException If there is something wrong with the page 
      *                            name or the repository
      */
     public WikiPage getPageInfo( String pageName, int version )
-        throws ProviderException
+        throws PageNotFoundException, ProviderException
     {
         return m_engine.getContentManager().getPage( WikiName.valueOf( pageName ), version );        
     }
@@ -254,10 +260,11 @@
      *  @param pageName The name of the page to fetch history for
      *  @return If the page does not exist, returns null, otherwise a List
      *          of WikiPages.
+     *  @throws PageNotFoundException if the wiki page cannot be found
      *  @throws ProviderException If the repository fails.
      */
     public List getVersionHistory( String pageName )
-        throws ProviderException
+        throws PageNotFoundException, ProviderException
     {
         return m_engine.getContentManager().getVersionHistory( WikiName.valueOf( pageName ) );
     }
@@ -329,7 +336,15 @@
     public void deleteVersion( WikiPage page )
         throws ProviderException
     {
-        m_engine.getContentManager().deleteVersion( page );
+        try
+        {
+            m_engine.getContentManager().deleteVersion( page );
+        }
+        catch( PageNotFoundException e )
+        {
+            // This should not happen. If it does, rethrow
+            throw new ProviderException( e.getMessage() );
+        }
     }
 
     /**
@@ -341,7 +356,15 @@
     public void deletePage( WikiPage page )
         throws ProviderException
     {
-        m_engine.getContentManager().deletePage( page );
+        try
+        {
+            m_engine.getContentManager().deletePage( page );
+        }
+        catch( PageNotFoundException e )
+        {
+            // This should not happen. If it does, rethrow
+            throw new ProviderException( e.getMessage() );
+        }
     }
 
  

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=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ReferenceManager.java Tue Mar 17 02:34:29 2009
@@ -28,6 +28,7 @@
 import org.apache.commons.lang.time.StopWatch;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventUtils;
@@ -177,8 +178,17 @@
     private void updatePageReferences( WikiPage page )
         throws ProviderException
     {
-        String content = m_engine.getPageManager().getPageText( page.getName(),
-                                                                WikiPageProvider.LATEST_VERSION );
+        String content;
+        try
+        {
+            content = m_engine.getPageManager().getPageText( page.getName(),
+                                                                    WikiPageProvider.LATEST_VERSION );
+        }
+        catch( PageNotFoundException e )
+        {
+            // This should not happen. If it does, rethrow
+            throw new ProviderException( e.getMessage() );
+        }
 
         TreeSet<String> res = new TreeSet<String>();
         Collection<String> links = m_engine.scanWikiLinks( page, content );
@@ -888,7 +898,7 @@
      *         does not exist, or if it has no references.
      */
     // FIXME: Return a Set instead of a Collection.
-    public synchronized Collection findReferrers( String pagename )
+    public synchronized Collection<String> findReferrers( String pagename )
     {
         Set<String> refs = getReferenceList( m_referredBy, pagename );
 
@@ -995,7 +1005,7 @@
      *  @return A Set of all defined page names that ReferenceManager knows about.
      *  @since 2.3.24
      */
-    public Set findCreated()
+    public Set<String> findCreated()
     {
         return new HashSet<String>( m_refersTo.keySet() );
     }
@@ -1004,18 +1014,13 @@
     {
         try
         {
-            String s = m_engine.getFinalPageName( orig );
-
-            if( s == null ) s = orig;
-
-            return s;
+            return m_engine.getFinalPageName( orig );
         }
-        catch( ProviderException e )
+        catch( Exception e )
         {
             log.error("Error while trying to fetch a page name; trying to cope with the situation.",e);
-
-            return orig;
         }
+        return orig;
     }
 
     /**

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=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Tue Mar 17 02:34:29 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "83";
+    public static final String     BUILD         = "84";
     
     /**
      *  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=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java Tue Mar 17 02:34:29 2009
@@ -23,6 +23,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.net.URI;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.security.Principal;
@@ -34,8 +35,6 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import net.sourceforge.stripes.action.RedirectResolution;
-
 import org.apache.commons.lang.time.StopWatch;
 import org.apache.wiki.action.WikiActionBean;
 import org.apache.wiki.action.WikiContextFactory;
@@ -906,9 +905,12 @@
     // FIXME: Does not yet support spaces
     public WikiPage getFrontPage( String space ) throws ProviderException
     {
-        WikiPage p = getPage( m_frontPage );
-        
-        if( p == null )
+        WikiPage p;
+        try
+        {
+            p = getPage( m_frontPage );
+        }
+        catch( PageNotFoundException e )
         {
             p = createPage( new WikiName(space,m_frontPage) );
         }
@@ -1085,8 +1087,8 @@
      */
     public String getSpecialPageReference( String original )
     {
-        RedirectResolution resolution = m_contextFactory.getSpecialPageResolution( original );
-        return resolution == null ? null : resolution.getUrl( Locale.getDefault() );
+        URI uri = m_contextFactory.getSpecialPageURI( original );
+        return uri == null ? null : uri.toString();
     }
 
     /**
@@ -1120,16 +1122,25 @@
         {
             try
             {
-                Attachment att = m_attachmentManager.getAttachmentInfo(title);
-
-                if(att == null)
+                Attachment att;
+                try
+                {
+                    att = m_attachmentManager.getAttachmentInfo(title);
+                }
+                catch( PageNotFoundException e )
                 {
                     return TextUtil.beautifyString( title );
                 }
 
-                String parent = TextUtil.beautifyString( att.getParent().getName() );
-
-                return parent + "/" + att.getFileName();
+                try
+                {
+                    String parent = TextUtil.beautifyString( att.getParent().getName() );
+                    return parent + "/" + att.getFileName();
+                }
+                catch( PageNotFoundException e )
+                {
+                    return title;
+                }
             }
             catch( ProviderException e )
             {
@@ -1172,7 +1183,7 @@
 
         try
         {
-            if( m_contextFactory.getSpecialPageResolution(page) != null ) return true;
+            if( m_contextFactory.getSpecialPageURI(page) != null ) return true;
 
             if( getFinalPageName( page ) != null )
             {
@@ -1181,7 +1192,7 @@
 
             att = getAttachmentManager().getAttachmentInfo( (WikiContext)null, page );
         }
-        catch( ProviderException e )
+        catch( Exception e )
         {
             log.debug("pageExists() failed to find attachments",e);
         }
@@ -1201,20 +1212,20 @@
     public boolean pageExists( String page, int version )
         throws ProviderException
     {
-        if( m_contextFactory.getSpecialPageResolution(page) != null ) return true;
-
-        String finalName = getFinalPageName( page );
+        if( m_contextFactory.getSpecialPageURI(page) != null ) return true;
 
         boolean isThere = false;
-
-        if( finalName != null )
+        String finalName;
+        try
         {
-            //
-            //  Go and check if this particular version of this page
-            //  exists.
-            //
+            //  Go and check if this particular version of this page exists
+            finalName = getFinalPageName( page );
             isThere = m_contentManager.pageExists( WikiName.valueOf( finalName ), version );
         }
+        catch( PageNotFoundException e )
+        {
+            // It's not there!
+        }
 
         return isThere;
     }
@@ -1239,17 +1250,17 @@
     }
 
     /**
-     *  Returns the correct page name, or null, if no such
-     *  page can be found.  Aliases are considered. This
+     *  Returns the correct page name This
      *  method simply delegates to
      *  {@link org.apache.wiki.action.WikiContextFactory#getFinalPageName(String)}.
      *  @since 2.0
      *  @param page Page name.
      *  @return The rewritten page name, or null, if the page does not exist.
      *  @throws ProviderException If something goes wrong in the backend.
+     *  @throws PageNotFoundException if the page cannot be found
      */
     public String getFinalPageName( String page )
-        throws ProviderException
+        throws PageNotFoundException, ProviderException
     {
         return m_contextFactory.getFinalPageName( page );
     }
@@ -1409,9 +1420,11 @@
         {
             result = m_pageManager.getPageText( page, version );
         }
+        catch( PageNotFoundException e )
+        {
+        }
         catch( ProviderException e )
         {
-            // FIXME
         }
         finally
         {
@@ -2209,10 +2222,10 @@
     public void deletePage( String pageName )
         throws ProviderException
     {
-        WikiPage p = getPage( pageName );
-
-        if( p != null )
+        WikiPage p;
+        try
         {
+            p = getPage( pageName );
             if( p instanceof Attachment )
             {
                 m_attachmentManager.deleteAttachment( (Attachment) p );
@@ -2230,6 +2243,10 @@
                 m_pageManager.deletePage( p );
             }
         }
+        catch( PageNotFoundException e )
+        {
+            // If page doesn't exist, do nothing
+        }
     }
 
     /**

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java Tue Mar 17 02:34:29 2009
@@ -34,6 +34,7 @@
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.auth.permissions.PagePermission;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
 import org.apache.wiki.providers.ProviderException;
@@ -63,7 +64,7 @@
     @HandlesEvent( "delete" )
     @HandlerPermission( permissionClass = PagePermission.class, target = "${page.qualifiedName}", actions = PagePermission.DELETE_ACTION )
     @WikiRequestContext( "del" )
-    public Resolution delete() throws ProviderException
+    public Resolution delete() throws PageNotFoundException, ProviderException
     {
         // If all versions of a page or attachment should be deleted, redirect
         // to the main page (for page) or parent page (for attachment)
@@ -125,7 +126,7 @@
      * exist, validation fails.
      */
     @ValidationMethod( when = ValidationState.ALWAYS )
-    public void validateBeforeDelete() throws ProviderException
+    public void validateBeforeDelete() throws PageNotFoundException, ProviderException
     {
         // If no version number supplied, always succeeds.
         if( m_version == Integer.MIN_VALUE )

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/ViewActionBean.java Tue Mar 17 02:34:29 2009
@@ -21,6 +21,8 @@
 
 package org.apache.wiki.action;
 
+import java.net.URI;
+
 import net.sourceforge.stripes.action.*;
 import net.sourceforge.stripes.controller.LifecycleStage;
 import net.sourceforge.stripes.validation.Validate;
@@ -32,6 +34,7 @@
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.content.ContentManager;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
 import org.apache.wiki.ui.stripes.HandlerPermission;
@@ -132,11 +135,10 @@
                     String pageName = pageParamError.getFieldValue();
 
                     // Is it a special page?
-                    RedirectResolution resolution = getContext().getEngine().getWikiContextFactory()
-                        .getSpecialPageResolution( pageName );
-                    if( resolution != null )
+                    URI uri = getContext().getEngine().getWikiContextFactory().getSpecialPageURI( pageName );
+                    if( uri != null )
                     {
-                        return resolution;
+                        return new RedirectResolution( uri.toString() );
                     }
 
                     // Ok, it really doesn't exist. Send 'em to the "Create new
@@ -157,8 +159,11 @@
             if( engine != null )
             {
                 // Bind the front page to the action bean
-                page = engine.getPage( engine.getFrontPage() );
-                if( page == null )
+                try
+                {
+                    page = engine.getPage( engine.getFrontPage() );
+                }
+                catch( PageNotFoundException e )
                 {
                     page = engine.getFrontPage( ContentManager.DEFAULT_SPACE );
                 }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentManager.java Tue Mar 17 02:34:29 2009
@@ -36,6 +36,7 @@
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.content.WikiName;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
@@ -46,12 +47,11 @@
 import com.opensymphony.oscache.base.NeedsRefreshException;
 
 /**
- *  Provides facilities for handling attachments.  All attachment
- *  handling goes through this class.
- *  <p>
- *  The AttachmentManager provides a facade towards the current WikiAttachmentProvider
+ *  <p>Provides facilities for handling attachments.  All attachment
+ *  handling goes through this class.</p>
+ *  <p>The AttachmentManager provides a facade towards the current WikiAttachmentProvider
  *  that is in use.  It is created by the WikiEngine as a singleton object, and
- *  can be requested through the WikiEngine.
+ *  can be requested through the WikiEngine.</p>
  *
  *  @since 1.9.28
  */
@@ -91,18 +91,17 @@
     private String[] m_forbiddenPatterns;
     
     /**
-     *  Creates a new AttachmentManager.  Note that creation will never fail,
+     *  <p>Creates a new AttachmentManager.  Note that creation will never fail,
      *  but it's quite likely that attachments do not function.
-     *  <p>
-     *  <b>DO NOT CREATE</b> an AttachmentManager on your own, unless you really
+     *  </p>
+     *  <p><b>DO NOT CREATE</b> an AttachmentManager on your own, unless you really
      *  know what you're doing.  Just use WikiEngine.getAttachmentManager() if
-     *  you're making a module for JSPWiki.
+     *  you're making a module for JSPWiki.</p>
      *
-     *  @param engine The wikiengine that owns this attachment manager.
+     *  @param engine The WikiEngine that owns this attachment manager
      *  @param props  A list of properties from which the AttachmentManager will seek
      *  its configuration.  Typically this is the "jspwiki.properties".
      */
-
     // FIXME: Perhaps this should fail somehow.
     public AttachmentManager( WikiEngine engine, Properties props )
     {
@@ -123,12 +122,13 @@
     /**
      *  Gets info on a particular attachment, latest version.
      *
-     *  @param name A full attachment name.
-     *  @return Attachment, or null, if no such attachment exists.
-     *  @throws ProviderException If something goes wrong.
+     *  @param name A full attachment name
+     *  @return the attachment
+     *  @throws ProviderException If something goes wrong
+     *  @throws PageNotFoundException if no such attachment or version exists
      */
     public Attachment getAttachmentInfo( String name )
-        throws ProviderException
+        throws ProviderException, PageNotFoundException
     {
         return m_engine.getContentManager().getPage( WikiName.valueOf( name ) );
     }
@@ -136,14 +136,15 @@
     /**
      *  Gets info on a particular attachment with the given version.
      *
-     *  @param name A full attachment name.
-     *  @param version A version number.
-     *  @return Attachment, or null, if no such attachment or version exists.
-     *  @throws ProviderException If something goes wrong.
+     *  @param name A full attachment name
+     *  @param version A version number
+     *  @return the attachment
+     *  @throws ProviderException If something goes wrong
+     *  @throws PageNotFoundException if no such attachment or version exists
      */
 
     public Attachment getAttachmentInfo( String name, int version )
-        throws ProviderException
+        throws ProviderException, PageNotFoundException
     {
         if( name == null )
         {
@@ -158,14 +159,15 @@
      *  attachment name.
      *
      *  @param context The current WikiContext
-     *  @param attachmentname The file name of the attachment.
-     *  @return Attachment, or null, if no such attachment exists.
-     *  @throws ProviderException If something goes wrong.
+     *  @param attachmentname The file name of the attachment
+     *  @return the attachment
+     *  @throws ProviderException If something goes wrong
+     *  @throws PageNotFoundException if no such attachment or version exists
      */
 
     public Attachment getAttachmentInfo( WikiContext context,
                                          String attachmentname )
-        throws ProviderException
+        throws ProviderException, PageNotFoundException
     {
         return getAttachmentInfo( context, attachmentname, WikiProvider.LATEST_VERSION );
     }
@@ -175,16 +177,17 @@
      *  attachment name.
      *
      *  @param context The current WikiContext
-     *  @param attachmentname The file name of the attachment.
-     *  @param version A particular version.
-     *  @return Attachment, or null, if no such attachment or version exists.
-     *  @throws ProviderException If something goes wrong.
+     *  @param attachmentname The file name of the attachment
+     *  @param version A particular version
+     *  @return the attachment
+     *  @throws ProviderException If something goes wrong
+     *  @throws PageNotFoundException if no such attachment or version exists
      */
 
     public Attachment getAttachmentInfo( WikiContext context,
                                          String attachmentname,
                                          int version )
-        throws ProviderException
+        throws ProviderException, PageNotFoundException
     {
         WikiPage currentPage = null;
 
@@ -192,6 +195,11 @@
         {
             currentPage = context.getPage();
         }
+        
+        if ( currentPage == null )
+        {
+            return null;
+        }
 
         WikiName name = currentPage.getQualifiedName().resolve( attachmentname );
         
@@ -211,11 +219,10 @@
      *  Returns the list of attachments associated with a given wiki page.
      *  If there are no attachments, returns an empty Collection.
      *
-     *  @param wikipage The wiki page from which you are seeking attachments for.
-     *  @return a valid collection of attachments.
-     *  @throws ProviderException If there was something wrong in the backend.
+     *  @param wikipage the wiki page from which you are seeking attachments for
+     *  @return a valid collection of attachments
+     *  @throws ProviderException if there was something wrong in the backend
      */
-
     // FIXME: This API should be changed to return a List.
     @SuppressWarnings("unchecked")
     public Collection listAttachments( WikiPage wikipage )
@@ -263,8 +270,7 @@
      *  @throws ProviderException If the backend fails due to some other reason.
      */
     public InputStream getAttachmentStream( Attachment att )
-        throws IOException,
-               ProviderException
+        throws IOException, ProviderException
     {
         return getAttachmentStream( null, att );
     }
@@ -387,9 +393,10 @@
      *  @return A list of Attachments.  May return null, if attachments are
      *          disabled.
      *  @throws ProviderException If the provider fails for some reason.
+     *  @throws PageNotFoundException if no such attachment or version exists
      */
     public List<WikiPage> getVersionHistory( String attachmentName )
-        throws ProviderException
+        throws ProviderException, PageNotFoundException
     {
         return m_engine.getContentManager().getVersionHistory( WikiName.valueOf(attachmentName) );
     }
@@ -399,23 +406,41 @@
      *
      *  @param att The attachment to delete
      *  @throws ProviderException If something goes wrong with the backend.
+     *  If a PageNotFoundException is generated by the ContentManager, it is
+     *  rethrown as a ProviderException
      */
     public void deleteVersion( WikiPage att )
         throws ProviderException
     {
-        m_engine.getContentManager().deleteVersion( att );
+        try
+        {
+            m_engine.getContentManager().deleteVersion( att );
+        }
+        catch( PageNotFoundException e )
+        {
+            throw new ProviderException( e.getMessage() );
+        }
     }
 
     /**
      *  Deletes all versions of the given attachment.
      *  @param att The Attachment to delete.
      *  @throws ProviderException if something goes wrong with the backend.
+     *  If a PageNotFoundException is generated by the ContentManager, it is
+     *  rethrown as a ProviderException
      */
     // FIXME: Should also use events!
     public void deleteAttachment( Attachment att )
         throws ProviderException
     {
-        m_engine.getContentManager().deletePage( att );
+        try
+        {
+            m_engine.getContentManager().deletePage( att );
+        }
+        catch( PageNotFoundException e )
+        {
+            throw new ProviderException( e.getMessage() );
+        }
     }
 
     /**

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentServlet.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentServlet.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentServlet.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/attachment/AttachmentServlet.java Tue Mar 17 02:34:29 2009
@@ -48,6 +48,7 @@
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.permissions.PermissionFactory;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.content.WikiName;
 import org.apache.wiki.filters.RedirectException;
 import org.apache.wiki.i18n.InternationalizationManager;
@@ -245,87 +246,87 @@
                 ver = Integer.parseInt( version );
             }
 
-            Attachment att = mgr.getAttachmentInfo( page, ver );
-
-            if( att != null )
+            Attachment att;
+            try
             {
-                //
-                //  Check if the user has permission for this attachment
-                //
-
-                Permission permission = PermissionFactory.getPagePermission( att, "view" );
-                if( !authmgr.checkPermission( context.getWikiSession(), permission ) )
-                {
-                    log.debug("User does not have permission for this");
-                    res.sendError( HttpServletResponse.SC_FORBIDDEN );
-                    return;
-                }
+                att = mgr.getAttachmentInfo( page, ver );
+            }
+            catch( PageNotFoundException e )
+            {
+                msg = "Attachment '" + page + "', version " + ver + " does not exist.";
+                log.info( msg );
+                res.sendError( HttpServletResponse.SC_NOT_FOUND, msg );
+                return;
+            }
 
+            //
+            //  Check if the user has permission for this attachment
+            //
 
-                //
-                //  Check if the client already has a version of this attachment.
-                //
-                if( HttpUtil.checkFor304( req, att ) )
-                {
-                    log.debug("Client has latest version already, sending 304...");
-                    res.sendError( HttpServletResponse.SC_NOT_MODIFIED );
-                    return;
-                }
+            Permission permission = PermissionFactory.getPagePermission( att, "view" );
+            if( !authmgr.checkPermission( context.getWikiSession(), permission ) )
+            {
+                log.debug("User does not have permission for this");
+                res.sendError( HttpServletResponse.SC_FORBIDDEN );
+                return;
+            }
 
-                String mimetype = getMimeType( context, att.getFileName() );
 
-                res.setContentType( mimetype );
+            //
+            //  Check if the client already has a version of this attachment.
+            //
+            if( HttpUtil.checkFor304( req, att ) )
+            {
+                log.debug("Client has latest version already, sending 304...");
+                res.sendError( HttpServletResponse.SC_NOT_MODIFIED );
+                return;
+            }
 
-                //
-                //  We use 'inline' instead of 'attachment' so that user agents
-                //  can try to automatically open the file.
-                //
+            String mimetype = getMimeType( context, att.getFileName() );
 
-                res.addHeader( "Content-Disposition",
-                               "inline; filename=\"" + att.getFileName() + "\";" );
+            res.setContentType( mimetype );
 
-                res.addDateHeader("Last-Modified",att.getLastModified().getTime());
+            //
+            //  We use 'inline' instead of 'attachment' so that user agents
+            //  can try to automatically open the file.
+            //
 
-                if( !att.isCacheable() )
-                {
-                    res.addHeader( "Pragma", "no-cache" );
-                    res.addHeader( "Cache-control", "no-cache" );
-                }
+            res.addHeader( "Content-Disposition",
+                           "inline; filename=\"" + att.getFileName() + "\";" );
 
-                // If a size is provided by the provider, report it.
-                if( att.getSize() >= 0 )
-                {
-                    // log.info("size:"+att.getSize());
-                    res.setContentLength( (int)att.getSize() );
-                }
+            res.addDateHeader("Last-Modified",att.getLastModified().getTime());
 
-                out = res.getOutputStream();
-                in  = mgr.getAttachmentStream( context, att );
+            if( !att.isCacheable() )
+            {
+                res.addHeader( "Pragma", "no-cache" );
+                res.addHeader( "Cache-control", "no-cache" );
+            }
 
-                int read = 0;
-                byte[] buffer = new byte[BUFFER_SIZE];
+            // If a size is provided by the provider, report it.
+            if( att.getSize() >= 0 )
+            {
+                // log.info("size:"+att.getSize());
+                res.setContentLength( (int)att.getSize() );
+            }
 
-                while( (read = in.read( buffer )) > -1 )
-                {
-                    out.write( buffer, 0, read );
-                }
+            out = res.getOutputStream();
+            in  = mgr.getAttachmentStream( context, att );
 
-                if(log.isDebugEnabled())
-                {
-                    msg = "Attachment "+att.getFileName()+" sent to "+req.getRemoteUser()+" on "+req.getRemoteAddr();
-                    log.debug( msg );
-                }
-                if( nextPage != null ) res.sendRedirect( nextPage );
+            int read = 0;
+            byte[] buffer = new byte[BUFFER_SIZE];
 
-                return;
+            while( (read = in.read( buffer )) > -1 )
+            {
+                out.write( buffer, 0, read );
             }
 
-            msg = "Attachment '" + page + "', version " + ver +
-                  " does not exist.";
+            if(log.isDebugEnabled())
+            {
+                msg = "Attachment "+att.getFileName()+" sent to "+req.getRemoteUser()+" on "+req.getRemoteAddr();
+                log.debug( msg );
+            }
+            if( nextPage != null ) res.sendRedirect( nextPage );
 
-            log.info( msg );
-            res.sendError( HttpServletResponse.SC_NOT_FOUND,
-                           msg );
             return;
         }
         catch( ProviderException pe )
@@ -722,9 +723,12 @@
         //  then that attachment gains a new version.
         //
 
-        Attachment att = mgr.getAttachmentInfo( context.getPage().getName() );
-
-        if( att == null )
+        Attachment att;
+        try
+        {
+            att = mgr.getAttachmentInfo( context.getPage().getName() );
+        }
+        catch( PageNotFoundException e )
         {
             String contentType = "application/octet-stream"; // FIXME: This is not a good guess
             WikiName path = context.getPage().getQualifiedName().resolve(filename);

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=755091&r1=755090&r2=755091&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 Tue Mar 17 02:34:29 2009
@@ -912,10 +912,17 @@
             page.save();
 
             // Refresh the context for post save filtering.
-            engine.getPage( page.getName() );
-            engine.textToHTML( context, proposedText );
-            engine.getFilterManager().doPostSaveFiltering( context, proposedText );
-
+            try
+            {
+                engine.getPage( page.getName() );
+                engine.textToHTML( context, proposedText );
+                engine.getFilterManager().doPostSaveFiltering( context, proposedText );
+            }
+            catch( PageNotFoundException e )
+            {
+                e.printStackTrace();
+                throw new WikiException( e.getMessage() );
+            }
             return Outcome.STEP_COMPLETE;
         }
     }
@@ -1014,10 +1021,15 @@
      *  @param path the path
      *  @return the {@link JCRWikiPage} 
      *  @throws ProviderException If the backend fails.
-     *  @throws PageNotFoundException If the page does not exist.
+     *  @throws PageNotFoundException If the page does not exist, or if <code>path</code>
+     *  is <code>null</code>
      */
     public JCRWikiPage getPage( WikiName path ) throws ProviderException, PageNotFoundException
     {
+        if ( path == null )
+        {
+            throw new PageNotFoundException( "(null)" );
+        }
         try
         {
             Session session = m_sessionManager.getSession();

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageNotFoundException.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageNotFoundException.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageNotFoundException.java Tue Mar 17 02:34:29 2009
@@ -28,7 +28,7 @@
  *  
  *  @since 3.0
  */
-public class PageNotFoundException extends ProviderException
+public class PageNotFoundException extends Exception
 {
     private static final long serialVersionUID = 1L;
 

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageRenamer.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageRenamer.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageRenamer.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageRenamer.java Tue Mar 17 02:34:29 2009
@@ -96,18 +96,28 @@
         //  Preconditions: "from" page must exist, and "to" page must not yet exist.
         //
         WikiEngine engine = context.getEngine();
-        WikiPage fromPage = engine.getPage( renameFrom );
-        
-        if( fromPage == null )
+        WikiPage fromPage;
+        try
+        {
+            fromPage = engine.getPage( renameFrom );
+        }
+        catch( PageNotFoundException e )
         {
             throw new WikiException("No such page "+renameFrom);
         }
         
-        WikiPage toPage = engine.getPage( renameTo );
-        
-        if( toPage != null )
+        WikiPage toPage;
+        try
+        {
+            toPage = engine.getPage( renameTo );
+            if( toPage != null )
+            {
+                throw new WikiException("Page already exists "+renameTo);
+            }
+        }
+        catch( PageNotFoundException e )
         {
-            throw new WikiException("Page already exists "+renameTo);
+            // Good. The page should NOT exist already.
         }
         
         //
@@ -137,9 +147,14 @@
         //  to the repo with no actual change.
         //
         
-        toPage = engine.getPage( renameTo );
-        
-        if( toPage == null ) throw new InternalWikiException("Rename seems to have failed for some strange reason - please check logs!");
+        try
+        {
+            toPage = engine.getPage( renameTo );
+        }
+        catch( PageNotFoundException e )
+        {
+            throw new InternalWikiException( "Rename seems to have failed for some strange reason - please check logs!" );
+        }
 
         toPage.setAttribute( WikiPage.CHANGENOTE, fromPage.getName() + " ==> " + toPage.getName() );
         toPage.setAuthor( context.getCurrentUser().getName() );

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/filters/FilterManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/filters/FilterManager.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/filters/FilterManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/filters/FilterManager.java Tue Mar 17 02:34:29 2009
@@ -96,7 +96,7 @@
  */
 public final class FilterManager extends ModuleManager
 {
-    private PriorityList    m_pageFilters = new PriorityList();
+    private PriorityList<PageFilter>    m_pageFilters = new PriorityList<PageFilter>();
 
     private HashMap<String, PageFilterInfo>          m_filterClassMap = new HashMap<String,PageFilterInfo>();
 
@@ -417,7 +417,7 @@
      *  
      *  @return A List of PageFilter objects
      */
-    public List getFilterList()
+    public List<PageFilter> getFilterList()
     {
         return m_pageFilters;
     }

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=755091&r1=755090&r2=755091&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 Tue Mar 17 02:34:29 2009
@@ -46,7 +46,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;
@@ -438,10 +437,9 @@
 
             return m_engine.getFinalPageName( page );
         }
-        catch( ProviderException e )
+        catch( Exception e )
         {
             log.warn("TranslatorReader got a faulty page name!",e);
-
             return page;  // FIXME: What would be the correct way to go back?
         }
     }
@@ -1674,7 +1672,7 @@
         {
             att = mgr.getAttachmentInfo( m_context, linktext );
         }
-        catch( ProviderException e )
+        catch( Exception e )
         {
             log.warn("Finding attachments failed: ",e);
             return null;

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Image.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Image.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Image.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Image.java Tue Mar 17 02:34:29 2009
@@ -29,7 +29,6 @@
 import org.apache.wiki.api.PluginException;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.attachment.AttachmentManager;
-import org.apache.wiki.providers.ProviderException;
 import org.apache.wiki.util.TextUtil;
 
 
@@ -133,14 +132,14 @@
         try
         {
             AttachmentManager mgr = engine.getAttachmentManager();
-            WikiPage        att = mgr.getAttachmentInfo( context, src );
+            WikiPage att = mgr.getAttachmentInfo( context, src );
 
             if( att != null )
             {
                 src = context.getURL( WikiContext.ATTACH, att.getName() );
             }
         }
-        catch( ProviderException e )
+        catch( Exception e )
         {
             throw new PluginException( rb.getString( "plugin.image.attachinfo.failed" ) + e.getMessage() );
         }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/InsertPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/InsertPage.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/InsertPage.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/InsertPage.java Tue Mar 17 02:34:29 2009
@@ -31,7 +31,6 @@
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.permissions.PermissionFactory;
-import org.apache.wiki.providers.ProviderException;
 import org.apache.wiki.util.TextUtil;
 
 
@@ -112,7 +111,7 @@
                     page = engine.getPage( includedPage );
                 }
             }
-            catch( ProviderException e )
+            catch( Exception e )
             {
                 res.append("<span class=\"error\">" + rb.getString( "plugin.insert.notfound" ) + "</span>");
                 return res.toString();

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=755091&r1=755090&r2=755091&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 Tue Mar 17 02:34:29 2009
@@ -32,6 +32,7 @@
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.permissions.PagePermission;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
 import org.apache.wiki.parser.PluginContent;
@@ -322,7 +323,15 @@
         WikiContext entryCtx = (WikiContext) context.clone();
         entryCtx.setPage( entry );
 
-        String html = engine.getHTML( entryCtx, engine.getPage(entry.getName()) );
+        String html = "";
+        try
+        {
+            html = engine.getHTML( entryCtx, engine.getPage(entry.getName()) );
+        }
+        catch( PageNotFoundException e )
+        {
+            // No content for you, then!
+        }
 
         // Extract the first h1/h2/h3 as title, and replace with null
         buffer.append("<div class=\"weblogentrytitle\">\n");
@@ -419,19 +428,19 @@
      *  @return a list of pages with their FIRST revisions.
      *  @throws ProviderException If something goes wrong
      */
-    public List findBlogEntries( PageManager mgr,
+    public List<WikiPage> findBlogEntries( PageManager mgr,
                                  String baseName, Date start, Date end )
         throws ProviderException
     {
-        Collection everyone = mgr.getAllPages();
+        Collection<WikiPage> everyone = mgr.getAllPages();
         ArrayList<WikiPage> result = new ArrayList<WikiPage>();
 
         baseName = makeEntryPage( baseName );
         SimpleDateFormat fmt = new SimpleDateFormat(DEFAULT_DATEFORMAT);
 
-        for( Iterator i = everyone.iterator(); i.hasNext(); )
+        for( Iterator<WikiPage> i = everyone.iterator(); i.hasNext(); )
         {
-            WikiPage p = (WikiPage)i.next();
+            WikiPage p = i.next();
 
             String pageName = p.getName();
 

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java Tue Mar 17 02:34:29 2009
@@ -35,6 +35,7 @@
 import org.apache.wiki.*;
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.content.WikiName;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
@@ -117,9 +118,11 @@
         {
             String blogid = getPageName( request );
 
-            WikiPage page    = m_engine.getPage( blogid );
-
-            if( page == null )
+            try
+            {
+                m_engine.getPage( blogid );
+            }
+            catch( PageNotFoundException e )
             {
                 throw new ServletException("Page "+blogid+" does not exist, cannot add blog post.");
             }
@@ -222,7 +225,7 @@
     }
 
     private Entry getBlogEntry( String entryid )
-        throws ProviderException
+        throws Exception
     {
         WikiPage page = m_engine.getPage( entryid );
         WikiPage firstVersion = m_engine.getPage( entryid, 1 );

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/rss/RSSGenerator.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/rss/RSSGenerator.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/rss/RSSGenerator.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/rss/RSSGenerator.java Tue Mar 17 02:34:29 2009
@@ -230,6 +230,10 @@
                        "\">"+att.getName()+"</a>" );
 
         }
+        catch( PageNotFoundException e )
+        {
+            log.debug( "Unable to load parent", e );
+        }
         catch( ProviderException e )
         {
             log.debug( "Unable to load parent", e );
@@ -277,6 +281,10 @@
                 res = getPageDescription( page );
             }
         }
+        catch( PageNotFoundException e )
+        {
+            log.error( "Unable to get description", e );
+        }
         catch( ProviderException e )
         {
             // FIXME: We should check if returning a plain empty string is ok,

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/search/BasicSearchProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/search/BasicSearchProvider.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/search/BasicSearchProvider.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/search/BasicSearchProvider.java Tue Mar 17 02:34:29 2009
@@ -30,6 +30,7 @@
 import org.apache.wiki.NoRequiredPropertyException;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
 import org.apache.wiki.providers.ProviderException;
@@ -184,6 +185,10 @@
                     }
                 }
             }
+            catch( PageNotFoundException e )
+            {
+                log.error( "Unable to page content", e );
+            }
             catch( ProviderException pe )
             {
                 log.error( "Unable to retrieve page from cache", pe );

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/search/LuceneSearchProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/search/LuceneSearchProvider.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/search/LuceneSearchProvider.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/search/LuceneSearchProvider.java Tue Mar 17 02:34:29 2009
@@ -49,6 +49,7 @@
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.attachment.AttachmentManager;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.content.WikiName;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
@@ -286,11 +287,11 @@
         try
         {
             Attachment att = mgr.getAttachmentInfo( attachmentName, version );
-            //FIXME: Find out why sometimes att is null
-            if(att != null)
-            {
-                return getAttachmentContent( att );
-            }
+            return getAttachmentContent( att );
+        }
+        catch (PageNotFoundException e)
+        {
+            log.error("Attachment cannot be loaded", e);
         }
         catch (ProviderException e)
         {
@@ -592,10 +593,10 @@
             {
                 Document doc = hits.doc(curr);
                 String pageName = doc.get(LUCENE_ID);
-                WikiPage page = m_engine.getPage(pageName, WikiPageProvider.LATEST_VERSION);
-
-                if(page != null)
+                WikiPage page;
+                try
                 {
+                    page = m_engine.getPage(pageName, WikiPageProvider.LATEST_VERSION);
                     if(page instanceof Attachment)
                     {
                         // Currently attachments don't look nice on the search-results page
@@ -621,8 +622,9 @@
                     SearchResult result = new SearchResultImpl( page, score, fragments );     
                     list.add(result);
                 }
-                else
+                catch( PageNotFoundException e )
                 {
+                    // No worries!
                     log.error("Lucene found a result page '" + pageName + "' that could not be loaded, removing from Lucene cache");
                     pageRemoved(m_engine.createPage( WikiName.valueOf( pageName ) ));
                 }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchMatcher.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchMatcher.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchMatcher.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchMatcher.java Tue Mar 17 02:34:29 2009
@@ -27,6 +27,7 @@
 
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.providers.ProviderException;
 
 
@@ -138,6 +139,11 @@
             {
                 return new SearchResultImpl( m_engine.getPage( wikiname ), totalscore );
             }
+            catch( PageNotFoundException e )
+            {
+                // FIXME: Should really log this
+                return null;
+            }
             catch( ProviderException e )
             {
                 // FIXME: Should really log this

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/CheckVersionTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/CheckVersionTag.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/CheckVersionTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/CheckVersionTag.java Tue Mar 17 02:34:29 2009
@@ -25,6 +25,7 @@
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.providers.ProviderException;
 
 
@@ -92,8 +93,7 @@
      */
     @Override
     public final int doWikiStartTag()
-        throws IOException,
-               ProviderException
+        throws IOException, PageNotFoundException, ProviderException
     {
         WikiEngine engine = m_wikiContext.getEngine();
         WikiPage   page   = m_wikiContext.getPage();

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/HistoryIteratorTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/HistoryIteratorTag.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/HistoryIteratorTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/HistoryIteratorTag.java Tue Mar 17 02:34:29 2009
@@ -28,6 +28,7 @@
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
 import org.apache.wiki.providers.ProviderException;
@@ -67,9 +68,12 @@
         {
             if( page != null && engine.pageExists(page) )
             {
-                Collection versions = engine.getVersionHistory( page.getName() );
-
-                if( versions == null )
+                Collection<WikiPage> versions;
+                try
+                {
+                    versions = engine.getVersionHistory( page.getName() );
+                }
+                catch( PageNotFoundException e )
                 {
                     // There is no history
                     return SKIP_BODY;

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertPageTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertPageTag.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertPageTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertPageTag.java Tue Mar 17 02:34:29 2009
@@ -25,6 +25,7 @@
 
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.providers.ProviderException;
 
 
@@ -109,31 +110,33 @@
         }
         else
         {
-            insertedPage = engine.getPage( m_pageName );
-        }
-
-        if( insertedPage != null )
-        {
-            // FIXME: Do version setting later.
-            // page.setVersion( WikiProvider.LATEST_VERSION );
-
-            log.debug("Inserting page "+insertedPage);
-
-            JspWriter out = pageContext.getOut();
-
-            WikiPage oldPage = m_wikiContext.setRealPage( insertedPage );
-            
-            switch( m_mode )
+            try
+            {
+                insertedPage = engine.getPage( m_pageName );
+                // FIXME: Do version setting later.
+                // page.setVersion( WikiProvider.LATEST_VERSION );
+
+                log.debug("Inserting page "+insertedPage);
+
+                JspWriter out = pageContext.getOut();
+
+                WikiPage oldPage = m_wikiContext.setRealPage( insertedPage );
+                
+                switch( m_mode )
+                {
+                  case HTML:
+                    out.print( engine.getHTML( m_wikiContext, insertedPage ) );
+                    break;
+                  case PLAIN:
+                    out.print( engine.getText( m_wikiContext, insertedPage ) );
+                    break;
+                }
+                m_wikiContext.setRealPage( oldPage );
+            }
+            catch( PageNotFoundException e )
             {
-              case HTML:
-                out.print( engine.getHTML( m_wikiContext, insertedPage ) );
-                break;
-              case PLAIN:
-                out.print( engine.getText( m_wikiContext, insertedPage ) );
-                break;
+                // No worries. Nothing to include here...
             }
-            
-            m_wikiContext.setRealPage( oldPage );
         }
 
         return SKIP_BODY;

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkTag.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkTag.java Tue Mar 17 02:34:29 2009
@@ -179,7 +179,7 @@
      * @throws ProviderException
      */
     private String figureOutURL()
-        throws ProviderException
+        throws PageNotFoundException, ProviderException
     {
         String url = null;
         WikiEngine engine = m_wikiContext.getEngine();

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkToParentTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkToParentTag.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkToParentTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkToParentTag.java Tue Mar 17 02:34:29 2009
@@ -25,6 +25,7 @@
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.content.PageNotFoundException;
 
 
 /**
@@ -48,7 +49,7 @@
      */
     @Override
     public int doWikiStartTag()
-        throws IOException, WikiException
+        throws IOException, PageNotFoundException, WikiException
     {
         WikiPage p = m_wikiContext.getPage();
 

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkToTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkToTag.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkToTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkToTag.java Tue Mar 17 02:34:29 2009
@@ -27,6 +27,7 @@
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.content.PageNotFoundException;
 
 
 /**
@@ -81,7 +82,7 @@
 
     
     public int doWikiStartTag()
-        throws IOException, WikiException
+        throws IOException, PageNotFoundException, WikiException
     {
         String     pageName = m_pageName;
         boolean    isattachment = false;

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/NoSuchPageTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/NoSuchPageTag.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/NoSuchPageTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/NoSuchPageTag.java Tue Mar 17 02:34:29 2009
@@ -24,6 +24,7 @@
 
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.providers.ProviderException;
 
 
@@ -56,8 +57,7 @@
     }
 
     public int doWikiStartTag()
-        throws IOException,
-               ProviderException
+        throws IOException, PageNotFoundException, ProviderException
     {
         WikiEngine engine = m_wikiContext.getEngine();
         WikiPage   page;

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PageExistsTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PageExistsTag.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PageExistsTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PageExistsTag.java Tue Mar 17 02:34:29 2009
@@ -22,6 +22,7 @@
 
 import java.io.IOException;
 
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.providers.ProviderException;
 
 
@@ -39,8 +40,7 @@
     private static final long serialVersionUID = 0L;
     
     public final int doWikiStartTag()
-        throws IOException,
-               ProviderException
+        throws IOException, PageNotFoundException, ProviderException
     {
         return (super.doWikiStartTag() == SKIP_BODY) ? EVAL_BODY_INCLUDE : SKIP_BODY;
     }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ParentPageNameTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ParentPageNameTag.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ParentPageNameTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/ParentPageNameTag.java Tue Mar 17 02:34:29 2009
@@ -25,6 +25,7 @@
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.providers.ProviderException;
 
 
@@ -44,7 +45,7 @@
      */
     @Override
     public final int doWikiStartTag()
-        throws IOException, ProviderException
+        throws IOException, PageNotFoundException, ProviderException
     {
         WikiEngine engine = m_wikiContext.getEngine();
         WikiPage   page   = m_wikiContext.getPage();

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PermissionTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PermissionTag.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PermissionTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PermissionTag.java Tue Mar 17 02:34:29 2009
@@ -34,7 +34,6 @@
 import org.apache.wiki.auth.permissions.GroupPermission;
 import org.apache.wiki.auth.permissions.PermissionFactory;
 import org.apache.wiki.auth.permissions.WikiPermission;
-import org.apache.wiki.providers.ProviderException;
 
 
 /**
@@ -160,7 +159,7 @@
                         return false;
                     }
                 }
-                catch( ProviderException e )
+                catch( Exception e )
                 {
                     // FIXME: What is the correct action here?
                     log.error( "Failed to find latest version", e );

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/HandlerInfo.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/HandlerInfo.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/HandlerInfo.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/HandlerInfo.java Tue Mar 17 02:34:29 2009
@@ -395,7 +395,11 @@
         if( m_permissionTargetExpression != null )
         {
             PropertyExpressionEvaluation evaluation = new PropertyExpressionEvaluation( m_permissionTargetExpression, object );
-            target = (String) evaluation.getValue();
+            Object value = evaluation.getValue();
+            if ( value != null )
+            {
+                target = value.toString();
+            }
             if( target == null )
             {
                 // If the target didn't evaluate, assume it's because some

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiInterceptor.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiInterceptor.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiInterceptor.java Tue Mar 17 02:34:29 2009
@@ -43,7 +43,6 @@
 import net.sourceforge.stripes.action.Resolution;
 import net.sourceforge.stripes.controller.*;
 
-
 /**
  * <p>
  * Stripes {@link net.sourceforge.stripes.controller.Interceptor} that
@@ -53,9 +52,11 @@
  * {@link  net.sourceforge.stripes.controller.LifecycleStage#ActionBeanResolution}
  * but before the second stage.
  * {@link net.sourceforge.stripes.controller.LifecycleStage#HandlerResolution}.
- * The second time the interceptor executes is after the second lifecycle stage,
- * but before the third stage,
- * {@link net.sourceforge.stripes.controller.LifecycleStage#BindingAndValidation}.
+ * The second time the interceptor executes is after the third lifecycle stage,
+ * aka
+ * {@link net.sourceforge.stripes.controller.LifecycleStage#BindingAndValidation},
+ * but before the fourth stage
+ * {@link net.sourceforge.stripes.controller.LifecycleStage#CustomValidation}.
  * See the
  * </p>
  * <p>
@@ -89,7 +90,7 @@
  * 
  * @author Andrew Jaquith
  */
-@Intercepts( { LifecycleStage.ActionBeanResolution, LifecycleStage.BindingAndValidation } )
+@Intercepts( { LifecycleStage.ActionBeanResolution, LifecycleStage.CustomValidation } )
 public class WikiInterceptor implements Interceptor
 {
     private static final Logger log = LoggerFactory.getLogger( WikiInterceptor.class );
@@ -102,8 +103,9 @@
 
     /**
      * Intercepts the Stripes lifecycle stages and dispatches execution to
-     * delegate methods {@link #interceptActionBeanResolution(ExecutionContext)}
-     * and {@link #interceptBindingAndValidation(ExecutionContext)}, whichever
+     * delegate methods
+     * {@link #interceptAfterActionBeanResolution(ExecutionContext)} and
+     * {@link #interceptAfterBindingAndValidation(ExecutionContext)}, whichever
      * is appropriate.
      * 
      * @param context the current execution context
@@ -118,11 +120,11 @@
     {
         if( LifecycleStage.ActionBeanResolution.equals( context.getLifecycleStage() ) )
         {
-            return interceptActionBeanResolution( context );
+            return interceptAfterActionBeanResolution( context );
         }
-        else if( LifecycleStage.BindingAndValidation.equals( context.getLifecycleStage() ) )
+        else if( LifecycleStage.CustomValidation.equals( context.getLifecycleStage() ) )
         {
-            return interceptBindingAndValidation( context );
+            return interceptAfterBindingAndValidation( context );
         }
         return null;
     }
@@ -144,7 +146,7 @@
      * @throws Exception if the underlying lifcycle stage's execution throws an
      *             Exception
      */
-    protected Resolution interceptActionBeanResolution( ExecutionContext context ) throws Exception
+    protected Resolution interceptAfterActionBeanResolution( ExecutionContext context ) throws Exception
     {
         // Did the handler resolution stage return a Resolution? If so, bail.
         Resolution r = context.proceed();
@@ -186,12 +188,14 @@
     /**
      * <p>
      * Intercepts the
+     * {@link net.sourceforge.stripes.controller.LifecycleStage#CustomValidation}
+     * lifecycle stage, to ensure that it runs after all
      * {@link net.sourceforge.stripes.controller.LifecycleStage#BindingAndValidation}
-     * lifecycle stage and checks for proper access to the current ActionBean
-     * and target event. The access-checking logic runs after after the rest of
-     * the BindingAndValidation processing logic does, after which point Stripes
-     * has already discovered the correct ActionBean, and bound and validated
-     * its request parameters.
+     * interceptors, and checks for proper access to the current ActionBean and
+     * target event. The access-checking logic runs after after the rest of the
+     * BindingAndValidation processing logic does, after which point Stripes has
+     * already discovered the correct ActionBean, and bound and validated its
+     * request parameters.
      * </p>
      * <p>
      * To determine if the user is allowed to access the target event method,
@@ -212,7 +216,7 @@
      * @throws Exception if the underlying lifcycle stage's execution throws an
      *             Exception
      */
-    protected Resolution interceptBindingAndValidation( ExecutionContext context ) throws Exception
+    protected Resolution interceptAfterBindingAndValidation( ExecutionContext context ) throws Exception
     {
         // Stash the WikiActionBean as a PageContext attribute
         WikiActionBean actionBean = (WikiActionBean) context.getActionBean();
@@ -274,17 +278,17 @@
 
     /**
      * Returns the WikiActionBean associated with the current
-     * {@link javax.servlet.jsp.PageContext}, which may have been previously stashed by
-     * {@link #interceptBindingAndValidation(ExecutionContext)}. Note that each
-     * PageContext can contain its own ActionBean. The ActionBean will be
-     * retrieved from page-scope attribute {@link WikiInterceptor#ATTR_ACTIONBEAN}.
-     * If the WikiActionBean cannot be obtained as a page-scope attribute, the
-     * request scope will be tried also.
+     * {@link javax.servlet.jsp.PageContext}, which may have been previously
+     * stashed by {@link #interceptAfterBindingAndValidation(ExecutionContext)}.
+     * Note that each PageContext can contain its own ActionBean. The ActionBean
+     * will be retrieved from page-scope attribute
+     * {@link WikiInterceptor#ATTR_ACTIONBEAN}. If the WikiActionBean cannot be
+     * obtained as a page-scope attribute, the request scope will be tried also.
      * 
      * @param pageContext the page context
      * @return the WikiActionBean
      * @throws IllegalStateException if the WikiActionBean was not found in the
-     *             page context or 
+     *             page context or
      */
     public static WikiActionBean findActionBean( PageContext pageContext )
     {
@@ -292,7 +296,7 @@
         if( bean == null )
         {
             bean = findActionBean( pageContext.getRequest() );
-            if ( bean == null )
+            if( bean == null )
             {
                 log.debug( "WikiActionBean not found under page context attribute '" + WikiInterceptor.ATTR_ACTIONBEAN
                            + "'! Something failed to stash it..." );
@@ -304,7 +308,7 @@
     /**
      * Returns the WikiActionBean associated with the current
      * {@link javax.servlet.http.HttpServletRequest}, which was previously
-     * stashed by {@link #interceptActionBeanResolution(ExecutionContext)}.
+     * stashed by {@link #interceptAfterActionBeanResolution(ExecutionContext)}.
      * Only the first ActionBean on a JSP will be stashed as a request-level
      * attribute. The ActionBean will be retrieved from attribute
      * {@link WikiInterceptor#ATTR_ACTIONBEAN}.

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageTypeConverter.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageTypeConverter.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageTypeConverter.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageTypeConverter.java Tue Mar 17 02:34:29 2009
@@ -19,6 +19,7 @@
 
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.providers.ProviderException;
 
 import net.sourceforge.stripes.controller.StripesFilter;
@@ -65,16 +66,29 @@
         try
         {
             page = engine.getPage( pageName );
-
-            String finalName = engine.getWikiContextFactory().getFinalPageName( pageName );
-            if( finalName == null || engine.getPage( finalName ) == null )
+        }
+        catch( PageNotFoundException e )
+        {
+            try
+            {
+                try
+                {
+                    String finalName = engine.getWikiContextFactory().getFinalPageName( pageName );
+                    return engine.getPage( finalName );
+                }
+                catch( PageNotFoundException e1 )
+                {
+                    errors.add( new LocalizableError( "common.nopage", pageName ) );
+                }
+            }
+            catch( ProviderException e2 )
             {
-                errors.add( new LocalizableError( "common.nopage", pageName ) );
+                errors.add( new SimpleError( e2.getMessage() ) );
             }
         }
         catch( ProviderException e )
         {
-            errors.add( new SimpleError( e.getMessage() ) );
+            errors.add( new SimpleError( "Provider exception: " + e.getMessage() ) );
         }
         return page;
     }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiRuntimeConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiRuntimeConfiguration.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiRuntimeConfiguration.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiRuntimeConfiguration.java Tue Mar 17 02:34:29 2009
@@ -42,6 +42,8 @@
  */
 public class WikiRuntimeConfiguration extends RuntimeConfiguration
 {
+    public static final String STRIPES_CONFIGURATION = "WikiRuntimeConfiguration";
+
     private Logger log = LoggerFactory.getLogger(WikiRuntimeConfiguration.class);
 
     private WikiEngine m_engine = null;
@@ -62,6 +64,9 @@
         ServletContext context = super.getServletContext();
         m_engine = WikiEngine.getInstance(context, null);
         log.info("WikiEngine is running.");
+        
+        // Stash the Configuration so JSPWiki (e.g., URLConstructors) can find it
+        context.setAttribute( STRIPES_CONFIGURATION, this );
     }
 
     /**

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/util/PriorityList.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/util/PriorityList.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/util/PriorityList.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/util/PriorityList.java Tue Mar 17 02:34:29 2009
@@ -33,10 +33,10 @@
  *  (that is, 100 is before 10 is before 0 is before -40).
  */
 @SuppressWarnings("unchecked")
-public class PriorityList
-    extends AbstractList
+public class PriorityList<T>
+    extends AbstractList<T>
 {
-    private ArrayList<Object> m_elements = new ArrayList<Object>();
+    private ArrayList<Item<T>> m_elements = new ArrayList<Item<T>>();
 
     /**
      *  This is the default priority, which is used if no priority
@@ -51,13 +51,13 @@
      *  @param o Object to add.
      *  @param priority Priority.
      */
-    public void add( Object o, int priority )
+    public void add( T o, int priority )
     {
         int i = 0;
 
         for( ; i < m_elements.size(); i++ )
         {
-            Item item = (Item) m_elements.get(i);
+            Item item = m_elements.get(i);
 
             if( item.m_priority < priority )
             {
@@ -78,7 +78,7 @@
      *  @param o Object to add.
      *  @return true, as per the general Collections.add contract.
      */
-    public boolean add( Object o )
+    public boolean add( T o )
     {
         add( o, DEFAULT_PRIORITY );
 
@@ -91,9 +91,9 @@
      *  @param index The index.
      *  @return The object at the list at the position "index".
      */
-    public Object get( int index )
+    public T get( int index )
     {
-        return ((Item)m_elements.get( index )).m_object;
+        return m_elements.get( index ).m_object;
     }
 
     /**
@@ -109,9 +109,9 @@
     /**
      *  Provides a holder for the priority-object 2-tuple.
      */
-    private static class Item
+    private static class Item<T>
     {
         public int     m_priority;
-        public Object  m_object;
+        public T m_object;
     }
 }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/RPCHandler.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/RPCHandler.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/RPCHandler.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/RPCHandler.java Tue Mar 17 02:34:29 2009
@@ -280,7 +280,7 @@
         {
             return toRPCBase64( m_engine.getHTML( pagename ) );
         }
-        catch( ProviderException e )
+        catch( Exception e )
         {
             throw new XmlRpcException( 1, pagename );
         }
@@ -295,7 +295,7 @@
         {
             return toRPCBase64( m_engine.getHTML( pagename, version ) );
         }
-        catch( ProviderException e )
+        catch( Exception e )
         {
             throw new XmlRpcException( 1, e.getMessage() );
         }
@@ -395,7 +395,7 @@
 
             return result;
         }
-        catch( ProviderException e )
+        catch( Exception e )
         {
             throw new XmlRpcException( 1, e.getMessage() );
         }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java Tue Mar 17 02:34:29 2009
@@ -231,7 +231,7 @@
         {
             return m_engine.getHTML( pagename );
         }
-        catch( ProviderException e )
+        catch( Exception e )
         {
             throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage() );            
         }
@@ -246,7 +246,7 @@
         {
             return m_engine.getHTML( pagename, version );
         }
-        catch( ProviderException e )
+        catch( Exception e )
         {
             throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage() );            
         }
@@ -337,7 +337,7 @@
 
             return result;
         }
-        catch( ProviderException e )
+        catch( Exception e )
         {
             throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage() );
         }

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/TestEngine.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/TestEngine.java?rev=755091&r1=755090&r2=755091&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/TestEngine.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/TestEngine.java Tue Mar 17 02:34:29 2009
@@ -44,6 +44,7 @@
 import org.apache.wiki.auth.SessionMonitor;
 import org.apache.wiki.auth.Users;
 import org.apache.wiki.auth.WikiSecurityException;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.content.WikiName;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
@@ -343,7 +344,16 @@
         }
 
         // Create page and wiki context
-        WikiPage page = createPage( WikiName.valueOf( pageName ) );
+        WikiPage page = null;
+        
+        try
+        {
+            page = getPage( pageName );
+        }
+        catch ( PageNotFoundException e )
+        {
+            page = createPage( WikiName.valueOf( pageName ) );
+        }
         WikiContext context = this.getWikiContextFactory().newViewContext( request, null, page );
         saveText( context, content );
     }