You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ja...@apache.org on 2009/03/15 21:33:55 UTC

svn commit: r754745 [1/2] - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/action/ src/java/org/apache/wiki/api/ src/java/org/apache/wiki/auth/ src/java/org/apache/wiki/auth/acl/ src/java/org/apache/wiki/content/ src...

Author: jalkanen
Date: Sun Mar 15 20:33:48 2009
New Revision: 754745

URL: http://svn.apache.org/viewvc?rev=754745&view=rev
Log:
The WikiEngine interface now also properly propagates PageNotFoundException upwards so that it's actually useful for other components.

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.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/EditActionBean.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/WikiContextFactory.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/AuthorizationManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/acl/DefaultAclManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/content/PageRenamer.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/rss/RSSGenerator.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchMatcher.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/DiffLinkTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditLinkTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertDiffTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/PermissionTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiPageTypeConverter.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.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/auth/acl/DefaultAclManagerTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/CounterPluginTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/render/CreoleRendererTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/render/WysiwygEditingRendererTest.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sun Mar 15 20:33:48 2009
@@ -1,3 +1,14 @@
+2009-03-15  Janne Jalkanen <ja...@apache.org>
+
+        * 3.0.0-svn-83
+        
+        * The WikiEngine interface now also properly propagates
+        PageNotFoundException upwards so that it's actually useful
+        for other components.  This meant quite a few small changes
+        and tweaks around the code, not all of which might make sense.
+        Please check your code for FIXME tags added by me if there's
+        something special you want to do in the error situation.
+        
 2009-03-12  Janne Jalkanen <ja...@apache.org>
 
         * 3.0.0-svn-82

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java Sun Mar 15 20:33:48 2009
@@ -36,6 +36,7 @@
 import org.apache.wiki.auth.acl.AclEntry;
 import org.apache.wiki.auth.acl.AclImpl;
 import org.apache.wiki.content.ContentManager;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.content.WikiName;
 import org.apache.wiki.providers.ProviderException;
 import org.apache.wiki.providers.WikiPageProvider;
@@ -541,7 +542,7 @@
         
     }
 
-    public WikiPage getParent() throws ProviderException
+    public WikiPage getParent() throws PageNotFoundException, ProviderException
     {
         return m_engine.getContentManager().getPage( m_name.getParent() );
     }

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=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Sun Mar 15 20:33:48 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "82";
+    public static final String     BUILD         = "83";
     
     /**
      *  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=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java Sun Mar 15 20:33:48 2009
@@ -51,6 +51,7 @@
 import org.apache.wiki.auth.acl.DefaultAclManager;
 import org.apache.wiki.auth.authorize.GroupManager;
 import org.apache.wiki.content.ContentManager;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.content.PageRenamer;
 import org.apache.wiki.content.WikiName;
 import org.apache.wiki.diff.DifferenceManager;
@@ -899,10 +900,11 @@
      *  
      *  @param space The space to get the front page for.
      *  @return A FQN of the page.
+     * @throws ProviderException 
      *  @since 3.0
      */
     // FIXME: Does not yet support spaces
