com.xpn.xwiki.plugin.applicationmanager
Class ApplicationManagerPluginApi

java.lang.Object
  extended by com.xpn.xwiki.api.Api
      extended by com.xpn.xwiki.plugin.PluginApi<ApplicationManagerPlugin>
          extended by com.xpn.xwiki.plugin.applicationmanager.ApplicationManagerPluginApi

public class ApplicationManagerPluginApi
extends PluginApi<ApplicationManagerPlugin>

Plugin for managing applications: installation, export, creation. The plugin uses the concept of an Application Descriptor describing an application (its version, the documents it contains, the translations, etc).

Version:
$Id: 4d85fb717b15124f997b34ae7e652f09b58deb7a $
See Also:
ApplicationManagerPlugin

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
          The logging tool.
 
Fields inherited from class com.xpn.xwiki.api.Api
context
 
Constructor Summary
ApplicationManagerPluginApi(ApplicationManagerPlugin plugin, XWikiContext context)
          Create an instance of the Application Manager plugin user api.
 
Method Summary
 int createApplication(XWikiApplication appXObjectDocument, boolean failOnExist)
          Create a new application descriptor base on provided application descriptor.
 XWikiApplication createApplicationDocument()
          Create empty application document.
 int deleteApplication(String appName)
          Delete an application descriptor document.
 int exportApplicationXAR(String appName)
          Export an application into XAR using Packaging plugin.
 int exportApplicationXAR(String appName, boolean recurse, boolean withDocHistory)
          Export an application into XAR using Packaging plugin.
 XWikiApplication getApplicationDocument(String appName)
          Get the application descriptor document of the provided application name.
 List<XWikiApplication> getApplicationDocumentList()
          Get all applications descriptors documents.
 XWikiExceptionApi getDefaultException()
           
 XWikiMessageTool getMessageTool()
          Deprecated. 
 XWikiApplication getRootApplication()
          Get the current wiki root application.
 int importApplication(String packageName)
          Import attached application XAR into current wiki and do all actions needed to installation an application.
 void logError(String errorMessage, XWikiException e)
          Log error and store details in the context.
 int reloadAllApplications()
          Reload all xwiki applications.
 int reloadApplication(String appName)
          Reload xwiki application.
 
Methods inherited from class com.xpn.xwiki.plugin.PluginApi
getInternalPlugin, getProtectedPlugin, setPlugin
 
Methods inherited from class com.xpn.xwiki.api.Api
convert, convert, convert, convertAttachments, 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
The logging tool.

Constructor Detail

ApplicationManagerPluginApi

public ApplicationManagerPluginApi(ApplicationManagerPlugin plugin,
                                   XWikiContext context)
Create an instance of the Application Manager plugin user api.

Parameters:
plugin - the entry point of the Application 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.

logError

public void logError(String errorMessage,
                     XWikiException e)
Log error and store details in the context.

Parameters:
errorMessage - error message.
e - the catched exception.

createApplicationDocument

public XWikiApplication createApplicationDocument()
                                           throws XWikiException
Create empty application document.

Returns:
an empty application descriptor document.
Throws:
XWikiException - all error that does not caused by user of this method.

createApplication

public int createApplication(XWikiApplication appXObjectDocument,
                             boolean failOnExist)
                      throws XWikiException
Create a new application descriptor base on provided application descriptor.

Parameters:
appXObjectDocument - the user application descriptor from which new descriptor will be created.
failOnExist - if true fail if the application descriptor to create already exists.
Returns:
error code . 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 - all error that does not caused by user of this method.

deleteApplication

public int deleteApplication(String appName)
                      throws XWikiException
Delete an application descriptor document.

Parameters:
appName - the name of the application.
Returns:
error code . 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 - all error that does not caused by user of this method.

getApplicationDocumentList

public List<XWikiApplication> getApplicationDocumentList()
                                                  throws XWikiException
Get all applications descriptors documents.

Returns:
a list of XWikiApplication.
Throws:
XWikiException - all error that does not caused by user of this method.

getApplicationDocument

public XWikiApplication getApplicationDocument(String appName)
                                        throws XWikiException
Get the application descriptor document of the provided application name.

Parameters:
appName - the name of the application.
Returns:
the application descriptor document. 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 - all error that does not caused by user of this method.

exportApplicationXAR

public int exportApplicationXAR(String appName)
                         throws XWikiException,
                                IOException
Export an application into XAR using Packaging plugin.

Parameters:
appName - the name of the application to export.
Returns:
error code . 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 - all error that does not caused by user of this method.
IOException - all error that does not caused by user of this method.

exportApplicationXAR

public int exportApplicationXAR(String appName,
                                boolean recurse,
                                boolean withDocHistory)
                         throws XWikiException,
                                IOException
Export an application into XAR using Packaging plugin.

Parameters:
appName - the name of the application.
recurse - if true include all dependencies applications into XAR.
withDocHistory - if true export with documents history.
Returns:
error code . 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 - all error that does not caused by user of this method.
IOException - all error that does not caused by user of this method.

importApplication

public int importApplication(String packageName)
                      throws XWikiException
Import attached application XAR into current wiki and do all actions needed to installation an application. See reloadApplication(String) for more.

Parameters:
packageName - the name of the attached XAR file to import.
Returns:
error code . 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 - all error that does not caused by user of this method.

reloadApplication

public int reloadApplication(String appName)
                      throws XWikiException
Reload xwiki application. It means :

Parameters:
appName - the name of the application to reload.
Returns:
error code . 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 - all error that does not caused by user of this method.

reloadAllApplications

public int reloadAllApplications()
                          throws XWikiException
Reload all xwiki applications. It means : - update XWikiPreferences with each application translation documents

Returns:
error code.
Throws:
XWikiException - all error that does not caused by user of this method.

getRootApplication

public XWikiApplication getRootApplication()
                                    throws XWikiException
Get the current wiki root application.

Returns:
the root application descriptor document. If can't find root application return null.
Throws:
XWikiException - all error that does not caused by user of this method.


Copyright © 2004-2013 XWiki. All Rights Reserved.