com.xpn.xwiki.plugin.packaging
Class Package

java.lang.Object
  extended by com.xpn.xwiki.plugin.packaging.Package

public class Package
extends Object


Field Summary
static String DEFAULT_FILEEXT
           
static String DefaultPackageFileName
           
static String DefaultPluginName
           
static int OK
           
static int Right
           
static String XAR_FILENAME_ENCODING
           
 
Constructor Summary
Package()
           
 
Method Summary
 boolean add(String docFullName, int DefaultAction, XWikiContext context)
           
 boolean add(String docFullName, String language, int DefaultAction, XWikiContext context)
           
 boolean add(String docFullName, String language, XWikiContext context)
           
 boolean add(String docFullName, XWikiContext context)
           
 boolean add(XWikiDocument doc, int defaultAction, XWikiContext context)
           
 boolean add(XWikiDocument doc, XWikiContext context)
           
 void addAllWikiDocuments(XWikiContext context)
           
 void addDocumentFilter(Object filter)
           
 void addToDir(XWikiDocument doc, File dir, boolean withVersions, XWikiContext context)
           
 void addToZip(XWikiDocument doc, ZipOutputStream zos, boolean withVersions, XWikiContext context)
          Deprecated. since 4.1M2
 void deleteAllWikiDocuments(XWikiContext context)
           
 String export(OutputStream os, XWikiContext context)
           
 String exportToDir(File dir, XWikiContext context)
           
 void filter(XWikiDocument doc, XWikiContext context)
           
protected  org.dom4j.Document fromXml(InputStream xml)
           
 String getAuthorName()
           
 List<DocumentInfo> getCustomMappingFiles()
           
 String getDescription()
           
 String getDirectoryForDocument(XWikiDocument doc)
          Generate a relative path based on provided document for the directory where the document should be stored.
protected  String getElementText(org.dom4j.Element docel, String name)
           
