com.xpn.xwiki.api
Class XWiki

java.lang.Object
  extended by com.xpn.xwiki.api.Api
      extended by com.xpn.xwiki.api.XWiki

public class XWiki
extends Api


Field Summary
protected static org.slf4j.Logger LOGGER
          Logging helper object.
 
Fields inherited from class com.xpn.xwiki.api.Api
context
 
Constructor Summary
XWiki(XWiki xwiki, XWikiContext context)
          XWiki API Constructor
 
Method Summary
 String addMandatory()
           
 void addToAllGroup(String fullwikiname)
          Priviledged API to add a user to the XWiki.XWikiAllGroup
 String addTooltip(String html, String message)
          Inserts a tooltip using toolTip.js
 String addTooltip(String html, String message, String params)
          Inserts a tooltip using toolTip.js
 String addTooltipJS()
          Inserts the tooltip Javascript
 boolean checkAccess(String docname, String right)
          Verify the rights the current user has on a document.
 XWikiUser checkAuth()
          Check authentication from request and set according persitent login information If it fails user is unlogged
 XWikiUser checkAuth(String username, String password, String rememberme)
          Check authentication from username and password and set according persitent login information If it fails user is unlogged
 String convertUsername(String username)
          API to convert the username depending on the configuration The username can be converted from email to a valid XWiki page name hidding the email address The username can be then used to login and link to the right user page
 boolean copyDocument(DocumentReference sourceDocumentReference, DocumentReference targetDocumentReference, String wikilanguage, boolean resetHistory, boolean overwrite)
          API to copy a translation of a document to another document of the same name in another wiki additionally resetting the version and overwriting the previous document
 boolean copyDocument(String docname, String targetdocname)
          API to copy a document to another document in the same wiki
 boolean copyDocument(String docname, String targetdocname, String wikilanguage)
          API to copy a translation of a document to another document in the same wiki
 boolean copyDocument(String docname, String sourceWiki, String targetWiki, String wikilanguage)
          API to copy a translation of a document to another document of the same name in another wiki
 boolean copyDocument(String docname, String targetdocname, String sourceWiki, String targetWiki, String wikilanguage, boolean reset)
          API to copy a translation of a document to another document of the same name in another wiki additionally resetting the version
 boolean copyDocument(String docname, String targetdocname, String sourceWiki, String targetWiki, String wikilanguage, boolean reset, boolean force)
          API to copy a translation of a document to another document of the same name in another wiki additionally resetting the version and overwriting the previous document
 int copySpaceBetweenWikis(String space, String sourceWiki, String targetWiki, String language, boolean clean)
          Privileged API to copy a space to another wiki, optionally deleting all document of the target space
 int countDocuments(String wheresql)
          API allowing to count the total number of documents that would be returned by a query.
 int countDocuments(String parameterizedWhereClause, List<?> parameterValues)
          API allowing to count the total number of documents that would be returned by a parameterized query.
 Document createDocument()
          API to create an empty document
 int createUser()
          Priviledged API to create a new user from the request This API is used by RegisterNewUser wiki page
 int createUser(boolean withValidation)
          Priviledged API to create a new user from the request This API is used by RegisterNewUser wiki page This version sends a validation email to the user Configuration of validation email is in the XWiki Preferences
 int createUser(boolean withValidation, String userRights)
          Priviledged API to create a new user from the request This API is used by RegisterNewUser wiki page This version sends a validation email to the user Configuration of validation email is in the XWiki Preferences
 boolean exists(DocumentReference reference)
          Returns whether a document exists or not
 boolean exists(String fullname)
          Returns whether a document exists or not
 void flushCache()
          Priviledged API to flush the cache of the Wiki installation This flushed the cache of all wikis, all plugins, all renderers
 String formatDate(Date date)
          API allowing to format a date according to the default Wiki setting The date format is provided in the 'dateformat' parameter of the XWiki Preferences
 String formatDate(Date date, String format)
          API allowing to format a date according to a custom format The date format is from java.text.SimpleDateFormat Example: "dd/MM/yyyy HH:mm:ss" or "d MMM yyyy" If the format is invalid the default format will be used to show the date
 Api get(String name)
          Returns a plugin from the plugin API.
 String getAdClientId()
          Returns the Advertisement client ID from the preferences
 String getAdType()
          Returns the Advertisement system from the preferences
 String getAttachmentURL(String fullname, String filename)
          API to retrieve the URL of an attached file in a Wiki Document The URL is generated differently depending on the environement (Servlet, Portlet, PDF, etc..) The URL generation can be modified by implementing a new XWikiURLFactory object For compatibility with any target environement (and especially the portlet environment) It is important to always use the URL functions to generate URL and never hardcode URLs
 Syntax getAvailableRendererSyntax(String syntaxType, String syntaxVersion)
          Find the corresponding available renderer syntax.
 String getBaseSkin()
          API to retrieve the current skin for this request and user.
 Class getClass(String documentName)
          Get the XWiki Class object defined in the passed Document name.
 List<String> getClassList()
          Get the list of available classes in the wiki
 List<String> getConfiguredSyntaxes()
           
 String getCounter(String name)
          Provides an absolute counter
 CriteriaService getCriteriaService()
          API to get the xwiki criteria service which allow to create various criteria : integer ranges, date periods, date intervals, etc.
 String getCurrentContentSyntaxId()
          Get the syntax of the document currently being executed.
 DocumentStats getCurrentMonthXWikiStats(String action)
          Deprecated. use getStatsService() instead
 String getDefaultDocumentSyntax()
           
 DeletedAttachment getDeletedAttachment(String id)
          Retrieve a specific attachment from the trash.
 List<DeletedAttachment> getDeletedAttachments(String docName)
          Retrieve all the deleted attachments that belonged to a certain document.
 List<DeletedAttachment> getDeletedAttachments(String docName, String filename)
          Retrieve all the deleted attachments that belonged to a certain document and had the specified name.
 DeletedDocument getDeletedDocument(String fullname, String lang, String index)
           
 List<DeletedDocument> getDeletedDocuments(String fullname, String lang)
           
 Document getDocument(DocumentReference reference)
          Loads an Document from the database.
 Document getDocument(Document doc, String rev)
          Load a specific revision of a document
 Document getDocument(String fullName)
          Loads an Document from the database.
 Document getDocument(String space, String fullname)
          Loads an Document from the database.
 Document getDocumentAsAuthor(DocumentReference reference)
          Loads an Document from the database.
 Document getDocumentAsAuthor(String fullName)
          Loads an Document from the database.
 String getEditorPreference()
          Retrieves the current editor preference for the request The preference is first looked up in the user preference and then in the space and wiki preference
 String getEncoding()
          API to retrieve the current encoding of the wiki engine The encoding is stored in xwiki.cfg Default encoding is ISO-8891-1
 String getFullNameSQL()
          Deprecated.  
 List<String> getIncludedMacros(String defaultSpace, String content)
          Returns the list of Macros documents in the specified content
 String getInterfaceLanguagePreference()
          API to access the interface language preference for the request Order of evaluation is: Language of the wiki in mono-lingual mode language request paramater language in context language user preference language in cookie language accepted by the navigator
 String getLanguagePreference()
          First try to find the current language in use from the XWiki context.
 String getLocalUserName(String user)
          API to retrieve a link to the User Name page displayed for the first name and last name of the user The link will link to the page on the local wiki even if the user is registered on a different wiki (in virtual wiki mode)
 String getLocalUserName(String user, boolean link)
          API to retrieve a text representing the user with the first name and last name of the user With the link param set to false it will not link to the user page With the link param set to true, the link will link to the page on the local wiki even if the user is registered on a different wiki (in virtual wiki mode)
 String getLocalUserName(String user, String format)
          API to retrieve a link to the User Name page displayed with a custom view The link will link to the page on the local wiki even if the user is registered on a different wiki (in virtual wiki mode) The formating is done using the format parameter which can contain velocity scripting and access all properties of the User profile using variables ($first_name $last_name $email $city)
 String getLocalUserName(String user, String format, boolean link)
          API to retrieve a text representing the user with a custom view The formating is done using the format parameter which can contain velocity scripting and access all properties of the User profile using variables ($first_name $last_name $email $city) With the link param set to false it will not link to the user page With the link param set to true, the link will link to the page on the local wiki even if the user is registered on a different wiki (in virtual wiki mode)
 String getMacroList()
          API to get the macro list from the XWiki Preferences The macro list are the macros available from the Macro Mapping System
 MetaClass getMetaclass()
          Get the global MetaClass object
 Object getObjectFromRequest(String className)
          API to create an object from the request The parameters are the ones that are created from doc.display("field","edit") calls
 Api getPlugin(String name)
          Returns a plugin from the plugin API.
 PropertyClass getPropertyClassFromName(String propPath)
          API to get the Property object from a class based on a property path A property path looks like XWiki.ArticleClass_fieldname
 QueryManager getQueryManager()
          Deprecated. since XE 2.4M2 use the Query Manager Script Service
 String getRefererText(String referer)
          API to retrieve a viewable referer text for a referer Referers are URL where users have clicked on a link to an XWiki page Search engine referer URLs are transformed to a nicer view (Google: search query string) For other URL the http:// part is stripped
 String getRelativeRequestURL()
          API Allowing to access the current request URL being requested as a relative URL.
 String getRequestURL()
          API Allowing to access the current request URL being requested.
 long getSectionEditingDepth()
           
 String getServletPath()
          API to get the Servlet path for the current wiki.
 String getServletPath(String wikiName)
          API to get the Servlet path for a given wiki.
 String getShortRefererText(String referer, int length)
          API to retrieve a viewable referer text for a referer with a maximum length Referers are URL where users have clicked on a link to an XWiki page Search engine referer URLs are transformed to a nicer view (Google: search query string) For other URL the http:// part is stripped
 String getSkin()
          API to retrieve the current skin for this request and user The skin is first derived from the request "skin" parameter If this parameter does not exist, the user preference "skin" is looked up If this parameter does not exist or is empty, the space preference "skin" is looked up If this parameter does not exist or is empty, the XWiki preference "skin" is looked up If this parameter does not exist or is empty, the xwiki.cfg parameter xwiki.defaultskin is looked up If this parameter does not exist or is empty, the xwiki.cfg parameter xwiki.defaultbaseskin is looked up If this parameter does not exist or is empty, the skin is "colibri"
 String getSkinFile(String filename)
          Return the URL of the static file provided by the current skin The file is first looked in the skin active for the user, the space or the wiki.
 String getSkinFile(String filename, boolean forceSkinAction)
          Return the URL of the static file provided by the current skin The file is first looked in the skin active for the user, the space or the wiki.
 String getSkinPreference(String preference)
          API to access a Skin Preference The skin object is the current user's skin
 String getSkinPreference(String preference, String defaultValue)
          API to access a Skin Preference The skin object is the current user's skin
 String getSpaceCopyright()
          API to access the copyright for this space.
 List<String> getSpaceDocsName(String SpaceName)
          API to list all documents in a space
 String getSpacePreference(String preference)
          API to access an Space Preference There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look in the XWiki Preferences
 String getSpacePreference(String preference, String defaultValue)
          API to access an Space Preference There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look in the XWiki Preferences
 int getSpacePreferenceAsInt(String preference)
          API to access a Space Preference as a int number There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look for the XWiki Preference
 int getSpacePreferenceAsInt(String preference, int defaultValue)
          API to access a space Preference as a int number There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look for the XWiki Preference
 long getSpacePreferenceAsLong(String preference)
          API to access a Space Preference as a long number There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look for the XWiki Preference
 long getSpacePreferenceAsLong(String preference, long defaultValue)
          API to access a Space Preference as a long number There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look for the XWiki Preference
 String getSpacePreferenceFor(String preference, String space)
          API to access an Space Preference There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look in the XWiki Preferences
 String getSpacePreferenceFor(String preference, String space, String defaultValue)
          API to access an XWiki Preference as a long number There can be one preference object per language This function will find the right preference object associated to the current active language
 List<String> getSpaces()
          API to list the current spaces in thiswiki
 StatsService getStatsService()
          Access statistics api
 String getTextArea(String content)
          Output content in the edit content textarea
 String getUniquePageName(String name)
          Generates a unique page name based on initial page name and already existing pages
 String getUniquePageName(String space, String name)
          Generates a unique page name based on initial page name and already existing pages
 String getURL(DocumentReference reference)
          API to retrieve the URL of an a Wiki Document in view mode The URL is generated differently depending on the environement (Servlet, Portlet, PDF, etc..) The URL generation can be modified by implementing a new XWikiURLFactory object For compatibility with any target environement (and especially the portlet environment) It is important to always use the URL functions to generate URL and never hardcode URLs
 String getURL(DocumentReference reference, String action, String querystring)
          API to retrieve the URL of a Wiki Document in any mode, optionally adding a query string The URL is generated differently depending on the environment (Servlet, Portlet, PDF, etc..) The URL generation can be modified by implementing a new XWikiURLFactory object.
 String getURL(String fullname)
          API to retrieve the URL of an a Wiki Document in view mode The URL is generated differently depending on the environement (Servlet, Portlet, PDF, etc..) The URL generation can be modified by implementing a new XWikiURLFactory object For compatibility with any target environement (and especially the portlet environment) It is important to always use the URL functions to generate URL and never hardcode URLs
 String getURL(String fullname, String action)
          API to retrieve the URL of an a Wiki Document in any mode.
 String getURL(String fullname, String action, String querystring)
          API to retrieve the URL of a Wiki Document in any mode, optionally adding a query string The URL is generated differently depending on the environment (Servlet, Portlet, PDF, etc..) The URL generation can be modified by implementing a new XWikiURLFactory object.
 String getURL(String fullname, String action, String querystring, String anchor)
          API to retrieve the URL of an a Wiki Document in any mode, optionally adding an anchor.
 String getURLContent(String surl)
          Returns the content of an HTTP/HTTPS URL
 String getURLContent(String surl, int timeout)
          Returns the content of an HTTP/HTTPS URL
 String getURLContent(String surl, String username, String password)
          Returns the content of an HTTP/HTTPS URL protected using Basic Authentication
 String getURLContent(String surl, String username, String password, int timeout)
          Returns the content of an HTTP/HTTPS URL protected using Basic Authentication
 byte[] getURLContentAsBytes(String surl)
          Returns the content of an HTTP/HTTPS URL as Bytes
 byte[] getURLContentAsBytes(String surl, String username, String password)
          Returns the content of an HTTP/HTTPS URL protected using Basic Authentication as Bytes
 User getUser()
           
 User getUser(String username)
           
 String getUserName(String user)
          API to retrieve a link to the User Name page displayed for the first name and last name of the user The link will link to the page on the wiki where the user is registered (in virtual wiki mode)
 String getUserName(String user, boolean link)
          API to retrieve a text representing the user with the first name and last name of the user With the link param set to false it will not link to the user page With the link param set to true, the link will link to the page on the wiki where the user was registered (in virtual wiki mode)
 String getUserName(String user, String format)
          API to retrieve a link to the User Name page displayed with a custom view.
 String getUserName(String user, String format, boolean link)
          API to retrieve a text representing the user with a custom view With the link param set to false it will not link to the user page With the link param set to true, the link will link to the page on the wiki where the user was registered (in virtual wiki mode) The formating is done using the format parameter which can contain velocity scripting and access all properties of the User profile using variables ($first_name $last_name $email $city)
 String getUserPreference(String preference)
          API to access a User Preference This function will look in the User profile for the preference If no preference is found it will look in the Space Preferences If no preference is found it will look in the XWiki Preferences
 String getUserPreferenceFromCookie(String preference)
          API to access a User Preference from cookie This function will look in the session cookie for the preference
 String getUserTimeZone()
           
 String getVersion()
           
 String getWebAppPath()
          API to get the webapp path for the current wiki.
 String getWysiwygToolbars()
          API to check if using which toolbars in Wysiwyg editor
 XWiki getXWiki()
          Privileged API allowing to access the underlying main XWiki Object
 String getXWikiPreference(String preference)
          API to access an XWiki Preference There can be one preference object per language This function will find the right preference object associated to the current active language
 String getXWikiPreference(String preference, String defaultValue)
          API to access an XWiki Preference There can be one preference object per language This function will find the right preference object associated to the current active language
 int getXWikiPreferenceAsInt(String preference)
          API to access an XWiki Preference as a int number There can be one preference object per language This function will find the right preference object associated to the current active language
 int getXWikiPreferenceAsInt(String preference, int defaultValue)
          API to access an XWiki Preference as an int number There can be one preference object per language This function will find the right preference object associated to the current active language
 long getXWikiPreferenceAsLong(String preference)
          API to access an XWiki Preference as a long number There can be one preference object per language This function will find the right preference object associated to the current active language
 long getXWikiPreferenceAsLong(String preference, long defaultValue)
          API to access an XWiki Preference as a long number There can be one preference object per language This function will find the right preference object associated to the current active language
 boolean hasAccessLevel(String level)
          API to check rights on the current document for the current user
 boolean hasAccessLevel(String level, String user, String docname)
          API to check rights on a document for a given user
 boolean hasBacklinks()
          API to check if the backlinks feature is active Backlinks are activated in xwiki.cfg or in the XWiki Preferences
 boolean hasEditComment()
          API to check if the edit comment feature is active Edit comments are activated in xwiki.cfg or in the XWiki Preferences
 boolean hasMinorEdit()
          API to check if the minor edit feature is active minor edit is activated in xwiki.cfg or in the XWiki Preferences
 boolean hasRecycleBin()
          API to check if the recycle bin feature is active recycle bin is activated in xwiki.cfg or in the XWiki Preferences
 boolean hasTags()
          API to check if the tags feature is active.
 String includeForm(String topic)
          API to execute a form in the context of an including topic The rendering is evaluated in the context of the including topic All velocity variables are the one of the including topic This api is usually called using #includeForm in a page, which modifies the behavior of "Edit this page" button to direct for Form mode (inline)
 String includeForm(String topic, boolean pre)
          API to execute a form in the context of an including topic, optionnaly surrounding the content with {pre}{/pre} to avoid future wiki rendering The rendering is evaluated in the context of the including topic All velocity variables are the one of the including topic This api is usually called using #includeForm in a page, which modifies the behavior of "Edit this page" button to direct for Form mode (inline).
 String includeTopic(String topic)
          API to include a topic into another The topic is rendered fully in the context of itself
 String includeTopic(String topic, boolean pre)
          API to include a topic into another, optionally surrounding the content with {pre}{/pre} to avoid future wiki rendering.
 String invokeServletAndReturnAsString(String url)
          Designed to include dynamic content, such as Servlets or JSPs, inside Velocity templates; works by creating a RequestDispatcher, buffering the output, then returning it as a string.
 boolean isEditCommentFieldHidden()
          API to check if the edit comment field is shown in the edit form Edit comments are activated in xwiki.cfg or in the XWiki Preferences
 boolean isEditCommentMandatory()
          API to check if the edit comment is mandatory (prompted by Javascript if empty) Edit comments are activated in xwiki.cfg or in the XWiki Preferences
 boolean isEditCommentSuggested()
          API to check if the edit comment is suggested (prompted once by Javascript if empty) Edit comments are activated in xwiki.cfg or in the XWiki Preferences
 boolean isMultiLingual()
          API to check is wiki is multi-lingual
 boolean isReadOnly()
          returns true if xwiki.readonly is set in the configuration file
 boolean isTitleInCompatibilityMode()
           
 boolean isVirtualMode()
          API to check if wiki is in multi-wiki mode (virtual)
 String parseContent(String content)
          API allowing to parse a text content to evaluate velocity scripts
 Object parseGroovyFromPage(String fullname)
          Privileged API to retrieve an object instanciated from groovy code in a String Groovy scripts compilation is cached
 Object parseGroovyFromPage(String script, String jarWikiPage)
          Privileged API to retrieve an object instantiated from groovy code in a String, using a classloader including all JAR files located in the passed page as attachments.
 Object parseGroovyFromString(String script)
          Privileged API to retrieve an object instantiated from groovy code in a String.
 String parseMessage()
          Deprecated. use XWikiMessageTool.get(String, List) instead. From velocity you can access XWikiMessageTool with $msg binding.
 String parseTemplate(String template)
          API to parse a velocity template provided by the current Skin The template is first looked in the skin active for the user, the space or the wiki.
 void refreshLinks()
          Priviledge API to regenerate the links/backlinks table Normally links and backlinks are stored when a page is modified This function will regenerate all the backlinks This function can be long to run
 boolean renamePage(Document doc, String newFullName)
          API to rename a page (experimental) Rights are necessary to edit the source and target page All objects and attachments ID are modified in the process to link to the new page name
 String renderChunk(Chunk chunk, boolean source, Document doc)
          API to render a chunk (difference between two versions
 String renderChunk(Chunk chunk, Document doc)
          API to render a chunk (difference between two versions
 String renderTemplate(String template)
          API to render a velocity template provided by the current Skin The template is first looked in the skin active for the user, the space or the wiki.
 String renderText(String text, Document doc)
          API to render a text in the context of a document
 void resetRenderingEngine()
          Priviledged API to reset the rendenring engine This would restore the rendering engine evaluation loop and take into account new configuration parameters
<T> List<T>
search(String wheresql)
          Privileged API allowing to run a search on the database returning a list of data This search is send to the store engine (Hibernate HQL, JCR XPATH or other)
<T> List<T>
search(String wheresql, int nb, int start)
          Privileged API allowing to run a search on the database returning a list of data.
<T> List<T>
search(String parameterizedWhereClause, int maxResults, int startOffset, List<?> parameterValues)
          Privileged API allowing to run a search on the database returning a list of data.
<T> List<T>
search(String parameterizedWhereClause, List<?> parameterValues)
          Privileged API allowing to run a search on the database returning a list of data.
 List<String> searchDocuments(String wheresql)
          API allowing to search for document names matching a query.
 List<Document> searchDocuments(String wheresql, boolean distinctbylanguage)
          API allowing to search for documents allowing to have mutliple entries per language
 List<Document> searchDocuments(String wheresql, boolean distinctbylanguage, int nb, int start)
          API allowing to search for documents allowing to have multiple entries per language
 List<String> searchDocuments(String wheresql, int nb, int start)
          API allowing to search for document names matching a query return only a limited number of elements and skipping the first rows.
 List<String> searchDocuments(String parameterizedWhereClause, int maxResults, int startOffset, List<?> parameterValues)
          Search documents by passing HQL where clause values as parameters.
 List<String> searchDocuments(String wheresql, int nb, int start, String selectColumns)
          Privileged API allowing to search for document names matching a query return only a limited number of elements and skipping the first rows.
 List<String> searchDocuments(String parameterizedWhereClause, List<?> parameterValues)
          Same as searchDocuments(String, int, int, java.util.List) but returns all rows.
 List<String> searchDocumentsNames(String wikiName, String parameterizedWhereClause, int maxResults, int startOffset, List<?> parameterValues)
          Search documents in the provided wiki by passing HQL where clause values as parameters.
 List<String> searchSpacesNames(String parametrizedSqlClause, int nb, int start, List<?> parameterValues)
          Search spaces by passing HQL where clause values as parameters.
 void sendConfirmationMail(String xwikiname, String password, String email, String contentfield)
          Priviledged API to send a confirmation email to a user
 void sendConfirmationMail(String xwikiname, String password, String email, String add_message, String contentfield)
          Priviledged API to send a confirmation email to a user
 void setReadOnly(boolean ro)
          Privileged API to set/unset the readonly status of the Wiki After setting this to true no writing to the database will be performed All Edit buttons will be removed and save actions disabled This is used for maintenance purposes
 int validateUser(boolean withConfirmEmail)
          Priviledged API to validate the return code given by a user in response to an email validation email The validation information are taken from the request object
 List<Document> wrapDocs(List<?> docs)
          Function to wrap a list of XWikiDocument into Document objects
 
Methods inherited from class com.xpn.xwiki.api.Api
convert, convert, getXWikiContext, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

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

Constructor Detail

XWiki

public XWiki(XWiki xwiki,
             XWikiContext context)
XWiki API Constructor

Parameters:
xwiki - XWiki Main Object to wrap
context - XWikiContext to wrap
Method Detail

getXWiki

@Programming
public XWiki getXWiki()
Privileged API allowing to access the underlying main XWiki Object

Returns:
Privileged Main XWiki Object

getVersion

public String getVersion()
Returns:
XWiki's version in the format (version).(SVN build number), or "Unknown version" if it failed to be retrieved

getRequestURL

public String getRequestURL()
                     throws XWikiException
API Allowing to access the current request URL being requested.

Returns:
the URL
Throws:
XWikiException - failed to create the URL

getRelativeRequestURL

public String getRelativeRequestURL()
                             throws XWikiException
API Allowing to access the current request URL being requested as a relative URL.

Returns:
the URL
Throws:
XWikiException - failed to create the URL
Since:
4.0M1

getDocument

public Document getDocument(String fullName)
                     throws XWikiException
Loads an Document from the database. Rights are checked before sending back the document.

Parameters:
fullName - the full name of the XWiki document to be loaded
Returns:
a Document object (if the document couldn't be found a new one is created in memory - but not saved, you can check whether it's a new document or not by using Document.isNew()
Throws:
XWikiException

getDocument

public Document getDocument(DocumentReference reference)
                     throws XWikiException
Loads an Document from the database. Rights are checked before sending back the document.

Parameters:
reference - the reference of the XWiki document to be loaded
Returns:
a Document object (if the document couldn't be found a new one is created in memory - but not saved, you can check whether it's a new document or not by using Document.isNew()
Throws:
XWikiException
Since:
2.3M1

getDocumentAsAuthor

public Document getDocumentAsAuthor(String fullName)
                             throws XWikiException
Loads an Document from the database. Rights are checked on the author (contentAuthor) of the document containing the currently executing script before sending back the loaded document.

Parameters:
fullName - the full name of the XWiki document to be loaded
Returns:
a Document object (if the document couldn't be found a new one is created in memory - but not saved, you can check whether it's a new document or not by using Document.isNew()
Throws:
XWikiException
Since:
2.3M2

getDocumentAsAuthor

public Document getDocumentAsAuthor(DocumentReference reference)
                             throws XWikiException
Loads an Document from the database. Rights are checked on the author (contentAuthor) of the document containing the currently executing script before sending back the loaded document.

Parameters:
reference - the reference of the XWiki document to be loaded
Returns:
a Document object (if the document couldn't be found a new one is created in memory - but not saved, you can check whether it's a new document or not by using Document.isNew()
Throws:
XWikiException
Since:
2.3M2

getDeletedDocuments

public List<DeletedDocument> getDeletedDocuments(String fullname,
                                                 String lang)
                                          throws XWikiException
Parameters:
fullname - the name of the document to search for.
lang - an optional language to filter results.
Returns:
A list with all the deleted versions of a document in the recycle bin.
Throws:
XWikiException - if any error

getDeletedDocument

public DeletedDocument getDeletedDocument(String fullname,
                                          String lang,
                                          String index)
                                   throws XWikiException
Parameters:
fullname - - XWikiDocument.getFullName()
lang - - XWikiDocument.getLanguage()
Returns:
specified documents in recycle bin
Throws:
XWikiException - if any error

getDeletedAttachments

public List<DeletedAttachment> getDeletedAttachments(String docName)
Retrieve all the deleted attachments that belonged to a certain document. Note that this does not distinguish between different incarnations of a document name, and it does not require that the document still exists, it returns all the attachments that at the time of their deletion had a document with the specified name as their owner.

Parameters:
docName - the name of the owner document
Returns:
A list with all the deleted attachments which belonged to the specified document. If no such attachments are found in the trash, an empty list is returned.

getDeletedAttachments

public List<DeletedAttachment> getDeletedAttachments(String docName,
                                                     String filename)
Retrieve all the deleted attachments that belonged to a certain document and had the specified name. Multiple versions can be returned since the same file can be uploaded and deleted several times, creating different instances in the trash. Note that this does not distinguish between different incarnations of a document name, and it does not require that the document still exists, it returns all the attachments that at the time of their deletion had a document with the specified name as their owner.

Parameters:
docName - the name of the document the attachment belonged to
filename - the name of the attachment to search for
Returns:
A list with all the deleted attachments which belonged to the specified document and had the specified filename. If no such attachments are found in the trash, an empty list is returned.

getDeletedAttachment

public DeletedAttachment getDeletedAttachment(String id)
Retrieve a specific attachment from the trash.

Parameters:
id - the unique identifier of the entry in the trash
Returns:
specified attachment from the trash, null if not found

exists

public boolean exists(String fullname)
               throws XWikiException
Returns whether a document exists or not

Parameters:
fullname - Fullname of the XWiki document to be loaded
Returns:
true if the document exists, false if not
Throws:
XWikiException

exists

public boolean exists(DocumentReference reference)
               throws XWikiException
Returns whether a document exists or not

Parameters:
reference - the reference of the document to check for its existence
Returns:
true if the document exists, false if not
Throws:
XWikiException
Since:
2.3M2

checkAccess

public boolean checkAccess(String docname,
                           String right)
Verify the rights the current user has on a document. If the document requires rights and the user is not authenticated he will be redirected to the login page.

Parameters:
docname - fullname of the document
right - right to check ("view", "edit", "admin", "delete")
Returns:
true if it exists

getDocument

public Document getDocument(String space,
                            String fullname)
                     throws XWikiException
Loads an Document from the database. Rights are checked before sending back the document.

Parameters:
space - Space to use in case no space is defined in the provided fullname
fullname - the full name or relative name of the document to load
Returns:
a Document object (if the document couldn't be found a new one is created in memory - but not saved, you can check whether it's a new document or not by using Document.isNew()
Throws:
XWikiException

getDocument

public Document getDocument(Document doc,
                            String rev)
                     throws XWikiException
Load a specific revision of a document

Parameters:
doc - Document for which to load a specific revision
rev - Revision number
Returns:
Specific revision of a document
Throws:
XWikiException

getTextArea

public String getTextArea(String content)
Output content in the edit content textarea

Parameters:
content - content to output
Returns:
the textarea text content

getClassList

public List<String> getClassList()
                          throws XWikiException
Get the list of available classes in the wiki

Returns:
list of classes names
Throws:
XWikiException

getMetaclass

public MetaClass getMetaclass()
Get the global MetaClass object

Returns:
MetaClass object

search

public <T> List<T> search(String wheresql)
               throws XWikiException
Privileged API allowing to run a search on the database returning a list of data This search is send to the store engine (Hibernate HQL, JCR XPATH or other)

Parameters:
wheresql - Query to be run (HQL, XPath)
Returns:
A list of rows (Object[])
Throws:
XWikiException

search

public <T> List<T> search(String parameterizedWhereClause,
                          List<?> parameterValues)
               throws XWikiException
Privileged API allowing to run a search on the database returning a list of data. The HQL where clause uses parameters (question marks) instead of values, and the actual values are passed in the parameters list. This allows generating a query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which manual encoding/escaping is needed to avoid SQL injections or bad queries.

Parameters:
parameterizedWhereClause - query to be run (HQL)
parameterValues - the where clause values that replace the question marks
Returns:
a list of rows, where each row has either the selected data type (XWikiDocument, String, Integer, etc.), or Object[] if more than one column was selected
Throws:
XWikiException

search

public <T> List<T> search(String wheresql,
                          int nb,
                          int start)
               throws XWikiException
Privileged API allowing to run a search on the database returning a list of data. This search is sent to the store engine (Hibernate HQL, JCR XPATH or other)

Parameters:
wheresql - Query to be run (HQL, XPath)
nb - return only 'nb' rows
start - skip the 'start' first elements
Returns:
A list of rows (Object[])
Throws:
XWikiException

search

public <T> List<T> search(String parameterizedWhereClause,
                          int maxResults,
                          int startOffset,
                          List<?> parameterValues)
               throws XWikiException
Privileged API allowing to run a search on the database returning a list of data. The HQL where clause uses parameters (question marks) instead of values, and the actual values are passed in the paremeters list. This allows generating a query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which manual encoding/escaping is needed to avoid sql injections or bad queries.

Parameters:
parameterizedWhereClause - query to be run (HQL)
maxResults - maximum number of results to return; if 0 all results are returned
startOffset - skip the first N results; if 0 no items are skipped
parameterValues - the where clause values that replace the question marks
Returns:
a list of rows, where each row has either the selected data type (XWikiDocument, String, Integer, etc.), or Object[] if more than one column was selected
Throws:
XWikiException

searchDocuments

public List<String> searchDocuments(String wheresql)
                             throws XWikiException
API allowing to search for document names matching a query. Examples:

Parameters:
wheresql - Query to be run (either starting with ", BaseObject as obj where.." or by "where ..."
Returns:
List of document names matching (Main.Page1, Main.Page2)
Throws:
XWikiException

countDocuments

public int countDocuments(String wheresql)
                   throws XWikiException
API allowing to count the total number of documents that would be returned by a query.

Parameters:
wheresql - Query to use, similar to the ones accepted by searchDocuments(String). If possible, it should not contain order by or group clauses, since this kind of queries are not portable.
Returns:
The number of documents that matched the query.
Throws:
XWikiException - if there was a problem executing the query.

searchDocuments

public List<String> searchDocuments(String wheresql,
                                    int nb,
                                    int start)
                             throws XWikiException
API allowing to search for document names matching a query return only a limited number of elements and skipping the first rows. The query part is the same as searchDocuments

Parameters:
wheresql - query to use similar to searchDocuments(wheresql)
nb - return only 'nb' rows
start - skip the first 'start' rows
Returns:
List of document names matching
Throws:
XWikiException
See Also:
searchDocuments(String where sql)

searchDocuments

public List<String> searchDocuments(String wheresql,
                                    int nb,
                                    int start,
                                    String selectColumns)
                             throws XWikiException
Privileged API allowing to search for document names matching a query return only a limited number of elements and skipping the first rows. The return values contain the list of columns specified in addition to the document space and name The query part is the same as searchDocuments

Parameters:
wheresql - query to use similar to searchDocuments(wheresql)
nb - return only 'nb' rows
start - skip the first 'start' rows
selectColumns - List of columns to add to the result
Returns:
List of Object[] with the column values of the matching rows
Throws:
XWikiException

searchDocuments

public List<Document> searchDocuments(String wheresql,
                                      boolean distinctbylanguage)
                               throws XWikiException
API allowing to search for documents allowing to have mutliple entries per language

Parameters:
wheresql - query to use similar to searchDocuments(wheresql)
distinctbylanguage - true to return multiple rows per language
Returns:
List of Document object matching
Throws:
XWikiException

searchDocuments

public List<Document> searchDocuments(String wheresql,
                                      boolean distinctbylanguage,
                                      int nb,
                                      int start)
                               throws XWikiException
API allowing to search for documents allowing to have multiple entries per language

Parameters:
wheresql - query to use similar to searchDocuments(wheresql)
distinctbylanguage - true to return multiple rows per language
nb - return only 'nb' rows
start - skip the first 'start' rows
Returns:
List of Document object matching
Throws:
XWikiException

searchDocuments

public List<String> searchDocuments(String parameterizedWhereClause,
                                    int maxResults,
                                    int startOffset,
                                    List<?> parameterValues)
                             throws XWikiException
Search documents by passing HQL where clause values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escaping yourself before calling them.

Example

 <code>
 #set($orphans = $xwiki.searchDocuments(" where doc.fullName <> ? and (doc.parent = ? or "
     + "(doc.parent = ? and doc.space = ?))",
     ["${doc.fullName}as", ${doc.fullName}, ${doc.name}, ${doc.space}]))
 </code>
 

Parameters:
parameterizedWhereClause - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))"
maxResults - the number of rows to return. If 0 then all rows are returned
startOffset - the number of rows to skip. If 0 don't skip any row
parameterValues - the where clause values that replace the question marks (?)
Returns:
a list of document names
Throws:
XWikiException - in case of error while performing the query

searchDocuments

public List<String> searchDocuments(String parameterizedWhereClause,
                                    List<?> parameterValues)
                             throws XWikiException
Same as searchDocuments(String, int, int, java.util.List) but returns all rows.

Throws:
XWikiException
See Also:
searchDocuments(String, int, int, java.util.List)

countDocuments

public int countDocuments(String parameterizedWhereClause,
                          List<?> parameterValues)
                   throws XWikiException
API allowing to count the total number of documents that would be returned by a parameterized query.

Parameters:
parameterizedWhereClause - the parameterized query to use, similar to the ones accepted by searchDocuments(String, List). If possible, it should not contain order by or group clauses, since this kind of queries are not portable.
parameterValues - The parameter values that replace the question marks.
Returns:
The number of documents that matched the query.
Throws:
XWikiException - if there was a problem executing the query.

searchDocumentsNames

public List<String> searchDocumentsNames(String wikiName,
                                         String parameterizedWhereClause,
                                         int maxResults,
                                         int startOffset,
                                         List<?> parameterValues)
                                  throws XWikiException
Search documents in the provided wiki by passing HQL where clause values as parameters. See searchDocuments(String, int, int, java.util.List) for more details.

Parameters:
wikiName - the name of the wiki where to search.
parameterizedWhereClause - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))"
maxResults - the number of rows to return. If 0 then all rows are returned
startOffset - the number of rows to skip. If 0 don't skip any row
parameterValues - the where clause values that replace the question marks (?)
Returns:
a list of document full names (Space.Name).
Throws:
XWikiException - in case of error while performing the query
See Also:
searchDocuments(String, int, int, java.util.List)

searchSpacesNames

public List<String> searchSpacesNames(String parametrizedSqlClause,
                                      int nb,
                                      int start,
                                      List<?> parameterValues)
                               throws XWikiException
Search spaces by passing HQL where clause values as parameters. See searchDocuments(String, int, int, List) for more about parameterized hql clauses.

Parameters:
parametrizedSqlClause - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))"
nb - the number of rows to return. If 0 then all rows are returned
start - the number of rows to skip. If 0 don't skip any row
parameterValues - the where clause values that replace the question marks (?)
Returns:
a list of spaces names.
Throws:
XWikiException - in case of error while performing the query