-    public WikiPage getFrontPage( String space )
+    public WikiPage getFrontPage( String space ) throws ProviderException
     {
         WikiPage p = getPage( m_frontPage );
         
@@ -1461,8 +1463,11 @@
      *
      *  @param page WikiName of the page to convert.
      *  @return HTML-rendered version of the page.
+     * @throws ProviderException 
+     * @throws PageNotFoundException 
      */
-    public String getHTML( String page )
+    public String getHTML( String page ) 
+        throws PageNotFoundException, ProviderException
     {
         return getHTML( page, WikiPageProvider.LATEST_VERSION );
     }
@@ -1475,8 +1480,11 @@
      *  @param pagename WikiName of the page to convert.
      *  @param version Version number to fetch
      *  @return HTML-rendered page text.
+     * @throws ProviderException 
+     * @throws PageNotFoundException 
      */
-    public String getHTML( String pagename, int version )
+    public String getHTML( String pagename, int version ) 
+        throws PageNotFoundException, ProviderException
     {
         WikiPage page = getPage( pagename, version );
 
@@ -1740,16 +1748,16 @@
         String diffText = m_differenceManager.makeDiff( context, oldText, proposedText );
         boolean isAuthenticated = context.getWikiSession().isAuthenticated();
         Fact[] facts = new Fact[5];
-        facts[0] = new Fact( PageManager.FACT_PAGE_NAME, page.getName() );
-        facts[1] = new Fact( PageManager.FACT_DIFF_TEXT, diffText );
-        facts[2] = new Fact( PageManager.FACT_PROPOSED_TEXT, proposedText );
-        facts[3] = new Fact( PageManager.FACT_CURRENT_TEXT, oldText);
-        facts[4] = new Fact( PageManager.FACT_IS_AUTHENTICATED, Boolean.valueOf( isAuthenticated ) );
-        String rejectKey = isAuthenticated ? PageManager.SAVE_REJECT_MESSAGE_KEY : null;
+        facts[0] = new Fact( ContentManager.FACT_PAGE_NAME, page.getName() );
+        facts[1] = new Fact( ContentManager.FACT_DIFF_TEXT, diffText );
+        facts[2] = new Fact( ContentManager.FACT_PROPOSED_TEXT, proposedText );
+        facts[3] = new Fact( ContentManager.FACT_CURRENT_TEXT, oldText);
+        facts[4] = new Fact( ContentManager.FACT_IS_AUTHENTICATED, Boolean.valueOf( isAuthenticated ) );
+        String rejectKey = isAuthenticated ? ContentManager.SAVE_REJECT_MESSAGE_KEY : null;
         Workflow workflow = builder.buildApprovalWorkflow( submitter,
-                                                           PageManager.SAVE_APPROVER,
+                                                           ContentManager.SAVE_APPROVER,
                                                            prepTask,
-                                                           PageManager.SAVE_DECISION_MESSAGE_KEY,
+                                                           ContentManager.SAVE_DECISION_MESSAGE_KEY,
                                                            facts,
                                                            completionTask,
                                                            rejectKey );
@@ -1855,12 +1863,13 @@
      *  
      *  @param name The WikiName of the object to create
      *  @return A new WikiPage object.
+     *  @throws ProviderException 
      *  @since 3.0
      */
     @SuppressWarnings("deprecation")
-    public WikiPage createPage( WikiName name )
+    public WikiPage createPage( WikiName name ) throws ProviderException
     {
-        return new JCRWikiPage( this, name );
+        return m_contentManager.addPage( name, ContentManager.JSPWIKI_CONTENT_TYPE );
     }
     
     /**
@@ -1868,9 +1877,10 @@
      *  
      *  @param fqn The fully qualified name of a wikipage.
      *  @return A new page.
+     *  @throws ProviderException 
      *  @since 3.0
      */
-    public WikiPage createPage( String fqn )
+    public WikiPage createPage( String fqn ) throws ProviderException
     {
         return createPage( WikiName.valueOf( fqn ) );
     }
@@ -1881,9 +1891,12 @@
      *
      *  @param pagereq The name of the page to look for.
      *  @return A WikiPage object, or null, if the page by the name could not be found.
+     * @throws ProviderException 
+     * @throws PageNotFoundException 
      */
 
-    public WikiPage getPage( String pagereq )
+    public WikiPage getPage( String pagereq ) 
+        throws PageNotFoundException, ProviderException
     {
         return getPage( pagereq, WikiProvider.LATEST_VERSION );
     }
@@ -1896,29 +1909,18 @@
      *  in which case it will look for the latest version (and this method then becomes
      *  the equivalent of getPage(String).
      *
-     *  @return A WikiPage object, or null, if the page could not be found; or if there
-     *  is no such version of the page.
+     *  @return A WikiPage object
+     *  @throws ProviderException 
+     *  @throws PageNotFoundException If the page cannot be found. 
      *  @since 1.6.7.
      */
 
-    public WikiPage getPage( String pagereq, int version )
+    public WikiPage getPage( String pagereq, int version ) 
+        throws PageNotFoundException, ProviderException
     {
-        try
-        {
-            WikiPage p = m_pageManager.getPageInfo( pagereq, version );
-
-            if( p == null )
-            {
-                p = m_attachmentManager.getAttachmentInfo( (WikiContext)null, pagereq );
-            }
-
-            return p;
-        }
-        catch( ProviderException e )
-        {
-            log.error( "Unable to fetch page info",e);
-            return null;
-        }
+        WikiPage p = m_contentManager.getPage( WikiName.valueOf( pagereq ), version );
+        
+        return p;
     }
 
 
@@ -1929,27 +1931,14 @@
      *  @param page Name of the page to look for
      *  @return an ordered List of WikiPages, each corresponding to a different
      *          revision of the page.
+     * @throws ProviderException 
+     * @throws PageNotFoundException 
      */
 
-    public List getVersionHistory( String page )
+    public List<WikiPage> getVersionHistory( String page ) 
+        throws PageNotFoundException, ProviderException
     {
-        List c = null;
-
-        try
-        {
-            c = m_pageManager.getVersionHistory( page );
-
-            if( c == null )
-            {
-                c = m_attachmentManager.getVersionHistory( page );
-            }
-        }
-        catch( ProviderException e )
-        {
-            log.error("FIXME");
-        }
-
-        return c;
+        return m_contentManager.getVersionHistory( WikiName.valueOf( page ) );
     }
 
     /**

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java Sun Mar 15 20:33:48 2009
@@ -26,6 +26,7 @@
 import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
 import net.sourceforge.stripes.action.*;
@@ -38,11 +39,13 @@
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.auth.permissions.PagePermission;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.filters.RedirectException;
 import org.apache.wiki.filters.SpamFilter;
 import org.apache.wiki.htmltowiki.HtmlStringToWikiTranslator;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
+import org.apache.wiki.providers.ProviderException;
 import org.apache.wiki.ui.stripes.HandlerPermission;
 import org.apache.wiki.ui.stripes.WikiActionBeanContext;
 import org.apache.wiki.ui.stripes.WikiRequestContext;
@@ -137,35 +140,44 @@
 
         log.info( "Editing page " + pagereq + ". User=" + user.getName() + ", host=" + request.getRemoteAddr() );
 
-        // If page is locked, make sure we tell the user
-        List<Message> messages = wikiContext.getMessages();
-        WikiEngine engine = wikiContext.getEngine();
-        PageManager mgr = engine.getPageManager();
-        PageLock lock = mgr.getCurrentLock( m_page );
-        if( lock != null )
+        try
         {
-            messages.add( new LocalizableMessage( "edit.locked", lock.getLocker(), lock.getTimeLeft() ) );
-        }
+            // If page is locked, make sure we tell the user
+            List<Message> messages = wikiContext.getMessages();
+            WikiEngine engine = wikiContext.getEngine();
+            PageManager mgr = engine.getPageManager();
+            PageLock lock = mgr.getCurrentLock( m_page );
+            if( lock != null )
+            {
+                messages.add( new LocalizableMessage( "edit.locked", lock.getLocker(), lock.getTimeLeft() ) );
+            }
         
-        // If user is not editing the latest one, tell user also
-        ValidationErrors errors = getContext().getValidationErrors();
-        WikiPage latest = engine.getPage( m_page.getName() );
-        if( latest.getVersion() != m_page.getVersion() )
-        {
-            errors.addGlobalError( new LocalizableError( "edit.restoring", m_page.getVersion() ) );
-        }
+            // If user is not editing the latest one, tell user also
+            ValidationErrors errors = getContext().getValidationErrors();
+            WikiPage latest = engine.getPage( m_page.getName() );
+            if( latest.getVersion() != m_page.getVersion() )
+            {
+                errors.addGlobalError( new LocalizableError( "edit.restoring", m_page.getVersion() ) );
+            }
 
-        // Attempt to lock the page.
-        lock = mgr.lockPage( m_page, user.getName() );
-        if( lock != null )
-        {
-            session.setAttribute( "lock-" + pagereq, lock );
-        }
+            // Attempt to lock the page.
+            lock = mgr.lockPage( m_page, user.getName() );
+            if( lock != null )
+            {
+                session.setAttribute( "lock-" + pagereq, lock );
+            }
 
-        // Load the page text
-        m_text = engine.getPureText( m_page );
+            // Load the page text
+            m_text = m_page.getContentAsString();
 
-        return new ForwardResolution( "/Edit.jsp" );
+            return new ForwardResolution( "/Edit.jsp" );
+        }
+        catch( ProviderException e )
+        {
+            // This shouldn't be happening
+            log.error("Unable to get page",e);
+            return new ErrorResolution( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+        }
     }
 
     /**

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/WikiContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/WikiContextFactory.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/WikiContextFactory.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/WikiContextFactory.java Sun Mar 15 20:33:48 2009
@@ -44,6 +44,7 @@
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.auth.SessionMonitor;
 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;
@@ -52,6 +53,7 @@
 import org.apache.wiki.tags.WikiTagBase;
 import org.apache.wiki.ui.stripes.HandlerInfo;
 import org.apache.wiki.ui.stripes.WikiActionBeanContext;
+import org.apache.wiki.ui.stripes.WikiInterceptor;
 import org.apache.wiki.url.StripesURLConstructor;
 import org.apache.wiki.util.TextUtil;
 
@@ -152,8 +154,10 @@
         {
             // If the page supplied was blank, default to the front page to
             // avoid NPEs
-            page = engine.getFrontPage( ContentManager.DEFAULT_SPACE );
-            context.setPage( page );
+            // FIXME: I don't think this should ever happen
+            throw new InternalWikiException("saveContext with null wikipage");
+            //page = engine.getFrontPage( ContentManager.DEFAULT_SPACE );
+            //context.setPage( page );
         }
         request.setAttribute( WikiTagBase.ATTR_CONTEXT, context );
     }
@@ -627,10 +631,9 @@
      *            exist
      * @return the wiki page
      */
-    protected final WikiPage resolvePage( HttpServletRequest request, String page )
+    protected final WikiPage resolvePage( HttpServletRequest request, String page ) throws PageNotFoundException, ProviderException
     {
         // See if the user included a version parameter
-        WikiPage wikipage;
         int version = WikiProvider.LATEST_VERSION;
         String rev = request.getParameter( "version" );
 
@@ -639,14 +642,15 @@
             version = Integer.parseInt( rev );
         }
 
-        wikipage = m_engine.getPage( page, version );
-
-        if( wikipage == null )
+        try
+        {
+            return m_engine.getPage( page, version );
+        }
+        catch( PageNotFoundException e )
         {
             page = MarkupParser.cleanLink( page );
-            wikipage = m_engine.createPage( WikiName.valueOf( page ) );
+            return m_engine.createPage( WikiName.valueOf( page ) );
         }
-        return wikipage;
     }
 
     /**

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java Sun Mar 15 20:33:48 2009
@@ -27,6 +27,7 @@
 
 import org.apache.wiki.JCRWikiPage;
 import org.apache.wiki.auth.acl.Acl;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.content.WikiName;
 import org.apache.wiki.providers.ProviderException;
 
@@ -230,11 +231,12 @@
     public void setContent( InputStream in ) throws ProviderException;
 
     /**
-     *  Returns the parent of the page. May be null, if this is already
-     *  a top-level page.
-     * @throws ProviderException 
+     *  Returns the parent of the page. 
+     *  
+     *  @throws ProviderException
+     *  @throws PageNotFoundException in case there is no parent page. 
      */
-    public WikiPage getParent() throws ProviderException;
+    public WikiPage getParent() throws PageNotFoundException, ProviderException;
 
     /**
      *  Returns a list of all subpages and attachments of this WikiPage.

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/AuthorizationManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/AuthorizationManager.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/AuthorizationManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/AuthorizationManager.java Sun Mar 15 20:33:48 2009
@@ -43,11 +43,13 @@
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.auth.user.UserDatabase;
 import org.apache.wiki.auth.user.UserProfile;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiSecurityEvent;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
+import org.apache.wiki.providers.ProviderException;
 import org.apache.wiki.util.ClassUtil;
 import org.freshcookies.security.policy.LocalPolicy;
 import org.freshcookies.security.policy.PolicyException;
@@ -219,12 +221,53 @@
         //
         // If the page or ACL is null, it's allowed.
         //
-        String pageName = ((PagePermission)permission).getPage();
-        WikiPage page = m_engine.getPage( pageName );
-        Acl acl;
         try
         {
-            acl = ( page == null) ? null : m_engine.getAclManager().getPermissions( page );
+            String pageName = ((PagePermission)permission).getPage();
+            WikiPage page = m_engine.getPage( pageName );
+            Acl acl;
+
+            acl = m_engine.getAclManager().getPermissions( page );
+        
+            if ( page == null || acl == null || acl.isEmpty() )
+            {
+                fireEvent( WikiSecurityEvent.ACCESS_ALLOWED, user, permission );
+                return true;
+            }
+
+            //
+            //  Next, iterate through the Principal objects assigned
+            //  this permission. If the context's subject possesses
+            //  any of these, the action is allowed.
+            //
+            
+            Principal[] aclPrincipals = acl.findPrincipals( permission );
+
+            log.debug( "Checking ACL entries..." );
+            log.debug( "Acl for this page is: " + acl );
+            log.debug( "Checking for principal: " + String.valueOf( aclPrincipals ) );
+            log.debug( "Permission: " + permission );
+
+            for( Principal aclPrincipal : aclPrincipals )
+            {
+                // If the ACL principal we're looking at is unresolved,
+                // try to resolve it here & correct the Acl
+                if ( aclPrincipal instanceof UnresolvedPrincipal )
+                {
+                    AclEntry aclEntry = acl.getEntry( aclPrincipal );
+                    aclPrincipal = resolvePrincipal( aclPrincipal.getName() );
+                    if ( aclEntry != null && !( aclPrincipal instanceof UnresolvedPrincipal ) )
+                    {
+                        aclEntry.setPrincipal( aclPrincipal );
+                    }
+                }
+
+                if ( hasRoleOrPrincipal( session, aclPrincipal ) )
+                {
+                    fireEvent( WikiSecurityEvent.ACCESS_ALLOWED, user, permission );
+                    return true;
+                }
+            }
         }
         catch( WikiSecurityException e )
         {
@@ -233,45 +276,18 @@
             fireEvent( WikiSecurityEvent.ACCESS_DENIED, user, permission );
             return false;
         }
-        
-        if ( page == null ||  acl == null || acl.isEmpty() )
+        catch( PageNotFoundException e )
         {
+            // Page does not exist, so this is kinda fine.
             fireEvent( WikiSecurityEvent.ACCESS_ALLOWED, user, permission );
-            return true;
+            return true;            
         }
-
-        //
-        //  Next, iterate through the Principal objects assigned
-        //  this permission. If the context's subject possesses
-        //  any of these, the action is allowed.
-
-        Principal[] aclPrincipals = acl.findPrincipals( permission );
-
-        log.debug( "Checking ACL entries..." );
-        log.debug( "Acl for this page is: " + acl );
-        log.debug( "Checking for principal: " + String.valueOf( aclPrincipals ) );
-        log.debug( "Permission: " + permission );
-
-        for( Principal aclPrincipal : aclPrincipals )
-        {
-            // If the ACL principal we're looking at is unresolved,
-            // try to resolve it here & correct the Acl
-            if ( aclPrincipal instanceof UnresolvedPrincipal )
-            {
-                AclEntry aclEntry = acl.getEntry( aclPrincipal );
-                aclPrincipal = resolvePrincipal( aclPrincipal.getName() );
-                if ( aclEntry != null && !( aclPrincipal instanceof UnresolvedPrincipal ) )
-                {
-                    aclEntry.setPrincipal( aclPrincipal );
-                }
-            }
-
-            if ( hasRoleOrPrincipal( session, aclPrincipal ) )
-            {
-                fireEvent( WikiSecurityEvent.ACCESS_ALLOWED, user, permission );
-                return true;
-            }
+        catch( ProviderException e )
+        {
+            // Something bad happened.  We log and default out.
+            log.info( "Unable to get ACL on page", e );
         }
+        
         fireEvent( WikiSecurityEvent.ACCESS_DENIED, user, permission );
         return false;
     }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/acl/DefaultAclManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/acl/DefaultAclManager.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/acl/DefaultAclManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/auth/acl/DefaultAclManager.java Sun Mar 15 20:33:48 2009
@@ -34,6 +34,7 @@
 import org.apache.wiki.auth.WikiSecurityException;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.auth.permissions.PermissionFactory;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
 import org.apache.wiki.providers.ProviderException;
@@ -166,10 +167,26 @@
         //  Does the page already have cached ACLs?
         //
         Acl acl = page.getAcl();
-        log.debug( "page="+page.getName()+"\n"+acl );
+        if( log.isDebugEnabled() ) log.debug( "page="+page.getName()+"\n"+acl );
 
         if( acl == null )
         {
+            try
+            {
+                acl = getPermissions(page.getParent());
+            }
+            catch( PageNotFoundException e )
+            {
+                // There is no parent
+                return new AclImpl();
+            }
+            catch( ProviderException e )
+            {
+                throw new WikiSecurityException("Unable to get parent page to check for permissions.");
+            }
+        }
+        // FIXME: Check if the above is sufficient; may be that parsing still needs to be done here
+/*
             //
             //  If null, try the parent.
             //
@@ -208,7 +225,7 @@
                 }
             }
         }
-
+*/
         return acl;
     }
 

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=754745&r1=754744&r2=754745&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 Sun Mar 15 20:33:48 2009
@@ -907,7 +907,9 @@
             WikiPage page = context.getPage();
 
             // Let the rest of the engine handle actual saving.
-            engine.getPageManager().putPageText( page, proposedText );
+            page.setContent( proposedText );
+            
+            page.save();
 
             // Refresh the context for post save filtering.
             engine.getPage( page.getName() );

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=754745&r1=754744&r2=754745&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 Sun Mar 15 20:33:48 2009
@@ -196,33 +196,37 @@
                 pageName = toPage.getName();
             }
             