protected  String getElementText(org.dom4j.Element docel, String name, String def)
           
 List<String> getErrors(XWikiContext context)
           
 String getExtensionId()
           
 String getFileNameFromDocument(XWikiDocument doc, XWikiContext context)
          Generate a file name based on provided document.
 List<DocumentInfo> getFiles()
           
 String getId()
           
 List<String> getInstalled(XWikiContext context)
           
 String getLicence()
           
 String getName()
           
 String getPathFromDocument(XWikiDocument doc, XWikiContext context)
          Generate a relative path based on provided document.
 List<String> getSkipped(XWikiContext context)
           
 int getStatus(XWikiContext context)
           
 String getVersion()
           
 boolean hasBackupPackImportRights(XWikiContext context)
           
 String Import(byte[] file, XWikiContext context)
          Load this package in memory from a byte array.
 String Import(InputStream file, XWikiContext context)
          Load this package in memory from an InputStream.
 int install(XWikiContext context)
           
 boolean isBackupPack()
          If true, the package will preserve the original author during import, rather than updating the author to the current (importing) user.
 boolean isInstallExension()
           
 boolean isVersionPreserved()
          If true, the package will preserve the current document version during import, regardless of whether or not the document history is included.
 boolean isWithVersions()
           
 String readFromDir(File dir, XWikiContext context)
          Load document files from provided directory and sub-directories into packager.
 int readFromDir(File dir, XWikiContext context, org.dom4j.Document description)
          Load document files from provided directory and sub-directories into packager.
 void setAuthorName(String authorName)
           
 void setBackupPack(boolean backupPack)
           
 void setDescription(String description)
           
 void setExtensionId(String extensionId)
           
 void setId(String id)
           
 void setInstallExension(boolean installExension)
           
 void setLicence(String licence)
           
 void setName(String name)
           
 void setPreserveVersion(boolean preserveVersion)
           
 void setVersion(String version)
           
 void setWithVersions(boolean withVersions)
          If set to true, history revisions in the archive will be imported when importing documents.
 int testInstall(boolean isAdmin, XWikiContext context)
           
 net.sf.json.JSONObject toJSON(XWikiContext wikiContext)
          Outputs the content of this package in the JSON format
 void toXML(OutputStream out, XWikiContext context)
          Write the package.xml file to an OutputStream
 void toXML(com.xpn.xwiki.internal.xml.XMLWriter wr)
          Write the package.xml file to an XMLWriter.
 String toXml(XWikiContext context)
          You should prefer toXML(com.xpn.xwiki.internal.xml.XMLWriter).
 boolean updateDoc(String docFullName, int action, XWikiContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OK

public static final int OK
See Also:
Constant Field Values

Right

public static final int Right
See Also:
Constant Field Values

DEFAULT_FILEEXT

public static final String DEFAULT_FILEEXT
See Also:
Constant Field Values

XAR_FILENAME_ENCODING

public static final String XAR_FILENAME_ENCODING
See Also:
Constant Field Values

DefaultPackageFileName

public static final String DefaultPackageFileName
See Also:
Constant Field Values

DefaultPluginName

public static final String DefaultPluginName
See Also:
Constant Field Values
Constructor Detail

Package

public Package()
Method Detail

getName

public String getName()

setName

public void setName(String name)

getDescription

public String getDescription()

setDescription

public void setDescription(String description)

getId

public String getId()

setId

public void setId(String id)

isInstallExension

public boolean isInstallExension()
Returns:
true if the extension packaged in the XAR should be registered as such automatically, false otherwise.

setInstallExension

public void setInstallExension(boolean installExension)

getExtensionId

public String getExtensionId()

setExtensionId

public void setExtensionId(String extensionId)

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()
If true, the package will preserve the original author during import, rather than updating the author to the current (importing) user.

See Also:
isWithVersions(), isVersionPreserved()

setBackupPack

public void setBackupPack(boolean backupPack)

hasBackupPackImportRights

public boolean hasBackupPackImportRights(XWikiContext context)

isVersionPreserved

public boolean isVersionPreserved()
If true, the package will preserve the current document version during import, regardless of whether or not the document history is included.

See Also:
isWithVersions(), isBackupPack()

setPreserveVersion

public void setPreserveVersion(boolean preserveVersion)

getFiles

public List<DocumentInfo> getFiles()

getCustomMappingFiles

public List<DocumentInfo> getCustomMappingFiles()

isWithVersions

public boolean isWithVersions()

setWithVersions

public void setWithVersions(boolean withVersions)
If set to true, history revisions in the archive will be imported when importing documents.


addDocumentFilter

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

add

public boolean add(XWikiDocument doc,
                   int defaultAction,
                   XWikiContext context)
            throws XWikiException
Throws:
XWikiException

add

public boolean add(XWikiDocument doc,
                   XWikiContext context)
            throws XWikiException
Throws:
XWikiException

updateDoc

public boolean updateDoc(String docFullName,
                         int action,
                         XWikiContext context)
                  throws XWikiException
Throws:
XWikiException

add

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

add

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

add

public boolean add(String docFullName,
                   XWikiContext context)
            throws XWikiException
Throws:
XWikiException

add

public boolean add(String docFullName,
                   String language,
                   XWikiContext context)
            throws XWikiException
Throws:
XWikiException

filter

public void filter(XWikiDocument doc,
                   XWikiContext context)
            throws ExcludeDocumentException
Throws:
ExcludeDocumentException

export

public String export(OutputStream os,
                     XWikiContext context)
              throws IOException,
                     XWikiException
Throws:
IOException
XWikiException

exportToDir

public String exportToDir(File dir,
                          XWikiContext context)
                   throws IOException,
                          XWikiException
Throws:
IOException
XWikiException

Import

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

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

Import

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

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

testInstall

public int testInstall(boolean isAdmin,
                       XWikiContext context)

install

public int install(XWikiContext context)
            throws XWikiException
Throws:
XWikiException

getErrors

public List<String> getErrors(XWikiContext context)

getSkipped

public List<String> getSkipped(XWikiContext context)

getInstalled

public List<String> getInstalled(XWikiContext context)

getStatus

public int getStatus(XWikiContext context)

toXml

public String toXml(XWikiContext context)
You should prefer toXML(com.xpn.xwiki.internal.xml.XMLWriter). If an error occurs, a stacktrace is dump to logs, and an empty String is returned.

Returns:
a package.xml file for the this package

toXML

public void toXML(com.xpn.xwiki.internal.xml.XMLWriter wr)
           throws IOException
Write the package.xml file to an XMLWriter.

Parameters:
wr - the writer to write to
Throws:
IOException - when an error occurs during streaming operation
Since:
2.3M2

toXML

public void toXML(OutputStream out,
                  XWikiContext context)
           throws IOException
Write the package.xml file to an OutputStream

Parameters:
out - the OutputStream to write to
context - curent XWikiContext
Throws:
IOException - when an error occurs during streaming operation
Since:
2.3M2

getPathFromDocument

public String getPathFromDocument(XWikiDocument doc,
                                  XWikiContext context)
Generate a relative path based on provided document.

Parameters:
doc - the document to export.
Returns:
the corresponding path.

getFileNameFromDocument

public String getFileNameFromDocument(XWikiDocument doc,
                                      XWikiContext context)
Generate a file name based on provided document.

Parameters:
doc - the document to export.
Returns:
the corresponding file name.

getDirectoryForDocument

public String getDirectoryForDocument(XWikiDocument doc)
Generate a relative path based on provided document for the directory where the document should be stored.

Parameters:
doc - the document to export
Returns:
the corresponding path

addToZip

@Deprecated
public void addToZip(XWikiDocument doc,
                                ZipOutputStream zos,
                                boolean withVersions,
                                XWikiContext context)
              throws XWikiException,
                     IOException
Deprecated. since 4.1M2

Write an XML serialized XWikiDocument to a ZipOutputStream

Parameters:
doc - the document to serialize
zos - the ZipOutputStream to write to
withVersions - if true, also serialize all document versions
context - current XWikiContext
Throws:
XWikiException - when an error occurs during documents access
IOException - when an error occurs during streaming operation

addToDir

public void addToDir(XWikiDocument doc,
                     File dir,
                     boolean withVersions,
                     XWikiContext context)
              throws XWikiException
Throws:
XWikiException

getElementText

protected String getElementText(org.dom4j.Element docel,
                                String name)

getElementText

protected String getElementText(org.dom4j.Element docel,
                                String name,
                                String def)

fromXml

protected org.dom4j.Document fromXml(InputStream xml)
                              throws org.dom4j.DocumentException
Throws:
org.dom4j.DocumentException

addAllWikiDocuments

public void addAllWikiDocuments(XWikiContext context)
                         throws XWikiException
Throws:
XWikiException

deleteAllWikiDocuments

public void deleteAllWikiDocuments(XWikiContext context)
                            throws XWikiException
Throws:
XWikiException

readFromDir

public int readFromDir(File dir,
                       XWikiContext context,
                       org.dom4j.Document description)
                throws IOException,
                       XWikiException
Load document files from provided directory and sub-directories into packager.

Parameters:
dir - the directory from where to load documents.
context - the XWiki context.
description - the package descriptor.
Returns:
the number of loaded documents.
Throws:
IOException - error when loading documents.
XWikiException - error when loading documents.

readFromDir

public String readFromDir(File dir,
                          XWikiContext context)
                   throws IOException,
                          XWikiException
Load document files from provided directory and sub-directories into packager.

Parameters:
dir - the directory from where to load documents.
context - the XWiki context.
Returns:
Throws:
IOException - error when loading documents.
XWikiException - error when loading documents.

toJSON

public net.sf.json.JSONObject toJSON(XWikiContext wikiContext)
Outputs the content of this package in the JSON format

Parameters:
wikiContext - the XWiki context
Returns:
a representation of this package under the JSON format
Since:
2.2M1


Copyright © 2004-2013 XWiki. All Rights Reserved.