public class XarPackage extends Object
Constructor and Description |
---|
XarPackage()
Default constructor.
|
XarPackage(Collection<XarEntry> entries) |
XarPackage(File file) |
XarPackage(InputStream xarStream) |
XarPackage(org.apache.commons.compress.archivers.zip.ZipFile zipFile) |
Modifier and Type | Method and Description |
---|---|
void |
addEntry(LocalDocumentReference reference)
Deprecated.
since 7.2M1, use
addPackageFile(LocalDocumentReference, int) instead |
void |
addEntry(LocalDocumentReference reference,
String entryName)
Add a new entry to the package.
|
void |
addEntry(LocalDocumentReference reference,
String entryName,
int action)
Add a new entry to the package.
|
void |
addPackageFile(LocalDocumentReference reference,
int action)
Add a new entry to the package.
|
Collection<XarEntry> |
getEntries() |
static Collection<XarEntry> |
getEntries(File file)
Get all entries found in a XAR file.
|
XarEntry |
getEntry(LocalDocumentReference reference) |
String |
getPackageAuthor() |
String |
getPackageDescription() |
String |
getPackageExtensionId() |
Collection<XarEntry> |
getPackageFiles() |
String |
getPackageLicense() |
String |
getPackageName() |
String |
getPackageVersion() |
boolean |
isPackageBackupPack() |
boolean |
isPackagePreserveVersion() |
void |
read(File directory)
Find and add the entries located in the passed XAR directory.
|
void |
read(InputStream xarStream)
Find and add the entries located in the passed XAR file.
|
void |
read(org.apache.commons.compress.archivers.zip.ZipFile zipFile)
Find and add the entries located in the passed XAR file.
|
void |
readDescriptor(InputStream stream)
Read a XML descriptor of a XAR package (usually names package.xml).
|
void |
setPackageAuthor(String packageAuthor) |
void |
setPackageBackupPack(boolean packageBackupPack) |
void |
setPackageDescription(String packageDescription) |
void |
setPackageExtensionId(String packageExtensionId) |
void |
setPackageLicense(String packageLicense) |
void |
setPackageName(String packageName) |
void |
setPackagePreserveVersion(boolean packagePreserveVersion) |
void |
setPackageVersion(String packageVersion) |
void |
setPreserveVersion(boolean preserveVersion)
Deprecated.
since 7.2M1, use
setPackagePreserveVersion(boolean) instead |
void |
write(OutputStream stream,
String encoding)
Write the package descriptor to the passed stream as XML.
|
void |
write(XMLStreamWriter writer)
Write the package descriptor to the passed XML stream.
|
void |
write(org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream zipStream,
String encoding)
Write and add the package descriptor to the passed ZIP stream.
|
public XarPackage()
public XarPackage(org.apache.commons.compress.archivers.zip.ZipFile zipFile) throws XarException, IOException
zipFile
- the XAR file as a ZipFile
XarException
- when failing to parse the XAR packageIOException
- when failing to read the filepublic XarPackage(File file) throws IOException, XarException
file
- the XAR fileIOException
- when failing to read the fileXarException
- when failing to parse the XAR packagepublic XarPackage(InputStream xarStream) throws IOException, XarException
xarStream
- an input stream the the XAR fileIOException
- when failing to read the fileXarException
- when failing to parse the XAR packagepublic XarPackage(Collection<XarEntry> entries)
entries
- the entries in the XAR filepublic static Collection<XarEntry> getEntries(File file) throws XarException, IOException
file
- the XAR fileXarException
- when failing to parse the XAR packageIOException
- when failing to read the filepublic void read(InputStream xarStream) throws IOException, XarException
xarStream
- an input stream to a XAR fileIOException
- when failing to read the fileXarException
- when failing to parse the XAR packagepublic void read(org.apache.commons.compress.archivers.zip.ZipFile zipFile) throws IOException, XarException
zipFile
- the XAR fileIOException
- when failing to read the fileXarException
- when failing to parse the XAR packagepublic void read(File directory) throws IOException, XarException
directory
- the expended XAR fileIOException
- when failing to read the fileXarException
- when failing to parse the XAR packagepublic String getPackageExtensionId()
public void setPackageExtensionId(String packageExtensionId)
packageExtensionId
- the identifier of the extension stored in the XAR packagepublic boolean isPackagePreserveVersion()
@Deprecated public void setPreserveVersion(boolean preserveVersion)
setPackagePreserveVersion(boolean)
insteadpreserveVersion
- true if the history should be preserved by defaultpublic void setPackagePreserveVersion(boolean packagePreserveVersion)
packagePreserveVersion
- true if the history should be preserved by defaultpublic String getPackageName()
public void setPackageName(String packageName)
packageName
- the name of the packagepublic String getPackageDescription()
public void setPackageDescription(String packageDescription)
packageDescription
- the description of packagepublic String getPackageLicense()
public void setPackageLicense(String packageLicense)
packageLicense
- the license of the packagepublic String getPackageAuthor()
public void setPackageAuthor(String packageAuthor)
packageAuthor
- the author of the packagepublic String getPackageVersion()
public void setPackageVersion(String packageVersion)
packageVersion
- the version of the packagepublic boolean isPackageBackupPack()
public void setPackageBackupPack(boolean packageBackupPack)
packageBackupPack
- true of the package is a backuppublic Collection<XarEntry> getPackageFiles()
public void addPackageFile(LocalDocumentReference reference, int action)
reference
- the entry reference since 7.2M1action
- the default action associated to this XAR (not used at the moment)@Deprecated public void addEntry(LocalDocumentReference reference)
addPackageFile(LocalDocumentReference, int)
insteadreference
- the entry referencepublic void addEntry(LocalDocumentReference reference, String entryName)
reference
- the entry referenceentryName
- the name of the entry (ZIP style)public void addEntry(LocalDocumentReference reference, String entryName, int action)
reference
- the entry referenceentryName
- the name of the entry (ZIP style)action
- the default action associated to this XAR (not used at the moment)public Collection<XarEntry> getEntries()
public XarEntry getEntry(LocalDocumentReference reference)
reference
- the reference of the documentpublic void readDescriptor(InputStream stream) throws XarException, IOException
stream
- the input stream to the XML file to parseXarException
- when failing to parse the descriptorIOException
- when failing to read the filepublic void write(org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream zipStream, String encoding) throws XarException, IOException
zipStream
- the ZIP stream in which to writeencoding
- the encoding to use to write the descriptorXarException
- when failing to parse the descriptorIOException
- when failing to read the filepublic void write(OutputStream stream, String encoding) throws XarException
stream
- the stream to the resulting XML fileencoding
- the encoding to use to write the descriptorXarException
- when failing to parse the descriptorpublic void write(XMLStreamWriter writer) throws XMLStreamException
writer
- the XML stream where to writeXMLStreamException
- when failing to write the fileCopyright © 2004–2022 XWiki. All rights reserved.