com.xpn.xwiki.plugin.wikimanager
Class WikiManager

java.lang.Object
  extended by com.xpn.xwiki.plugin.wikimanager.WikiManager

public final class WikiManager
extends Object

Hidden toolkit use by the plugin API that make all the plugins actions.

Version:
$Id: 97584fdd55574d43e8a1d13cb9d65d84591ef0d3 $

Field Summary
protected static org.slf4j.Logger LOGGER
          The logging tool.
 
Constructor Summary
WikiManager()
          Default constructor.
WikiManager(XWikiPluginMessageTool messageTool)
          Deprecated. 
 
Method Summary
 boolean canCreateWiki(XWikiContext context)
           
 boolean canDeleteWiki(XWikiContext context)
           
 boolean canEditWiki(XWikiContext context)
           
 XWikiServer createNewWiki(XWikiServer userWikiSuperDoc, boolean failOnExist, String templateWikiName, String packageName, String comment, XWikiContext context)
          Create new wiki.
 XWikiServer createNewWiki(XWikiServer userWikiSuperDoc, boolean failOnExist, String comment, XWikiContext context)
          Create a new empty virtual wiki.
 XWikiServer createNewWikiFromPackage(XWikiServer userWikiSuperDoc, String packageName, boolean failOnExist, String comment, XWikiContext context)
          Create a new virtual wiki.
 XWikiServer createNewWikiFromTemplate(XWikiServer userWikiSuperDoc, String templateWikiName, boolean failOnExist, String comment, XWikiContext context)
          Create a new virtual wiki.
 void createWikiTemplate(XWikiServer wikiXObjectDocument, String packageName, String comment, XWikiContext context)
          Create a template wiki.
 void deleteWiki(String wikiNameToDelete, boolean deleteDatabase, XWikiContext context)
          Delete an existing wiki.
 void deleteWikiAlias(String wikiNameToDelete, int objectId, XWikiContext context)
          Delete an existing wiki alias.
 List<Wiki> getAllWikis(XWikiContext context)
          Get all Wiki.
 XWikiDocument getDocument(String wikiName, String fullname, XWikiContext context)
          Encapsulate XWiki.getDocument(String, XWikiContext) adding wiki switch.
 XWikiPluginMessageTool getMessageTool(XWikiContext context)
          Deprecated. 
 XWikiServer getWikiAlias(String wikiName, int objectId, boolean validate, XWikiContext context)
          Get the wiki descriptor document.
 List<XWikiServer> getWikiAliasList(XWikiContext context)
          Get all the wikis descriptors documents.
 Wiki getWikiFromDocument(XWikiDocument document, XWikiContext context)
          Get Wiki described by provided document.
 Wiki getWikiFromDocumentName(String documentFullName, XWikiContext context)
          Get Wiki described by document with provided full name.
 Wiki getWikiFromName(String wikiName, XWikiContext context)
          Get Wiki with provided name.
 XWikiServer getWikiTemplateAlias(String wikiName, int objectId, XWikiContext context, boolean validate)
          Get template wiki descriptor document.
 List<XWikiServer> getWikiTemplateAliasList(XWikiContext context)
          Get all the templates wikis descriptors documents.
 boolean isWikiAliasExist(String wikiName, int objectId, XWikiContext context)
          Indicate of wiki descriptor document exist.
 List<XWikiDocument> searchDocuments(String wikiName, String wheresql, XWikiContext context)
          Encapsulate XWikiStoreInterface.searchDocuments(String, XWikiContext) adding wiki switch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final org.slf4j.Logger LOGGER
The logging tool.

Constructor Detail

WikiManager

@Deprecated
public WikiManager(XWikiPluginMessageTool messageTool)
Deprecated. 

Parameters:
messageTool - the message tool

WikiManager

public WikiManager()
Default constructor.

Method Detail

getMessageTool

@Deprecated
public XWikiPluginMessageTool getMessageTool(XWikiContext context)
Deprecated. 

Get the XWikiPluginMessageTool to use with WikiManager.

Parameters:
context - the XWiki context.
Returns:
a translated strings manager.

getDocument

public XWikiDocument getDocument(String wikiName,
                                 String fullname,
                                 XWikiContext context)
                          throws XWikiException
Encapsulate XWiki.getDocument(String, XWikiContext) adding wiki switch.