-            WikiPage p = engine.getPage( pageName );
+            try
+            {
+                WikiPage p = engine.getPage( pageName );
             
-            String sourceText = engine.getPureText( p );
+                String sourceText = engine.getPureText( p );
             
-            String newText = replaceReferrerString( context, sourceText, fromPage.getName(), toPage.getName() );
+                String newText = replaceReferrerString( context, sourceText, fromPage.getName(), toPage.getName() );
             
-            if( m_camelCase )
-                newText = replaceCCReferrerString( context, newText, fromPage.getName(), toPage.getName() );
+                if( m_camelCase )
+                    newText = replaceCCReferrerString( context, newText, fromPage.getName(), toPage.getName() );
             
-            if( !sourceText.equals( newText ) )
-            {
-                p.setAttribute( WikiPage.CHANGENOTE, fromPage.getName()+" ==> "+toPage.getName() );
-                p.setAuthor( context.getCurrentUser().getName() );
-         
-                try
+                if( !sourceText.equals( newText ) )
                 {
+                    p.setAttribute( WikiPage.CHANGENOTE, fromPage.getName()+" ==> "+toPage.getName() );
+                    p.setAuthor( context.getCurrentUser().getName() );
+         
                     engine.getPageManager().putPageText( p, newText );
                     engine.updateReferences( p );
                 }
-                catch( ProviderException e )
-                {
-                    //
-                    //  We fail with an error, but we will try to continue to rename
-                    //  other referrers as well.
-                    //
-                    log.error("Unable to perform rename.",e);
-                }
+            }
+            catch( PageNotFoundException e )
+            {
+                // Just continue
+            }
+            catch( ProviderException e )
+            {
+                //
+                //  We fail with an error, but we will try to continue to rename
+                //  other referrers as well.
+                //
+                log.error("Unable to perform rename.",e);
             }
         }
     }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java Sun Mar 15 20:33:48 2009
@@ -28,15 +28,19 @@
 import java.util.regex.PatternSyntaxException;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.wiki.*;
+import org.apache.wiki.StringTransmutator;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.PluginException;
 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.parser.MarkupParser;
 import org.apache.wiki.parser.WikiDocument;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.preferences.Preferences.TimeFormat;
