com.xpn.xwiki.plugin.wikimanager
Class WikiManager

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

public final class WikiManager
extends java.lang.Object

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

Version:
$Id: WikiManager.java 27632 2010-03-14 16:17:42Z tmortagne $

Field Summary
protected static org.apache.commons.logging.Log LOG
          The logging tool.
 
Constructor Summary
WikiManager(com.xpn.xwiki.plugin.applicationmanager.core.plugin.XWikiPluginMessageTool messageTool)
           
 
Method Summary
 boolean canCreateWiki(com.xpn.xwiki.XWikiContext context)
           
 boolean canDeleteWiki(com.xpn.xwiki.XWikiContext context)
           
 boolean canEditWiki(com.xpn.xwiki.XWikiContext context)
           
 XWikiServer createNewWiki(XWikiServer userWikiSuperDoc, boolean failOnExist, java.lang.String templateWikiName, java.lang.String packageName, java.lang.String comment, com.xpn.xwiki.XWikiContext context)
          Create new wiki.
 XWikiServer createNewWiki(XWikiServer userWikiSuperDoc, boolean failOnExist, java.lang.String comment, com.xpn.xwiki.XWikiContext context)
          Create a new empty virtual wiki.
 XWikiServer createNewWikiFromPackage(XWikiServer userWikiSuperDoc, java.lang.String packageName, boolean failOnExist, java.lang.String comment, com.xpn.xwiki.XWikiContext context)
          Create a new virtual wiki.
 XWikiServer createNewWikiFromTemplate(XWikiServer userWikiSuperDoc, java.lang.String templateWikiName, boolean failOnExist, java.lang.String comment, com.xpn.xwiki.XWikiContext context)
          Create a new virtual wiki.
 void createWikiTemplate(XWikiServer wikiXObjectDocument, java.lang.String packageName, java.lang.String comment, com.xpn.xwiki.XWikiContext context)
          Create a template wiki.
 void deleteWiki(java.lang.String wikiNameToDelete, boolean deleteDatabase, com.xpn.xwiki.XWikiContext context)
          Delete an existing wiki.
 void deleteWikiAlias(java.lang.String wikiNameToDelete, int objectId, com.xpn.xwiki.XWikiContext context)
          Delete an existing wiki alias.
 java.util.List<Wiki> getAllWikis(com.xpn.xwiki.XWikiContext context)
          Get all Wiki.
 com.xpn.xwiki.doc.XWikiDocument getDocument(java.lang.String wikiName, java.lang.String fullname, com.xpn.xwiki.XWikiContext context)
          Encapsulate XWiki.getDocument(String, XWikiContext) adding wiki switch.
 com.xpn.xwiki.plugin.applicationmanager.core.plugin.XWikiPluginMessageTool getMessageTool(com.xpn.xwiki.XWikiContext context)
          Get the XWikiPluginMessageTool to use with WikiManager.
 XWikiServer getWikiAlias(java.lang.String wikiName, int objectId, boolean validate, com.xpn.xwiki.XWikiContext context)
          Get the wiki descriptor document.
 java.util.List<XWikiServer> getWikiAliasList(com.xpn.xwiki.XWikiContext context)
          Get all the wikis descriptors documents.
 Wiki getWikiFromDocument(com.xpn.xwiki.doc.XWikiDocument document, com.xpn.xwiki.XWikiContext context)
          Get Wiki described by provided document.
 Wiki getWikiFromDocumentName(java.lang.String documentFullName, com.xpn.xwiki.XWikiContext context)
          Get Wiki described by document with provided full name.
 Wiki getWikiFromName(java.lang.String wikiName, com.xpn.xwiki.XWikiContext context)
          Get Wiki with provided name.
 XWikiServer getWikiTemplateAlias(java.lang.String wikiName, int objectId, com.xpn.xwiki.XWikiContext context, boolean validate)
          Get template wiki descriptor document.
 java.util.List<XWikiServer> getWikiTemplateAliasList(com.xpn.xwiki.XWikiContext context)
          Get all the templates wikis descriptors documents.
 void importPackage(java.lang.String packageName, java.lang.String targetWiki, com.xpn.xwiki.XWikiContext context)
          Import XAR package into wiki.
 boolean isWikiAliasExist(java.lang.String wikiName, int objectId, com.xpn.xwiki.XWikiContext context)
          Indicate of wiki descriptor document exist.
 void saveDocument(java.lang.String wikiName, com.xpn.xwiki.doc.XWikiDocument doc, java.lang.String comment, com.xpn.xwiki.XWikiContext context)
          Encapsulate XWiki.saveDocument(XWikiDocument, XWikiContext) adding wiki switch.
 java.util.List<com.xpn.xwiki.doc.XWikiDocument> searchDocuments(java.lang.String wikiName, java.lang.String wheresql, com.xpn.xwiki.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

LOG

protected static final org.apache.commons.logging.Log LOG
The logging tool.

Constructor Detail

WikiManager

public WikiManager(com.xpn.xwiki.plugin.applicationmanager.core.plugin.XWikiPluginMessageTool messageTool)
Parameters:
messageTool - the message tool
Method Detail

getMessageTool

public com.xpn.xwiki.plugin.applicationmanager.core.plugin.XWikiPluginMessageTool getMessageTool(com.xpn.xwiki.XWikiContext context)
Get the XWikiPluginMessageTool to use with WikiManager.

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

saveDocument

public void saveDocument(java.lang.String wikiName,
                         com.xpn.xwiki.doc.XWikiDocument doc,
                         java.lang.String comment,
                         com.xpn.xwiki.XWikiContext context)
                  throws com.xpn.xwiki.XWikiException
Encapsulate XWiki.saveDocument(XWikiDocument, XWikiContext) adding wiki switch.

Parameters:
wikiName - the name of the wiki where to save the document.
doc - the document to save.
comment - the comment to use when saving document.
context - the XWiki Context.
Throws:
com.xpn.xwiki.XWikiException - error when calling XWiki.saveDocument(XWikiDocument, String, XWikiContext).
See Also:
XWiki.saveDocument(XWikiDocument, XWikiContext)

getDocument

public com.xpn.xwiki.doc.XWikiDocument getDocument(java.lang.String wikiName,
                                                   java.lang.String fullname,
                                                   com.xpn.xwiki.XWikiContext context)
                                            throws com.xpn.xwiki.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 dos not exist return new XWikiDocument.
Throws:
com.xpn.xwiki.XWikiException - error when calling XWiki.getDocument(String, XWikiContext) .
See Also:
XWiki.getDocument(String, XWikiContext)

searchDocuments

public java.util.List<com.xpn.xwiki.doc.XWikiDocument> searchDocuments(java.lang.String wikiName,
                                                                       java.lang.String wheresql,
                                                                       com.xpn.xwiki.XWikiContext context)
                                                                throws com.xpn.xwiki.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:
com.xpn.xwiki.XWikiException - error when searching for documents.
See Also:
XWikiStoreInterface.searchDocuments(String, XWikiContext)

canCreateWiki

public boolean canCreateWiki(com.xpn.xwiki.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(com.xpn.xwiki.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(com.xpn.xwiki.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(com.xpn.xwiki.doc.XWikiDocument document,
                                com.xpn.xwiki.XWikiContext context)
                         throws com.xpn.xwiki.XWikiException
Get Wiki described by provided document.

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

getWikiFromName

public Wiki getWikiFromName(java.lang.String wikiName,
                            com.xpn.xwiki.XWikiContext context)
                     throws com.xpn.xwiki.XWikiException
Get Wiki with provided name.

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

getWikiFromDocumentName

public Wiki getWikiFromDocumentName(java.lang.String documentFullName,
                                    com.xpn.xwiki.XWikiContext context)
                             throws com.xpn.xwiki.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:
com.xpn.xwiki.XWikiException - error when getting document.

getAllWikis

public java.util.List<Wiki> getAllWikis(com.xpn.xwiki.XWikiContext context)
                                 throws com.xpn.xwiki.XWikiException
Get all Wiki.

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

createNewWikiFromPackage

public XWikiServer createNewWikiFromPackage(XWikiServer userWikiSuperDoc,
                                            java.lang.String packageName,
                                            boolean failOnExist,
                                            java.lang.String comment,
                                            com.xpn.xwiki.XWikiContext context)
                                     throws com.xpn.xwiki.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:
com.xpn.xwiki.XWikiException - error when:
See Also:
createNewWiki(XWikiServer, boolean, String, XWikiContext), createNewWikiFromTemplate(XWikiServer, String, boolean, String, XWikiContext)

createNewWikiFromTemplate

public XWikiServer createNewWikiFromTemplate(XWikiServer userWikiSuperDoc,
                                             java.lang.String templateWikiName,
                                             boolean failOnExist,
                                             java.lang.String comment,
                                             com.xpn.xwiki.XWikiContext context)
                                      throws com.xpn.xwiki.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 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:
com.xpn.xwiki.XWikiException - error when:
See Also:
createNewWiki(XWikiServer, boolean, String, XWikiContext), createNewWikiFromPackage(XWikiServer, String, boolean, String, XWikiContext)

createNewWiki

public XWikiServer createNewWiki(XWikiServer userWikiSuperDoc,
                                 boolean failOnExist,
                                 java.lang.String comment,
                                 com.xpn.xwiki.XWikiContext context)
                          throws com.xpn.xwiki.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:
com.xpn.xwiki.XWikiException - error when:

createNewWiki

public XWikiServer createNewWiki(XWikiServer userWikiSuperDoc,
                                 boolean failOnExist,
                                 java.lang.String templateWikiName,
                                 java.lang.String packageName,
                                 java.lang.String comment,
                                 com.xpn.xwiki.XWikiContext context)
                          throws com.xpn.xwiki.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:
com.xpn.xwiki.XWikiException - error when:

importPackage

public void importPackage(java.lang.String packageName,
                          java.lang.String targetWiki,
                          com.xpn.xwiki.XWikiContext context)
                   throws com.xpn.xwiki.XWikiException
Import XAR package into wiki.

Parameters:
packageName - the name of the attached package file.
targetWiki - the name of the wiki where to install loaded XWikiDocument from XAR package.
context - the XWiki context.
Throws:
com.xpn.xwiki.XWikiException - error when:

deleteWiki

public void deleteWiki(java.lang.String wikiNameToDelete,
                       boolean deleteDatabase,
                       com.xpn.xwiki.XWikiContext context)
                throws com.xpn.xwiki.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:
com.xpn.xwiki.XWikiException - error when:
  • getting wiki descriptor document.
  • or deleteing wiki.
Since:
1.1

deleteWikiAlias

public void deleteWikiAlias(java.lang.String wikiNameToDelete,
                            int objectId,
                            com.xpn.xwiki.XWikiContext context)
                     throws com.xpn.xwiki.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:
com.xpn.xwiki.XWikiException - error when:
  • getting wiki descriptor document.
  • or deleteing wiki.
Since:
1.1

getWikiAlias

public XWikiServer getWikiAlias(java.lang.String wikiName,
                                int objectId,
                                boolean validate,
                                com.xpn.xwiki.XWikiContext context)
                         throws com.xpn.xwiki.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:
com.xpn.xwiki.XWikiException - error when getting wiki descriptor document.

getWikiAliasList

public java.util.List<XWikiServer> getWikiAliasList(com.xpn.xwiki.XWikiContext context)
                                             throws com.xpn.xwiki.XWikiException
Get all the wikis descriptors documents.

Parameters:
context - the XWiki context.
Returns:
a list of XWikiServer.
Throws:
com.xpn.xwiki.XWikiException - error when:
  • getting the list of wiki descriptor XWikiDocument.
  • or getting XWikiServerClass unique instance.

isWikiAliasExist

public boolean isWikiAliasExist(java.lang.String wikiName,
                                int objectId,
                                com.xpn.xwiki.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(java.lang.String wikiName,
                                        int objectId,
                                        com.xpn.xwiki.XWikiContext context,
                                        boolean validate)
                                 throws com.xpn.xwiki.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:
com.xpn.xwiki.XWikiException - error when:
  • getting XWikiServerClass unique instance.
  • or when searching for wiki descriptor with "visibility" field equals to "template".

getWikiTemplateAliasList

public java.util.List<XWikiServer> getWikiTemplateAliasList(com.xpn.xwiki.XWikiContext context)
                                                     throws com.xpn.xwiki.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:
com.xpn.xwiki.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,
                               java.lang.String packageName,
                               java.lang.String comment,
                               com.xpn.xwiki.XWikiContext context)
                        throws com.xpn.xwiki.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:
com.xpn.xwiki.XWikiException - error when creating new wiki from XAR package.


Copyright © 2004-2010 XWiki. All Rights Reserved.