Class JcrPackageImpl
java.lang.Object
org.apache.jackrabbit.vault.packaging.impl.JcrPackageImpl
- All Implemented Interfaces:
AutoCloseable,Comparable<JcrPackage>,JcrPackage
Implements a JcrPackage
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longmax allowed package size for using a memory archiveFields inherited from interface org.apache.jackrabbit.vault.packaging.JcrPackage
MIME_TYPE, NN_VLT_DEFINITION, NT_VLT_PACKAGE, NT_VLT_PACKAGE_DEFINITION -
Constructor Summary
ConstructorsConstructorDescriptionJcrPackageImpl(@NotNull JcrPackageRegistry mgr, @Nullable Node node) JcrPackageImpl(@NotNull JcrPackageRegistry mgr, @Nullable Node node, @Nullable ZipVaultPackage pack) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this package and destroys all temporary data.intvoidextract(ImportOptions opts) Extracts the package contents to the repository.@NotNull PackageId[]extractSubpackages(@NotNull ImportOptions opts) Processes this package and extracts all sub packages.@Nullable PropertygetData()Returns the jcr:data property of the packageReturns the package definition of this package@Nullable NodeReturns the definition node ornullif not existsgetNode()Returns the underlying nodeReturns the vault package stored in the data of this package.protected @NotNull VaultPackagegetPackage(boolean forceFileArchive) Creates a new package by creating the appropriate archive.Returns a list of the installed packages that this package depends on.longgetSize()Returns the size of the underlying package.Returns the snapshot that was taken when installing this package.Returns the dependencies that are not resolved.voidinstall(ImportOptions opts) Installs the package contents to the repository but creates a snapshot if necessary.booleanisEmpty()Checks if the package has content.booleanChecks if this package is installed.booleanisSealed()Checks if this package is sealed. this is the case, if it was not modified since it was unwrapped.booleanisValid()Checks if the underlying node contains the correct structure.snapshot(ExportOptions opts, boolean replace) Creates a snapshot of this package.voidTries to unwrap the definition of this package.voiduninstall(ImportOptions opts) Reverts the changes of a prior installation of this package.booleanverifyId(boolean autoFix, boolean autoSave) Deprecated.
-
Field Details
-
MAX_MEMORY_ARCHIVE_SIZE
public static final long MAX_MEMORY_ARCHIVE_SIZEmax allowed package size for using a memory archive- See Also:
-
-
Constructor Details
-
JcrPackageImpl
public JcrPackageImpl(@NotNull @NotNull JcrPackageRegistry mgr, @Nullable @Nullable Node node) throws RepositoryException - Throws:
RepositoryException
-
JcrPackageImpl
public JcrPackageImpl(@NotNull @NotNull JcrPackageRegistry mgr, @Nullable @Nullable Node node, @Nullable @Nullable ZipVaultPackage pack) throws RepositoryException - Throws:
RepositoryException
-
-
Method Details
-
getDefinition
Returns the package definition of this package- Specified by:
getDefinitionin interfaceJcrPackage- Returns:
- the package definition or
nullif this package is not valid. - Throws:
RepositoryException- if an error occurs
-
compareTo
- Specified by:
compareToin interfaceComparable<JcrPackage>
-
isValid
public boolean isValid()Checks if the underlying node contains the correct structure.- Specified by:
isValidin interfaceJcrPackage- Returns:
trueif this package is valid.
-
isInstalled
Checks if this package is installed. Note: the default implementation only checks theJcrPackageDefinition.getLastUnpacked()date. If the package is replaced since it was installed. this method will returnfalse.- Specified by:
isInstalledin interfaceJcrPackage- Returns:
trueif this package is installed.- Throws:
RepositoryException- if an error occurs.
-
isEmpty
public boolean isEmpty()Checks if the package has content.- Specified by:
isEmptyin interfaceJcrPackage- Returns:
trueif this package doesn't have content
-
getNode
Returns the underlying node- Specified by:
getNodein interfaceJcrPackage- Returns:
- the node
-
isSealed
public boolean isSealed()Checks if this package is sealed. this is the case, if it was not modified since it was unwrapped.- Specified by:
isSealedin interfaceJcrPackage- Returns:
trueif this package is sealed.
-
verifyId
Deprecated.Checks if the package id is correct in respect to the installation path and adjusts it accordingly.- Specified by:
verifyIdin interfaceJcrPackage- Parameters:
autoFix-trueto automatically fix the idautoSave-trueto save changes immediately- Returns:
truealways.- Throws:
RepositoryException- if an error occurs.
-
tryUnwrap
Tries to unwrap the definition of this package.- Throws:
IOException- if an I/O error occurs or if the underlying file is not a packageRepositoryException- if a repository error occurs
-
getPackage
Returns the vault package stored in the data of this package. Opens the package implicitly thereforeJcrPackage.close()needs to be afterwards. This is potentially a costly operation as this requires uncompressing the ZIP stream (and potentially creating temporary files) therefore prefer usingJcrPackage.getDefinition()whenever possible to access meta data.- Specified by:
getPackagein interfaceJcrPackage- Returns:
- the package, this is closed when
JcrPackage.close()is called on this package - Throws:
RepositoryException- if an error occursIOException- if an I/O error occurs
-
getPackage
@NotNull protected @NotNull VaultPackage getPackage(boolean forceFileArchive) throws RepositoryException, IOException Creates a new package by creating the appropriate archive. This is basically a workaround to ensure that 'rewrap' has a zip file to work on. Ideally rewrap should not rely on the archive format.- Parameters:
forceFileArchive- iftruea file archive is enforced- Returns:
- the package
- Throws:
RepositoryException- If a repository error occurs.IOException- if an i/o error occurs.
-
extract
Extracts the package contents to the repository. Opens the package implicitly thereforeJcrPackage.close()needs to be afterwards.- Specified by:
extractin interfaceJcrPackage- Parameters:
opts- import options- Throws:
RepositoryException- if a repository error during installation occurs.PackageException- if an error during packaging occursIOException- if an I/O error occurs
-
install
Installs the package contents to the repository but creates a snapshot if necessary. Opens the package implicitly thereforeJcrPackage.close()needs to be afterwards.- Specified by:
installin interfaceJcrPackage- Parameters:
opts- import options- Throws:
RepositoryException- if a repository error during installation occurs.PackageException- if an error during packaging occursIOException- if an I/O error occurs
-
extractSubpackages
@NotNull public @NotNull PackageId[] extractSubpackages(@NotNull @NotNull ImportOptions opts) throws RepositoryException, PackageException, IOException Processes this package and extracts all sub packages. No content of this package or its sub packages is extracted and not snapshots are taken. IfImportOptions.isNonRecursive()istrue, then only the direct sub packages are extracted. The extraction ensures that the sub packages have a dependency to their parent package.- Specified by:
extractSubpackagesin interfaceJcrPackage- Parameters:
opts- import options- Returns:
- the list of subpackages that were extracted
- Throws:
RepositoryException- if a repository error during installation occurs.PackageException- if an error during packaging occursIOException- if an I/O error occurs
-
getUnresolvedDependencies
Returns the dependencies that are not resolved. If theDependencyHandlingis set to strict, the package will not installed if any unresolved dependencies are listed.- Specified by:
getUnresolvedDependenciesin interfaceJcrPackage- Returns:
- the array of unresolved dependencies.
- Throws:
RepositoryException- if an error accessing the repository occurrs
-
getResolvedDependencies
Returns a list of the installed packages that this package depends on.- Specified by:
getResolvedDependenciesin interfaceJcrPackage- Returns:
- the array of resolved dependencies
- Throws:
RepositoryException- if an error accessing the repository occurrs
-
snapshot
public JcrPackage snapshot(ExportOptions opts, boolean replace) throws RepositoryException, PackageException, IOException Creates a snapshot of this package.- Specified by:
snapshotin interfaceJcrPackage- Parameters:
opts- export optionsreplace- iftrueany existing snapshot is replaced.- Returns:
- a package that represents the snapshot of this package or
nullif it wasn't created. - Throws:
RepositoryException- if a repository error during installation occurs.PackageException- if an error during packaging occursIOException- if an I/O error occurs
-
getSnapshot
Returns the snapshot that was taken when installing this package.- Specified by:
getSnapshotin interfaceJcrPackage- Returns:
- the snapshot package or
null - Throws:
RepositoryException- if an error occurs.
-
uninstall
Reverts the changes of a prior installation of this package.- Specified by:
uninstallin interfaceJcrPackage- Parameters:
opts- import options- Throws:
RepositoryException- if a repository error during installation occurs.PackageException- if an error during packaging occurs or if no snapshot is available.IOException- if an I/O error occurs
-
getSize
public long getSize()Returns the size of the underlying package.- Specified by:
getSizein interfaceJcrPackage- Returns:
- the size in bytes or -1 if not valid.
-
close
public void close()Closes this package and destroys all temporary data. Only necessary to call whenJcrPackage.getPackage(),JcrPackage.extract(ImportOptions)orJcrPackage.install(ImportOptions)has been called. Is a no-op when none of these methods have been called on this package.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceJcrPackage
-
getData
Returns the jcr:data property of the package- Specified by:
getDatain interfaceJcrPackage- Returns:
- the jcr:data property
- Throws:
RepositoryException- if an error occurrs
-
getDefNode
Returns the definition node ornullif not exists- Specified by:
getDefNodein interfaceJcrPackage- Returns:
- the definition node.
- Throws:
RepositoryException- if an error occurrs
-