wrapDocs

public List<Document> wrapDocs(List<?> docs)
Function to wrap a list of XWikiDocument into Document objects

Parameters:
docs - list of XWikiDocument
Returns:
list of Document objects

parseContent

public String parseContent(String content)
API allowing to parse a text content to evaluate velocity scripts

Parameters:
content -
Returns:
evaluated content if the content contains velocity scripts

parseTemplate

public String parseTemplate(String template)
API to parse a velocity template provided by the current Skin The template is first looked in the skin active for the user, the space or the wiki. If the template does not exist in that skin, the template is looked up in the "parent skin" of the skin

Parameters:
template - Template name ("view", "edit", "comment")
Returns:
Evaluated content from the template

renderTemplate

public String renderTemplate(String template)
API to render a velocity template provided by the current Skin The template is first looked in the skin active for the user, the space or the wiki. If the template does not exist in that skin, the template is looked up in the "parent skin" of the skin

Parameters:
template - Template name ("view", "edit", "comment")
Returns:
Evaluated content from the template

invokeServletAndReturnAsString

public String invokeServletAndReturnAsString(String url)
Designed to include dynamic content, such as Servlets or JSPs, inside Velocity templates; works by creating a RequestDispatcher, buffering the output, then returning it as a string.

Parameters:
url - URL of the servlet
Returns:
text result of the servlet