Parameters:
wikiName - the name of the wiki where to get the document.
fullname - the full name of the document to get.
context - the XWiki context.
Returns:
the document with full name equals to fullname and wiki wikiName. If it does not exist return new XWikiDocument.
Throws:
XWikiException - error when calling XWiki.getDocument(String, XWikiContext) .
See Also:
XWiki.getDocument(String, XWikiContext)

searchDocuments

public List<XWikiDocument> searchDocuments(String wikiName,
                                           String wheresql,
                                           XWikiContext context)
                                    throws XWikiException
Encapsulate XWikiStoreInterface.searchDocuments(String, XWikiContext) adding wiki switch.

Parameters:
wikiName - the name of the wiki where to search for documents.
wheresql - the conditions to add to HQL request.
context - the XWiki context.
Returns:
the list of documents that match the wheresql conditions. If nothing found return empty List.
Throws:
XWikiException - error when searching for documents.
See Also:
XWikiStoreInterface.searchDocuments(String, XWikiContext)

canCreateWiki

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

canEditWiki

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

canDeleteWiki

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

getWikiFromDocument

public Wiki getWikiFromDocument(XWikiDocument document,
                                XWikiContext context)
                         throws XWikiException
Get Wiki described by provided document.

Parameters:
document - the wiki document descriptor.
context - the XWiki context.
Returns:
the Wiki object.
Throws:
XWikiException - error when creating Wiki object.

getWikiFromName

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

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

getWikiFromDocumentName

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

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

getAllWikis

public List<Wiki> getAllWikis(XWikiContext context)
                       throws XWikiException
Get all Wiki.

Parameters:
context - the XWiki context.
Returns:
the list of all Wiki.
Throws:
XWikiException - error when getting wikis documents descriptors.

createNewWikiFromPackage

public XWikiServer createNewWikiFromPackage(XWikiServer userWikiSuperDoc,
                                            String packageName,
                                            boolean failOnExist,
                                            String comment,
                                            XWikiContext context)
                                     throws XWikiException
Create a new virtual wiki. The new wiki is initialized with provided xar package.

Parameters:
userWikiSuperDoc - a wiki descriptor document from which the new wiki descriptor document will be created.
packageName - the name of the attached XAR file to import in the new wiki.
failOnExist - if true throw exception when wiki already exist. If false overwrite existing wiki.
comment - the comment to use when saving descriptor document.
context - the XWiki context.
Returns:
the new wiki descriptor document.
Throws:
XWikiException - error when:
See Also:
createNewWiki(XWikiServer, boolean, String, XWikiContext), createNewWikiFromTemplate(XWikiServer, String, boolean, String, XWikiContext)

createNewWikiFromTemplate

public XWikiServer createNewWikiFromTemplate(XWikiServer userWikiSuperDoc,
                                             String templateWikiName,
                                             boolean failOnExist,
                                             String comment,
                                             XWikiContext context)
                                      throws XWikiException
Create a new virtual wiki. The new wiki is a copy of provided existing wiki.

Parameters:
userWikiSuperDoc - a wiki descriptor document from which the new wiki descriptor document will be created.
templateWikiName - the name of the wiki from where to copy document to the new wiki.
failOnExist - if true throw exception when wiki already exist. If false overwrite existing wiki.
comment - the comment to use when saving descriptor document.
context - the XWiki context.
Returns:
the new wiki descriptor document.
Throws:
XWikiException - error when:
See Also:
createNewWiki(XWikiServer, boolean, String, XWikiContext), createNewWikiFromPackage(XWikiServer, String, boolean, String, XWikiContext)

createNewWiki

public XWikiServer createNewWiki(XWikiServer userWikiSuperDoc,
                                 boolean failOnExist,
                                 String comment,
                                 XWikiContext context)
                          throws XWikiException
Create a new empty virtual wiki.

Parameters:
userWikiSuperDoc - 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.
comment - the comment to use when saving descriptor document.
context - the XWiki context.
Returns:
the new wiki descriptor document.
Throws:
XWikiException - error when:

createNewWiki

public XWikiServer createNewWiki(XWikiServer userWikiSuperDoc,
                                 boolean failOnExist,
                                 String templateWikiName,
                                 String packageName,
                                 String comment,
                                 XWikiContext context)
                          throws XWikiException
Create new wiki.

