|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ecyrd.jspwiki.WikiContext
public class WikiContext
Provides state information throughout the processing of a page. A WikiContext is born when the JSP pages that are the main entry points, are invoked. The JSPWiki engine creates the new WikiContext, which basically holds information about the page, the handling engine, and in which context (view, edit, etc) the call was done.
A WikiContext also provides request-specific variables, which can be used to communicate between plugins on the same page, or between different instances of the same plugin. A WikiContext variable is valid until the processing of the page has ended. For an example, please see the Counter plugin.
When a WikiContext is created, it automatically associates a
WikiSession
object with the user's HttpSession. The
WikiSession contains information about the user's authentication
status, and is consulted by getCurrentUser()
.
object
Counter
Field Summary | |
---|---|
static String |
ATTACH
|
static String |
COMMENT
|
static String |
CONFLICT
User has an internal conflict, and does quite not know what to do. |
static String |
CREATE_GROUP
|
static String |
DELETE
|
static String |
DIFF
User is viewing a DIFF between the two versions of the page. |
static String |
EDIT
The EDIT context - the user is editing the page. |
static String |
ERROR
An error has been encountered and the user needs to be informed. |
static String |
FIND
|
static String |
INFO
User is viewing page history. |
protected static org.apache.log4j.Logger |
log
|
static String |
LOGIN
User is preparing for a login/authentication. |
static String |
LOGOUT
User is preparing to log out. |
static String |
NONE
|
static String |
OTHER
|
static String |
PREFS
|
static String |
PREVIEW
User is previewing the changes he just made. |
static String |
RENAME
|
static String |
RSS
|
static String |
UPLOAD
|
static String |
VIEW
The VIEW context - the user just wants to view the page contents. |
Constructor Summary | |
---|---|
WikiContext(WikiEngine engine,
javax.servlet.http.HttpServletRequest request,
WikiPage page)
Creates a new WikiContext for the given WikiEngine, WikiPage and HttpServletRequest. |
|
WikiContext(WikiEngine engine,
WikiPage page)
Create a new WikiContext for the given WikiPage. |
Method Summary | |
---|---|
Object |
clone()
Returns a shallow clone of the WikiContext. |
static WikiContext |
findContext(javax.servlet.jsp.PageContext pageContext)
This method can be used to find the WikiContext programmatically from a JSP PageContext. |
Principal |
getCurrentUser()
Convenience method that gets the current user. |
WikiEngine |
getEngine()
Returns the handling engine. |
String |
getHttpParameter(String paramName)
This method will safely return any HTTP parameters that might have been defined. |
javax.servlet.http.HttpServletRequest |
getHttpRequest()
If the request did originate from a HTTP request, then the HTTP request can be fetched here. |
WikiPage |
getPage()
Returns the page that is being handled. |
WikiPage |
getRealPage()
|
String |
getRequestContext()
Returns the request context. |
String |
getTemplate()
Gets the template that is to be used throughout this request. |
String |
getURL(String context,
String page)
|
String |
getURL(String context,
String page,
String params)
Returns an URL from a page. |
Object |
getVariable(String key)
Gets a previously set variable. |
String |
getViewURL(String page)
|
WikiSession |
getWikiSession()
Returns the WikiSession associated with the context. |
boolean |
hasAccess(javax.servlet.http.HttpServletResponse response)
Checks whether the current user has access to this wiki context, by obtaining the required Permission ( requiredPermission() )
and delegating the access check to
AuthorizationManager.checkPermission(WikiSession, Permission) . |
boolean |
hasAccess(javax.servlet.http.HttpServletResponse response,
boolean redirect)
Checks whether the current user has access to this wiki context (and optionally redirects if not), by obtaining the required Permission ( requiredPermission() )
and delegating the access check to
AuthorizationManager.checkPermission(WikiSession, Permission) . |
Permission |
requiredPermission()
Returns the permission required to successfully execute this context. |
void |
setPage(WikiPage page)
Sets the page that is being handled. |
WikiPage |
setRealPage(WikiPage page)
Sometimes you may want to render the page using some other page's context. |
void |
setRequestContext(String arg)
Sets the request context. |
void |
setTemplate(String dir)
Sets the template to be used for this request. |
void |
setVariable(String key,
Object data)
Sets a variable. |
protected void |
updatePermission()
Protected method that updates the value returned by the requiredPermission()
method. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String VIEW
public static final String EDIT
public static final String LOGIN
public static final String LOGOUT
public static final String DIFF
public static final String INFO
public static final String PREVIEW
public static final String CONFLICT
public static final String ERROR
public static final String UPLOAD
public static final String COMMENT
public static final String FIND
public static final String CREATE_GROUP
public static final String PREFS
public static final String RENAME
public static final String DELETE
public static final String ATTACH
public static final String RSS
public static final String NONE
public static final String OTHER
protected static org.apache.log4j.Logger log
Constructor Detail |
---|
public WikiContext(WikiEngine engine, WikiPage page)
WikiContext(WikiEngine, HttpServletRequest, WikiPage)
.
engine
- The WikiEngine that is handling the request.page
- The WikiPage. If you want to create a
WikiContext for an older version of a page, you must use this
constructor.public WikiContext(WikiEngine engine, javax.servlet.http.HttpServletRequest request, WikiPage page)
Creates a new WikiContext for the given WikiEngine, WikiPage and HttpServletRequest. This constructor will also look up the HttpSession associated with the request, and determine if a WikiSession object is present. If not, a new one is created.
After the WikiSession object is obtained, the current authentication
status is checked. If not authenticated, or if the login status reported
by the container has changed, the constructor attempts to log in the user
with
AuthenticationManager.login(HttpServletRequest)
.
engine
- The WikiEngine that is handling the requestrequest
- The HttpServletRequest that should be associated with this
context. This parameter may be null
.page
- The WikiPage. If you want to create a WikiContext for an
older version of a page, you must supply this parameterMethod Detail |
---|
public WikiPage setRealPage(WikiPage page)
page
- The real page which is being rendered.
public WikiPage getRealPage()
public WikiEngine getEngine()
public WikiPage getPage()
public void setPage(WikiPage page)
public String getRequestContext()
public void setRequestContext(String arg)
arg
- The request context (one of the predefined contexts.)public Object getVariable(String key)
key
- The variable name.
public void setVariable(String key, Object data)
key
- The variable name.data
- The variable value.public String getHttpParameter(String paramName)
paramName
- Parameter name to look for.
public javax.servlet.http.HttpServletRequest getHttpRequest()
public void setTemplate(String dir)
public String getTemplate()
public Principal getCurrentUser()
public String getViewURL(String page)
public String getURL(String context, String page)
public String getURL(String context, String page, String params)
public Object clone()
clone
in class Object
public WikiSession getWikiSession()
WikiSession.guestSession()
.
public static WikiContext findContext(javax.servlet.jsp.PageContext pageContext)
WikiTagBase.ATTR_CONTEXT
.
pageContext
- the JSP page context
public Permission requiredPermission()
PropertyPermission
"os.name",
"read"
). This method is guaranteed to always return a valid,
non-null permission.
public boolean hasAccess(javax.servlet.http.HttpServletResponse response) throws IOException
requiredPermission()
)
and delegating the access check to
AuthorizationManager.checkPermission(WikiSession, Permission)
.
If the user is allowed, this method returns true
;
false
otherwise. If access is allowed,
the wiki context will be added to the request as an attribute
with the key name WikiTagBase.ATTR_CONTEXT
.
Note that this method will automatically redirect the user to
a login or error page, as appropriate, if access fails. This is
NOT guaranteed to be default behavior in the future.
response
- the http response
IOException
public boolean hasAccess(javax.servlet.http.HttpServletResponse response, boolean redirect) throws IOException
requiredPermission()
)
and delegating the access check to
AuthorizationManager.checkPermission(WikiSession, Permission)
.
If the user is allowed, this method returns true
;
false
otherwise. If access is allowed,
the wiki context will be added to the request as attribute
with the key name WikiTagBase.ATTR_CONTEXT
.
IOException
protected void updatePermission()
requiredPermission()
method. Will always be called when the page name, request context, or variable
changes.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |