Class JcrPackageImpl

    • Field Detail

      • MAX_MEMORY_ARCHIVE_SIZE

        public static final long MAX_MEMORY_ARCHIVE_SIZE
        max allowed package size for using a memory archive
        See Also:
        Constant Field Values
    • Constructor Detail

      • JcrPackageImpl

        public JcrPackageImpl​(@NotNull
                              @NotNull JcrPackageRegistry mgr,
                              @Nullable
                              @Nullable javax.jcr.Node node)
                       throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • JcrPackageImpl

        public JcrPackageImpl​(@NotNull
                              @NotNull JcrPackageRegistry mgr,
                              @Nullable
                              @Nullable javax.jcr.Node node,
                              @Nullable
                              @Nullable ZipVaultPackage pack)
                       throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
    • Method Detail

      • getDefinition

        public JcrPackageDefinition getDefinition()
                                           throws javax.jcr.RepositoryException
        Returns the package definition of this package
        Specified by:
        getDefinition in interface JcrPackage
        Returns:
        the package definition or null if this package is not valid.
        Throws:
        javax.jcr.RepositoryException - if an error occurrs
      • isValid

        public boolean isValid()
        Checks if the underlying node contains the correct structure.
        Specified by:
        isValid in interface JcrPackage
        Returns:
        true if this package is valid.
      • isInstalled

        public boolean isInstalled()
                            throws javax.jcr.RepositoryException
        Checks if this package is installed. Note: the default implementation only checks the JcrPackageDefinition.getLastUnpacked() date. If the package is replaced since it was installed. this method will return false.
        Specified by:
        isInstalled in interface JcrPackage
        Returns:
        true if this package is installed.
        Throws:
        javax.jcr.RepositoryException - if an error occurs.
      • isEmpty

        public boolean isEmpty()
        Checks if the package has content.
        Specified by:
        isEmpty in interface JcrPackage
        Returns:
        true if this package doesn't have content
      • getNode

        public javax.jcr.Node getNode()
        Returns the underlying node
        Specified by:
        getNode in interface JcrPackage
        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:
        isSealed in interface JcrPackage
        Returns:
        true if this package is sealed.
      • verifyId

        @Deprecated
        public boolean verifyId​(boolean autoFix,
                                boolean autoSave)
                         throws javax.jcr.RepositoryException
        Deprecated.
        Checks if the package id is correct in respect to the installation path and adjusts it accordingly.
        Specified by:
        verifyId in interface JcrPackage
        Parameters:
        autoFix - true to automatically fix the id
        autoSave - true to save changes immediately
        Returns:
        true always.
        Throws:
        javax.jcr.RepositoryException - if an error occurs.
      • tryUnwrap

        public void tryUnwrap()
                       throws IOException,
                              javax.jcr.RepositoryException
        Tries to unwrap the definition of this package.
        Throws:
        IOException - if an I/O error occurs or if the underlying file is not a package
        javax.jcr.RepositoryException - if a repository error occurs
      • getPackage

        public VaultPackage getPackage()
                                throws javax.jcr.RepositoryException,
                                       IOException
        Returns the vault package stored in the data of this package
        Specified by:
        getPackage in interface JcrPackage
        Returns:
        the package, this is closed when JcrPackage.close() is called on this package
        Throws:
        javax.jcr.RepositoryException - if an error occurs
        IOException - if an I/O error occurs
      • getPackage

        @NotNull
        protected @NotNull VaultPackage getPackage​(boolean forceFileArchive)
                                            throws javax.jcr.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 realy on the archive format.
        Parameters:
        forceFileArchive - if true a file archive is enforced
        Returns:
        the package
        Throws:
        javax.jcr.RepositoryException - If a repository error occurrs.
        IOException - if an i/o error occurrs.
      • extract

        public void extract​(ImportOptions opts)
                     throws javax.jcr.RepositoryException,
                            PackageException,
                            IOException
        Extracts the package contents to the repository
        Specified by:
        extract in interface JcrPackage
        Parameters:
        opts - import options
        Throws:
        javax.jcr.RepositoryException - if a repository error during installation occurs.
        PackageException - if an error during packaging occurs
        IOException - if an I/O error occurs
      • install

        public void install​(ImportOptions opts)
                     throws javax.jcr.RepositoryException,
                            PackageException,
                            IOException
        Installs the package contents to the repository but creates a snapshot if necessary.
        Specified by:
        install in interface JcrPackage
        Parameters:
        opts - import options
        Throws:
        javax.jcr.RepositoryException - if a repository error during installation occurs.
        PackageException - if an error during packaging occurs
        IOException - if an I/O error occurs
      • extractSubpackages

        @NotNull
        public @NotNull PackageId[] extractSubpackages​(@NotNull
                                                       @NotNull ImportOptions opts)
                                                throws javax.jcr.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. If ImportOptions.isNonRecursive() is true, then only the direct sub packages are extracted. The extraction ensures that the sub packages have a dependency to their parent package.
        Specified by:
        extractSubpackages in interface JcrPackage
        Parameters:
        opts - import options
        Returns:
        the list of subpackages that were extracted
        Throws:
        javax.jcr.RepositoryException - if a repository error during installation occurs.
        PackageException - if an error during packaging occurs
        IOException - if an I/O error occurs
      • getUnresolvedDependencies

        public Dependency[] getUnresolvedDependencies()
                                               throws javax.jcr.RepositoryException
        Returns the dependencies that are not resolved. If the DependencyHandling is set to strict, the package will not installed if any unresolved dependencies are listed.
        Specified by:
        getUnresolvedDependencies in interface JcrPackage
        Returns:
        the array of unresolved dependencies.
        Throws:
        javax.jcr.RepositoryException - if an error accessing the repository occurrs
      • getResolvedDependencies

        public PackageId[] getResolvedDependencies()
                                            throws javax.jcr.RepositoryException
        Returns a list of the installed packages that this package depends on.
        Specified by:
        getResolvedDependencies in interface JcrPackage
        Returns:
        the array of resolved dependencies
        Throws:
        javax.jcr.RepositoryException - if an error accessing the repository occurrs
      • snapshot

        public JcrPackage snapshot​(ExportOptions opts,
                                   boolean replace)
                            throws javax.jcr.RepositoryException,
                                   PackageException,
                                   IOException
        Creates a snapshot of this package.
        Specified by:
        snapshot in interface JcrPackage
        Parameters:
        opts - export options
        replace - if true any existing snapshot is replaced.
        Returns:
        a package that represents the snapshot of this package or null if it wasn't created.
        Throws:
        javax.jcr.RepositoryException - if a repository error during installation occurs.
        PackageException - if an error during packaging occurs
        IOException - if an I/O error occurs
      • getSnapshot

        public JcrPackage getSnapshot()
                               throws javax.jcr.RepositoryException
        Returns the snapshot that was taken when installing this package.
        Specified by:
        getSnapshot in interface JcrPackage
        Returns:
        the snapshot package or null
        Throws:
        javax.jcr.RepositoryException - if an error occurs.
      • uninstall

        public void uninstall​(ImportOptions opts)
                       throws javax.jcr.RepositoryException,
                              PackageException,
                              IOException
        Reverts the changes of a prior installation of this package.
        Specified by:
        uninstall in interface JcrPackage
        Parameters:
        opts - import options
        Throws:
        javax.jcr.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:
        getSize in interface JcrPackage
        Returns:
        the size in bytes or -1 if not valid.
      • getData

        @Nullable
        public @Nullable javax.jcr.Property getData()
                                             throws javax.jcr.RepositoryException
        Returns the jcr:data property of the package
        Specified by:
        getData in interface JcrPackage
        Returns:
        the jcr:data property
        Throws:
        javax.jcr.RepositoryException - if an error occurrs
      • getDefNode

        @Nullable
        public @Nullable javax.jcr.Node getDefNode()
                                            throws javax.jcr.RepositoryException
        Returns the definition node or null if not exists
        Specified by:
        getDefNode in interface JcrPackage
        Returns:
        the definition node.
        Throws:
        javax.jcr.RepositoryException - if an error occurrs