com.xpn.xwiki.plugin.wikimanager
Class WikiManagerPluginApi

java.lang.Object
  extended by com.xpn.xwiki.api.Api
      extended by com.xpn.xwiki.plugin.PluginApi<WikiManagerPlugin>
          extended by com.xpn.xwiki.plugin.wikimanager.WikiManagerPluginApi

public class WikiManagerPluginApi
extends PluginApi<WikiManagerPlugin>

API for managing wikis (create wiki, delete wiki, create wiki from template, etc).

Version:
$Id: 0e7c073eb9d1c1e10e77c38c7a92b62155ef7598 $
See Also:
WikiManagerPlugin

Field Summary
static String CONTEXT_LASTERRORCODE
          Field name of the last error code inserted in context.
static String CONTEXT_LASTEXCEPTION
          Field name of the last API exception inserted in context.
protected static org.slf4j.Logger LOGGER
          Logging tool.
 
Fields inherited from class com.xpn.xwiki.api.Api
context
 
Constructor Summary
WikiManagerPluginApi(WikiManagerPlugin plugin, XWikiContext context)
          Create an instance of the Wiki Manager plugin user api.
 
Method Summary
 boolean canCreateWiki()
           
 boolean canDeleteWiki()
           
 boolean canEditWiki()
           
 int createNewWiki(String wikiName, String templateWiki, String pkgName, XWikiServer wikiXObjectDocument, boolean failOnExist)
          Create a new wiki from template.
 XWikiServer createWikiDocument()
          Create an empty not saved XWikiServer.
 int createWikiTemplate(String templateName, String templateDescription, String packageName)
          Create a new xiki with XWikiServerClass "visibility" field set to "template".
 int deleteWiki(String wikiName)
          Delete wiki descriptor document and wiki's database.
 int deleteWiki(String wikiName, boolean deleteDatabase)
          Delete wiki descriptor document and wiki's database.
 int deleteWiki(String wikiName, int objectId)
          Deprecated. Use deleteWikiAlias(String, int) since 1.1.
 int deleteWikiAlias(String wikiName, int objectId)
          Delete wiki descriptor alias document from database.
 List<Wiki> getAllWikis()
           
 XWikiExceptionApi getDefaultException()
           
 XWikiMessageTool getMessageTool()
          Deprecated. 
 GlobalSearchPluginApi getSearchApi()
           
 XWikiServer getWikiDocument(String wikiName)
          Get wiki descriptor document corresponding to provided wiki name.
 XWikiServer getWikiDocument(String wikiName, int objectId)
          Get wiki descriptor document corresponding to provided wiki name.
 List<XWikiServer> getWikiDocumentList()
          Get the list of all wiki descriptor documents.
 Wiki getWikiFromDocumentName(String documentFullName)
          Get Wiki described by document with provided full name.
 Wiki getWikiFromName(String wikiName)
          Get Wiki with provided name.
 XWikiServer getWikiTemplateDocument(String wikiName)
          Get wiki descriptor document corresponding to provided wiki name with XWikiServerClass "visibility" field set to "template".
 XWikiServer getWikiTemplateDocument(String wikiName, int objectId)
          Get wiki descriptor document corresponding to provided wiki name with XWikiServerClass "visibility" field set to "template".
 List<XWikiServer> getWikiTemplateList()
           
 boolean isWikiExist(String wikiName)
          Check if a Server of the given name exists in the master Wiki by checking if the "XWiki.XWikiServer{serverName}" document is new.
 boolean isWikiExist(String wikiName, int objectId)
          Check if a Server of the given name exists in the master Wiki by checking if the "XWiki.XWikiServer{serverName}" document is new.
 boolean isWikiNameAvailable(String wikiName)
          Indicate if the provided wiki name could be used to create a new wiki.
 int setIsWikiTemplate(String wikiName, boolean isWikiTemplate)
          Change the XWikiServerClass "visibility" field of a wiki descriptor document.
 int setWikiVisibility(String wikiName, int objectId, String visibility)
          Change the XWikiServerClass "visibility" field of a wiki descriptor document.
 int setWikiVisibility(String wikiName, String visibility)
          Change the XWikiServerClass "visibility" field of a wiki descriptor document.
 
Methods inherited from class com.xpn.xwiki.plugin.PluginApi
getInternalPlugin, getProtectedPlugin, setPlugin
 
Methods inherited from class com.xpn.xwiki.api.Api
convert, convert, getXWikiContext, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_LASTERRORCODE

public static final String CONTEXT_LASTERRORCODE
Field name of the last error code inserted in context.

See Also:
Constant Field Values

CONTEXT_LASTEXCEPTION

public static final String CONTEXT_LASTEXCEPTION
Field name of the last API exception inserted in context.

See Also:
Constant Field Values

LOGGER

protected static final org.slf4j.Logger LOGGER
Logging tool.

Constructor Detail

WikiManagerPluginApi

public WikiManagerPluginApi(WikiManagerPlugin plugin,
                            XWikiContext context)
Create an instance of the Wiki Manager plugin user api.

Parameters:
plugin - the entry point of the Wiki Manager plugin.
context - the XWiki context.
Method Detail

getDefaultException

public XWikiExceptionApi getDefaultException()
Returns:
the default plugin api exception.

getMessageTool

@Deprecated
public XWikiMessageTool getMessageTool()
Deprecated. 

Returns:
the plugin internationalization service.

getSearchApi

public GlobalSearchPluginApi getSearchApi()
Returns:
the GlobalSearch plugin api.

canCreateWiki

public boolean canCreateWiki()
Returns:
true if the it's possible to create a wiki in this context

canEditWiki

public boolean canEditWiki()
Returns:
true if the it's possible to edit a wiki descriptor in this context

canDeleteWiki

public boolean canDeleteWiki()
Returns:
true if the it's possible to delete a wiki in this context

createNewWiki

public int createNewWiki(String wikiName,
                         String templateWiki,
                         String pkgName,
                         XWikiServer wikiXObjectDocument,
                         boolean failOnExist)
                  throws XWikiException
Create a new wiki from template.

Parameters:
wikiName - the name of the new wiki.
templateWiki - the name of the wiki from where to copy document to the new wiki.
pkgName - the name of the attached XAR file to import in the new wiki.
wikiXObjectDocument - a wiki descriptor document from which the new wiki descriptor document will be created.
failOnExist - if true throw exception when wiki already exist. If false overwrite existing wiki.
Returns:
If there is error, it add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.

deleteWiki

public int deleteWiki(String wikiName,
                      boolean deleteDatabase)
               throws XWikiException
Delete wiki descriptor document and wiki's database.

Parameters:
wikiName - the name of the wiki to delete.
deleteDatabase - if true wiki's database is also removed.
Returns:
If there is error, it add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.
Since:
1.1

deleteWiki

public int deleteWiki(String wikiName)
               throws XWikiException
Delete wiki descriptor document and wiki's database.

Parameters:
wikiName - the name of the wiki to delete.
Returns:
If there is error, it add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.

deleteWiki

@Deprecated
public int deleteWiki(String wikiName,
                                 int objectId)
               throws XWikiException
Deprecated. Use deleteWikiAlias(String, int) since 1.1.

Delete wiki descriptor document from database.

Parameters:
wikiName - the name of the wiki to delete.
objectId - the id of the XWiki object included in the document to manage.
Returns:
If there is error, it add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.

deleteWikiAlias

public int deleteWikiAlias(String wikiName,
                           int objectId)
                    throws XWikiException
Delete wiki descriptor alias document from database.

Parameters:
wikiName - the name of the wiki to delete.
objectId - the id of the XWiki object included in the document to manage.
Returns:
If there is error, it add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.
Since:
1.1

getWikiFromName

public Wiki getWikiFromName(String wikiName)
                     throws XWikiException
Get Wiki with provided name.

Parameters:
wikiName - the name of the wiki.
Returns:
the Wiki object.
Throws:
XWikiException - error when getting document from wiki name.

getAllWikis

public List<Wiki> getAllWikis()
                       throws XWikiException
Returns:
the list of all Wiki.
Throws:
XWikiException - error when getting wiki documents descriptors.

getWikiFromDocumentName

public Wiki getWikiFromDocumentName(String documentFullName)
                             throws XWikiException
Get Wiki described by document with provided full name.

Parameters:
documentFullName - the full name of the wiki document descriptor.
Returns:
the Wiki object.
Throws:
XWikiException - error when getting document.

getWikiDocument

public XWikiServer getWikiDocument(String wikiName)
                            throws XWikiException
Get wiki descriptor document corresponding to provided wiki name.

Parameters:
wikiName - the name of the wiki.
Returns:
null if there is an error and add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.

getWikiDocument

public XWikiServer getWikiDocument(String wikiName,
                                   int objectId)
                            throws XWikiException
