incubator-jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r755079 - /incubator/jspwiki/trunk/src/java/org/apache/wiki/action/WikiContextFactory.java
Date Tue, 17 Mar 2009 02:18:05 GMT
Author: ajaquith
Date: Tue Mar 17 02:18:05 2009
New Revision: 755079

URL: http://svn.apache.org/viewvc?rev=755079&view=rev
Log:
WikiContextFactory getSpecialPageResolution() has been renamed getSpecialPageURI(), and returns
URIs rather than Stripes Resolutions.

Modified:
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/WikiContextFactory.java

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=755079&r1=755078&r2=755079&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 Tue Mar
17 02:18:05 2009
@@ -33,17 +33,18 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.PageContext;
 
-import net.sourceforge.stripes.action.RedirectResolution;
 import net.sourceforge.stripes.mock.MockHttpServletRequest;
 import net.sourceforge.stripes.mock.MockHttpServletResponse;
 import net.sourceforge.stripes.mock.MockHttpSession;
 import net.sourceforge.stripes.util.ResolverUtil;
 
-import org.apache.wiki.*;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiProvider;
+import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.WikiException;
 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;
@@ -53,7 +54,6 @@
 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;
 
@@ -148,22 +148,11 @@
         // Stash the WikiSession as a request attribute
         WikiSession wikiSession = SessionMonitor.getInstance( engine ).find( request.getSession()
);
         request.setAttribute( ATTR_WIKISESSION, wikiSession );
-
-        WikiPage page = context.getPage();
-        if( page == null )
-        {
-            // If the page supplied was blank, default to the front page to
-            // avoid NPEs
-            // 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 );
     }
 
-    /** Private map with JSPs as keys, Resolutions as values */
-    private final Map<String, RedirectResolution> m_specialRedirects;
+    /** Private map with JSPs as keys, URIs (for absolute or relative URLs)  as values */
+    private final Map<String, URI> m_specialRedirects;
 
     private final WikiEngine m_engine;
 
@@ -187,7 +176,7 @@
     {
         super();
         m_engine = engine;
-        m_specialRedirects = new HashMap<String, RedirectResolution>();
+        m_specialRedirects = new HashMap<String, URI>();
 
         initRequestContextMap( properties );
         initSpecialPageRedirects( properties );
@@ -242,10 +231,10 @@
      * 
      * @since 2.4.20
      * @param page the page name.
-     * @return The rewritten page name, or <code>null</code>, if the page
-     *         does not exist.
+     * @return The rewritten page name
+     * @throws PageNotFoundException if the page does not exist
      */
-    public final String getFinalPageName( String page ) throws ProviderException
+    public final String getFinalPageName( String page ) throws PageNotFoundException, ProviderException
     {
         boolean isThere = simplePageExists( page );
         String finalName = page;
@@ -289,8 +278,8 @@
 
     /**
      * <p>
-     * If the page is a special page, this method returns a
-     * {@link net.sourceforge.stripes.action.RedirectResolution} for that page;
+     * If the page is a special page, this method returns an
+     * a String representing the relative or absolute URL to that page;
      * otherwise, it returns <code>null</code>.
      * </p>
      * <p>
@@ -299,9 +288,8 @@
      * always be redirected to "RecentChanges.jsp" instead of trying to find a
      * Wiki page called "RecentChanges".
      * </p>
-     * TODO: fix this algorithm
      */
-    public final RedirectResolution getSpecialPageResolution( String page )
+    public final URI getSpecialPageURI( String page )
     {
         return m_specialRedirects.get( page );
     }
@@ -477,23 +465,18 @@
                             // No http:// ftp:// or other authority, so it must be relative
to webapp /
                             if ( !redirectUrl.startsWith( "/" ) )
                             {
-                                redirectUrl = "/" + redirectUrl;
+                                uri = new URI( "/" + redirectUrl );
                             }
                         }
+                        
+                        // Add the URI for the special page
+                        m_specialRedirects.put( specialPage, uri );
                     }
                     catch( URISyntaxException e )
                     {
                         // The user supplied a STRANGE reference
                         log.error( "Strange special page reference: " + redirectUrl );
                     }
-                    
-                    // Add a new RedirectResolution for the special page
-                    RedirectResolution resolution = m_specialRedirects.get( specialPage );
-                    if( resolution == null )
-                    {
-                        resolution = new RedirectResolution( redirectUrl );
-                        m_specialRedirects.put( specialPage, resolution );
-                    }
                 }
             }
         }
@@ -555,7 +538,14 @@
             // funny plurals)
             if( pageName != null )
             {
-                page = resolvePage( request, pageName );
+                try
+                {
+                    page = resolvePage( request, pageName );
+                }
+                catch( PageNotFoundException e )
+                {
+                    // If we can't find the page, it must not exist yet (which is ok)
+                }
             }
         }
 
@@ -601,13 +591,13 @@
             page = pages[0];
             try
             {
-                // Look for singular/plural variants; if one
-                // not found, take the one the user supplied
+                // Look for singular/plural variants
                 String finalPage = getFinalPageName( page );
-                if( finalPage != null )
-                {
-                    page = finalPage;
-                }
+                return finalPage;
+            }
+            catch( PageNotFoundException e )
+            {
+                // No worries; use the one the user supplied
             }
             catch( ProviderException e )
             {
@@ -667,6 +657,6 @@
         {
             return true;
         }
-        return m_engine.getPageManager().pageExists( page );
+        return m_engine.pageExists( page );
     }
 }



Mime
View raw message