getSkinFile

public String getSkinFile(String filename)
Return the URL of the static file provided by the current skin The file is first looked in the skin active for the user, the space or the wiki. If the file does not exist in that skin, the file is looked up in the "parent skin" of the skin. The file can be a CSS file, an image file, a javascript file, etc.

Parameters:
filename - Filename to be looked up in the skin (logo.gif, style.css)
Returns:
URL to access this file

getSkinFile

public String getSkinFile(String filename,
                          boolean forceSkinAction)
Return the URL of the static file provided by the current skin The file is first looked in the skin active for the user, the space or the wiki. If the file does not exist in that skin, the file is looked up in the "parent skin" of the skin. The file can be a CSS file, an image file, a javascript file, etc.

Parameters:
filename - Filename to be looked up in the skin (logo.gif, style.css)
forceSkinAction - true to make sure that static files are retrieved through the skin action, to allow parsing of velocity on CSS files
Returns:
URL to access this file

getSkin

public String getSkin()
API to retrieve the current skin for this request and user The skin is first derived from the request "skin" parameter If this parameter does not exist, the user preference "skin" is looked up If this parameter does not exist or is empty, the space preference "skin" is looked up If this parameter does not exist or is empty, the XWiki preference "skin" is looked up If this parameter does not exist or is empty, the xwiki.cfg parameter xwiki.defaultskin is looked up If this parameter does not exist or is empty, the xwiki.cfg parameter xwiki.defaultbaseskin is looked up If this parameter does not exist or is empty, the skin is "colibri"

