com.xpn.xwiki
Class XWikiContext

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<Object,Object>
          extended by com.xpn.xwiki.XWikiContext
All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public class XWikiContext
extends Hashtable<Object,Object>

See Also:
Serialized Form

Field Summary
static String EXECUTIONCONTEXT_KEY
           
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.
 
Constructor Summary
XWikiContext()
           
 
Method Summary
 void addBaseClass(BaseClass bclass)
           
 void addDisplayedField(String fieldname)
           
 XWikiContext clone()
           
 void declareInExecutionContext(org.xwiki.context.ExecutionContext executionContext)
          There are several places where the XWiki context needs to be declared in the execution, so we add a common method here.
 void dropPermissions()
          Drop permissions for the remainder of the request cycle.
 void flushClassCache()
          Empty the class cache.
 String getAction()
           
 BaseClass getBaseClass(DocumentReference documentReference)
           
 int getCacheDuration()
           
 String getDatabase()
           
 List<String> getDisplayedFields()
           
 XWikiDocument getDoc()
           
 String getEditorWysiwyg()
           
 XWikiEngineContext getEngineContext()
           
 XWikiForm getForm()
           
 String getInterfaceLanguage()
           
 String getLanguage()
          Deprecated. since 4.3M1 use getLocale() instead
 String getLinksAction()
           
 String getLinksQueryString()
           
 Locale getLocale()
           
 String getLocalUser()
          Deprecated. since 3.1M1 use getUserReference() instead
 String getMainXWiki()
           
 XWikiMessageTool getMessageTool()
           
 int getMode()
           
 String getOriginalDatabase()
          Get the "original" database name.
 XWikiRequest getRequest()
           
 XWikiResponse getResponse()
           
 URL getURL()
           
 XWikiURLFactory getURLFactory()
           
 String getUser()
          Deprecated. since 3.1M1 use getUserReference() instead
 DocumentReference getUserReference()
           
 Util getUtil()
           
 XWikiValidationStatus getValidationStatus()
           
 XWiki getWiki()
           
 String getWikiOwner()
          Deprecated. use XWiki.getWikiOwner(String, XWikiContext) instead
 XWikiDocument getWikiServer()
           
 org.apache.xmlrpc.server.XmlRpcServer getXMLRPCServer()
           
 XWikiUser getXWikiUser()
          Deprecated. since 3.1M1 use getUserReference() instead
 boolean hasDroppedPermissions()
           
 boolean isFinished()
           
 boolean isMainWiki()
           
 boolean isMainWiki(String wikiName)
           
 Object put(Object key, Object value)
          
 Object remove(Object key)
          
 void setAction(String action)
           
 void setCacheDuration(int cacheDuration)
           
 void setDatabase(String database)
           
 void setDoc(XWikiDocument doc)
           
 void setEngineContext(XWikiEngineContext engine_context)
           
 void setFinished(boolean finished)
           
 void setForm(XWikiForm form)
           
 void setInterfaceLanguage(String interfaceLanguage)
           
 void setLanguage(String language)
          Deprecated. since 4.3M1 use setLocale(Locale) instead
 void setLinksAction(String action)
           
 void setLinksQueryString(String value)
           
 void setLocale(Locale locale)
           
 void setMainXWiki(String str)
           
 void setMode(int mode)
           
 void setOriginalDatabase(String database)
           
 void setRequest(XWikiRequest request)
           
 void setResponse(XWikiResponse response)
           
 void setURL(URL url)
           
 void setURLFactory(XWikiURLFactory URLFactory)
           
 void setUser(String user)
          Deprecated. since 3.1M1 use setUserReference(DocumentReference) instead
 void setUserReference(DocumentReference userReference)
           
 void setValidationStatus(XWikiValidationStatus status)
           
 void setWiki(XWiki wiki)
           
 void setWikiOwner(String wikiOwner)
          Deprecated. never made any sense since the context database can change any time
 void setWikiServer(XWikiDocument doc)
          Deprecated. never made any sense since the context database can change any time
 void setXMLRPCServer(org.apache.xmlrpc.server.XmlRpcServer xmlRpcServer)
           
 void unsetLinksAction()
           
 void unsetLinksQueryString()
           
 
Methods inherited from class java.util.Hashtable
clear, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, putAll, rehash, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_PROVIDER

public static ParameterizedType TYPE_PROVIDER
Type instance for Provider.

Since:
5.0M1

MODE_SERVLET

public static final int MODE_SERVLET
See Also:
Constant Field Values

MODE_PORTLET

public static final int MODE_PORTLET
See Also:
Constant Field Values

MODE_XMLRPC

public static final int MODE_XMLRPC
See Also:
Constant Field Values

MODE_ATOM

public static final int MODE_ATOM
See Also:
Constant Field Values

MODE_PDF

public static final int MODE_PDF
See Also:
Constant Field Values

MODE_GWT

public static final int MODE_GWT
See Also:
Constant Field Values

MODE_GWT_DEBUG

public static final int MODE_GWT_DEBUG
See Also:
Constant Field Values

EXECUTIONCONTEXT_KEY

public static final String EXECUTIONCONTEXT_KEY
See Also:
Constant Field Values

LOGGER

protected static final org.slf4j.Logger LOGGER
Logging helper object.

Constructor Detail

XWikiContext

public XWikiContext()
Method Detail

getWiki

public XWiki getWiki()

getUtil

public Util getUtil()

setWiki

public void setWiki(XWiki wiki)

getEngineContext

public XWikiEngineContext getEngineContext()

setEngineContext

public void setEngineContext(XWikiEngineContext engine_context)

getRequest

public XWikiRequest getRequest()

setRequest

