com.xpn.xwiki.plugin.packaging
Class PackageAPI

java.lang.Object
  extended by com.xpn.xwiki.api.Api
      extended by com.xpn.xwiki.plugin.packaging.PackageAPI

public class PackageAPI
extends Api


Field Summary
 
Fields inherited from class com.xpn.xwiki.api.Api
context
 
Constructor Summary
PackageAPI(Package plugin, XWikiContext context)
           
 
Method Summary
 boolean add(String docFullName)
           
 boolean add(String docFullName, int DefaultAction)
           
 void addDocumentFilter(Object filter)
           
 void backupWiki()
           
 String export()
           
 String getAuthorName()
           
 String getDescription()
           
 List<String> getErrors()
           
 List<DocumentInfoAPI> getFiles()
           
 List<String> getInstalled()
           
 String getLicence()
           
 String getName()
           
 Package getPackage()
           
 List<String> getSkipped()
           
 int getStatus()
           
 String getVersion()
           
 boolean hasBackupPackImportRights()
          Indicate if the current user has the right to import a package as a backup pack.
 String Import(byte[] file)
          Load a package in memory from a byte array.
 String Import(InputStream file)
          Load a package in memory from an InputStream.
 boolean importPackageFromByteArray(byte[] data)
          Similar to Import(byte[]), except expected errors are catch.
 int install()
           
 boolean isBackupPack()
           
 boolean isVersionPreserved()
           
 boolean isWithVersions()
           
 void setAuthorName(String authorName)
           
 void setBackupPack(boolean backupPack)
           
 void setDescription(String description)
           
 void setDocumentAction(String docFullName, int action)
           
 void setDocumentAction(String docFullName, String language, int action)
           
 void setLicence(String licence)
           
 void setName(String name)
           
 void setPreserveVersion(boolean preserveVersion)
          Sets the flag for the packager to preserve or not existing versions of documents when installing with install().
 void setVersion(String version)
           
 void setWithVersions(boolean withVersions)
          Sets the flag for the packager to import or not history revisions included in the archive when installing with install().
 int testInstall()
           
 int testInstall(boolean isAdmin)
           
 net.sf.json.JSONObject toJSON()
           
 String toXml()
           
 
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
 

Constructor Detail

PackageAPI

public PackageAPI(Package plugin,
                  XWikiContext context)
           throws PackageException
Throws:
PackageException
Method Detail

getName

public String getName()

setName

public void setName(String name)

getPackage

public Package getPackage()

getDescription

public String getDescription()

setDescription

public void setDescription(String description)

getVersion

public String getVersion()

setVersion

public void setVersion(String version)

getLicence

public String getLicence()

setLicence

public void setLicence(String licence)

getAuthorName

public String getAuthorName()

setAuthorName

public void setAuthorName(String authorName)

isBackupPack

public boolean isBackupPack()

setBackupPack

public void setBackupPack(boolean backupPack)

hasBackupPackImportRights

public boolean hasBackupPackImportRights()
Indicate if the current user has the right to import a package as a backup pack. In this implementation, to be able to import has backup pack the user must have the admin right on the XWiki.XWikiPreferences document from the main wiki (xwiki:XWiki.XWikiPreferences). The goal is to prevent local wiki administrators from importing documents saved with a global administrator as the author (rights escalation).

Returns:
true if the current user has the rights to import a package as a backup pack, false otherwise

isVersionPreserved

public boolean isVersionPreserved()

setPreserveVersion

public void setPreserveVersion(boolean preserveVersion)
Sets the flag for the packager to preserve or not existing versions of documents when installing with install(). If set to true, the existing history revisions of documents will be preserve, if not, the history will be overridden.

Parameters:
preserveVersion -

isWithVersions

public boolean isWithVersions()

setWithVersions

public void setWithVersions(boolean withVersions)
Sets the flag for the packager to import or not history revisions included in the archive when installing with install(). This flag will be ignored if isWithVersions() flag is set to true. This means it's not possible to import with versions, preserving the existing document history. The behavior of the packager in this case fall backs on just adding a new version to the exsting history (ignoring the history from the package).

Parameters:
withVersions - should the versions contained in the archive (if any) be imported when installing.

addDocumentFilter

public void addDocumentFilter(Object filter)
                       throws PackageException
Throws:
PackageException

getFiles

public List<DocumentInfoAPI> getFiles()

add

public boolean add(String docFullName,
                   int DefaultAction)
            throws XWikiException
Throws:
XWikiException

add

public boolean add(String docFullName)
            throws XWikiException
Throws:
XWikiException

setDocumentAction

public void setDocumentAction(String docFullName,
                              int action)

setDocumentAction

public void setDocumentAction(String docFullName,
                              String language,
                              int action)

export

public String export()
              throws IOException,
                     XWikiException
Throws:
IOException
XWikiException

importPackageFromByteArray

public boolean importPackageFromByteArray(byte[] data)
Similar to Import(byte[]), except expected errors are catch. This version should be privileged when using the packager API from velocity scripts since it will not display stack-trace in case of error (for example if the passed file is not a valid package).

Parameters:
data - the file to create the package from, as a byte array.
Returns:
true if the package creation succeeded, false otherwise. If the package creation failed, the error message is placed in the velocity context under the import_error key,
Since:
2.2M1

Import

public String Import(byte[] file)
              throws IOException,
                     XWikiException
Load a package in memory from a byte array. It may be installed later using install(). Your should prefer Import(InputStream) which may avoid loading the package twice in memory.

Parameters:
file - an byte array containing a zipped package file
Returns:
an empty string, useless.
Throws:
IOException - while reading the ZipFile
XWikiException - when package content is broken

Import

public String Import(InputStream file)
              throws IOException,
                     XWikiException
Load a package in memory from an InputStream. It may be installed later using install().

Parameters:
file - is an InputStream of a zipped package file
Returns:
an empty string, useless.
Throws:
IOException - while reading the ZipFile
XWikiException - when package content is broken
Since:
2.3M2

testInstall

public int testInstall()

testInstall

public int testInstall(boolean isAdmin)

backupWiki

public void backupWiki()
                throws XWikiException,
                       IOException
Throws:
XWikiException
IOException

toXml

public String toXml()

toJSON

public net.sf.json.JSONObject toJSON()
Returns:
a representation of this package under the JSON format
Since:
2.2M1

install

public int install()
            throws XWikiException
Throws:
XWikiException

getErrors

public List<String> getErrors()

getSkipped

public List<String> getSkipped()

getInstalled

public List<String> getInstalled()

getStatus

public int getStatus()


Copyright © 2004–2014 XWiki. All rights reserved.