+import org.apache.wiki.providers.ProviderException;
 import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.util.RegExpUtil;
 import org.apache.wiki.util.TextUtil;
@@ -322,9 +326,10 @@
                 WikiPage page = null;
                 if( m_lastModified )
                 {
-                    page = m_engine.getPage( pageName );
-                    if( page != null )
+                    try
                     {
+                        page = m_engine.getPage( pageName );
+
                         Date lastModPage = page.getLastModified();
                         if( log.isDebugEnabled() )
                         {
@@ -335,7 +340,11 @@
                             m_dateLastModified = lastModPage;
                         }
                     }
-
+                    catch( PageNotFoundException e ) {}
+                    catch( ProviderException e )
+                    {
+                        log.debug( "Error while getting page data", e );
+                    }
                 }
             }
         }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/ReferringPagesPlugin.java Sun Mar 15 20:33:48 2009
@@ -29,8 +29,10 @@
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.PluginException;
 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;
 import org.apache.wiki.util.TextUtil;
 
 
@@ -86,10 +88,10 @@
             pageName = context.getPage().getName();
         }
 
-        WikiPage page = context.getEngine().getPage( pageName );
-        
-        if( page != null )
+        try
         {
+            WikiPage page = context.getEngine().getPage( pageName );
+        
             Collection   links  = refmgr.findReferrers( page.getName() );
             String       wikitext = "";
 
@@ -148,7 +150,13 @@
             
             return result.toString();
         }
-
+        catch( PageNotFoundException e )
+        {} // Fine
+        catch( ProviderException e )
+        {
+            throw new PluginException("Unable to get the latest page",e);
+        }
+        
         return "";
     }
 

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=754745&r1=754744&r2=754745&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 Sun Mar 15 20:33:48 2009
@@ -27,6 +27,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.content.WikiName;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
@@ -237,7 +238,7 @@
         return sb.toString();
     }
 
-    private String getPageDescription( WikiPage page )
+    private String getPageDescription( WikiPage page ) throws PageNotFoundException, ProviderException
     {
         StringBuilder buf = new StringBuilder();
         String author = getAuthor(page);
@@ -263,15 +264,24 @@
 
     private String getEntryDescription( WikiPage page )
     {
-        String res;
+        String res = "";
 
-        if( page instanceof Attachment )
+        try
         {
-            res = getAttachmentDescription( (WikiPage)page );
+            if( page instanceof Attachment )
+            {
+                res = getAttachmentDescription( (WikiPage)page );
+            }
+            else
+            {
+                res = getPageDescription( page );
+            }
         }
-        else
+        catch( ProviderException e )
         {
-            res = getPageDescription( page );
+            // FIXME: We should check if returning a plain empty string is ok,
+            //        as this just gobbles up the actual error.
+            log.error( "Unable to get description", e );
         }
 
         return res;

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/search/SearchManager.java Sun Mar 15 20:33:48 2009
@@ -28,6 +28,7 @@
 import org.apache.wiki.api.FilterException;
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventUtils;
@@ -330,8 +331,20 @@
         //  Makes sure that we're indexing the latest version of this
         //  page.
         //
-        WikiPage p = m_engine.getPage( wikiContext.getPage().getName() );
-        reindexPage( p );
+        WikiPage p;
+        try
+        {
+            p = m_engine.getPage( wikiContext.getPage().getName() );
+            reindexPage( p );
+        }
+        catch( PageNotFoundException e )
+        {
+            // Swallow quietly; something went wrong but no point making fuss about it.
+        }
+        catch( ProviderException e )
+        {
+            log.info("Could not reindex a page",e);
+        }
     }
 
     /**
@@ -355,11 +368,19 @@
         {
             String pageName = ((WikiPageEvent) event).getPageName();
 
-            WikiPage p = m_engine.getPage( pageName );
-            if( p != null )
+            try
             {
+                WikiPage p = m_engine.getPage( pageName );
                 pageRemoved( p );
             }
+            catch( PageNotFoundException e )
+            {
+                throw new InternalWikiException("Page removed already!?!");
+            }
+            catch( ProviderException e ) 
+            {
+                // FIXME: How should it deal with this?
+            }
         }
     }
 

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=754745&r1=754744&r2=754745&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 Sun Mar 15 20:33:48 2009
@@ -27,6 +27,7 @@
 
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.providers.ProviderException;
 
 
 /**
@@ -38,7 +39,6 @@
  * @since 2.1.5
  * @author ebu at ecyrd dot com
  */
-// FIXME: Move to the "search" -package in 3.0
 public class SearchMatcher
 {
     private QueryItem[] m_queries;
@@ -134,7 +134,15 @@
 
         if( totalscore > 0 )
         {
-            return new SearchResultImpl( wikiname, totalscore );
+            try
+            {
+                return new SearchResultImpl( m_engine.getPage( wikiname ), totalscore );
+            }
+            catch( ProviderException e )
+            {
+                // FIXME: Should really log this
+                return null;
+            }
         }
 
         return null;
@@ -156,9 +164,9 @@
          *  @param name Page Name
          *  @param score A score from 0+
          */
-        public SearchResultImpl( String name, int score )
+        public SearchResultImpl( WikiPage page, int score )
         {
-            m_page  = m_engine.getPage( name );
+            m_page  = page;
             m_score = score;
         }
 

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/DiffLinkTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/DiffLinkTag.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/DiffLinkTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/DiffLinkTag.java Sun Mar 15 20:33:48 2009
@@ -21,10 +21,15 @@
 package org.apache.wiki.tags;
 
 import java.io.IOException;
+
 import javax.servlet.jsp.JspWriter;
 
-import org.apache.wiki.*;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.content.PageNotFoundException;
+import org.apache.wiki.providers.ProviderException;
 
 
 /**
@@ -113,51 +118,58 @@
             return SKIP_BODY;
         }
 
-        if( VER_LATEST.equals(getVersion()) )
+        try
         {
-            WikiPage latest = engine.getPage( pageName, 
-                                              WikiProvider.LATEST_VERSION );
-
-            if( latest == null )
+            if( VER_LATEST.equals(getVersion()) )
             {
-                // This may occur if matchEnglishPlurals is on, and we access the wrong page name
-                return SKIP_BODY;
+                WikiPage latest = engine.getPage( pageName, 
+                                                  WikiProvider.LATEST_VERSION );
+                r1 = latest.getVersion();
+            }
+            else if( VER_PREVIOUS.equals(getVersion()) )
+            {
+                r1 = m_wikiContext.getPage().getVersion() - 1;
+                r1 = (r1 < 1 ) ? 1 : r1;
+            }
+            else if( VER_CURRENT.equals(getVersion()) )
+            {
+                r1 = m_wikiContext.getPage().getVersion();
+            }
+            else
+            {
+                r1 = Integer.parseInt( getVersion() );
             }
-            r1 = latest.getVersion();
-        }
-        else if( VER_PREVIOUS.equals(getVersion()) )
-        {
-            r1 = m_wikiContext.getPage().getVersion() - 1;
-            r1 = (r1 < 1 ) ? 1 : r1;
-        }
-        else if( VER_CURRENT.equals(getVersion()) )
-        {
-            r1 = m_wikiContext.getPage().getVersion();
-        }
-        else
-        {
-            r1 = Integer.parseInt( getVersion() );
-        }
 
-        if( VER_LATEST.equals(getNewVersion()) )
-        {
-            WikiPage latest = engine.getPage( pageName,
-                                              WikiProvider.LATEST_VERSION );
+            if( VER_LATEST.equals(getNewVersion()) )
+            {
+                WikiPage latest = engine.getPage( pageName,
+                                                  WikiProvider.LATEST_VERSION );
 
-            r2 = latest.getVersion();
-        }
-        else if( VER_PREVIOUS.equals(getNewVersion()) )
-        {
-            r2 = m_wikiContext.getPage().getVersion() - 1;
-            r2 = (r2 < 1 ) ? 1 : r2;
+                r2 = latest.getVersion();
+            }
+            else if( VER_PREVIOUS.equals(getNewVersion()) )
+            {
+                r2 = m_wikiContext.getPage().getVersion() - 1;
+                r2 = (r2 < 1 ) ? 1 : r2;
+            }
+            else if( VER_CURRENT.equals(getNewVersion()) )
+            {
+                r2 = m_wikiContext.getPage().getVersion();
+            }
+            else
+            {
+                r2 = Integer.parseInt( getNewVersion() );
+            }
         }
-        else if( VER_CURRENT.equals(getNewVersion()) )
+        catch( PageNotFoundException e )
         {
-            r2 = m_wikiContext.getPage().getVersion();
+            // This may occur if matchEnglishPlurals is on, and we access the wrong page name
+            return SKIP_BODY;
         }
-        else
+        catch( ProviderException e )
         {
-            r2 = Integer.parseInt( getNewVersion() );
+            log.error( "Unable to get page data", e );
+            return SKIP_BODY;
         }
 
         String url = m_wikiContext.getURL( WikiContext.DIFF,

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditLinkTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditLinkTag.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditLinkTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/EditLinkTag.java Sun Mar 15 20:33:48 2009
@@ -26,6 +26,8 @@
 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.providers.ProviderException;
 
 
 /**
@@ -110,7 +112,19 @@
                 if( page == null )
                 {
                     // No page, so go fetch according to page name.
-                    page = engine.getPage( m_pageName );
+                    try
+                    {
+                        page = engine.getPage( m_pageName );
+                    }
+                    catch( PageNotFoundException e )
+                    {
+                        return SKIP_BODY;
+                    }
+                    catch( ProviderException e )
+                    {
+                        log.error( "Unable to fetch page", e );
+                        return SKIP_BODY;
+                    }
                 }
                 
                 if( page != null )

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertDiffTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertDiffTag.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertDiffTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertDiffTag.java Sun Mar 15 20:33:48 2009
@@ -27,6 +27,8 @@
 
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
+import org.apache.wiki.content.PageNotFoundException;
+import org.apache.wiki.providers.ProviderException;
 
 
 /**
@@ -91,8 +93,19 @@
         }
         else
         {
-            ctx = (WikiContext)m_wikiContext.clone();
-            ctx.setPage( engine.getPage(m_pageName) );
+            try
+            {
+                ctx = (WikiContext)m_wikiContext.clone();
+                ctx.setPage( engine.getPage(m_pageName) );
+            }
+            catch(PageNotFoundException e)
+            {
+                return SKIP_BODY;
+            }
+            catch( ProviderException e )
+            {
+                throw new IOException( "Unable to get page "+e.getMessage() );
+            }
         }
 
         Integer vernew = (Integer) pageContext.getAttribute( ATTR_NEWVERSION,

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=754745&r1=754744&r2=754745&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 Sun Mar 15 20:33:48 2009
@@ -32,6 +32,7 @@
 import org.apache.wiki.*;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.parser.JSPWikiMarkupParser;
 import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.providers.ProviderException;
@@ -345,7 +346,8 @@
         return addTo + buf.toString();
     }
 
-    private String makeBasicURL( String context, String page, String parms, boolean absolute )
+    private String makeBasicURL( String context, String page, String parms, boolean absolute ) 
+        throws PageNotFoundException, ProviderException
     {
         String url;
         WikiEngine engine = m_wikiContext.getEngine();

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=754745&r1=754744&r2=754745&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 Sun Mar 15 20:33:48 2009
@@ -34,6 +34,7 @@
 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;
 
 
 /**
@@ -150,10 +151,19 @@
             //
             if( EDIT.equals(permission) )
             {
-                WikiPage latest = m_wikiContext.getEngine().getPage( page.getName() );
-                if( page.getVersion() != WikiProvider.LATEST_VERSION &&
-                    latest.getVersion() != page.getVersion() )
+                try
                 {
+                    WikiPage latest = m_wikiContext.getEngine().getPage( page.getName() );
+                    if( page.getVersion() != WikiProvider.LATEST_VERSION &&
+                        latest.getVersion() != page.getVersion() )
+                    {
+                        return false;
+                    }
+                }
+                catch( ProviderException e )
+                {
+                    // FIXME: What is the correct action here?
+                    log.error( "Failed to find latest version", e );
                     return false;
                 }
             }

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=754745&r1=754744&r2=754745&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 Sun Mar 15 20:33:48 2009
@@ -61,22 +61,21 @@
     {
         WikiRuntimeConfiguration config = (WikiRuntimeConfiguration) StripesFilter.getConfiguration();
         WikiEngine engine = config.getEngine();
-        WikiPage page = engine.getPage( pageName );
-        if( page == null )
+        WikiPage page = null;
+        try
         {
-            try
-            {
-                String finalName = engine.getWikiContextFactory().getFinalPageName( pageName );
-                if( finalName == null || engine.getPage( finalName ) == null )
-                {
-                    errors.add( new LocalizableError( "common.nopage", pageName ) );
-                }
-            }
-            catch( ProviderException e )
+            page = engine.getPage( pageName );
+
+            String finalName = engine.getWikiContextFactory().getFinalPageName( pageName );
+            if( finalName == null || engine.getPage( finalName ) == null )
             {
-                errors.add( new SimpleError( e.getMessage() ) );
+                errors.add( new LocalizableError( "common.nopage", pageName ) );
             }
         }
+        catch( ProviderException e )
+        {
+            errors.add( new SimpleError( e.getMessage() ) );
+        }
         return page;
     }
 

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java Sun Mar 15 20:33:48 2009
@@ -44,7 +44,8 @@
     /** Error code: no such page. */
     public static final int ERR_NOPAGE       = 1;
     public static final int ERR_NOPERMISSION = 2;
-
+    public static final int ERR_SERVER_ERROR = 3;
+    
     /**
      *  Link to a local wiki page.
      */

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java Sun Mar 15 20:33:48 2009
@@ -36,6 +36,7 @@
 import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.WikiSecurityException;
 import org.apache.wiki.auth.permissions.PermissionFactory;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.content.WikiName;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
@@ -64,6 +65,10 @@
 
     private WikiContext m_context;
     
+    private static final int ERR_NOTFOUND      = 404;
+    private static final int ERR_SERVER_ERROR  = 500;
+    private static final int ERR_UNAUTHORIZED  = 401;
+    
     /**
      *  {@inheritDoc}
      */
@@ -96,21 +101,21 @@
             {
                 if( !mgr.checkPermission( m_context.getWikiSession(), PermissionFactory.getPagePermission( page, permission ) ))
                 {
-                    throw new XmlRpcException( 1, "No permission" );
+                    throw new XmlRpcException( ERR_UNAUTHORIZED, "No permission" );
                 }   
             }
             else
             {
-                throw new XmlRpcException( 1, "Unknown login" );
+                throw new XmlRpcException( ERR_UNAUTHORIZED, "Unknown login" );
             }
         }
         catch( WikiSecurityException e )
         {
-            throw new XmlRpcException( 1, e.getMessage(), e );
+            throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage(), e );
         }
         catch( LoginException e )
         {
-            throw new XmlRpcException( 1, e.getMessage(), e );
+            throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage(), e );
         }
         return;
     }
@@ -130,13 +135,25 @@
                                     String password )
         throws XmlRpcException
     {
-        WikiPage page = m_context.getEngine().getPage( blogid );
+        WikiPage page;
+        try
+        {
+            page = m_context.getEngine().getPage( blogid );
 
-        checkPermissions( page, username, password, "view" );
+            checkPermissions( page, username, password, "view" );
 
-        Hashtable ht = new Hashtable();
+            Hashtable ht = new Hashtable();
 
-        return ht;
+            return ht;
+        }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException(ERR_NOTFOUND,"No such page");
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException(ERR_SERVER_ERROR,"No such page");
+        }
     }
 
     private String getURL( String page )
@@ -153,35 +170,46 @@
      *  @param page The actual entry page
      *  @return A metaWeblog entry struct.
      */
