org.apache.wiki.url
Class ShortURLConstructor

java.lang.Object
  extended by org.apache.wiki.url.DefaultURLConstructor
      extended by org.apache.wiki.url.ShortURLConstructor
All Implemented Interfaces:
URLConstructor
Direct Known Subclasses:
ShortViewURLConstructor

public class ShortURLConstructor
extends DefaultURLConstructor

Provides a way to do short URLs of the form /wiki/PageName.

Since:
2.2

Field Summary
protected  String m_urlPrefix
          Contains the path part after the JSPWiki base URL
static String PROP_PREFIX
          This corresponds to your WikiServlet path.
 
Fields inherited from class org.apache.wiki.url.DefaultURLConstructor
m_engine, m_pathPrefix
 
Constructor Summary
ShortURLConstructor()
           
 
Method Summary
 String getForwardPage(javax.servlet.http.HttpServletRequest req)
          This method is not needed for the DefaultURLConstructor.
 void initialize(WikiEngine engine, Properties properties)
          Initializes.
 String makeURL(String context, String name, boolean absolute, String parameters)
          Constructs the URL with a bunch of parameters.
 String parsePage(String context, javax.servlet.http.HttpServletRequest request, String encoding)
          Should parse the "page" parameter from the actual request.
 
Methods inherited from class org.apache.wiki.url.DefaultURLConstructor
doReplacement, getURLPattern, parsePageFromURL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_urlPrefix

protected String m_urlPrefix
Contains the path part after the JSPWiki base URL


PROP_PREFIX

public static final String PROP_PREFIX
This corresponds to your WikiServlet path. By default, it is assumed to be "wiki/", but you can set it to whatever you like - including an empty name.

See Also:
Constant Field Values
Constructor Detail

ShortURLConstructor

public ShortURLConstructor()
Method Detail

initialize

public void initialize(WikiEngine engine,
                       Properties properties)
Initializes. Note that the engine is not fully initialized at this point, so don't do anything fancy here - use lazy init, if you have to.

Specified by:
initialize in interface URLConstructor
Overrides:
initialize in class DefaultURLConstructor
Parameters:
engine - The WikiEngine that this URLConstructor belongs to
properties - Properties used to initialize

makeURL

public String makeURL(String context,
                      String name,
                      boolean absolute,
                      String parameters)
Constructs the URL with a bunch of parameters.

Specified by:
makeURL in interface URLConstructor
Overrides:
makeURL in class DefaultURLConstructor
Parameters:
context - The request context (@see WikiContext) that you want the URL for
name - The page name (or in case of WikiContext.NONE, the auxiliary JSP page or resource you want to point at. This must be URL encoded. Null is NOT safe.
absolute - True, if you need an absolute URL. False, if both relative and absolute URLs are fine.
parameters - If null or empty, no parameters are added. An URL parameter string (these must be URL-encoded, and separated with &)
Returns:
An URL pointing to the resource. Must never return null - throw an InternalWikiException if something goes wrong.

parsePage

public String parsePage(String context,
                        javax.servlet.http.HttpServletRequest request,
                        String encoding)
                 throws UnsupportedEncodingException
Should parse the "page" parameter from the actual request. 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.

Specified by:
parsePage in interface URLConstructor
Overrides:
parsePage in class DefaultURLConstructor
Parameters:
context - In which request context the request was made (this should help in parsing)
request - The HTTP request that was used when coming here
encoding - The encoding with which the request was made (UTF-8 or ISO-8859-1).
Returns:
This method must return the name of the resource.
Throws:
UnsupportedEncodingException

getForwardPage

public String getForwardPage(javax.servlet.http.HttpServletRequest req)
This method is not needed for the DefaultURLConstructor.

Specified by:
getForwardPage in interface URLConstructor
Overrides:
getForwardPage in class DefaultURLConstructor
Parameters:
req - The HTTP Request that was used to end up in this page.
Returns:
"Wiki.jsp", "PageInfo.jsp", etc. Just return the name, JSPWiki will figure out the page.


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.