jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r919819 - in /incubator/jspwiki/trunk: src/java/org/apache/wiki/url/ tests/java/org/apache/wiki/url/
Date Sat, 06 Mar 2010 19:14:11 GMT
Author: ajaquith
Date: Sat Mar  6 19:14:11 2010
New Revision: 919819

URL: http://svn.apache.org/viewvc?rev=919819&view=rev
Log:
Removed old URLConstructors. Fixed bug in StripesUrlContructor that caused it to exhibit slightly
behavior different different behavior than DefaultUrlContructor. It now generates URLs identically.
Method parsePage() was removed from UrlContructor's interface spec. (The only URLConstructor
implementation is StripesUrlConstructor, anyway, it doesn't need to do any page-param parsing
because the framework takes care of it.)

Added:
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/StripesURLConstructorTest.java
      - copied, changed from r897361, incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/DefaultURLConstructorTest.java
Removed:
    incubator/jspwiki/trunk/src/java/org/apache/wiki/url/DefaultURLConstructor.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/url/ShortURLConstructor.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/url/ShortViewURLConstructor.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/DefaultURLConstructorTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/ShortURLConstructorTest.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/ShortViewURLConstructorTest.java
Modified:
    incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/url/URLConstructor.java
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/AllTests.java

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java?rev=919819&r1=919818&r2=919819&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java Sat Mar
 6 19:14:11 2010
@@ -38,7 +38,6 @@
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.action.AbstractPageActionBean;
-import org.apache.wiki.action.AttachmentActionBean;
 import org.apache.wiki.action.GroupActionBean;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
@@ -52,7 +51,7 @@
  * 
  * @since 2.2
  */
-public class StripesURLConstructor extends DefaultURLConstructor
+public class StripesURLConstructor implements URLConstructor
 {
     private static final Logger log = LoggerFactory.getLogger( StripesURLConstructor.class
);
     
@@ -91,7 +90,6 @@
      *            be {@code null} if no parameters
      * @return the URL
      */
-    @Override
     public String makeURL( String context, String name, boolean absolute, String parameters
)
     {
         // Lazily obtain the binding factory reference
@@ -104,7 +102,7 @@
         String pathPrefix;
         UrlBuilder urlBuilder;
         boolean engineAbsolute = "absolute".equals( m_engine.getWikiProperties().getProperty(
WikiEngine.PROP_REFSTYLE ) );
-        pathPrefix = ( absolute | engineAbsolute ) ? m_baseUrl + m_pathPrefix : m_pathPrefix
;
+        pathPrefix = ( absolute | engineAbsolute ) ? m_baseUrl : m_pathPrefix ;
         
         // Split up the parameters
         Map<String,String> params = splitParamString(parameters);
@@ -128,20 +126,7 @@
             // Append the "name" parameter for page/group action beans (argh; we have to
do stupid if/else tricks)
             if ( name != null )
             {
-                if( AttachmentActionBean.class.isAssignableFrom( beanClass ) )
-                {
-                    int slashAt = name.indexOf( '/' );
-                    if ( slashAt == -1 )
-                    {
-                        urlBuilder.addParameter( "page",name );
-                    }
-                    else
-                    {
-                        urlBuilder.addParameter( "page", name.substring( 0,  slashAt ) );
-                        urlBuilder.addParameter( "attachment", name.substring( slashAt +
1,  name.length() ) );
-                    }
-                }
-                else if( AbstractPageActionBean.class.isAssignableFrom( beanClass ) )
+                if( AbstractPageActionBean.class.isAssignableFrom( beanClass ) )
                 {
                     urlBuilder.addParameter( "page", name );
                 }
@@ -168,6 +153,7 @@
         String url = pathPrefix + urlBuilder.toString();
         url = StringUtils.replace( url, "+", "%20" );
         url = StringUtils.replace( url, "%2F", "/" );
+        url = StringUtils.replace( url, "&amp%3B", "&amp;" ); // Fix double URL-encoding
 
         return url;
     }
@@ -177,8 +163,6 @@
      */
     public void initialize( WikiEngine engine, Properties properties )
     {
-        super.initialize( engine, properties );
-
         m_engine = engine;
         m_pathPrefix = getContextPath( engine );
         m_baseUrl = engine.getBaseURL();
@@ -189,6 +173,16 @@
         log.info( "StripesURLConstructor initialized." );
     }
 
+    /**
+     * Returns the webapp context portion of the base URL. This will be
+     * the substring of the base URL after the host, beginning with a slash
+     * and minus the trailing slash. For example, a base URL of
+     * {@code http://localhost:8080/JSPWiki/} has a context path of {@code /JSPWiki},
+     * while {@code http://localhost:8080/} has a context path of that is a
+     * zero-length string.
+     * @param engine the wiki engine
+     * @return the context path
+     */
     public static String getContextPath( WikiEngine engine )
     {
         // Initialize the path prefix for building URLs

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/url/URLConstructor.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/url/URLConstructor.java?rev=919819&r1=919818&r2=919819&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/url/URLConstructor.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/url/URLConstructor.java Sat Mar  6 19:14:11
2010
@@ -21,8 +21,6 @@
 package org.apache.wiki.url;
 
 import java.util.Properties;
-import java.io.IOException;
-import javax.servlet.http.HttpServletRequest;
 
 import org.apache.wiki.WikiEngine;
 
@@ -65,33 +63,4 @@
                            String name,
                            boolean absolute,
                            String parameters );
-
-    /**
-     *  Should parse the "page" parameter from the actual
-     *  request.  This is essentially the reverse of makeURL() - whenever a request 
-     *  constructed by calls to makeURL() is passed to this routine, it MUST be
-     *  able to parse the resource name (WikiPage, Attachment, other resource) from
-     *  the request.
-     *  
-     *  @param context In which request context the request was made (this should
-     *                 help in parsing)
-     *  @param request The HTTP request that was used when coming here
-     *  @param encoding The encoding with which the request was made (e.g., UTF-8).
-     *  @return This method must return the name of the resource.
-     *  @throws IOException If parsing failes
-     */
-    public String parsePage( String context,
-                             HttpServletRequest request,
-                             String encoding )
-        throws IOException;
-    
-    /**
-     *  Returns information which JSP page should continue handling
-     *  this type of request.
-     *  
-     * @param request The HTTP Request that was used to end up in this page.
-     * @return "Wiki.jsp", "PageInfo.jsp", etc.  Just return the name,
-     *         JSPWiki will figure out the page.
-     */
-    public String getForwardPage( HttpServletRequest request );
 }

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/AllTests.java?rev=919819&r1=919818&r2=919819&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/AllTests.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/AllTests.java Sat Mar  6 19:14:11
2010
@@ -34,9 +34,7 @@
     {
         TestSuite suite = new TestSuite("URL constructor tests");
 
-        suite.addTest( DefaultURLConstructorTest.suite() );
-        suite.addTest( ShortURLConstructorTest.suite() );
-        suite.addTest( ShortViewURLConstructorTest.suite() );
+        suite.addTest( StripesURLConstructorTest.suite() );
 
         return suite;
     }