Returns:
The current skin for this request and user

getBaseSkin

public String getBaseSkin()
API to retrieve the current skin for this request and user. Each skin has a skin it is based on. If not the base skin is the xwiki.cfg parameter "xwiki.defaultbaseskin". If this parameter does not exist or is empty, the base skin is "colibri".

Returns:
The current baseskin for this request and user

getSpaceCopyright

public String getSpaceCopyright()
API to access the copyright for this space. The copyright is read in the space preferences. If it does not exist or is empty it is read from the XWiki preferences.

Returns:
the text for the copyright

getXWikiPreference

public String getXWikiPreference(String preference)
API to access an XWiki Preference There can be one preference object per language This function will find the right preference object associated to the current active language

Parameters:
preference - Preference name
Returns:
The preference for this wiki and the current language

getXWikiPreference

public String getXWikiPreference(String preference,
                                 String defaultValue)
API to access an XWiki Preference There can be one preference object per language This function will find the right preference object associated to the current active language

Parameters:
preference - Preference name
defaultValue - default value to return if the prefenrece does not exist or is empty
Returns:
The preference for this wiki and the current language

getSpacePreference

public String getSpacePreference(String preference)
API to access an Space Preference There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look in the XWiki Preferences

Parameters:
preference - Preference name
Returns:
The preference for this wiki and the current language

