public class XWikiContext extends Hashtable<Object,Object>
Context
class is
available as a predefined variable for scripting inside any wiki page. You can access it using $xcontext
in Velocity scripts or simply xcontext
in Groovy ones. The Context
class provides a means
of getting contextual information about the current request or configuring XWiki on the fly.Modifier and Type | Field and Description |
---|---|
static String |
EXECUTIONCONTEXT_KEY |
static String |
KEY_LEGACY_VELOCITYCONTEXT
Deprecated.
use
VelocityManager.getVelocityContext() instead |
protected static org.slf4j.Logger |
LOGGER
Logging helper object.
|
static int |
MODE_ATOM |
static int |
MODE_GWT |
static int |
MODE_GWT_DEBUG |
static int |
MODE_PDF |
static int |
MODE_PORTLET |
static int |
MODE_SERVLET |
static int |
MODE_XMLRPC |
static ParameterizedType |
TYPE_PROVIDER
Type instance for
Provider<XWikiContext> . |
Constructor and Description |
---|
XWikiContext() |
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keys, keySet, merge, putAll, putIfAbsent, rehash, remove, replace, replace, replaceAll, size, toString, values
public static final ParameterizedType TYPE_PROVIDER
Provider<XWikiContext>
.public static final int MODE_SERVLET
public static final int MODE_PORTLET
public static final int MODE_XMLRPC
public static final int MODE_ATOM
public static final int MODE_PDF
public static final int MODE_GWT
public static final int MODE_GWT_DEBUG
public static final String EXECUTIONCONTEXT_KEY
@Deprecated public static final String KEY_LEGACY_VELOCITYCONTEXT
VelocityManager.getVelocityContext()
insteadprotected static final org.slf4j.Logger LOGGER
public XWiki getWiki()
public Util getUtil()
public void setWiki(XWiki wiki)
public XWikiEngineContext getEngineContext()
public void setEngineContext(XWikiEngineContext engine_context)
public XWikiRequest getRequest()
public void setRequest(XWikiRequest request)
public String getAction()
public void setAction(String action)
public XWikiResponse getResponse()
public void setResponse(XWikiResponse response)
@Deprecated public String getDatabase()
getWikiId()
insteadpublic String getWikiId()
public WikiReference getWikiReference()
@Deprecated public void setDatabase(String wikiId)
setWikiId(String)
insteadwikiId
- the current wiki idpublic void setWikiId(String wikiId)
wikiId
- the current wiki idpublic void setWikiReference(WikiReference wikiReference)
wikiReference
- the current wiki reference@Deprecated public String getOriginalDatabase()
getOriginalWikiId()
insteadpublic String getOriginalWikiId()
@Deprecated public void setOriginalDatabase(String wikiId)
setOriginalWikiId(String)
insteadpublic void setOriginalWikiId(String wikiId)
wikiId
- the wiki id originally requested by the userpublic boolean isMainWiki()
public boolean isMainWiki(String wikiName)
wikiName
- the name of the wiki.public XWikiDocument getDoc()
public void setDoc(XWikiDocument doc)
public DocumentReference getUserReference()
public void setUserReference(DocumentReference userReference)
@Deprecated public void setUser(String user)
setUserReference(DocumentReference)
instead@Deprecated public String getUser()
getUserReference()
instead@Deprecated public String getLocalUser()
getUserReference()
instead@Deprecated public XWikiUser getXWikiUser()
getUserReference()
instead@Deprecated public String getLanguage()
getLocale()
instead@Deprecated public void setLanguage(String language)
setLocale(Locale)
insteadpublic Locale getLocale()
public void setLocale(Locale locale)
locale
- the current locale@Deprecated public String getInterfaceLanguage()
getInterfaceLocale()
insteadpublic Locale getInterfaceLocale()
Locale
to use to display the user interfacepublic void setInterfaceLocale(Locale interfaceLocale)
interfaceLocale
- the Locale
to use to display the contentpublic int getMode()
public void setMode(int mode)
public URL getURL()
public void setURL(URL url)
public XWikiURLFactory getURLFactory()
public void setURLFactory(XWikiURLFactory URLFactory)
public XWikiForm getForm()
public void setForm(XWikiForm form)
public boolean isFinished()
isResponseSent()
this method will ensure that the template is executed even if the
result of the execution is not sent. See Utils.parseTemplate(String, boolean, XWikiContext)
for details.true
if the response has been sent and no new reponse should be sent anymore.public void setFinished(boolean finished)
isFinished()
.finished
- Set to true
if the response has been sent.@Unstable public boolean isResponseSent()
isFinished()
this method will always prevent the execution of the template.
See Utils.parseTemplate(String, boolean, XWikiContext)
for details.true
if the response has been sent, no new reponse should be sent anymore
and the template should not be parsed.public void setResponseSent(boolean responseSent)
isResponseSent()
.responseSent
- Set to true
if the response has been sent and the template should not be executed.public XWikiDocument getWikiServer()
public int getCacheDuration()
public void setCacheDuration(int cacheDuration)
public String getMainXWiki()
public void setMainXWiki(String str)
public void addBaseClass(BaseClass bclass)
public BaseClass getBaseClass(DocumentReference classReference)
public void removeBaseClass(DocumentReference classReference)
classReference
- the reference of the classpublic void flushClassCache()
public void setLinksAction(String action)
public void unsetLinksAction()
public String getLinksAction()
public void setLinksQueryString(String value)
public void unsetLinksQueryString()
public String getLinksQueryString()
@Deprecated public XWikiMessageTool getMessageTool()
ContextualLocalizationManager
component insteadpublic XWikiValidationStatus getValidationStatus()
public void setValidationStatus(XWikiValidationStatus status)
public void addDisplayedField(String fieldname)
@Deprecated public String getEditorWysiwyg()
public void dropPermissions()
After this is called:
Api.hasProgrammingRights()
will always return false.XWiki.getDocumentAsAuthor(org.xwiki.model.reference.DocumentReference)
,
XWiki.getDocumentAsAuthor(String)
, Document.saveAsAuthor()
,
Document.saveAsAuthor(String)
,
Document.saveAsAuthor(String, boolean)
, and
Document.deleteAsAuthor()
will perform all of their actions as if the document's
content author was the guest user (XWiki.XWikiGuest).
In effect, no code requiring "programming right" will run, and if the document content author (see:
Document.getContentAuthor()
) is a user who has "programming right", there will be no
way for code following this call to save another document as this user, blessing it too with programming right.
Once dropped, permissions cannot be regained for the duration of the request.
If you are interested in a more flexable sandboxing method which sandboxed code only for the remainder of the
rendering cycle, consider using Document.dropPermissions()
.
public boolean hasDroppedPermissions()
dropPermissions()
has been called on this context, or if the
XWikiConstant.DROPPED_PERMISSIONS
key has been set in the
ExecutionContext
for this thread. This is done by calling
{Document#dropPermissions()}public XWikiContext clone()
public void declareInExecutionContext(org.xwiki.context.ExecutionContext executionContext)
executionContext
- The execution context.public DocumentReference getAuthorReference()
Copyright © 2004–2021 XWiki. All rights reserved.