-    private Hashtable<String,Object> makeEntry( WikiPage page )
+    private Hashtable<String,Object> makeEntry( WikiPage page ) throws XmlRpcException
     {
         Hashtable<String, Object> ht = new Hashtable<String, Object>();
 
-        WikiPage firstVersion = m_context.getEngine().getPage( page.getName(), 1 );
-
-        ht.put("dateCreated", firstVersion.getLastModified());
-        ht.put("link", getURL(page.getName()));
-        ht.put("permaLink", getURL(page.getName()));
-        ht.put("postid", page.getName());
-        ht.put("userid", page.getAuthor());
+        try
+        {
+            WikiPage firstVersion = m_context.getEngine().getPage( page.getName(), 1 );
 
-        String pageText = m_context.getEngine().getText(page.getName());
-        String title = "";
-        int firstLine = pageText.indexOf('\n');
+            ht.put("dateCreated", firstVersion.getLastModified());
+            ht.put("link", getURL(page.getName()));
+            ht.put("permaLink", getURL(page.getName()));
+            ht.put("postid", page.getName());
+            ht.put("userid", page.getAuthor());
+
+            String pageText = m_context.getEngine().getText(page.getName());
+            String title = "";
+            int firstLine = pageText.indexOf('\n');
 
-        if( firstLine > 0 )
-        {
-            title = pageText.substring( 0, firstLine );
-        }
+            if( firstLine > 0 )
+            {
+                title = pageText.substring( 0, firstLine );
+            }
             
-        if( title.trim().length() == 0 ) title = page.getName();
-
-        // Remove wiki formatting
-        while( title.startsWith("!") ) title = title.substring(1);
+            if( title.trim().length() == 0 ) title = page.getName();
 
-        ht.put("title", title);
-        ht.put("description", pageText);
+            // Remove wiki formatting
+            while( title.startsWith("!") ) title = title.substring(1);
 
+            ht.put("title", title);
+            ht.put("description", pageText);
+        }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException(ERR_NOTFOUND,"Not found");
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException(ERR_SERVER_ERROR,e.getMessage());
+        }
+        
         return ht;
     }
 
@@ -210,12 +238,12 @@
 
         log.info( "metaWeblog.getRecentPosts() called");
 
-        WikiPage page = m_context.getEngine().getPage( blogid );
-
-        checkPermissions( page, username, password, "view" );
-
         try
         {
+            WikiPage page = m_context.getEngine().getPage( blogid );
+
+            checkPermissions( page, username, password, "view" );
+
             WeblogPlugin plugin = new WeblogPlugin();
 
             List<WikiPage> changed = plugin.findBlogEntries(m_context.getEngine().getPageManager(), 
@@ -234,11 +262,15 @@
             }
 
         }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException( ERR_NOTFOUND, e.getMessage() );
+        }
         catch( ProviderException e )
         {
             log.error( "Failed to list recent posts", e );
 
-            throw new XmlRpcException( 0, e.getMessage() );
+            throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage() );
         }
 
         return result;
@@ -265,11 +297,11 @@
         log.info("metaWeblog.newPost() called");
         WikiEngine engine = m_context.getEngine();
         
-        WikiPage page = engine.getPage( blogid );
-        checkPermissions( page, username, password, "createPages" );
-
         try
         {
+            WikiPage page = engine.getPage( blogid );
+            checkPermissions( page, username, password, "createPages" );
+            
             WeblogEntryPlugin plugin = new WeblogEntryPlugin();
 
             String pageName = plugin.getNewEntryPage( engine, blogid );
@@ -288,10 +320,14 @@
 
             engine.saveText( context, text.toString() );
         }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException( ERR_NOTFOUND, "Not found" );
+        }
         catch( Exception e )
         {
             log.error("Failed to create weblog entry",e);
-            throw new XmlRpcException( 0, "Failed to create weblog entry: "+e.getMessage() );
+            throw new XmlRpcException( ERR_SERVER_ERROR, "Failed to create weblog entry: "+e.getMessage() );
         }
 
         return ""; // FIXME:
@@ -321,16 +357,15 @@
 
         log.info("metaWeblog.newMediaObject() called");
 
-        WikiPage page = engine.getPage( blogid );
-        checkPermissions( page, username, password, "upload" );
-
-        String name = (String) content.get( "name" );
-        byte[] data = (byte[]) content.get( "bits" );
-
-        AttachmentManager attmgr = engine.getAttachmentManager();
-
         try
         {
+            WikiPage page = engine.getPage( blogid );
+            checkPermissions( page, username, password, "upload" );
+
+            String name = (String) content.get( "name" );
+            byte[] data = (byte[]) content.get( "bits" );
+
+            AttachmentManager attmgr = engine.getAttachmentManager();
             Attachment att = engine.getContentManager().addPage( WikiName.valueOf( blogid ).resolve( name ),
                                                                  "application/octet-stream"); //FIXME! Needs a better guess
             att.setAuthor( username );
@@ -341,10 +376,14 @@
 
             url = engine.getURL( WikiContext.ATTACH, att.getName(), null, true );
         }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException( ERR_NOTFOUND, "Not found" );
+        }
         catch( Exception e )
         {
             log.error( "Failed to upload attachment", e );
-            throw new XmlRpcException( 0, "Failed to upload media object: "+e.getMessage() );
+            throw new XmlRpcException( ERR_SERVER_ERROR, "Failed to upload media object: "+e.getMessage() );
         }
 
         Hashtable<String, Object> result = new Hashtable<String, Object>();
@@ -369,12 +408,12 @@
         WikiEngine engine = m_context.getEngine();
         log.info("metaWeblog.editPost("+postid+") called");
 
-        // FIXME: Is postid correct?  Should we determine it from the page name?
-        WikiPage page = engine.getPage( postid );
-        checkPermissions( page, username, password, "edit" );
-
         try
         {
+            // FIXME: Is postid correct?  Should we determine it from the page name?
+            WikiPage page = engine.getPage( postid );
+            checkPermissions( page, username, password, "edit" );
+
             WikiPage entryPage = (WikiPage)page.clone();
             entryPage.setAuthor( username );
 
@@ -389,10 +428,14 @@
 
             engine.saveText( context, text.toString() );
         }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException( ERR_NOTFOUND, "Not found" );
+        }
         catch( Exception e )
         {
             log.error("Failed to create weblog entry",e);
-            throw new XmlRpcException( 0, "Failed to update weblog entry: "+e.getMessage() );
+            throw new XmlRpcException( ERR_SERVER_ERROR, "Failed to update weblog entry: "+e.getMessage() );
         }
 
         return true;
@@ -409,10 +452,22 @@
     {
         String wikiname = "FIXME";
 
-        WikiPage page = m_context.getEngine().getPage( wikiname );
+        try
+        {
+            WikiPage page;
+            page = m_context.getEngine().getPage( wikiname );
 
-        checkPermissions( page, username, password, "view" );
+            checkPermissions( page, username, password, "view" );
 
-        return makeEntry( page );
+            return makeEntry( page );
+        }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException(ERR_NOTFOUND,"Not found");
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException(ERR_SERVER_ERROR,e.getMessage());
+        }
     }
 }

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=754745&r1=754744&r2=754745&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 Sun Mar 15 20:33:48 2009
@@ -29,8 +29,10 @@
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.auth.permissions.PermissionFactory;
+import org.apache.wiki.content.PageNotFoundException;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
+import org.apache.wiki.providers.ProviderException;
 import org.apache.wiki.util.TextUtil;
 import org.apache.xmlrpc.XmlRpcException;
 
@@ -189,29 +191,58 @@
      *  @param pagename Page Name as an RPC string (URL-encoded UTF-8)
      *  @return Real page name, as Java string.
      *  @throws XmlRpcException, if there is something wrong with the page.
+     * @throws  
+     * @throws PageNotFoundException 
      */
     private String parsePageCheckCondition( String pagename )
         throws XmlRpcException
     {
-        pagename = fromRPCString( pagename );
-
-        if( !m_engine.pageExists(pagename) )
+        try
         {
-            throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );
-        }
+            pagename = fromRPCString( pagename );
+
+            if( !m_engine.pageExists(pagename) )
+            {
+                throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );
+            }
 
-        WikiPage p = m_engine.getPage( pagename );
+            WikiPage p = m_engine.getPage( pagename );
         
-        checkPermission( PermissionFactory.getPagePermission( p, PagePermission.VIEW_ACTION ) );
+            checkPermission( PermissionFactory.getPagePermission( p, PagePermission.VIEW_ACTION ) );
         
-        return pagename;
+            return pagename;
+        }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException(1,"Not found");
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException(1,e.getMessage());            
+        }
     }
 
+    private WikiPage getWikiPage( String name, int version ) throws XmlRpcException
+    {
+        try
+        {
+            return m_engine.getPage(name,version);
+        }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException(1,"Not found");
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException(2,e.getMessage());
+        }
+    }
+    
     public Hashtable getPageInfo( String pagename )
         throws XmlRpcException
     {
         pagename = parsePageCheckCondition( pagename );
-        return encodeWikiPage( m_engine.getPage(pagename) );
+        return encodeWikiPage( getWikiPage(pagename,-1) );
     }
 
     public Hashtable getPageInfoVersion( String pagename, int version )
@@ -219,7 +250,7 @@
     {
         pagename = parsePageCheckCondition( pagename );
 
-        return encodeWikiPage( m_engine.getPage( pagename, version ) );
+        return encodeWikiPage( getWikiPage( pagename, version ) );
     }
 
     public byte[] getPage( String pagename )
@@ -245,7 +276,14 @@
     {
         pagename = parsePageCheckCondition( pagename );
 
-        return toRPCBase64( m_engine.getHTML( pagename ) );
+        try
+        {
+            return toRPCBase64( m_engine.getHTML( pagename ) );
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException( 1, pagename );
+        }
     }
 
     public byte[] getPageHTMLVersion( String pagename, int version )
@@ -253,7 +291,14 @@
     {
         pagename = parsePageCheckCondition( pagename );
 
-        return toRPCBase64( m_engine.getHTML( pagename, version ) );
+        try
+        {
+            return toRPCBase64( m_engine.getHTML( pagename, version ) );
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException( 1, e.getMessage() );
+        }
     }
 
     public Vector listLinks( String pagename )
@@ -261,91 +306,99 @@
     {
         pagename = parsePageCheckCondition( pagename );
 
-        WikiPage page = m_engine.getPage( pagename );
-        String pagedata = m_engine.getPureText( page );
-
-        LinkCollector localCollector = new LinkCollector();
-        LinkCollector extCollector   = new LinkCollector();
-        LinkCollector attCollector   = new LinkCollector();
-
-        WikiContext context = m_engine.getWikiContextFactory().newViewContext( page );
-        context.setVariable( WikiEngine.PROP_REFSTYLE, "absolute" );
-
-        m_engine.textToHTML( context,
-                             pagedata,
-                             localCollector,
-                             extCollector,
-                             attCollector );
+        try
+        {
+            WikiPage page = m_engine.getPage( pagename );
+            String pagedata = m_engine.getPureText( page );
 
-        Vector<Hashtable<String, String>> result = new Vector<Hashtable<String, String>>();
+            LinkCollector localCollector = new LinkCollector();
+            LinkCollector extCollector   = new LinkCollector();
+            LinkCollector attCollector   = new LinkCollector();
+
+            WikiContext context = m_engine.getWikiContextFactory().newViewContext( page );
+            context.setVariable( WikiEngine.PROP_REFSTYLE, "absolute" );
+
+            m_engine.textToHTML( context,
+                                 pagedata,
+                                 localCollector,
+                                 extCollector,
+                                 attCollector );
 
-        //
-        //  Add local links.
-        //
-        for( Iterator i = localCollector.getLinks().iterator(); i.hasNext(); )
-        {
-            String link = (String) i.next();
-            Hashtable<String, String> ht = new Hashtable<String, String>();
-            ht.put( "page", toRPCString( link ) );
-            ht.put( "type", LINK_LOCAL );
+            Vector<Hashtable<String, String>> result = new Vector<Hashtable<String, String>>();
 
             //
-            //  FIXME: This is a kludge.  The link format should really be queried
-            //  from the TranslatorReader itself.  Also, the link format should probably
-            //  have information on whether the page exists or not.
+            //  Add local links.
             //
+            for( Iterator i = localCollector.getLinks().iterator(); i.hasNext(); )
+            {
+                String link = (String) i.next();
+                Hashtable<String, String> ht = new Hashtable<String, String>();
+                ht.put( "page", toRPCString( link ) );
+                ht.put( "type", LINK_LOCAL );
+
+                //
+                //  FIXME: This is a kludge.  The link format should really be queried
+                //  from the TranslatorReader itself.  Also, the link format should probably
+                //  have information on whether the page exists or not.
+                //
+
+                //
+                //  FIXME: The current link collector interface is not very good, since
+                //  it causes this.
+                //
+
+                if( m_engine.pageExists(link) )
+                {
+                    ht.put( "href", context.getURL(WikiContext.VIEW,link) );
+                }
+                else
+                {
+                    ht.put( "href", context.getURL(WikiContext.EDIT,link) );
+                }
+
+                result.add( ht );
+            }
 
             //
-            //  FIXME: The current link collector interface is not very good, since
-            //  it causes this.
+            // Add links to inline attachments
             //
-
-            if( m_engine.pageExists(link) )
-            {
-                ht.put( "href", context.getURL(WikiContext.VIEW,link) );
-            }
-            else
+            for( Iterator i = attCollector.getLinks().iterator(); i.hasNext(); )
             {
-                ht.put( "href", context.getURL(WikiContext.EDIT,link) );
-            }
+                String link = (String) i.next();
 
-            result.add( ht );
-        }
+                Hashtable<String, String> ht = new Hashtable<String, String>();
 
-        //
-        // Add links to inline attachments
-        //
-        for( Iterator i = attCollector.getLinks().iterator(); i.hasNext(); )
-        {
-            String link = (String) i.next();
+                ht.put( "page", toRPCString( link ) );
+                ht.put( "type", LINK_LOCAL );
+                ht.put( "href", context.getURL(WikiContext.ATTACH,link) );
 
-            Hashtable<String, String> ht = new Hashtable<String, String>();
+                result.add( ht );
+            }
 
-            ht.put( "page", toRPCString( link ) );
-            ht.put( "type", LINK_LOCAL );
-            ht.put( "href", context.getURL(WikiContext.ATTACH,link) );
+            //
+            // External links don't need to be changed into XML-RPC strings,
+            // simply because URLs are by definition ASCII.
+            //
 
-            result.add( ht );
-        }
+            for( Iterator i = extCollector.getLinks().iterator(); i.hasNext(); )
+            {
+                String link = (String) i.next();
+                
+                Hashtable<String, String> ht = new Hashtable<String, String>();
+
+                ht.put( "page", link );
+                ht.put( "type", LINK_EXTERNAL );
+                ht.put( "href", link );
 
-        //
-        // External links don't need to be changed into XML-RPC strings,
-        // simply because URLs are by definition ASCII.
-        //
+                result.add( ht );
+            }
 
-        for( Iterator i = extCollector.getLinks().iterator(); i.hasNext(); )
+            return result;
+        }
+        catch( ProviderException e )
         {
-            String link = (String) i.next();
-
-            Hashtable<String, String> ht = new Hashtable<String, String>();
-
-            ht.put( "page", link );
-            ht.put( "type", LINK_EXTERNAL );
-            ht.put( "href", link );
-
-            result.add( ht );
+            throw new XmlRpcException( 1, e.getMessage() );
         }
 
-        return result;
     }
 }

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=754745&r1=754744&r2=754745&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 Sun Mar 15 20:33:48 2009
@@ -29,6 +29,8 @@
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.auth.permissions.PermissionFactory;
+import org.apache.wiki.content.PageNotFoundException;
+import org.apache.wiki.providers.ProviderException;
 import org.apache.xmlrpc.XmlRpcException;
 
 
@@ -146,15 +148,21 @@
     private String parsePageCheckCondition( String pagename )
         throws XmlRpcException
     {
-        if( !m_engine.pageExists(pagename) )
+        try
         {
-            throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );
-        }
-
-        WikiPage p = m_engine.getPage( pagename );
+            WikiPage p = m_engine.getPage( pagename );
         