getSpacePreferenceFor

public String getSpacePreferenceFor(String preference,
                                    String space)
API to access an Space Preference There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look in the XWiki Preferences

Parameters:
preference - Preference name
space - The space for which this preference is requested
Returns:
The preference for this wiki and the current language

getSpacePreference

public String getSpacePreference(String preference,
                                 String defaultValue)
API to access an Space Preference There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look in the XWiki Preferences

Parameters:
preference - Preference name
defaultValue - default value to return if the preference does not exist or is empty
Returns:
The preference for this wiki and the current language

getSkinPreference

public String getSkinPreference(String preference)
API to access a Skin Preference The skin object is the current user's skin

Parameters:
preference - Preference name
Returns:
The preference for the current skin

getSkinPreference

public String getSkinPreference(String preference,
                                String defaultValue)
API to access a Skin Preference The skin object is the current user's skin

Parameters:
preference - Preference name
defaultValue - default value to return if the preference does not exist or is empty
Returns:
The preference for the current skin

getSpacePreferenceFor

public String getSpacePreferenceFor(String preference,
                                    String space,
                                    String defaultValue)
API to access an XWiki Preference as a long number There can be one preference object per language This function will find the right preference object associated to the current active language

Parameters:
preference - Preference name
space - The space for which this preference is requested
defaultValue - default value to return if the prefenrece does not exist or is empty
Returns:
The preference for this wiki and the current language in long format

getXWikiPreferenceAsLong

public long getXWikiPreferenceAsLong(String preference,
                                     long defaultValue)
API to access an XWiki Preference as a long number There can be one preference object per language This function will find the right preference object associated to the current active language

Parameters:
preference - Preference name
defaultValue - default value to return if the prefenrece does not exist or is empty
Returns:
The preference for this wiki and the current language in long format

getXWikiPreferenceAsLong

public long getXWikiPreferenceAsLong(String preference)
API to access an XWiki Preference as a long number There can be one preference object per language This function will find the right preference object associated to the current active language

Parameters:
preference - Preference name
Returns:
The preference for this wiki and the current language in long format

getSpacePreferenceAsLong

public long getSpacePreferenceAsLong(String preference,
                                     long defaultValue)
API to access a Space Preference as a long number There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look for the XWiki Preference

Parameters:
preference - Preference name
defaultValue - default value to return if the prefenrece does not exist or is empty
Returns:
The preference for this wiki and the current language in long format

getSpacePreferenceAsLong

public long getSpacePreferenceAsLong(String preference)
API to access a Space Preference as a long number There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look for the XWiki Preference

Parameters:
preference - Preference name
Returns:
The preference for this wiki and the current language in long format

getXWikiPreferenceAsInt

public int getXWikiPreferenceAsInt(String preference,
                                   int defaultValue)
API to access an XWiki Preference as an int number There can be one preference object per language This function will find the right preference object associated to the current active language

Parameters:
preference - Preference name
defaultValue - default value to return if the prefenrece does not exist or is empty
Returns:
The preference for this wiki and the current language in int format

getXWikiPreferenceAsInt

public int getXWikiPreferenceAsInt(String preference)
API to access an XWiki Preference as a int number There can be one preference object per language This function will find the right preference object associated to the current active language

Parameters:
preference - Preference name
Returns:
The preference for this wiki and the current language in int format

getSpacePreferenceAsInt

public int getSpacePreferenceAsInt(String preference,
                                   int defaultValue)
API to access a space Preference as a int number There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look for the XWiki Preference

Parameters:
preference - Preference name
defaultValue - default value to return if the prefenrece does not exist or is empty
Returns:
The preference for this wiki and the current language in int format

getSpacePreferenceAsInt

public int getSpacePreferenceAsInt(String preference)
API to access a Space Preference as a int number There can be one preference object per language This function will find the right preference object associated to the current active language If no preference is found it will look for the XWiki Preference

Parameters:
preference - Preference name
Returns:
The preference for this wiki and the current language in int format

getUserPreference

public String getUserPreference(String preference)
API to access a User Preference This function will look in the User profile for the preference If no preference is found it will look in the Space Preferences If no preference is found it will look in the XWiki Preferences

Parameters:
preference - Preference name
Returns:
The preference for this wiki and the current language

getUserPreferenceFromCookie

public String getUserPreferenceFromCookie(String preference)
API to access a User Preference from cookie This function will look in the session cookie for the preference

Parameters:
preference - Preference name
Returns:
The preference for this wiki and the current language

getLanguagePreference

public String getLanguagePreference()
First try to find the current language in use from the XWiki context. If none is used and if the wiki is not multilingual use the default language defined in the XWiki preferences. If the wiki is multilingual try to get the language passed in the request. If none was passed try to get it from a cookie. If no language cookie exists then use the user default language and barring that use the browser's "Accept-Language" header sent in HTTP request. If none is defined use the default language.

Returns:
the language to use

getInterfaceLanguagePreference

public String getInterfaceLanguagePreference()
API to access the interface language preference for the request Order of evaluation is: Language of the wiki in mono-lingual mode language request paramater language in context language user preference language in cookie language accepted by the navigator

Returns:
the document language preference for the request

isVirtualMode

public boolean isVirtualMode()
API to check if wiki is in multi-wiki mode (virtual)

Returns:
true for multi-wiki/false for mono-wiki

isMultiLingual

public boolean isMultiLingual()
API to check is wiki is multi-lingual

Returns:
true for multi-lingual/false for mono-lingual

flushCache

public void flushCache()
Priviledged API to flush the cache of the Wiki installation This flushed the cache of all wikis, all plugins, all renderers


resetRenderingEngine

public void resetRenderingEngine()
Priviledged API to reset the rendenring engine This would restore the rendering engine evaluation loop and take into account new configuration parameters


createUser

public int createUser()
               throws XWikiException
Priviledged API to create a new user from the request This API is used by RegisterNewUser wiki page

Returns:
true for success/false for failure
Throws:
XWikiException

createUser

public int createUser(boolean withValidation)
               throws XWikiException
Priviledged API to create a new user from the request This API is used by RegisterNewUser wiki page This version sends a validation email to the user Configuration of validation email is in the XWiki Preferences

Parameters:
withValidation - true to send the validationemail
Returns:
true for success/false for failure
Throws:
XWikiException

createUser

public int createUser(boolean withValidation,
                      String userRights)
               throws XWikiException
Priviledged API to create a new user from the request This API is used by RegisterNewUser wiki page This version sends a validation email to the user Configuration of validation email is in the XWiki Preferences

Parameters:
withValidation - true to send the validation email
userRights - Rights to set for the user for it's own page(defaults to "edit")
Returns:
true for success/false for failure
Throws:
XWikiException

validateUser

public int validateUser(boolean withConfirmEmail)
                 throws XWikiException
Priviledged API to validate the return code given by a user in response to an email validation email The validation information are taken from the request object

