com.xpn.xwiki.api
Class Api

java.lang.Object
  extended by com.xpn.xwiki.api.Api
Direct Known Subclasses:
ActivityEvent, Attachment, ChartingPluginApi, Context, CriteriaService, DeletedAttachment, DeletedDocument, DiffPluginApi, Document, DocumentInfoAPI, Element, GooglePluginApi, LDAPPluginApi, MailPluginApi, PackageAPI, PluginApi, QueryPluginApi, RevisionInfo, RightsManagerGroupsApi, RightsManagerRightsApi, RightsManagerUsersApi, SearchResults, StatsService, SVGPluginApi, SyndEntrySourceApi, User, UserDirectoryPluginAPI, Util, XWiki, XWikiExceptionApi, XWikiUserManagementToolsAPI

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.


Field Summary
protected  XWikiContext context
          The current context, needed by the underlying protected object.
 
Constructor Summary
Api(XWikiContext context)
           
 
Method Summary
protected  List<Document> convert(List<XWikiDocument> xdocList)
          Convert a list of internal representation of documents to public api documents.
protected  Document convert(XWikiDocument xdoc)
          Convert an internal representation of document to public api document.
protected  XWikiContext getXWikiContext()
          Get the current context.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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()
Get the current context. For the moment, this is a crucial part of the request lifecycle, as it is the only access point to all the components needed for handling a request. Note: This method is protected so that users of this API do not get to see the XWikiContext object which should not be exposed.

Returns:
The XWiki Context object containing all information about the current XWiki instance, including information on the current request and response.

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 or false 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 the admin right or false 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 the admin right or false 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.

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.