-        checkPermission( PermissionFactory.getPagePermission( p, PagePermission.VIEW_ACTION ) );
-        return pagename;
+            checkPermission( PermissionFactory.getPagePermission( p, PagePermission.VIEW_ACTION ) );
+            return pagename;
+        }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );            
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage() );            
+        }
     }
 
     public Hashtable getPageInfo( String pagename )
@@ -162,7 +170,18 @@
     {
         pagename = parsePageCheckCondition( pagename );
         
-        return encodeWikiPage( m_engine.getPage(pagename) );
+        try
+        {
+            return encodeWikiPage( m_engine.getPage(pagename) );
+        }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );            
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage() );            
+        }
     }
 
     public Hashtable getPageInfoVersion( String pagename, int version )
@@ -170,7 +189,19 @@
     {
         pagename = parsePageCheckCondition( pagename );
 
-        return encodeWikiPage( m_engine.getPage( pagename, version ) );
+        try
+        {
+            return encodeWikiPage( m_engine.getPage( pagename, version ) );
+        }
+        catch( PageNotFoundException e )
+        {
+            throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );            
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage() );            
+        }
+            
     }
 
     public String getPage( String pagename )
@@ -196,7 +227,14 @@
     {
         pagename = parsePageCheckCondition( pagename );
 
-        return m_engine.getHTML( pagename );
+        try
+        {
+            return m_engine.getHTML( pagename );
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage() );            
+        }
     }
 
     public String getPageHTMLVersion( String pagename, int version )
@@ -204,7 +242,14 @@
     {
         pagename = parsePageCheckCondition( pagename );
 
-        return m_engine.getHTML( pagename, version );
+        try
+        {
+            return m_engine.getHTML( pagename, version );
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage() );            
+        }
     }
 
     public Vector listLinks( String pagename )
@@ -212,82 +257,89 @@
     {
         pagename = parsePageCheckCondition( pagename );
 
-        WikiPage page = m_engine.getPage( pagename );
-        String pagedata = m_engine.getPureText( page );
-
-        LinkCollector localCollector = new LinkCollector();
-        LinkCollector extCollector   = new LinkCollector();
-        LinkCollector attCollector   = new LinkCollector();
-
-        WikiContext context = m_engine.getWikiContextFactory().newViewContext( page );
-        context.setVariable( WikiEngine.PROP_REFSTYLE, "absolute" );
-
-        m_engine.textToHTML( context,
-                             pagedata,
-                             localCollector,
-                             extCollector,
-                             attCollector );
-
-        Vector<Hashtable<String, String>> result = new Vector<Hashtable<String, String>>();
-
-        // FIXME: Contains far too much common with RPCHandler.  Refactor!
-
-        //
-        //  Add local links.
-        //
-        for( Iterator i = localCollector.getLinks().iterator(); i.hasNext(); )
+        try
         {
-            String link = (String) i.next();
-            Hashtable<String, String> ht = new Hashtable<String, String>();
-            ht.put( "page", link );
-            ht.put( "type", LINK_LOCAL );
+            WikiPage page = m_engine.getPage( pagename );
+            String pagedata = m_engine.getPureText( page );
 
-            if( m_engine.pageExists(link) )
+            LinkCollector localCollector = new LinkCollector();
+            LinkCollector extCollector   = new LinkCollector();
+            LinkCollector attCollector   = new LinkCollector();
+
+            WikiContext context = m_engine.getWikiContextFactory().newViewContext( page );
+            context.setVariable( WikiEngine.PROP_REFSTYLE, "absolute" );
+
+            m_engine.textToHTML( context,
+                                 pagedata,
+                                 localCollector,
+                                 extCollector,
+                                 attCollector );
+
+            Vector<Hashtable<String, String>> result = new Vector<Hashtable<String, String>>();
+
+            // FIXME: Contains far too much common with RPCHandler.  Refactor!
+
+            //
+            //  Add local links.
+            //
+            for( Iterator i = localCollector.getLinks().iterator(); i.hasNext(); )
             {
-                ht.put( "href", context.getViewURL(link) );
+                String link = (String) i.next();
+                Hashtable<String, String> ht = new Hashtable<String, String>();
+                ht.put( "page", link );
+                ht.put( "type", LINK_LOCAL );
+
+                if( m_engine.pageExists(link) )
+                {
+                    ht.put( "href", context.getViewURL(link) );
+                }
+                else
+                {
+                    ht.put( "href", context.getURL(WikiContext.EDIT,link) );
+                }
+
+                result.add( ht );
             }
-            else
+
+            //
+            // Add links to inline attachments
+            //
+            for( Iterator i = attCollector.getLinks().iterator(); i.hasNext(); )
             {
-                ht.put( "href", context.getURL(WikiContext.EDIT,link) );
-            }
+                String link = (String) i.next();
 
-            result.add( ht );
-        }
+                Hashtable<String, String> ht = new Hashtable<String, String>();
 
-        //
-        // Add links to inline attachments
-        //
-        for( Iterator i = attCollector.getLinks().iterator(); i.hasNext(); )
-        {
-            String link = (String) i.next();
+                ht.put( "page", link );
+                ht.put( "type", LINK_LOCAL );
+                ht.put( "href", context.getURL(WikiContext.ATTACH,link) );
 
-            Hashtable<String, String> ht = new Hashtable<String, String>();
+                result.add( ht );
+            }
 
-            ht.put( "page", link );
-            ht.put( "type", LINK_LOCAL );
-            ht.put( "href", context.getURL(WikiContext.ATTACH,link) );
+            //
+            // External links don't need to be changed into XML-RPC strings,
+            // simply because URLs are by definition ASCII.
+            //
 
-            result.add( ht );
-        }
+            for( Iterator i = extCollector.getLinks().iterator(); i.hasNext(); )
+            {
+                String link = (String) i.next();
 
-        //
-        // External links don't need to be changed into XML-RPC strings,
-        // simply because URLs are by definition ASCII.
-        //
+                Hashtable<String, String> ht = new Hashtable<String, String>();
 
-        for( Iterator i = extCollector.getLinks().iterator(); i.hasNext(); )
-        {
-            String link = (String) i.next();
+                ht.put( "page", link );
+                ht.put( "type", LINK_EXTERNAL );
+                ht.put( "href", link );
 
-            Hashtable<String, String> ht = new Hashtable<String, String>();
-
-            ht.put( "page", link );
-            ht.put( "type", LINK_EXTERNAL );
-            ht.put( "href", link );
+                result.add( ht );
+            }
 
-            result.add( ht );
+            return result;
+        }
+        catch( ProviderException e )
+        {
+            throw new XmlRpcException( ERR_SERVER_ERROR, e.getMessage() );
         }
-
-        return result;
     }
 }

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java Sun Mar 15 20:33:48 2009
@@ -75,7 +75,7 @@
         m_engine.shutdown();
     }
 
-    public void testGetPermissions() throws WikiSecurityException
+    public void testGetPermissions() throws ProviderException, WikiSecurityException
     {
         WikiPage page = m_engine.getPage( "TestDefaultPage" );
         Acl acl = m_engine.getAclManager().getPermissions( page );
@@ -178,7 +178,7 @@
         assertFalse( m.find() );
     }
 
-    public void testPrintAcl() throws WikiSecurityException
+    public void testPrintAcl() throws Exception
     {
         // Verify that the printed Acl for the test page is OK
         WikiPage page = m_engine.getPage( "TestAclPage" );

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java?rev=754745&r1=754744&r2=754745&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java Sun Mar 15 20:33:48 2009
@@ -38,6 +38,7 @@
 import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.content.WikiName;
+import org.apache.wiki.providers.ProviderException;
 import org.apache.wiki.render.XHTMLRenderer;
 import org.apache.wiki.util.TextUtil;
 
@@ -99,7 +100,7 @@
     private String translate( String src )
     throws IOException,
             NoRequiredPropertyException,
-            ServletException
+            ServletException, ProviderException
     {
         return translate( testEngine.createPage( WikiName.valueOf( PAGE_NAME ) ), src );
     }
@@ -107,7 +108,7 @@
     private String translate( WikiEngine e, String src )
         throws IOException,
                NoRequiredPropertyException,
-               ServletException
+               ServletException, ProviderException
     {
         return translate( e, e.createPage( WikiName.valueOf( PAGE_NAME ) ), src );
     }