Package com.xpn.xwiki.api
Class Api
- java.lang.Object
-
- com.xpn.xwiki.api.Api
-
- Direct Known Subclasses:
Attachment
,Context
,CriteriaService
,DeletedAttachment
,DeletedDocument
,Document
,DocumentInfoAPI
,Element
,MailPluginApi
,PackageAPI
,PluginApi
,RevisionInfo
,RightsManagerGroupsApi
,RightsManagerRightsApi
,RightsManagerUsersApi
,StatsService
,SVGPluginApi
,User
,Util
,XWiki
public class Api extends Object
Base class for all API Objects. API Objects are the Java Objects that can be manipulated from Velocity or Groovy in XWiki documents.- Version:
- $Id: 1579fbbd1f48149084879bd78177b56c74ca1869 $
-
-
Field Summary
Fields Modifier and Type Field Description protected XWikiContext
context
The current context, needed by the underlying protected object.
-
Constructor Summary
Constructors Constructor Description Api(XWikiContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Attachment
convert(XWikiAttachment xattach)
Convert an internal representation of an attachment to the public api Attachment.protected Document
convert(XWikiDocument xdoc)
Convert an internal representation of document to public api document.protected List<Document>
convert(List<XWikiDocument> xdocList)
Convert a list of internal representation of documents to public api documents.protected List<Attachment>
convertAttachments(List<XWikiAttachment> xattaches)
Convert a list of attachments in their internal form to a list of public api Attachments.protected AuthorizationManager
getAuthorizationManager()
protected ContextualAuthorizationManager
getContextualAuthorizationManager()
protected XWikiContext
getXWikiContext()
Note 1: This method is protected so that users of this API do not get to see the XWikiContext object which should not be exposed.protected boolean
hasAccess(Right right, DocumentReference entityReference)
Verifies if the context user has the access identified byright
on the entity identified byentityReference
.boolean
hasAccessLevel(String right, String docname)
Check if the current user has an access level on a given document.boolean
hasAdminRights()
Check if the current user has administration rights either on the current wiki or on the current space.boolean
hasProgrammingRights()
Check if the current document has programming rights, meaning that it was last saved by a user with the programming right globally granted.boolean
hasWikiAdminRights()
Check if the current user has administration rights on the current wiki, regardless of any space admin rights that might also be available.
-
-
-
Field Detail
-
context
protected XWikiContext context
The current context, needed by the underlying protected object.- See Also:
getXWikiContext()
-
-
Constructor Detail
-
Api
public Api(XWikiContext context)
- Parameters:
context
- the XWiki Context object- See Also:
getXWikiContext()
-
-
Method Detail
-
getXWikiContext
protected XWikiContext getXWikiContext()
Note 1: This method is protected so that users of this API do not get to see the XWikiContext object which should not be exposed.Note 2: This is not longer the canonical way of retrieving the XWiki Context. The new way is to get it from the
ExecutionContext
.- Returns:
- the current context containing all state information about the current request
-
getAuthorizationManager
protected AuthorizationManager getAuthorizationManager()
- Returns:
- the
AuthorizationManager
component - Since:
- 10.6RC1
-
getContextualAuthorizationManager
protected ContextualAuthorizationManager getContextualAuthorizationManager()
- Returns:
- the
ContextualAuthorizationManager
component - Since:
- 12.5RC1, 11.10.6
-
hasProgrammingRights
public boolean hasProgrammingRights()
Check if the current document has programming rights, meaning that it was last saved by a user with the programming right globally granted.- Returns:
true
if the current document has the Programming right orfalse
otherwise.
-
hasAdminRights
public boolean hasAdminRights()
Check if the current user has administration rights either on the current wiki or on the current space.- Returns:
true
if the current user has theadmin
right orfalse
otherwise.
-
hasWikiAdminRights
public boolean hasWikiAdminRights()
Check if the current user has administration rights on the current wiki, regardless of any space admin rights that might also be available.- Returns:
true
if the current user has theadmin
right orfalse
otherwise.- Since:
- 3.2M3
-
hasAccessLevel
public boolean hasAccessLevel(String right, String docname) throws XWikiException
Check if the current user has an access level on a given document.- Parameters:
right
- The name of the right to verify (eg "programming", "admin", "register", etc).docname
- The document for which to verify the right.- Returns:
true
if the current user has the specified right,false
otherwise.- Throws:
XWikiException
- In case of an error finding the document or accessing groups information.
-
hasAccess
protected boolean hasAccess(Right right, DocumentReference entityReference)
Verifies if the context user has the access identified byright
on the entity identified byentityReference
. Note that some rights may be checked higher in hierarchy of the provided entity if such right is not enabled at lowest hierarchy level provided.- Parameters:
right
- the right to checkentityReference
- the entity on which to check the right- Returns:
true
if the user has the specified right on the entity,false
otherwise- Since:
- 11.5RC1
-
convert
protected List<Document> convert(List<XWikiDocument> xdocList)
Convert a list of internal representation of documents to public api documents.- Parameters:
xdocList
- the internal documents.- Returns:
- the plublic api documents.
-
convert
protected Document convert(XWikiDocument xdoc)
Convert an internal representation of document to public api document.- Parameters:
xdoc
- the internal document.- Returns:
- the plublic api document.
-
convert
protected Attachment convert(XWikiAttachment xattach)
Convert an internal representation of an attachment to the public api Attachment.- Parameters:
xattach
- The internal XWikiAttachment object- Returns:
- The public api Attachment object
- Since:
- 5.0M2
-
convertAttachments
protected List<Attachment> convertAttachments(List<XWikiAttachment> xattaches)
Convert a list of attachments in their internal form to a list of public api Attachments.- Parameters:
xattaches
- The List of XWikiAttachment objects- Returns:
- A List of Attachment objects
- Since:
- 5.0M2
-
-