Parameters:
withConfirmEmail - true to send a account confirmation email/false to not send it
Returns:
Success of Failure code (0 for success, -1 for missing programming rights, > 0 for other errors
Throws:
XWikiException

addToAllGroup

public void addToAllGroup(String fullwikiname)
                   throws XWikiException
Priviledged API to add a user to the XWiki.XWikiAllGroup

Parameters:
fullwikiname - user name to add
Throws:
XWikiException

sendConfirmationMail

public void sendConfirmationMail(String xwikiname,
                                 String password,
                                 String email,
                                 String add_message,
                                 String contentfield)
                          throws XWikiException
Priviledged API to send a confirmation email to a user

Parameters:
xwikiname - user to send the email to
password - password to put in the mail
email - email to send to
add_message - Additional message to send to the user
contentfield - Preference field to use as a mail template
Throws:
XWikiException - if the mail was not send successfully

sendConfirmationMail

public void sendConfirmationMail(String xwikiname,
                                 String password,
                                 String email,
                                 String contentfield)
                          throws XWikiException
Priviledged API to send a confirmation email to a user

Parameters:
xwikiname - user to send the email to
password - password to put in the mail
email - email to send to
contentfield - Preference field to use as a mail template
Throws:
XWikiException - if the mail was not send successfully

copyDocument

public boolean copyDocument(String docname,
                            String targetdocname)
                     throws XWikiException
API to copy a document to another document in the same wiki

Parameters:
docname - source document
targetdocname - target document
Returns:
true if the copy was sucessfull
Throws:
XWikiException - if the document was not copied properly

copyDocument

public boolean copyDocument(String docname,
                            String targetdocname,
                            String wikilanguage)
                     throws XWikiException
API to copy a translation of a document to another document in the same wiki

Parameters:
docname - source document
targetdocname - target document
wikilanguage - language to copy
Returns:
true if the copy was sucessfull
Throws:
XWikiException - if the document was not copied properly

copyDocument

public boolean copyDocument(String docname,
                            String sourceWiki,
                            String targetWiki,
                            String wikilanguage)
                     throws XWikiException
API to copy a translation of a document to another document of the same name in another wiki

Parameters:
docname - source document
sourceWiki - source wiki
targetWiki - target wiki
wikilanguage - language to copy
Returns:
true if the copy was sucessfull
Throws:
XWikiException - if the document was not copied properly

copyDocument

public boolean copyDocument(String docname,
                            String targetdocname,
                            String sourceWiki,
                            String targetWiki,
                            String wikilanguage,
                            boolean reset)
                     throws XWikiException
API to copy a translation of a document to another document of the same name in another wiki additionally resetting the version

Parameters:
docname - source document
sourceWiki - source wiki
targetWiki - target wiki
wikilanguage - language to copy
reset - true to reset versions
Returns:
true if the copy was sucessfull
Throws:
XWikiException - if the document was not copied properly

copyDocument

public boolean copyDocument(String docname,
                            String targetdocname,
                            String sourceWiki,
                            String targetWiki,
                            String wikilanguage,
                            boolean reset,
                            boolean force)
                     throws XWikiException
API to copy a translation of a document to another document of the same name in another wiki additionally resetting the version and overwriting the previous document

Parameters:
docname - source document name
targetdocname - target document name
sourceWiki - source wiki
targetWiki - target wiki
wikilanguage - language to copy
reset - true to reset versions
force - true to overwrite the previous document
Returns:
true if the copy was sucessfull
Throws:
XWikiException - if the document was not copied properly

copyDocument

public boolean copyDocument(DocumentReference sourceDocumentReference,
                            DocumentReference targetDocumentReference,
                            String wikilanguage,
                            boolean resetHistory,
                            boolean overwrite)
                     throws XWikiException
API to copy a translation of a document to another document of the same name in another wiki additionally resetting the version and overwriting the previous document

Parameters:
sourceDocumentReference - the reference to the document to copy
targetDocumentReference - the reference to the document to create
wikilanguage - language to copy
resetHistory - true to reset versions
overwrite - true to overwrite the previous document
Returns:
true if the copy was sucessful
Throws:
XWikiException - if the document was not copied properly
Since:
3.0M3

copySpaceBetweenWikis

public int copySpaceBetweenWikis(String space,
                                 String sourceWiki,
                                 String targetWiki,
                                 String language,
                                 boolean clean)
                          throws XWikiException
Privileged API to copy a space to another wiki, optionally deleting all document of the target space

Parameters:
space - source Space
sourceWiki - source Wiki
targetWiki - target Wiki
language - language to copy
clean - true to delete all document of the target space
Returns:
number of copied documents
Throws:
XWikiException - if the space was not copied properly

includeTopic

public String includeTopic(String topic)
                    throws XWikiException
API to include a topic into another The topic is rendered fully in the context of itself

Parameters:
topic - page name of the topic to include
Returns:
the content of the included page
Throws:
XWikiException - if the include failed

includeForm

public String includeForm(String topic)
                   throws XWikiException
API to execute a form in the context of an including topic The rendering is evaluated in the context of the including topic All velocity variables are the one of the including topic This api is usually called using #includeForm in a page, which modifies the behavior of "Edit this page" button to direct for Form mode (inline)

Parameters:
topic - page name of the form to execute
Returns:
the content of the included page
Throws:
XWikiException - if the include failed

includeTopic

public String includeTopic(String topic,
                           boolean pre)
                    throws XWikiException
API to include a topic into another, optionally surrounding the content with {pre}{/pre} to avoid future wiki rendering. The topic is rendered fully in the context of itself.

Parameters:
topic - page name of the topic to include
pre - true to add {pre} {/pre} (only if includer document is 1.0 syntax)
Returns:
the content of the included page
Throws:
XWikiException - if the include failed

includeForm

public String includeForm(String topic,
                          boolean pre)
                   throws XWikiException
API to execute a form in the context of an including topic, optionnaly surrounding the content with {pre}{/pre} to avoid future wiki rendering The rendering is evaluated in the context of the including topic All velocity variables are the one of the including topic This api is usually called using #includeForm in a page, which modifies the behavior of "Edit this page" button to direct for Form mode (inline).

Parameters:
topic - page name of the form to execute
pre - true to add {pre} {/pre} (only if includer document is 1.0 syntax)
Returns:
the content of the included page
Throws:
XWikiException - if the include failed

hasAccessLevel

public boolean hasAccessLevel(String level)
API to check rights on the current document for the current user

Parameters:
level - right to check (view, edit, comment, delete)
Returns:
true if right is granted/false if not

hasAccessLevel

public boolean hasAccessLevel(String level,
                              String user,
                              String docname)
API to check rights on a document for a given user

Parameters:
level - right to check (view, edit, comment, delete)
user - user for which to check the right
docname - document on which to check the rights
Returns:
true if right is granted/false if not

renderText

public String renderText(String text,
                         Document doc)
                  throws XWikiException
API to render a text in the context of a document

Parameters:
text - text to render
doc - the text is evaluated in the content of this document
Returns:
evaluated content
Throws:
XWikiException - if the evaluation went wrong

renderChunk

public String renderChunk(Chunk chunk,
                          Document doc)
API to render a chunk (difference between two versions

Parameters:
chunk - difference between versions to render
doc - document to use as a context for rendering
Returns:
resuilt of the rendering

renderChunk

public String renderChunk(Chunk chunk,
                          boolean source,
                          Document doc)
API to render a chunk (difference between two versions

Parameters:
chunk - difference between versions to render
doc - document to use as a context for rendering
source - true to render the difference as wiki source and not as wiki rendered text
Returns:
resuilt of the rendering

getSpaces

public List<String> getSpaces()
                       throws XWikiException
API to list the current spaces in thiswiki

Returns:
a list for strings reprenseting the spaces
Throws:
XWikiException - if something went wrong

getSpaceDocsName

public List<String> getSpaceDocsName(String SpaceName)
                              throws XWikiException
API to list all documents in a space

Parameters:
SpaceName - space tolest
Returns:
A list of strings to lest the document
Throws:
XWikiException - if the loading went wrong

getEncoding

public String getEncoding()
API to retrieve the current encoding of the wiki engine The encoding is stored in xwiki.cfg Default encoding is ISO-8891-1

Returns:
encoding active in this wiki

getAttachmentURL

public String getAttachmentURL(String fullname,
                               String filename)
                        throws XWikiException
API to retrieve the URL of an attached file in a Wiki Document The URL is generated differently depending on the environement (Servlet, Portlet, PDF, etc..) The URL generation can be modified by implementing a new XWikiURLFactory object For compatibility with any target environement (and especially the portlet environment) It is important to always use the URL functions to generate URL and never hardcode URLs

Parameters:
fullname - page name which includes the attached file
filename - attached filename to create a link for
Returns:
a URL as a string pointing to the filename
Throws:
XWikiException - if the URL could not be generated properly

getURL

public String getURL(String fullname)
              throws XWikiException
API to retrieve the URL of an a Wiki Document in view mode The URL is generated differently depending on the environement (Servlet, Portlet, PDF, etc..) The URL generation can be modified by implementing a new XWikiURLFactory object For compatibility with any target environement (and especially the portlet environment) It is important to always use the URL functions to generate URL and never hardcode URLs

Parameters:
fullname - the name of the document for which to return the URL for
Returns:
a URL as a string pointing to the wiki document in view mode
Throws:
XWikiException - if the URL could not be generated properly

getURL

public String getURL(DocumentReference reference)
              throws XWikiException
API to retrieve the URL of an a Wiki Document in view mode The URL is generated differently depending on the environement (Servlet, Portlet, PDF, etc..) The URL generation can be modified by implementing a new XWikiURLFactory object For compatibility with any target environement (and especially the portlet environment) It is important to always use the URL functions to generate URL and never hardcode URLs

Parameters:
reference - the reference to the document for which to return the URL for
Returns:
a URL as a string pointing to the wiki document in view mode
Throws:
XWikiException - if the URL could not be generated properly
Since:
2.3M2

getURL

public String getURL(String fullname,
                     String action)
              throws XWikiException
API to retrieve the URL of an a Wiki Document in any mode. The URL is generated differently depending on the environment (Servlet, Portlet, PDF, etc..). The URL generation can be modified by implementing a new XWikiURLFactory object For compatibility with any target environement (and especially the portlet environment). It is important to always use the URL functions to generate URL and never hardcode URLs.

Parameters:
fullname - the page name which includes the attached file
action - the mode in which to access the document (view/edit/save/..). Any valid XWiki action is possible.
Returns:
a URL as a string pointing to the wiki document in view mode
Throws:
XWikiException - if the URL could not be generated properly

getURL

public String getURL(String fullname,
                     String action,
                     String querystring)
              throws XWikiException
API to retrieve the URL of a Wiki Document in any mode, optionally adding a query string The URL is generated differently depending on the environment (Servlet, Portlet, PDF, etc..) The URL generation can be modified by implementing a new XWikiURLFactory object. The query string will be modified to be added in the way the environment needs it. It is important to not add the query string parameter manually after a URL. Some environments will not accept this (like the Portlet environement).

Parameters:
fullname - the page name which includes the attached file
action - the mode in which to access the document (view/edit/save/..). Any valid XWiki action is possible
querystring - the Query String to provide in the usual mode (name1=value1&name2=value=2) including encoding
Returns:
a URL as a string pointing to the wiki document in view mode
Throws:
XWikiException - if the URL could not be generated properly

getURL

public String getURL(DocumentReference reference,
                     String action,
                     String querystring)
              throws XWikiException
API to retrieve the URL of a Wiki Document in any mode, optionally adding a query string The URL is generated differently depending on the environment (Servlet, Portlet, PDF, etc..) The URL generation can be modified by implementing a new XWikiURLFactory object. The query string will be modified to be added in the way the environment needs it. It is important to not add the query string parameter manually after a URL. Some environments will not accept this (like the Portlet environement).

Parameters:
reference - the reference to the document for which to return the URL for
action - the mode in which to access the document (view/edit/save/..). Any valid XWiki action is possible
querystring - the Query String to provide in the usual mode (name1=value1&name2=value=2) including encoding
Returns:
a URL as a string pointing to the wiki document in view mode
Throws:
XWikiException - if the URL could not be generated properly
Since:
3.0M3

getURL

public String getURL(String fullname,
                     String action,
                     String querystring,
                     String anchor)
              throws XWikiException
API to retrieve the URL of an a Wiki Document in any mode, optionally adding an anchor. The URL is generated differently depending on the environement (Servlet, Portlet, PDF, etc..) The URL generation can be modified by implementing a new XWikiURLFactory object. The anchor will be modified to be added in the way the environment needs it. It is important to not add the anchor parameter manually after a URL. Some environments will not accept this (like the Portlet environement).

Parameters:
fullname - the page name which includes the attached file
action - the mode in which to access the document (view/edit/save/..). Any valid XWiki action is possible
querystring - the Query String to provide in the usual mode (name1=value1&name2=value=2) including encoding
anchor - the anchor that points at a location within the passed document name
Returns:
a URL as a string pointing to the wiki document in view mode
Throws:
XWikiException - if the URL could not be generated properly

getCurrentMonthXWikiStats

@Deprecated
public DocumentStats getCurrentMonthXWikiStats(String action)
Deprecated. use getStatsService() instead

API to access the current starts for the Wiki for a specific action It retrieves the number of times the action was performed for the whole wiki The statistics module need to be activated (xwiki.stats=1 in xwiki.cfg)

Parameters:
action - action for which to retrieve statistics (view/save/download)
Returns:
A DocumentStats object with number of actions performed, unique visitors, number of visits

getRefererText

public String getRefererText(String referer)
API to retrieve a viewable referer text for a referer Referers are URL where users have clicked on a link to an XWiki page Search engine referer URLs are transformed to a nicer view (Google: search query string) For other URL the http:// part is stripped

Parameters:
referer - referer URL to transform
Returns:
A viewable string

getShortRefererText

public String getShortRefererText(String referer,
                                  int length)
API to retrieve a viewable referer text for a referer with a maximum length Referers are URL where users have clicked on a link to an XWiki page Search engine referer URLs are transformed to a nicer view (Google: search query string) For other URL the http:// part is stripped

Parameters:
referer - referer URL to transform
length - Maximum length. "..." is added to the end of the text
Returns:
A viewable string

getFullNameSQL

@Deprecated
public String getFullNameSQL()
Deprecated. 

Deprecated API which was retrieving the SQL to represent the fullName Document field depending on the database used This is not needed anymore and returns 'doc.fullName' for all databases

Returns:
"doc.fullName"

getUserName

public String getUserName(String user)
API to retrieve a link to the User Name page displayed for the first name and last name of the user The link will link to the page on the wiki where the user is registered (in virtual wiki mode)

Parameters:
user - Fully qualified username as retrieved from $context.user (XWiki.LudovicDubost)
Returns:
The first name and last name fields surrounded with a link to the user page

getUserName

public String getUserName(String user,
                          String format)
API to retrieve a link to the User Name page displayed with a custom view. The link will link to the page on the wiki where the user is registered (in virtual wiki mode) The formating is done using the format parameter which can contain velocity scripting and access all properties of the User profile using variables ($first_name $last_name $email $city)

Parameters:
user - Fully qualified username as retrieved from $context.user (XWiki.LudovicDubost)
format - formatting to be used ("$first_name $last_name", "$first_name")
Returns:
The first name and last name fields surrounded with a link to the user page

getLocalUserName

public String getLocalUserName(String user)
API to retrieve a link to the User Name page displayed for the first name and last name of the user The link will link to the page on the local wiki even if the user is registered on a different wiki (in virtual wiki mode)

Parameters:
user - Fully qualified username as retrieved from $context.user (XWiki.LudovicDubost)
Returns:
The first name and last name fields surrounded with a link to the user page

getLocalUserName

public String getLocalUserName(String user,
                               String format)
API to retrieve a link to the User Name page displayed with a custom view The link will link to the page on the local wiki even if the user is registered on a different wiki (in virtual wiki mode) The formating is done using the format parameter which can contain velocity scripting and access all properties of the User profile using variables ($first_name $last_name $email $city)

Parameters:
user - Fully qualified username as retrieved from $context.user (XWiki.LudovicDubost)
format - formatting to be used ("$first_name $last_name", "$first_name")
Returns:
The first name and last name fields surrounded with a link to the user page

getUserName

public String getUserName(String user,
                          boolean link)
API to retrieve a text representing the user with the first name and last name of the user With the link param set to false it will not link to the user page With the link param set to true, the link will link to the page on the wiki where the user was registered (in virtual wiki mode)

Parameters:
user - Fully qualified username as retrieved from $context.user (XWiki.LudovicDubost)
link - false to not add an HTML link to the user profile
Returns:
The first name and last name fields surrounded with a link to the user page

getUserName

public String getUserName(String user,
                          String format,
                          boolean link)
API to retrieve a text representing the user with a custom view With the link param set to false it will not link to the user page With the link param set to true, the link will link to the page on the wiki where the user was registered (in virtual wiki mode) The formating is done using the format parameter which can contain velocity scripting and access all properties of the User profile using variables ($first_name $last_name $email $city)

Parameters:
user - Fully qualified username as retrieved from $context.user (XWiki.LudovicDubost)
format - formatting to be used ("$first_name $last_name", "$first_name")
link - false to not add an HTML link to the user profile
Returns:
The first name and last name fields surrounded with a link to the user page

getLocalUserName

public String getLocalUserName(String user,
                               boolean link)
API to retrieve a text representing the user with the first name and last name of the user With the link param set to false it will not link to the user page With the link param set to true, the link will link to the page on the local wiki even if the user is registered on a different wiki (in virtual wiki mode)

Parameters:
user - Fully qualified username as retrieved from $context.user (XWiki.LudovicDubost)
link - false to not add an HTML link to the user profile
Returns:
The first name and last name fields surrounded with a link to the user page

getLocalUserName

public String getLocalUserName(String user,
                               String format,
                               boolean link)
API to retrieve a text representing the user with a custom view The formating is done using the format parameter which can contain velocity scripting and access all properties of the User profile using variables ($first_name $last_name $email $city) With the link param set to false it will not link to the user page With the link param set to true, the link will link to the page on the local wiki even if the user is registered on a different wiki (in virtual wiki mode)

Parameters:
user - Fully qualified username as retrieved from $context.user (XWiki.LudovicDubost)
format - formatting to be used ("$first_name $last_name", "$first_name")
link - false to not add an HTML link to the user profile
Returns:
The first name and last name fields surrounded with a link to the user page

getUser

public User getUser()

getUser

public User getUser(String username)

formatDate

public String formatDate(Date date)
API allowing to format a date according to the default Wiki setting The date format is provided in the 'dateformat' parameter of the XWiki Preferences

Parameters:
date - date object to format
Returns:
A string with the date formating from the default Wiki setting

formatDate

public String formatDate(Date date,
                         String format)
API allowing to format a date according to a custom format The date format is from java.text.SimpleDateFormat Example: "dd/MM/yyyy HH:mm:ss" or "d MMM yyyy" If the format is invalid the default format will be used to show the date

Parameters:
date - date to format
format - format of the date to be used
Returns:
the formatted date
See Also:
SimpleDateFormat

getUserTimeZone

public String getUserTimeZone()

get

public Api get(String name)
Returns a plugin from the plugin API. Plugin Rights can be verified. Note that although this API is a duplicate of getPlugin(String) it used to provide an easy access from Velocity to XWiki plugins. Indeed Velocity has a feature in that if a class has a get method, using the dot notation will automatically call the get method for the class. See http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html#propertylookuprules. This this allows the following constructs: $xwiki.pluginName.somePluginMethod()

Parameters:
name - Name of the plugin to retrieve (either short of full class name)
Returns:
a plugin object

getPlugin

public Api getPlugin(String name)
Returns a plugin from the plugin API. Plugin Rights can be verified.

Parameters:
name - Name of the plugin to retrieve (either short of full class name)
Returns:
a plugin object

getAdType

public String getAdType()
Returns the Advertisement system from the preferences

Returns:
"google" or "none"

getAdClientId

public String getAdClientId()
Returns the Advertisement client ID from the preferences

Returns:
an Ad affiliate ID

getURLContent

public String getURLContent(String surl,
                            String username,
                            String password)
                     throws IOException
Returns the content of an HTTP/HTTPS URL protected using Basic Authentication

Parameters:
surl - url to retrieve
username - username for the basic authentication
password - password for the basic authentication
Returns:
Content of the specified URL
Throws:
IOException

getURLContent

public String getURLContent(String surl)
                     throws IOException
Returns the content of an HTTP/HTTPS URL

Parameters:
surl - url to retrieve
Returns:
Content of the specified URL
Throws:
IOException

getURLContent

public String getURLContent(String surl,
                            String username,
                            String password,
                            int timeout)
                     throws IOException
Returns the content of an HTTP/HTTPS URL protected using Basic Authentication

Parameters:
surl - url to retrieve
username - username for the basic authentication
password - password for the basic authentication
timeout - manuel timeout in milliseconds
Returns:
Content of the specified URL
Throws:
IOException

getURLContent

public String getURLContent(String surl,
                            int timeout)
                     throws IOException
Returns the content of an HTTP/HTTPS URL

Parameters:
surl - url to retrieve
timeout - manuel timeout in milliseconds
Returns:
Content of the specified URL
Throws:
IOException

getURLContentAsBytes

public byte[] getURLContentAsBytes(String surl,
                                   String username,
                                   String password)
                            throws IOException
Returns the content of an HTTP/HTTPS URL protected using Basic Authentication as Bytes

Parameters:
surl - url to retrieve
username - username for the basic authentication
password - password for the basic authentication
Returns:
Content of the specified URL
Throws:
IOException

getURLContentAsBytes

public byte[] getURLContentAsBytes(String surl)
                            throws IOException
Returns the content of an HTTP/HTTPS URL as Bytes

Parameters:
surl - url to retrieve
Returns:
Content of the specified URL
Throws:
IOException

getIncludedMacros

public List<String> getIncludedMacros(String defaultSpace,
                                      String content)
Returns the list of Macros documents in the specified content

Parameters:
defaultSpace - Default space to use for relative path names
content - Content to parse
Returns:
ArrayList of document names

isReadOnly

public boolean isReadOnly()
returns true if xwiki.readonly is set in the configuration file

Returns:
the value of xwiki.isReadOnly()
See Also:
XWiki

setReadOnly

public void setReadOnly(boolean ro)
Privileged API to set/unset the readonly status of the Wiki After setting this to true no writing to the database will be performed All Edit buttons will be removed and save actions disabled This is used for maintenance purposes

Parameters:
ro - true to set read-only mode/false to unset

refreshLinks

public void refreshLinks()
                  throws XWikiException
Priviledge API to regenerate the links/backlinks table Normally links and backlinks are stored when a page is modified This function will regenerate all the backlinks This function can be long to run

Throws:
XWikiException - exception if the generation fails

hasBacklinks

public boolean hasBacklinks()
                     throws XWikiException
API to check if the backlinks feature is active Backlinks are activated in xwiki.cfg or in the XWiki Preferences

Returns:
true if the backlinks feature is active
Throws:
XWikiException - exception if the preference could not be retrieved

hasTags

public boolean hasTags()
                throws XWikiException
API to check if the tags feature is active. Tags are activated in xwiki.cfg or in the XWiki Preferences

Returns:
true if the tags feature is active, false otherwise
Throws:
XWikiException - exception if the preference could not be retrieved

hasEditComment

public boolean hasEditComment()
API to check if the edit comment feature is active Edit comments are activated in xwiki.cfg or in the XWiki Preferences

Returns:

isEditCommentFieldHidden

public boolean isEditCommentFieldHidden()
API to check if the edit comment field is shown in the edit form Edit comments are activated in xwiki.cfg or in the XWiki Preferences

Returns:

isEditCommentSuggested

public boolean isEditCommentSuggested()
API to check if the edit comment is suggested (prompted once by Javascript if empty) Edit comments are activated in xwiki.cfg or in the XWiki Preferences

Returns:

isEditCommentMandatory

public boolean isEditCommentMandatory()
API to check if the edit comment is mandatory (prompted by Javascript if empty) Edit comments are activated in xwiki.cfg or in the XWiki Preferences

Returns:

hasMinorEdit

public boolean hasMinorEdit()
API to check if the minor edit feature is active minor edit is activated in xwiki.cfg or in the XWiki Preferences


hasRecycleBin

public boolean hasRecycleBin()
API to check if the recycle bin feature is active recycle bin is activated in xwiki.cfg or in the XWiki Preferences


renamePage

public boolean renamePage(Document doc,
                          String newFullName)
API to rename a page (experimental) Rights are necessary to edit the source and target page All objects and attachments ID are modified in the process to link to the new page name

Parameters:
doc - page to rename
newFullName - target page name to move the information to
Throws:
XWikiException - exception if the rename fails

getEditorPreference

public String getEditorPreference()
Retrieves the current editor preference for the request The preference is first looked up in the user preference and then in the space and wiki preference

Returns:
"wysiwyg" or "text"

parseGroovyFromString

public Object parseGroovyFromString(String script)
                             throws XWikiException
Privileged API to retrieve an object instantiated from groovy code in a String. Note that Groovy scripts compilation is cached.

Parameters:
script - the Groovy class definition string (public class MyClass { ... })
Returns:
An object instantiating this class
Throws:
XWikiException

parseGroovyFromPage

public Object parseGroovyFromPage(String script,
                                  String jarWikiPage)
                           throws XWikiException
Privileged API to retrieve an object instantiated from groovy code in a String, using a classloader including all JAR files located in the passed page as attachments. Note that Groovy scripts compilation is cached

Parameters:
script - the Groovy class definition string (public class MyClass { ... })
Returns:
An object instantiating this class
Throws:
XWikiException

parseGroovyFromPage

public Object parseGroovyFromPage(String fullname)
                           throws XWikiException
Privileged API to retrieve an object instanciated from groovy code in a String Groovy scripts compilation is cached

Parameters:
fullname - // script containing a Groovy class definition (public class MyClass { ... })
Returns:
An object instanciating this class
Throws:
XWikiException

getMacroList

public String getMacroList()
API to get the macro list from the XWiki Preferences The macro list are the macros available from the Macro Mapping System

Returns:
String with each macro on each line

getWysiwygToolbars

public String getWysiwygToolbars()
API to check if using which toolbars in Wysiwyg editor

Returns:
a string value

getObjectFromRequest

public Object getObjectFromRequest(String className)
                            throws XWikiException
API to create an object from the request The parameters are the ones that are created from doc.display("field","edit") calls

Parameters:
className - XWiki Class Name to create the object from
Returns:
a BaseObject wrapped in an Object
Throws:
XWikiException - exception if the object could not be read

createDocument

public Document createDocument()
API to create an empty document

Returns:
an XWikiDocument wrapped in a Document

convertUsername

public String convertUsername(String username)
API to convert the username depending on the configuration The username can be converted from email to a valid XWiki page name hidding the email address The username can be then used to login and link to the right user page

Parameters:
username - username to use for login
Returns:
converted wiki page name for this username

getPropertyClassFromName

public PropertyClass getPropertyClassFromName(String propPath)
API to get the Property object from a class based on a property path A property path looks like XWiki.ArticleClass_fieldname

Parameters:
propPath - Property path
Returns:
a PropertyClass object from a BaseClass object

getUniquePageName

public String getUniquePageName(String name)
Generates a unique page name based on initial page name and already existing pages

Parameters:
name -
Returns:
a unique page name

getUniquePageName

public String getUniquePageName(String space,
                                String name)
Generates a unique page name based on initial page name and already existing pages

Parameters:
space -
name -
Returns:
a unique page name

addTooltip

public String addTooltip(String html,
                         String message,
                         String params)
Inserts a tooltip using toolTip.js

Parameters:
html - HTML viewed
message - HTML Tooltip message
params - Parameters in Javascropt added to the tooltip config
Returns:
HTML with working tooltip

addTooltip

public String addTooltip(String html,
                         String message)
Inserts a tooltip using toolTip.js

Parameters:
html - HTML viewed
message - HTML Tooltip message
Returns:
HTML with working tooltip

addTooltipJS

public String addTooltipJS()
Inserts the tooltip Javascript

Returns:

addMandatory

public String addMandatory()

getClass

public Class getClass(String documentName)
               throws XWikiException
Get the XWiki Class object defined in the passed Document name.

Note: This method doesn't require any rights for accessing the passed Document (as opposed to the Object.getClass() method which does require to get a Document object first. This is thus useful in cases where the calling code doesn't have the access right to the specified Document. It is safe because there are no sensitive data stored in a Class definition.

Parameters:
documentName - the name of the document for which to get the Class object. For example "XWiki.XWikiPreferences"
Returns:
the XWiki Class object defined in the passed Document name. If the passed Document name points to a Document with no Class defined then an empty Class object is returned (i.e. a Class object with no properties).
Throws:
XWikiException - if the passed document name doesn't point to a valid Document

getCounter

public String getCounter(String name)
Provides an absolute counter

Parameters:
name - Counter name
Returns:
String

checkAuth

public XWikiUser checkAuth()
                    throws XWikiException
Check authentication from request and set according persitent login information If it fails user is unlogged

Returns:
null if failed, non null XWikiUser if sucess
Throws:
XWikiException

checkAuth

public XWikiUser checkAuth(String username,
                           String password,
                           String rememberme)
                    throws XWikiException
Check authentication from username and password and set according persitent login information If it fails user is unlogged

Parameters:
username - username to check
password - password to check
rememberme - "1" if you want to remember the login accross navigator restart
Returns:
null if failed, non null XWikiUser if sucess
Throws:
XWikiException

getStatsService

public StatsService getStatsService()
Access statistics api

Returns:
a StatsService instance that can be used to retrieve different xwiki statistics

getCriteriaService

public CriteriaService getCriteriaService()
API to get the xwiki criteria service which allow to create various criteria : integer ranges, date periods, date intervals, etc.

Returns:
the xwiki criteria service

getConfiguredSyntaxes

public List<String> getConfiguredSyntaxes()
Returns:
the ids of configured syntaxes for this wiki (eg "xwiki/1.0", "xwiki/2.0", "mediawiki/1.0", etc)

getQueryManager

@Deprecated
public QueryManager getQueryManager()
Deprecated. since XE 2.4M2 use the Query Manager Script Service

Returns:
secure QueryManager for execute queries to store.

getServletPath

public String getServletPath(String wikiName)
API to get the Servlet path for a given wiki. In mono wiki this is "bin/" or "xwiki/". In virtual mode and if xwiki.virtual.usepath is enabled in xwiki.cfg, it is "wiki/wikiname/".

Parameters:
wikiName - wiki for which to get the path
Returns:
The servlet path

getServletPath

public String getServletPath()
API to get the Servlet path for the current wiki. In mono wiki this is "bin/" or "xwiki/". In virtual mode and if xwiki.virtual.usepath is enabled in xwiki.cfg, it is "wiki/wikiname/".

Returns:
The servlet path

getWebAppPath

public String getWebAppPath()
API to get the webapp path for the current wiki. This usually is "xwiki/". It can be configured in xwiki.cfg with the config xwiki.webapppath.

Returns:
The servlet path

getDefaultDocumentSyntax

public String getDefaultDocumentSyntax()
Returns:
the syntax id of the syntax to use when creating new documents.

getAvailableRendererSyntax

public Syntax getAvailableRendererSyntax(String syntaxType,
                                         String syntaxVersion)
Find the corresponding available renderer syntax.

If syntaxVersion is null the last version of the available provided syntax type is returned.

Parameters:
syntaxType - the syntax type
syntaxVersion - the syntax version
Returns:
the available corresponding Syntax. Null if no available renderer can be found.

getSectionEditingDepth

public long getSectionEditingDepth()
Returns:
the section depth for which section editing is available (can be configured through xwiki.section.depth configuration property. Defaults to 2 when not defined

isTitleInCompatibilityMode

public boolean isTitleInCompatibilityMode()
Returns:
true if title handling should be using the compatibility mode or not. When the compatibility mode is active, if the document's content first header (level 1 or level 2) matches the document's title the first header is stripped.

getCurrentContentSyntaxId

public String getCurrentContentSyntaxId()
Get the syntax of the document currently being executed.

The document currently being executed is not the same than the context document since when including a page with velocity #includeForm(), method for example the context doc is the includer document even if includeForm() fully execute and render the included document before insert it in the includer document.

If the current document can't be found, the method assume that the executed document is the context document (it's generally the case when a document is directly rendered with XWikiDocument.getRenderedContent(XWikiContext) for example).

Returns:
the syntax identifier

parseMessage

@Deprecated
public String parseMessage()
Deprecated. use XWikiMessageTool.get(String, List) instead. From velocity you can access XWikiMessageTool with $msg binding.

API to parse the message being stored in the Context. A message can be an error message or an information message either as text or as a message ID pointing to ApplicationResources. The message is also parse for velocity scripts

Returns:
Final message