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 XWikiContextcontextThe 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 Attachmentconvert(XWikiAttachment xattach)Convert an internal representation of an attachment to the public api Attachment.protected Documentconvert(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 AuthorizationManagergetAuthorizationManager()protected ContextualAuthorizationManagergetContextualAuthorizationManager()protected XWikiContextgetXWikiContext()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 booleanhasAccess(Right right, DocumentReference entityReference)Verifies if the context user has the access identified byrighton the entity identified byentityReference.booleanhasAccessLevel(String right, String docname)Check if the current user has an access level on a given document.booleanhasAdminRights()Check if the current user has administration rights either on the current wiki or on the current space.booleanhasProgrammingRights()Check if the current document has programming rights, meaning that it was last saved by a user with the programming right globally granted.booleanhasWikiAdminRights()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
AuthorizationManagercomponent - Since:
- 10.6RC1
-
getContextualAuthorizationManager
protected ContextualAuthorizationManager getContextualAuthorizationManager()
- Returns:
- the
ContextualAuthorizationManagercomponent - 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:
trueif the current document has the Programming right orfalseotherwise.
-
hasAdminRights
public boolean hasAdminRights()
Check if the current user has administration rights either on the current wiki or on the current space.- Returns:
trueif the current user has theadminright orfalseotherwise.
-
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:
trueif the current user has theadminright orfalseotherwise.- 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:
trueif the current user has the specified right,falseotherwise.- 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 byrighton 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:
trueif the user has the specified right on the entity,falseotherwise- 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
-
-