Package org.apache.wiki.url
Class ShortURLConstructor
- java.lang.Object
-
- org.apache.wiki.url.DefaultURLConstructor
-
- org.apache.wiki.url.ShortURLConstructor
-
- All Implemented Interfaces:
Initializable
,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
Fields Modifier and Type Field Description protected java.lang.String
m_urlPrefix
Contains the path part after the JSPWiki base URLstatic java.lang.String
PROP_PREFIX
This corresponds to your WikiServlet path.-
Fields inherited from class org.apache.wiki.url.DefaultURLConstructor
m_engine, m_pathPrefix
-
-
Constructor Summary
Constructors Constructor Description ShortURLConstructor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getForwardPage(javax.servlet.http.HttpServletRequest req)
This method is not needed for the DefaultURLConstructor.void
initialize(Engine engine, java.util.Properties properties)
Initializes this Engine component.java.lang.String
makeURL(java.lang.String context, java.lang.String name, java.lang.String parameters)
Constructs the URL with a bunch of parameters.java.lang.String
parsePage(java.lang.String context, javax.servlet.http.HttpServletRequest request, java.nio.charset.Charset encoding)
Should parse the "page" parameter from the actual request.-
Methods inherited from class org.apache.wiki.url.DefaultURLConstructor
doReplacement, getURLPattern
-
-
-
-
Field Detail
-
m_urlPrefix
protected java.lang.String m_urlPrefix
Contains the path part after the JSPWiki base URL
-
PROP_PREFIX
public static final java.lang.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(Engine engine, java.util.Properties properties)
Initializes this Engine component. 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 interfaceInitializable
- Overrides:
initialize
in classDefaultURLConstructor
- Parameters:
engine
- Engine performing the initialization.properties
- Properties for setup.
-
makeURL
public java.lang.String makeURL(java.lang.String context, java.lang.String name, java.lang.String parameters)
Constructs the URL with a bunch of parameters.- Specified by:
makeURL
in interfaceURLConstructor
- Overrides:
makeURL
in classDefaultURLConstructor
- Parameters:
context
- The request context (@see WikiContext) that you want the URL forname
- 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.parameters
- If null or empty, no parameters are added. 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 java.lang.String parsePage(java.lang.String context, javax.servlet.http.HttpServletRequest request, java.nio.charset.Charset encoding)
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 interfaceURLConstructor
- Overrides:
parsePage
in classDefaultURLConstructor
- Parameters:
context
- In which request context the request was made (this should help in parsing)request
- The HTTP request that was used when coming hereencoding
- The encoding with which the request was made (UTF-8 or ISO-8859-1).- Returns:
- This method must return the name of the resource.
-
getForwardPage
public java.lang.String getForwardPage(javax.servlet.http.HttpServletRequest req)
This method is not needed for the DefaultURLConstructor.- Specified by:
getForwardPage
in interfaceURLConstructor
- Overrides:
getForwardPage
in classDefaultURLConstructor
- 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.
-
-