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.apache.commons.logging.Log LOG
           
 
Fields inherited from class com.xpn.xwiki.api.Api
context
 
Constructor Summary
XWiki(XWiki xwiki, XWikiContext context)
          XWiki API Constructor
 
Method Summary
 java.lang.String addMandatory()
           
 void addToAllGroup(java.lang.String fullwikiname)
          Priviledged API to add a user to the XWiki.XWikiAllGroup
 java.lang.String addTooltip(java.lang.String html, java.lang.String message)
          Inserts a tooltip using toolTip.js
 java.lang.String addTooltip(java.lang.String html, java.lang.String message, java.lang.String params)
          Inserts a tooltip using toolTip.js
 java.lang.String addTooltipJS()
          Inserts the tooltip Javascript
 boolean checkAccess(java.lang.String docname, java.lang.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(java.lang.String username, java.lang.String password, java.lang.String rememberme)
          Check authentication from username and password and set according persitent login information If it fails user is unlogged
 java.lang.String convertUsername(java.lang.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(java.lang.String docname, java.lang.String targetdocname)
          Privileged API to copy a document to another document in the same wiki
 boolean copyDocument(java.lang.String docname, java.lang.String targetdocname, java.lang.String wikilanguage)
          Privileged API to copy a translation of a document to another document in the same wiki
 boolean copyDocument(java.lang.String docname, java.lang.String sourceWiki, java.lang.String targetWiki, java.lang.String wikilanguage)
          Privileged API to copy a translation of a document to another document of the same name in another wiki
 boolean copyDocument(java.lang.String docname, java.lang.String targetdocname, java.lang.String sourceWiki, java.lang.String targetWiki, java.lang.String wikilanguage, boolean reset)
          Privileged API to copy a translation of a document to another document of the same name in another wiki additionally resetting the version
 boolean copyDocument(java.lang.String docname, java.lang.String targetdocname, java.lang.String sourceWiki, java.lang.String targetWiki, java.lang.String wikilanguage, boolean reset, boolean force)
          Privileged 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 copyWikiWeb(java.lang.String web, java.lang.String sourceWiki, java.lang.String targetWiki, java.lang.String wikiLanguage, boolean clean)
          Privileged API to copy a space to another wiki, optionally deleting all document of the target space
 int countDocuments(java.lang.String wheresql)
          API allowing to count the total number of documents that would be returned by a query.
 int countDocuments(java.lang.String parametrizedSqlClause, java.util.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 createNewWiki(java.lang.String wikiName, java.lang.String wikiUrl, java.lang.String wikiAdmin, java.lang.String baseWikiName, boolean failOnExist)
          Priviledged API to create a new Wiki from an existing wiki This creates the database, copies to documents from a existing wiki Assigns the admin rights, creates the Wiki identification page in the main wiki
 int createNewWiki(java.lang.String wikiName, java.lang.String wikiUrl, java.lang.String wikiAdmin, java.lang.String baseWikiName, java.lang.String description, boolean failOnExist)
          Priviledged API to create a new Wiki from an existing wiki This creates the database, copies to documents from a existing wiki Assigns the admin rights, creates the Wiki identification page in the main wiki
 int createNewWiki(java.lang.String wikiName, java.lang.String wikiUrl, java.lang.String wikiAdmin, java.lang.String baseWikiName, java.lang.String description, java.lang.String language, boolean failOnExist)
          Priviledged API to create a new Wiki from an existing wiki This creates the database, copies to documents from a existing wiki Assigns the admin rights, creates the Wiki identification page in the main wiki Copy is limited to documents of a specified language.
 XWikiQuery createQueryFromRequest(java.lang.String className)
          API to create a query from a request Object The request object is the result of a form created from the displaySearch() and displaySearchColumns() functions
 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, java.lang.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
 java.lang.String displaySearch(java.lang.String fieldname, java.lang.String className)
          API to display a field in search mode for a specific class without preselected values This field data can then be used to generate an XWiki Query showing a table with the relevant data
 java.lang.String displaySearch(java.lang.String fieldname, java.lang.String className, java.lang.String prefix, XWikiCriteria criteria)
          API to display a field in search mode for a specific class with preselected values, optionally adding a prefix to the field name This field data can then be used to generate an XWiki Query showing a table with the relevant data
 java.lang.String displaySearch(java.lang.String fieldname, java.lang.String className, XWikiCriteria criteria)
          API to display a field in search mode for a specific class with preselected values This field data can then be used to generate an XWiki Query showing a table with the relevant data
 java.lang.String displaySearchColumns(java.lang.String className, java.lang.String prefix, XWikiQuery query)
          API to display a select box for the list of available field for a specific class, optionally adding a prefix This field data can then be used to generate an XWiki Query showing a table with the relevant data
 java.lang.String displaySearchColumns(java.lang.String className, XWikiQuery query)
          API to display a select box for the list of available field for a specific class This field data can then be used to generate an XWiki Query showing a table with the relevant data
 java.lang.String displaySearchOrder(java.lang.String className, java.lang.String prefix, XWikiQuery query)
          API to display a select box for the list of available field for a specific class, optionally adding a prefix This field data can then be used to generate the order element of an XWiki Query showing a table with the relevant data
 java.lang.String displaySearchOrder(java.lang.String className, XWikiQuery query)
          API to display a select box for the list of available field for a specific class This field data can then be used to generate the order element of an XWiki Query showing a table with the relevant data
 boolean exists(java.lang.String fullname)
          Returns wether 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
 java.lang.String formatDate(java.util.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
 java.lang.String formatDate(java.util.Date date, java.lang.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(java.lang.String name)
          Returns a plugin from the plugin API.
 java.lang.String getAdClientId()
          Returns the Advertisement client ID from the preferences
 java.lang.String getAdType()
          Returns the Advertisement system from the preferences
 java.lang.String getAttachmentURL(java.lang.String fullname, java.lang.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
 java.lang.String getBaseSkin()
          API to retrieve the current skin for this request and user.
 Class getClass(java.lang.String documentName)
          Get the XWiki Class object defined in the passed Document name.
 java.util.List<java.lang.String> getClassList()
          Get the list of available classes in the wiki
 java.util.List<java.lang.String> getConfiguredSyntaxes()
           
 java.lang.String getCounter(java.lang.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.
 DocumentStats getCurrentMonthXWikiStats(java.lang.String action)
          Deprecated. use getStatsService() instead
 DeletedDocument getDeletedDocument(java.lang.String fullname, java.lang.String lang, java.lang.String index)
           
 java.util.List<DeletedDocument> getDeletedDocuments(java.lang.String fullname, java.lang.String lang)
           
 Document getDocument(Document doc, java.lang.String rev)
          Load a specific revision of a document
 Document getDocument(java.lang.String fullname)
          Loads an Document from the database.
 Document getDocument(java.lang.String web, java.lang.String fullname)
          Loads an Document from the database.
 java.lang.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
 java.lang.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
 java.lang.Object getExoPortalService(java.lang.String className)
          Privileged API to access an eXo Platform Portal service from the Wiki Engine
 java.lang.Object getExoService(java.lang.String className)
          Privileged API to access an eXo Platform service from the Wiki Engine
 java.lang.String getFormEncoded(java.lang.String content)
          Transform a text in a form compatible text
 java.lang.String getFullNameSQL()
          Deprecated.  
 java.lang.String getHTMLArea(java.lang.String content)
          Output content in the edit content htmlarea
 java.util.List<java.lang.String> getIncludedMacros(java.lang.String defaultweb, java.lang.String content)
          Returns the list of Macros documents in the specified content
 java.lang.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
 java.lang.String getLanguagePreference()
          First try to find the current language in use from the XWiki context.
 java.lang.String getLocalUserName(java.lang.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)
 java.lang.String getLocalUserName(java.lang.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)
 java.lang.String getLocalUserName(java.lang.String user, java.lang.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)
 java.lang.String getLocalUserName(java.lang.String user, java.lang.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)
 java.lang.String getMacroList()
          API to get the macro list from the XWiki Preferences The macro list are the macros available from the Macro Mapping System
 java.lang.String getMessage(java.lang.String id)
          API to get a message 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 parsed for velocity scripts
 MetaClass getMetaclass()
          Get the global MetaClass object
 Object getObjectFromRequest(java.lang.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(java.lang.String name)
          Returns a plugin from the plugin API.
 PropertyClass getPropertyClassFromName(java.lang.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()
           
 java.lang.String getRefererText(java.lang.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
 java.lang.String getRequestURL()
          API Allowing to access the current request URL being requested
 java.lang.String getServletPath()
          API to get the Servlet path for the current wiki.
 java.lang.String getServletPath(java.lang.String wikiName)
          API to get the Servlet path for a given wiki.
 java.lang.String getShortRefererText(java.lang.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
 java.lang.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 "albatross"
 java.lang.String getSkinFile(java.lang.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.
 java.lang.String getSkinFile(java.lang.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.
 java.lang.String getSkinPreference(java.lang.String prefname)
          API to access a Skin Preference The skin object is the current user's skin
 java.lang.String getSkinPreference(java.lang.String prefname, java.lang.String default_value)
          API to access a Skin Preference The skin object is the current user's skin
 java.util.List<java.lang.String> getSpaceDocsName(java.lang.String SpaceName)
          API to list all documents in a space
 java.util.List<java.lang.String> getSpaces()
          API to list the current spaces in thiswiki
 StatsService getStatsService()
          Access statistics api
 java.lang.String getTextArea(java.lang.String content)
          Output content in the edit content textarea
 java.lang.String getUniquePageName(java.lang.String name)
          Generates a unique page name based on initial page name and already existing pages
 java.lang.String getUniquePageName(java.lang.String space, java.lang.String name)
          Generates a unique page name based on initial page name and already existing pages
 java.lang.String getURL(java.lang.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
 java.lang.String getURL(java.lang.String fullname, java.lang.String action)
          API to retrieve the URL of an a Wiki Document in any 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
 java.lang.String getURL(java.lang.String fullname, java.lang.String action, java.lang.String querystring)
          API to retrieve the URL of an a Wiki Document in any mode, optionally adding a query string 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 query string will be modified to be added in the way the environement needs it It is important to not add the query string parameter manually after a URL Some environements will not accept this (like the Portlet environement)
 java.lang.String getURLContent(java.lang.String surl)
          Returns the content of an HTTP/HTTPS URL
 java.lang.String getURLContent(java.lang.String surl, int timeout)
          Returns the content of an HTTP/HTTPS URL
 java.lang.String getURLContent(java.lang.String surl, java.lang.String username, java.lang.String password)
          Returns the content of an HTTP/HTTPS URL protected using Basic Authentication
 java.lang.String getURLContent(java.lang.String surl, java.lang.String username, java.lang.String password, int timeout)
          Returns the content of an HTTP/HTTPS URL protected using Basic Authentication
 byte[] getURLContentAsBytes(java.lang.String surl)
          Returns the content of an HTTP/HTTPS URL as Bytes
 byte[] getURLContentAsBytes(java.lang.String surl, java.lang.String username, java.lang.String password)
          Returns the content of an HTTP/HTTPS URL protected using Basic Authentication as Bytes
 User getUser()
           
 User getUser(java.lang.String username)
           
 java.lang.String getUserName(java.lang.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)
 java.lang.String getUserName(java.lang.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)
 java.lang.String getUserName(java.lang.String user, java.lang.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)
 java.lang.String getUserName(java.lang.String user, java.lang.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)
 java.lang.String getUserPreference(java.lang.String prefname)
          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
 java.lang.String getUserPreferenceFromCookie(java.lang.String prefname)
          API to access a User Preference from cookie This function will look in the session cookie for the preference
 java.lang.String getUserTimeZone()
           
 java.lang.String getVersion()
           
 java.lang.String getWebAppPath()
          API to get the webapp path for the current wiki.
 java.lang.String getWebCopyright()
          API to access the copyright for this space.
 java.lang.String getWebPreference(java.lang.String prefname)
          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
 java.lang.String getWebPreference(java.lang.String prefname, java.lang.String default_value)
          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 getWebPreferenceAsInt(java.lang.String prefname)
          API to access an Web 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 getWebPreferenceAsInt(java.lang.String prefname, int default_value)
          API to access an Web 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 getWebPreferenceAsLong(java.lang.String prefname)
          API to access an Web 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 getWebPreferenceAsLong(java.lang.String prefname, long default_value)
          API to access an Web 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
 java.lang.String getWebPreferenceFor(java.lang.String prefname, java.lang.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
 java.lang.String getWebPreferenceFor(java.lang.String prefname, java.lang.String space, java.lang.String default_value)
          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
 java.lang.String getWysiwygToolbars()
          API to check if using which toolbars in Wysiwyg editor
 java.lang.String getXMLEncoded(java.lang.String content)
          Transform a text in a XML compatible text
 XWiki getXWiki()
          Priviledge API allowing to access the underlying main XWiki Object
 java.lang.String getXWikiPreference(java.lang.String prefname)
          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
 java.lang.String getXWikiPreference(java.lang.String prefname, java.lang.String default_value)
          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(java.lang.String prefname)
          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(java.lang.String prefname, int default_value)
          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(java.lang.String prefname)
          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(java.lang.String prefname, long default_value)
          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(java.lang.String level)
          API to check rights on the current document for the current user
 boolean hasAccessLevel(java.lang.String level, java.lang.String user, java.lang.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.
 java.lang.String includeForm(java.lang.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)
 java.lang.String includeForm(java.lang.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)
 java.lang.String includeTopic(java.lang.String topic)
          API to include a topic into another The topic is rendered fully in the context of itself
 java.lang.String includeTopic(java.lang.String topic, boolean pre)
          API to include a topic into another, optionnaly surrounding the content with {pre}{/pre} to avoid future wiki rendering The topic is rendered fully in the context of itself
 java.lang.String invokeServletAndReturnAsString(java.lang.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 isVirtualMode()
          API to check if wiki is in multi-wiki mode (virtual)
 java.lang.String parseContent(java.lang.String content)
          API allowing to parse a text content to evaluate velocity scripts
 java.lang.Object parseGroovyFromPage(java.lang.String fullname)
          Privileged API to retrieve an object instanciated from groovy code in a String Groovy scripts compilation is cached
 java.lang.Object parseGroovyFromPage(java.lang.String script, java.lang.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.
 java.lang.Object parseGroovyFromString(java.lang.String script)
          Privileged API to retrieve an object instantiated from groovy code in a String.
 java.lang.String parseMessage()
          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
 java.lang.String parseMessage(java.lang.String id)
          API to parse a message 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
 java.lang.String parseTemplate(java.lang.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, java.lang.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
 java.lang.String renderChunk(org.suigeneris.jrcs.diff.delta.Chunk chunk, boolean source, Document doc)
          API to render a chunk (difference between two versions
 java.lang.String renderChunk(org.suigeneris.jrcs.diff.delta.Chunk chunk, Document doc)
          API to render a chunk (difference between two versions
 java.lang.String renderTemplate(java.lang.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.
 java.lang.String renderText(java.lang.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
 java.util.List search(java.lang.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)
 java.util.List search(java.lang.String wheresql, int nb, int start)
          Priviledged 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)
 java.util.List search(XWikiQuery query)
          API to run a search from an XWikiQuery Object An XWikiQuery object can be created from a request using the createQueryFromRequest function
 java.lang.String searchAsTable(XWikiQuery query)
          API to run a search from an XWikiQuery Object and display it as a HTML table An XWikiQuery object can be created from a request using the createQueryFromRequest function
 java.util.List<java.lang.String> searchDocuments(java.lang.String wheresql)
          API allowing to search for document names matching a query.
 java.util.List<Document> searchDocuments(java.lang.String wheresql, boolean distinctbylanguage)
          API allowing to search for documents allowing to have mutliple entries per language
 java.util.List<Document> searchDocuments(java.lang.String wheresql, boolean distinctbylanguage, int nb, int start)
          API allowing to search for documents allowing to have mutliple entries per language
 java.util.List<java.lang.String> searchDocuments(java.lang.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.
 java.util.List<java.lang.String> searchDocuments(java.lang.String parametrizedSqlClause, int nb, int start, java.util.List<?> parameterValues)
          Search documents by passing HQL where clause values as parameters.
 java.util.List<java.lang.String> searchDocuments(java.lang.String wheresql, int nb, int start, java.lang.String selectColumns)
          Priviledged API allowing to search for document names matching a query return only a limited number of elements and skipping the first rows.
 java.util.List<java.lang.String> searchDocuments(java.lang.String parametrizedSqlClause, java.util.List<?> parameterValues)
          Same as searchDocuments(String, int, int, java.util.List) but returns all rows.
 java.util.List<java.lang.String> searchDocumentsNames(java.lang.String wikiName, java.lang.String parametrizedSqlClause, int nb, int start, java.util.List<?> parameterValues)
          Search documents in the provided wiki by passing HQL where clause values as parameters.
 java.util.List<java.lang.String> searchSpacesNames(java.lang.String parametrizedSqlClause, int nb, int start, java.util.List<?> parameterValues)
          Search spaces by passing HQL where clause values as parameters.
 void sendConfirmationMail(java.lang.String xwikiname, java.lang.String password, java.lang.String email, java.lang.String contentfield)
          Priviledged API to send a confirmation email to a user
 void sendConfirmationMail(java.lang.String xwikiname, java.lang.String password, java.lang.String email, java.lang.String add_message, java.lang.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
 java.util.List<Document> wrapDocs(java.util.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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG
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

public XWiki getXWiki()
Priviledge API allowing to access the underlying main XWiki Object

Returns:
Priviledged Main XWiki Object

getVersion

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

getRequestURL

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

Returns:
URL
Throws:
XWikiException

getDocument

public Document getDocument(java.lang.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 or null if it is not accessible
Throws:
XWikiException

getDeletedDocuments

public java.util.List<DeletedDocument> getDeletedDocuments(java.lang.String fullname,
                                                           java.lang.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(java.lang.String fullname,
                                          java.lang.String lang,
                                          java.lang.String index)
                                   throws XWikiException
Parameters:
fullname - - XWikiDocument.getFullName()
lang - - XWikiDocument.getLanguage()
Returns:
specified documents in recycle bin
Throws:
XWikiException - if any error

exists

public boolean exists(java.lang.String fullname)
               throws XWikiException
Returns wether 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

checkAccess

public boolean checkAccess(java.lang.String docname,
                           java.lang.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(java.lang.String web,
                            java.lang.String fullname)
                     throws XWikiException
Loads an Document from the database. Rights are checked before sending back the document.

Parameters:
web - 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 or null if it is not accessible
Throws:
XWikiException

getDocument

public Document getDocument(Document doc,
                            java.lang.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

getFormEncoded

public java.lang.String getFormEncoded(java.lang.String content)
Transform a text in a form compatible text

Parameters:
content - text to transform
Returns:
encoded result

getXMLEncoded

public java.lang.String getXMLEncoded(java.lang.String content)
Transform a text in a XML compatible text

Parameters:
content - text to transform
Returns:
encoded result

getTextArea

public java.lang.String getTextArea(java.lang.String content)
Output content in the edit content textarea

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

getHTMLArea

public java.lang.String getHTMLArea(java.lang.String content)
Output content in the edit content htmlarea

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

getClassList

public java.util.List<java.lang.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 java.util.List search(java.lang.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 java.util.List search(java.lang.String wheresql,
                             int nb,
                             int start)
                      throws XWikiException
Priviledged 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)
nb - return only 'nb' rows
start - skip the 'start' first elements
Returns:
A list of rows (Object[])
Throws:
XWikiException

searchDocuments

public java.util.List<java.lang.String> searchDocuments(java.lang.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(java.lang.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 java.util.List<java.lang.String> searchDocuments(java.lang.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 java.util.List<java.lang.String> searchDocuments(java.lang.String wheresql,
                                                        int nb,
                                                        int start,
                                                        java.lang.String selectColumns)
                                                 throws XWikiException
Priviledged 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 java.util.List<Document> searchDocuments(java.lang.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 java.util.List<Document> searchDocuments(java.lang.String wheresql,
                                                boolean distinctbylanguage,
                                                int nb,
                                                int start)
                                         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
nb - return only 'nb' rows
start - skip the first 'start' rows
Returns:
List of Document object matching
Throws:
XWikiException

searchDocuments

public java.util.List<java.lang.String> searchDocuments(java.lang.String parametrizedSqlClause,
                                                        int nb,
                                                        int start,
                                                        java.util.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:
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 document names
Throws:
XWikiException - in case of error while performing the query

searchDocuments

public java.util.List<java.lang.String> searchDocuments(java.lang.String parametrizedSqlClause,
                                                        java.util.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(java.lang.String parametrizedSqlClause,
                          java.util.List<?> parameterValues)
                   throws XWikiException
API allowing to count the total number of documents that would be returned by a parameterized query.

Parameters:
wheresql - 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 java.util.List<java.lang.String> searchDocumentsNames(java.lang.String wikiName,
                                                             java.lang.String parametrizedSqlClause,
                                                             int nb,
                                                             int start,
                                                             java.util.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.
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 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 java.util.List<java.lang.String> searchSpacesNames(java.lang.String parametrizedSqlClause,
                                                          int nb,
                                                          int start,
                                                          java.util.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 java.util.List<Document> wrapDocs(java.util.List<?> docs)
Function to wrap a list of XWikiDocument into Document objects

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

parseContent

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

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

parseMessage

public java.lang.String parseMessage()
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

parseMessage

public java.lang.String parseMessage(java.lang.String id)
API to parse a message 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

Parameters:
id -
Returns:
Final message

getMessage

public java.lang.String getMessage(java.lang.String id)
API to get a message 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 parsed for velocity scripts

Parameters:
id -
Returns:
Final message

parseTemplate

public java.lang.String parseTemplate(java.lang.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 java.lang.String renderTemplate(java.lang.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 java.lang.String invokeServletAndReturnAsString(java.lang.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 java.lang.String getSkinFile(java.lang.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 java.lang.String getSkinFile(java.lang.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 java.lang.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 "albatross"

Returns:
The current skin for this request and user

getBaseSkin

public java.lang.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 "albatross".

Returns:
The current baseskin for this request and user

getWebCopyright

public java.lang.String getWebCopyright()
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 java.lang.String getXWikiPreference(java.lang.String prefname)
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:
prefname - Preference name
Returns:
The preference for this wiki and the current language

getXWikiPreference

public java.lang.String getXWikiPreference(java.lang.String prefname,
                                           java.lang.String default_value)
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:
prefname - Preference name
default_value - default value to return if the prefenrece does not exist or is empty
Returns:
The preference for this wiki and the current language

getWebPreference

public java.lang.String getWebPreference(java.lang.String prefname)
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:
prefname - Preference name
Returns:
The preference for this wiki and the current language

getWebPreferenceFor

public java.lang.String getWebPreferenceFor(java.lang.String prefname,
                                            java.lang.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:
prefname - Preference name
space - The space for which this preference is requested
Returns:
The preference for this wiki and the current language

getWebPreference

public java.lang.String getWebPreference(java.lang.String prefname,
                                         java.lang.String default_value)
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:
prefname - Preference name
default_value - 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 java.lang.String getSkinPreference(java.lang.String prefname)
API to access a Skin Preference The skin object is the current user's skin

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

getSkinPreference

public java.lang.String getSkinPreference(java.lang.String prefname,
                                          java.lang.String default_value)
API to access a Skin Preference The skin object is the current user's skin

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

getWebPreferenceFor

public java.lang.String getWebPreferenceFor(java.lang.String prefname,
                                            java.lang.String space,
                                            java.lang.String default_value)
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:
prefname - Preference name
space - The space for which this preference is requested
default_value - 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(java.lang.String prefname,
                                     long default_value)
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:
prefname - Preference name
default_value - 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(java.lang.String prefname)
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:
prefname - Preference name
Returns:
The preference for this wiki and the current language in long format

getWebPreferenceAsLong

public long getWebPreferenceAsLong(java.lang.String prefname,
                                   long default_value)
API to access an Web 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:
prefname - Preference name
default_value - 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

getWebPreferenceAsLong

public long getWebPreferenceAsLong(java.lang.String prefname)
API to access an Web 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:
prefname - Preference name
Returns:
The preference for this wiki and the current language in long format

getXWikiPreferenceAsInt

public int getXWikiPreferenceAsInt(java.lang.String prefname,
                                   int default_value)
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:
prefname - Preference name
default_value - 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(java.lang.String prefname)
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:
prefname - Preference name
Returns:
The preference for this wiki and the current language in int format

getWebPreferenceAsInt

public int getWebPreferenceAsInt(java.lang.String prefname,
                                 int default_value)
API to access an Web 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:
prefname - Preference name
default_value - 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

getWebPreferenceAsInt

public int getWebPreferenceAsInt(java.lang.String prefname)
API to access an Web 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:
prefname - Preference name
Returns:
The preference for this wiki and the current language in int format

getUserPreference

public java.lang.String getUserPreference(java.lang.String prefname)
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:
prefname - Preference name
Returns:
The preference for this wiki and the current language

getUserPreferenceFromCookie

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

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

getLanguagePreference

public java.lang.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 java.lang.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,
                      java.lang.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

createNewWiki

public int createNewWiki(java.lang.String wikiName,
                         java.lang.String wikiUrl,
                         java.lang.String wikiAdmin,
                         java.lang.String baseWikiName,
                         boolean failOnExist)
                  throws XWikiException
Priviledged API to create a new Wiki from an existing wiki This creates the database, copies to documents from a existing wiki Assigns the admin rights, creates the Wiki identification page in the main wiki

Parameters:
wikiName - Wiki Name to create
wikiUrl - Wiki URL to accept requests from
wikiAdmin - Wiki admin user
baseWikiName - Wiki to copy documents from
failOnExist - true to fail if the wiki already exists, false to overwrite
Returns:
Success of Failure code (0 for success, -1 for missing programming rights, > 0 for other errors
Throws:
XWikiException

createNewWiki

public int createNewWiki(java.lang.String wikiName,
                         java.lang.String wikiUrl,
                         java.lang.String wikiAdmin,
                         java.lang.String baseWikiName,
                         java.lang.String description,
                         boolean failOnExist)
                  throws XWikiException
Priviledged API to create a new Wiki from an existing wiki This creates the database, copies to documents from a existing wiki Assigns the admin rights, creates the Wiki identification page in the main wiki

Parameters:
wikiName - Wiki Name to create
wikiUrl - Wiki URL to accept requests from
wikiAdmin - Wiki admin user
baseWikiName - Wiki to copy documents from
description - Description of the Wiki
failOnExist - true to fail if the wiki already exists, false to overwrite
Returns:
Success of Failure code (0 for success, -1 for missing programming rights, > 0 for other errors
Throws:
XWikiException

createNewWiki

public int createNewWiki(java.lang.String wikiName,
                         java.lang.String wikiUrl,
                         java.lang.String wikiAdmin,
                         java.lang.String baseWikiName,
                         java.lang.String description,
                         java.lang.String language,
                         boolean failOnExist)
                  throws XWikiException
Priviledged API to create a new Wiki from an existing wiki This creates the database, copies to documents from a existing wiki Assigns the admin rights, creates the Wiki identification page in the main wiki Copy is limited to documents of a specified language. If a document for the language is not found, the default language document is used

Parameters:
wikiName - Wiki Name to create
wikiUrl - Wiki URL to accept requests from
wikiAdmin - Wiki admin user
baseWikiName - Wiki to copy documents from
description - Description of the Wiki
language - Language to copy
failOnExist - true to fail if the wiki already exists, false to overwrite
Returns:
Success of Failure code (0 for success, -1 for missing programming rights, > 0 for other errors
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(java.lang.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(java.lang.String xwikiname,
                                 java.lang.String password,
                                 java.lang.String email,
                                 java.lang.String add_message,
                                 java.lang.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(java.lang.String xwikiname,
                                 java.lang.String password,
                                 java.lang.String email,
                                 java.lang.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(java.lang.String docname,
                            java.lang.String targetdocname)
                     throws XWikiException
Privileged 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(java.lang.String docname,
                            java.lang.String targetdocname,
                            java.lang.String wikilanguage)
                     throws XWikiException
Privileged 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(java.lang.String docname,
                            java.lang.String sourceWiki,
                            java.lang.String targetWiki,
                            java.lang.String wikilanguage)
                     throws XWikiException
Privileged 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(java.lang.String docname,
                            java.lang.String targetdocname,
                            java.lang.String sourceWiki,
                            java.lang.String targetWiki,
                            java.lang.String wikilanguage,
                            boolean reset)
                     throws XWikiException
Privileged 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(java.lang.String docname,
                            java.lang.String targetdocname,
                            java.lang.String sourceWiki,
                            java.lang.String targetWiki,
                            java.lang.String wikilanguage,
                            boolean reset,
                            boolean force)
                     throws XWikiException
Privileged 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
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

copyWikiWeb

public int copyWikiWeb(java.lang.String web,
                       java.lang.String sourceWiki,
                       java.lang.String targetWiki,
                       java.lang.String wikiLanguage,
                       boolean clean)
                throws XWikiException
Privileged API to copy a space to another wiki, optionally deleting all document of the target space

Parameters:
web - source Space
sourceWiki - source Wiki
targetWiki - target Wiki
wikiLanguage - 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 java.lang.String includeTopic(java.lang.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 java.lang.String includeForm(java.lang.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 java.lang.String includeTopic(java.lang.String topic,
                                     boolean pre)
                              throws XWikiException
API to include a topic into another, optionnaly 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}
Returns:
the content of the included page
Throws:
XWikiException - if the include failed

includeForm

public java.lang.String includeForm(java.lang.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}
Returns:
the content of the included page
Throws:
XWikiException - if the include failed

hasAccessLevel

public boolean hasAccessLevel(java.lang.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(java.lang.String level,
                              java.lang.String user,
                              java.lang.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 java.lang.String renderText(java.lang.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 java.lang.String renderChunk(org.suigeneris.jrcs.diff.delta.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 java.lang.String renderChunk(org.suigeneris.jrcs.diff.delta.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 java.util.List<java.lang.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 java.util.List<java.lang.String> getSpaceDocsName(java.lang.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 java.lang.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 java.lang.String getAttachmentURL(java.lang.String fullname,
                                         java.lang.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 java.lang.String getURL(java.lang.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 - page name which includes the attached file
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 java.lang.String getURL(java.lang.String fullname,
                               java.lang.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 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
action - 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 java.lang.String getURL(java.lang.String fullname,
                               java.lang.String action,
                               java.lang.String querystring)
                        throws XWikiException
API to retrieve the URL of an a Wiki Document in any mode, optionally adding a query string 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 query string will be modified to be added in the way the environement needs it It is important to not add the query string parameter manually after a URL Some environements will not accept this (like the Portlet environement)

Parameters:
fullname - page name which includes the attached file
action - mode in which to access the document (view/edit/save/..). Any valid XWiki action is possible.
querystring - 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

getExoService

public java.lang.Object getExoService(java.lang.String className)
                               throws XWikiException
Privileged API to access an eXo Platform service from the Wiki Engine

Parameters:
className - eXo classname to retrieve the service from
Returns:
A object representing the service or null if the user doesn't have programming rights
Throws:
XWikiException - if the service cannot be loaded
Since:
1.1 Beta 1

getExoPortalService

public java.lang.Object getExoPortalService(java.lang.String className)
                                     throws XWikiException
Privileged API to access an eXo Platform Portal service from the Wiki Engine

Parameters:
className - eXo classname to retrieve the service from
Returns:
A object representing the service or null if the user doesn't have programming rights
Throws:
XWikiException - if the service cannot be loaded
Since:
1.1 Beta 1

getCurrentMonthXWikiStats

@Deprecated
public DocumentStats getCurrentMonthXWikiStats(java.lang.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 java.lang.String getRefererText(java.lang.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 java.lang.String getShortRefererText(java.lang.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 java.lang.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 java.lang.String getUserName(java.lang.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 java.lang.String getUserName(java.lang.String user,
                                    java.lang.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 java.lang.String getLocalUserName(java.lang.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 java.lang.String getLocalUserName(java.lang.String user,
                                         java.lang.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 java.lang.String getUserName(java.lang.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 java.lang.String getUserName(java.lang.String user,
                                    java.lang.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 java.lang.String getLocalUserName(java.lang.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 java.lang.String getLocalUserName(java.lang.String user,
                                         java.lang.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(java.lang.String username)

formatDate

public java.lang.String formatDate(java.util.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 java.lang.String formatDate(java.util.Date date,
                                   java.lang.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 java.lang.String getUserTimeZone()

get

public Api get(java.lang.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(java.lang.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 java.lang.String getAdType()
Returns the Advertisement system from the preferences

Returns:
"google" or "none"

getAdClientId

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

Returns:
an Ad affiliate ID

getURLContent

public java.lang.String getURLContent(java.lang.String surl,
                                      java.lang.String username,
                                      java.lang.String password)
                               throws java.io.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:
java.io.IOException

getURLContent

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

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

getURLContent

public java.lang.String getURLContent(java.lang.String surl,
                                      java.lang.String username,
                                      java.lang.String password,
                                      int timeout)
                               throws java.io.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:
java.io.IOException

getURLContent

public java.lang.String getURLContent(java.lang.String surl,
                                      int timeout)
                               throws java.io.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:
java.io.IOException

getURLContentAsBytes

public byte[] getURLContentAsBytes(java.lang.String surl,
                                   java.lang.String username,
                                   java.lang.String password)
                            throws java.io.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:
java.io.IOException

getURLContentAsBytes

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

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

getIncludedMacros

public java.util.List<java.lang.String> getIncludedMacros(java.lang.String defaultweb,
                                                          java.lang.String content)
Returns the list of Macros documents in the specified content

Parameters:
defaultweb - Default Web 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,
                          java.lang.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 java.lang.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 java.lang.Object parseGroovyFromString(java.lang.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 java.lang.Object parseGroovyFromPage(java.lang.String script,
                                            java.lang.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 java.lang.Object parseGroovyFromPage(java.lang.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 java.lang.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 java.lang.String getWysiwygToolbars()
API to check if using which toolbars in Wysiwyg editor

Returns:
a string value

getObjectFromRequest

public Object getObjectFromRequest(java.lang.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 java.lang.String convertUsername(java.lang.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

displaySearchColumns

public java.lang.String displaySearchColumns(java.lang.String className,
                                             XWikiQuery query)
                                      throws XWikiException
API to display a select box for the list of available field for a specific class This field data can then be used to generate an XWiki Query showing a table with the relevant data

Parameters:
className - XWiki Class Name to display the list of columns for
query - Query to pre-select the currently selected columns
Returns:
text of the select field
Throws:
XWikiException - exception is a failure occured

displaySearchColumns

public java.lang.String displaySearchColumns(java.lang.String className,
                                             java.lang.String prefix,
                                             XWikiQuery query)
                                      throws XWikiException
API to display a select box for the list of available field for a specific class, optionally adding a prefix This field data can then be used to generate an XWiki Query showing a table with the relevant data

Parameters:
className - XWiki Class Name to display the list of columns for
prefix - Prefix to add to the field name
query - Query to pre-select the currently selected columns
Returns:
text of the select field
Throws:
XWikiException - exception is a failure occured

displaySearchOrder

public java.lang.String displaySearchOrder(java.lang.String className,
                                           XWikiQuery query)
                                    throws XWikiException
API to display a select box for the list of available field for a specific class This field data can then be used to generate the order element of an XWiki Query showing a table with the relevant data

Parameters:
className - XWiki Class Name to display the list of columns for
query - Query to pre-select the currently selected columns
Returns:
text of the select field
Throws:
XWikiException - exception is a failure occured

displaySearchOrder

public java.lang.String displaySearchOrder(java.lang.String className,
                                           java.lang.String prefix,
                                           XWikiQuery query)
                                    throws XWikiException
API to display a select box for the list of available field for a specific class, optionally adding a prefix This field data can then be used to generate the order element of an XWiki Query showing a table with the relevant data

Parameters:
className - XWiki Class Name to display the list of columns for
prefix - Prefix to add to the field name
query - Query to pre-select the currently selected columns
Returns:
text of the select field
Throws:
XWikiException - exception is a failure occured

displaySearch

public java.lang.String displaySearch(java.lang.String fieldname,
                                      java.lang.String className)
                               throws XWikiException
API to display a field in search mode for a specific class without preselected values This field data can then be used to generate an XWiki Query showing a table with the relevant data

Parameters:
fieldname - field name in the class
className - class name to display the field from
Returns:
text of the select field
Throws:
XWikiException - exception is a failure occured

displaySearch

public java.lang.String displaySearch(java.lang.String fieldname,
                                      java.lang.String className,
                                      XWikiCriteria criteria)
                               throws XWikiException
API to display a field in search mode for a specific class with preselected values This field data can then be used to generate an XWiki Query showing a table with the relevant data

Parameters:
fieldname - field name in the class
className - class name to display the field from
criteria - XWikiCriteria object (usually the XWikiQuery object) to take the preselected values from
Returns:
text of the select field
Throws:
XWikiException - exception is a failure occured

displaySearch

public java.lang.String displaySearch(java.lang.String fieldname,
                                      java.lang.String className,
                                      java.lang.String prefix,
                                      XWikiCriteria criteria)
                               throws XWikiException
API to display a field in search mode for a specific class with preselected values, optionally adding a prefix to the field name This field data can then be used to generate an XWiki Query showing a table with the relevant data

Parameters:
fieldname - field name in the class
className - class name to display the field from
prefix - prefix to add to the field name
criteria - XWikiCriteria object (usually the XWikiQuery object) to take the preselected values from
Returns:
text of the select field
Throws:
XWikiException - exception is a failure occured

search

public java.util.List search(XWikiQuery query)
                      throws XWikiException
API to run a search from an XWikiQuery Object An XWikiQuery object can be created from a request using the createQueryFromRequest function

Parameters:
query - query to run the search for
Returns:
A list of document names matching the query
Throws:
XWikiException - exception is a failure occured

createQueryFromRequest

public XWikiQuery createQueryFromRequest(java.lang.String className)
                                  throws XWikiException
API to create a query from a request Object The request object is the result of a form created from the displaySearch() and displaySearchColumns() functions

Parameters:
className - class name to create the query from
Returns:
an XWikiQuery object matching the selected values in the request object
Throws:
XWikiException - exception is a failure occured

searchAsTable

public java.lang.String searchAsTable(XWikiQuery query)
                               throws XWikiException
API to run a search from an XWikiQuery Object and display it as a HTML table An XWikiQuery object can be created from a request using the createQueryFromRequest function

Parameters:
query - query to run the search for
Returns:
An HTML table showing the result
Throws:
XWikiException - exception is a failure occured

getPropertyClassFromName

public PropertyClass getPropertyClassFromName(java.lang.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 java.lang.String getUniquePageName(java.lang.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 java.lang.String getUniquePageName(java.lang.String space,
                                          java.lang.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 java.lang.String addTooltip(java.lang.String html,
                                   java.lang.String message,
                                   java.lang.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 java.lang.String addTooltip(java.lang.String html,
                                   java.lang.String message)
Inserts a tooltip using toolTip.js

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

addTooltipJS

public java.lang.String addTooltipJS()
Inserts the tooltip Javascript

Returns:

addMandatory

public java.lang.String addMandatory()

getClass

public Class getClass(java.lang.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 Document.getxWikiClass() 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 java.lang.String getCounter(java.lang.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(java.lang.String username,
                           java.lang.String password,
                           java.lang.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 java.util.List<java.lang.String> getConfiguredSyntaxes()
Returns:
the ids of configured syntaxes for this wiki (eg "xwiki/1.0", "xwiki/2.0", "mediawiki/1.0", etc)

getQueryManager

public QueryManager getQueryManager()
Returns:
secure QueryManager for execute queries to store.

getServletPath

public java.lang.String getServletPath(java.lang.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 java.lang.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 java.lang.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


Copyright © 2004-2008 XWiki. All Rights Reserved.