public void setRequest(XWikiRequest request)

getAction

public String getAction()

setAction

public void setAction(String action)

getResponse

public XWikiResponse getResponse()

setResponse

public void setResponse(XWikiResponse response)

getDatabase

public String getDatabase()

setDatabase

public void setDatabase(String database)

put

public Object put(Object key,
                  Object value)

Make sure to keep database fields and map synchronized.

Specified by:
put in interface Map<Object,Object>
Overrides:
put in class Hashtable<Object,Object>
See Also:
Hashtable.put(java.lang.Object, java.lang.Object)

remove

public Object remove(Object key)

Make sure to keep database field and map synchronized.

Specified by:
remove in interface Map<Object,Object>
Overrides:
remove in class Hashtable<Object,Object>
See Also:
Hashtable.remove(java.lang.Object)

getOriginalDatabase

public String getOriginalDatabase()
Get the "original" database name. In single wiki mode this will be "xwiki", but in virtual wiki mode this will be the database name for the wiki which the user requested. If the database is switched to load some piece of data, this will remember what it should be switched back to.

Returns:
the db name originally requested by the user.

setOriginalDatabase

public void setOriginalDatabase(String database)

isMainWiki

public boolean isMainWiki()
Returns:
true it's main wiki's context, false otherwise.

isMainWiki

public boolean isMainWiki(String wikiName)
Parameters:
wikiName - the name of the wiki.
Returns:
true it's main wiki's context, false otherwise.

getDoc

public XWikiDocument getDoc()

setDoc

public void setDoc(XWikiDocument doc)

getUserReference

public DocumentReference getUserReference()

setUserReference

public void setUserReference(DocumentReference userReference)

setUser

@Deprecated
public void setUser(String user)
Deprecated. since 3.1M1 use setUserReference(DocumentReference) instead


getUser

@Deprecated
public String getUser()
Deprecated. since 3.1M1 use getUserReference() instead


getLocalUser

@Deprecated
public String getLocalUser()
Deprecated. since 3.1M1 use getUserReference() instead


getXWikiUser

@Deprecated
public XWikiUser getXWikiUser()
Deprecated. since 3.1M1 use getUserReference() instead


getLanguage

@Deprecated
public String getLanguage()
Deprecated. since 4.3M1 use getLocale() instead


setLanguage

@Deprecated
public void setLanguage(String language)
Deprecated. since 4.3M1 use setLocale(Locale) instead


getLocale

public Locale getLocale()
Returns:
the current locale

setLocale

public void setLocale(Locale locale)
Parameters:
locale - the current locale

getInterfaceLanguage

public String getInterfaceLanguage()

setInterfaceLanguage

public void setInterfaceLanguage(String interfaceLanguage)

getMode

public int getMode()

setMode

public void setMode(int mode)

getURL

public URL getURL()

setURL

public void setURL(URL url)

getURLFactory

public XWikiURLFactory getURLFactory()

setURLFactory

public void setURLFactory(XWikiURLFactory URLFactory)

getForm

public XWikiForm getForm()

setForm

public void setForm(XWikiForm form)

isFinished

public boolean isFinished()

setFinished

public void setFinished(boolean finished)

getXMLRPCServer

public org.apache.xmlrpc.server.XmlRpcServer getXMLRPCServer()

setXMLRPCServer

public void setXMLRPCServer(org.apache.xmlrpc.server.XmlRpcServer xmlRpcServer)

setWikiOwner

@Deprecated
public void setWikiOwner(String wikiOwner)
Deprecated. never made any sense since the context database can change any time


getWikiOwner

@Deprecated
public String getWikiOwner()
Deprecated. use XWiki.getWikiOwner(String, XWikiContext) instead


setWikiServer

@Deprecated
public void setWikiServer(XWikiDocument doc)
Deprecated. never made any sense since the context database can change any time


getWikiServer

public XWikiDocument getWikiServer()

getCacheDuration

public int getCacheDuration()

setCacheDuration

public void setCacheDuration(int cacheDuration)

getMainXWiki

public String getMainXWiki()

setMainXWiki

public void setMainXWiki(String str)

addBaseClass

public void addBaseClass(BaseClass bclass)

getBaseClass

public BaseClass getBaseClass(DocumentReference documentReference)
Since:
2.2M2

flushClassCache

public void flushClassCache()
Empty the class cache.


setLinksAction

public void setLinksAction(String action)

unsetLinksAction

public void unsetLinksAction()

getLinksAction

public String getLinksAction()

setLinksQueryString

public void setLinksQueryString(String value)

unsetLinksQueryString

public void unsetLinksQueryString()

getLinksQueryString

public String getLinksQueryString()

getMessageTool

public XWikiMessageTool getMessageTool()

getValidationStatus

public XWikiValidationStatus getValidationStatus()

setValidationStatus

public void setValidationStatus(XWikiValidationStatus status)

addDisplayedField

public void addDisplayedField(String fieldname)

getDisplayedFields

public List<String> getDisplayedFields()

getEditorWysiwyg

public String getEditorWysiwyg()

dropPermissions

public void dropPermissions()
Drop permissions for the remainder of the request cycle.

After this is called:

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().

Since:
3.0M3

hasDroppedPermissions

public boolean hasDroppedPermissions()
Returns:
true if 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()}

clone

public XWikiContext clone()
Overrides:
clone in class Hashtable<Object,Object>

declareInExecutionContext

public void declareInExecutionContext(org.xwiki.context.ExecutionContext executionContext)
There are several places where the XWiki context needs to be declared in the execution, so we add a common method here.

Parameters:
executionContext - The execution context.


Copyright © 2004-2013 XWiki. All Rights Reserved.