Copied: incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/StripesURLConstructorTest.java
(from r897361, incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/DefaultURLConstructorTest.java)
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/StripesURLConstructorTest.java?p2=incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/StripesURLConstructorTest.java&p1=incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/DefaultURLConstructorTest.java&r1=897361&r2=919819&rev=919819&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/DefaultURLConstructorTest.java
(original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/url/StripesURLConstructorTest.java
Sat Mar  6 19:14:11 2010
@@ -26,20 +26,18 @@
 
 import java.util.Properties;
 
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.WikiException;
-import org.apache.wiki.url.DefaultURLConstructor;
-import org.apache.wiki.url.ShortViewURLConstructor;
-import org.apache.wiki.url.URLConstructor;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.apache.wiki.ui.stripes.ShortUrlFilter;
 
 
-public class DefaultURLConstructorTest extends TestCase
+public class StripesURLConstructorTest extends TestCase
 {
     TestEngine testEngine;
 
@@ -60,10 +58,10 @@
         throws WikiException
     {
         props.setProperty( WikiEngine.PROP_BASEURL, baseURL );
-        if( prefix != null ) props.setProperty( ShortViewURLConstructor.PROP_PREFIX, prefix
);
+        if( prefix != null ) props.setProperty( ShortUrlFilter.PROP_PREFIX, prefix );
         
         testEngine = new TestEngine(props);
-        URLConstructor constr = new DefaultURLConstructor();
+        URLConstructor constr = new StripesURLConstructor();
         
         constr.initialize( testEngine, props );
         
@@ -168,6 +166,6 @@
 
     public static Test suite()
     {
-        return new TestSuite( DefaultURLConstructorTest.class );
+        return new TestSuite( StripesURLConstructorTest.class );
     }
 }



Mime
View raw message