Get wiki descriptor document corresponding to provided wiki name.

Parameters:
wikiName - the name of the wiki.
objectId - the id of the XWiki object included in the document to manage.
Returns:
null if there is an error and add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.

getWikiDocumentList

public List<XWikiServer> getWikiDocumentList()
                                      throws XWikiException
Get the list of all wiki descriptor documents.

Returns:
the list XWikiServer.
Throws:
XWikiException - critical error in xwiki engine.

createWikiDocument

public XWikiServer createWikiDocument()
                               throws XWikiException
Create an empty not saved XWikiServer.

Returns:
an empty not saved XWikiServer.
Throws:
XWikiException - critical error in xwiki engine.

isWikiExist

public boolean isWikiExist(String wikiName)
Check if a Server of the given name exists in the master Wiki by checking if the "XWiki.XWikiServer{serverName}" document is new.

Parameters:
wikiName - the name of the server to be checked
Returns:
true if server exists, false otherwise

isWikiExist

public boolean isWikiExist(String wikiName,
                           int objectId)
Check if a Server of the given name exists in the master Wiki by checking if the "XWiki.XWikiServer{serverName}" document is new.

Parameters:
wikiName - the name of the server to be checked
objectId - the id of the XWiki object included in the document to manage.
Returns:
true if server exists, false otherwise

isWikiNameAvailable

public boolean isWikiNameAvailable(String wikiName)
                            throws XWikiException
Indicate if the provided wiki name could be used to create a new wiki.

Parameters:
wikiName - the name of the wiki.
Returns:
true if the name is already used, false otherwise.
Throws:
XWikiException - error when trying to find an existing database/schema by name.

setWikiVisibility

public int setWikiVisibility(String wikiName,
                             String visibility)
                      throws XWikiException
Change the XWikiServerClass "visibility" field of a wiki descriptor document.

Parameters:
wikiName - the name of the wiki descriptor.
visibility - the new value of "visibility" field. Can be "public", "private" or "template".
Returns:
If there is error, it add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.

setWikiVisibility

public int setWikiVisibility(String wikiName,
                             int objectId,
                             String visibility)
                      throws XWikiException
Change the XWikiServerClass "visibility" field of a wiki descriptor document.

Parameters:
wikiName - the name of the wiki descriptor.
objectId - the id of the XWiki object included in the document to manage.
visibility - the new value of "visibility" field. Can be "public", "private" or "template".
Returns:
If there is error, it add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.

setIsWikiTemplate

public int setIsWikiTemplate(String wikiName,
                             boolean isWikiTemplate)
                      throws XWikiException
Change the XWikiServerClass "visibility" field of a wiki descriptor document.

Parameters:
wikiName - the name of the wiki descriptor.
isWikiTemplate - true if it's a wiki template, false otherwise.
Returns:
If there is error, it add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.

createWikiTemplate

public int createWikiTemplate(String templateName,
                              String templateDescription,
                              String packageName)
                       throws XWikiException
Create a new xiki with XWikiServerClass "visibility" field set to "template".

Parameters:
templateName - the name of the new wiki template to create.
templateDescription - the description of the new wiki template to create.
packageName - the name of the attached XAR file to import in the new wiki.
Returns:
If there is error, it add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.

getWikiTemplateDocument

public XWikiServer getWikiTemplateDocument(String wikiName)
                                    throws XWikiException
Get wiki descriptor document corresponding to provided wiki name with XWikiServerClass "visibility" field set to "template".

Parameters:
wikiName - the name of the wiki template.
Returns:
null if there is an error and add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.

getWikiTemplateDocument

public XWikiServer getWikiTemplateDocument(String wikiName,
                                           int objectId)
                                    throws XWikiException
Get wiki descriptor document corresponding to provided wiki name with XWikiServerClass "visibility" field set to "template".

Parameters:
wikiName - the name of the wiki template.
objectId - the id of the XWiki object included in the document to manage.
Returns:
null if there is an error and add error code in context CONTEXT_LASTERRORCODE field and exception in context's CONTEXT_LASTEXCEPTION field.

Error codes can be :

Throws:
XWikiException - critical error in xwiki engine.

getWikiTemplateList

public List<XWikiServer> getWikiTemplateList()
                                      throws XWikiException
Returns:
all the template wiki. Wiki with "visibility" field equals to "template".
Throws:
XWikiException - critical error in xwiki engine.


Copyright © 2004-2013 XWiki. All Rights Reserved.