Parameters:
userWikiSuperDoc - 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.
templateWikiName - the name of the wiki from where to copy document to the new wiki.
packageName - the name of the attached XAR file to import in the new wiki.
comment - the comment to use when saving descriptor document.
context - the XWiki context.
Returns:
the new wiki descriptor document.
Throws:
XWikiException - error when:

deleteWiki

public void deleteWiki(String wikiNameToDelete,
                       boolean deleteDatabase,
                       XWikiContext context)
                throws XWikiException
Delete an existing wiki.

Parameters:
wikiNameToDelete - the name of the wiki to delete.
deleteDatabase - if true wiki's database is also removed.
context - the XWiki context.
Throws:
XWikiException - error when:
  • getting wiki descriptor document.
  • or deleteing wiki.
Since:
1.1

deleteWikiAlias

public void deleteWikiAlias(String wikiNameToDelete,
                            int objectId,
                            XWikiContext context)
                     throws XWikiException
Delete an existing wiki alias. If it's the last alias it delete the wiki.

Parameters:
wikiNameToDelete - the name of the wiki to delete.
objectId - the id of the XWiki object included in the document to manage.
context - the XWiki context.
Throws:
XWikiException - error when:
  • getting wiki descriptor document.
  • or deleteing wiki.
Since:
1.1

getWikiAlias

public XWikiServer getWikiAlias(String wikiName,
                                int objectId,
                                boolean validate,
                                XWikiContext context)
                         throws XWikiException
Get the wiki descriptor document.

Parameters:
wikiName - the name of the wiki.
objectId - the id of the XWiki object included in the document to manage.
validate - when wiki descriptor document does not exist :
context - the XWiki context.
Returns:
a wiki descriptor document.
Throws:
XWikiException - error when getting wiki descriptor document.

getWikiAliasList

public List<XWikiServer> getWikiAliasList(XWikiContext context)
                                   throws XWikiException
Get all the wikis descriptors documents.

Parameters:
context - the XWiki context.
Returns:
a list of XWikiServer.
Throws:
XWikiException - error when:

isWikiAliasExist

public boolean isWikiAliasExist(String wikiName,
                                int objectId,
                                XWikiContext context)
Indicate of wiki descriptor document exist.

Parameters:
wikiName - the name of the wiki.
objectId - the id of the XWiki object included in the document to manage.
context - the XWiki context.
Returns:
true if wiki descriptor exist, false if not.

getWikiTemplateAlias

public XWikiServer getWikiTemplateAlias(String wikiName,
                                        int objectId,
                                        XWikiContext context,
                                        boolean validate)
                                 throws XWikiException
Get template wiki descriptor document.

A template wiki is a wiki which the XWiki.XWikiServerClass "visibility" field is set to "template".

Parameters:
wikiName - the name of the template wiki.
objectId - the id of the XWiki object included in the document to manage.
context - the XWiki context.
validate - when wiki descriptor document does not exist :
Returns:
a wiki descriptor document.
Throws:
XWikiException - error when:
  • getting XWikiServerClass unique instance.
  • or when searching for wiki descriptor with "visibility" field equals to "template".

getWikiTemplateAliasList

public List<XWikiServer> getWikiTemplateAliasList(XWikiContext context)
                                           throws XWikiException
Get all the templates wikis descriptors documents.

A template wiki is a wiki which the XWiki.XWikiServerClass "visibility" field is set to "template".

Parameters:
context - the XWiki context.
Returns:
a list of XWikiServer.
Throws:
XWikiException - eeor when:
  • getting XWikiServerClass unique instance.
  • or when searching for all wikis descriptors with "visibility" field equals to "template".

createWikiTemplate

public void createWikiTemplate(XWikiServer wikiXObjectDocument,
                               String packageName,
                               String comment,
                               XWikiContext context)
                        throws XWikiException
Create a template wiki. The new template wiki is initialized with provided xar package.

A template wiki is a wiki which the XWiki.XWikiServerClass "visibility" field is set to "template".

Parameters:
wikiXObjectDocument - a wiki descriptor document from which the new template wiki descriptor document will be created.
packageName - the name of the attached XAR file to import in the new template wiki.
comment - the comment to use when saving descriptor document.
context - the XWiki context.
Throws:
XWikiException - error when creating new wiki from XAR package.


Copyright © 2004-2013 XWiki. All Rights Reserved.