Interface JcrPackageManager

    • Method Detail

      • open

        @CheckForNull
        JcrPackage open​(@Nonnull
                        PackageId id)
                 throws RepositoryException
        Opens a package with the given package id.
        Parameters:
        id - the package id.
        Returns:
        the new package or null it the package does not exist or is not valid.
        Throws:
        RepositoryException - if an error occurs
        Since:
        2.3.22
      • open

        @CheckForNull
        JcrPackage open​(@Nonnull
                        Node node)
                 throws RepositoryException
        Opens a package that is based on the given node.
        Parameters:
        node - the underlying node
        Returns:
        the new package or null it the package is not valid.
        Throws:
        RepositoryException - if an error occurs
      • open

        @CheckForNull
        JcrPackage open​(@Nonnull
                        Node node,
                        boolean allowInvalid)
                 throws RepositoryException
        Opens a package that is based on the given node. If allowInvalid is true also invalid packages are returned, but only if the node is file like (i.e. is nt:hierarchyNode and has a jcr:content/jcr:data property).
        Parameters:
        node - the underlying node
        allowInvalid - if true invalid packages are openend, too.
        Returns:
        the new package or null it the package is not valid unless allowInvalid is true.
        Throws:
        RepositoryException - if an error occurs
      • resolve

        @CheckForNull
        PackageId resolve​(@Nonnull
                          Dependency dependency,
                          boolean onlyInstalled)
                   throws RepositoryException
        Finds the id of the package that matches the given dependency best. If onlyInstalled is true only installed packages are searched.
        Parameters:
        dependency - dependency information
        onlyInstalled - if true only installed packages are searched.
        Returns:
        the id of the matching package or null if not found.
        Throws:
        RepositoryException - if an error occurs
        Since:
        2.4.6
      • usage

        @Nonnull
        PackageId[] usage​(@Nonnull
                          PackageId id)
                   throws RepositoryException
        Returns the package ids of installed packages that depend on the given package.
        Parameters:
        id - the package id to search for
        Returns:
        the array of package ids.
        Throws:
        RepositoryException - if an error occurs
        Since:
        3.1.32
      • upload

        @Nonnull
        JcrPackage upload​(@Nonnull
                          java.io.File file,
                          boolean isTmpFile,
                          boolean replace,
                          @Nullable
                          java.lang.String nameHint)
                   throws RepositoryException,
                          java.io.IOException
        Uploads a package. The location is chosen from the installation path of the package. if the package does not provide such a path, the nameHint is respected and the package is placed below the package root. if the package already exists at that path it is not installed and null is returned unless replace is true.
        Parameters:
        file - package file to upload
        isTmpFile - indicates if the given file is a temp file and can be deleted when the package is closed
        replace - if true existing packages are replaced.
        nameHint - hint for the name if package does not provide one
        Returns:
        the new jcr package
        Throws:
        RepositoryException - if an error occurrs
        java.io.IOException - if an I/O error occurrs
      • upload

        @Nonnull
        JcrPackage upload​(@Nonnull
                          java.io.File file,
                          boolean isTmpFile,
                          boolean replace,
                          @Nullable
                          java.lang.String nameHint,
                          boolean strict)
                   throws RepositoryException,
                          java.io.IOException
        Uploads a package. The location is chosen from the installation path of the package. if the package does not provide such a path, the nameHint is respected and the package is placed below the package root. if the package already exists at that path it is not uploaded a ItemExistsException is thrown unless replace is true.
        Parameters:
        file - package file to upload
        isTmpFile - indicates if the given file is a temp file and can be deleted when the package is closed
        replace - if true existing packages are replaced.
        nameHint - hint for the name if package does not provide one
        strict - if true import is more strict in regards to errors
        Returns:
        the new jcr package
        Throws:
        RepositoryException - if an error occurrs
        java.io.IOException - if an I/O error occurrs
      • upload

        @Nonnull
        JcrPackage upload​(@Nonnull
                          java.io.InputStream in,
                          boolean replace)
                   throws RepositoryException,
                          java.io.IOException
        Uploads a package. The location is chosen from the installation path of the package. if the package does not provide such a path an IOException is thrown. if the package already exists at that path it is not uploaded a ItemExistsException is thrown unless replace is true.
        Parameters:
        in - input stream that provides the content of the package. note that after this method returns, the input stream is closed in any case.
        replace - if true existing packages are replaced.
        Returns:
        the new jcr package
        Throws:
        RepositoryException - if an error occurrs
        java.io.IOException - if an I/O error occurrs
      • upload

        @Nonnull
        JcrPackage upload​(@Nonnull
                          java.io.InputStream in,
                          boolean replace,
                          boolean strict)
                   throws RepositoryException,
                          java.io.IOException
        Uploads a package. The location is chosen from the installation path of the package. if the package does not provide such a path an IOException is thrown. if the package already exists at that path it is not uploaded a ItemExistsException is thrown unless replace is true.
        Parameters:
        in - input stream that provides the content of the package. note that after this method returns, the input stream is closed in any case.
        replace - if true existing packages are replaced.
        strict - if true import is more strict in regards to errors
        Returns:
        the new jcr package
        Throws:
        RepositoryException - if an error occurrs
        java.io.IOException - if an I/O error occurrs
      • create

        @Nonnull
        JcrPackage create​(@Nullable
                          Node folder,
                          @Nonnull
                          java.lang.String name)
                   throws RepositoryException,
                          java.io.IOException
        Creates a new package below the given folder.
        Parameters:
        folder - parent folder or null for the package root
        name - name of the new package
        Returns:
        a new jcr package
        Throws:
        RepositoryException - if a repository error occurrs
        java.io.IOException - if an I/O exception occurs
      • create

        @Nonnull
        JcrPackage create​(@Nonnull
                          java.lang.String group,
                          @Nonnull
                          java.lang.String name)
                   throws RepositoryException,
                          java.io.IOException
        Creates a new package with the new group and name.
        Parameters:
        group - group of the new package
        name - name of the new package
        Returns:
        a new jcr package
        Throws:
        RepositoryException - if a repository error occurrs
        java.io.IOException - if an I/O exception occurs
        Since:
        2.2.5
      • create

        @Nonnull
        JcrPackage create​(@Nonnull
                          java.lang.String group,
                          @Nonnull
                          java.lang.String name,
                          @Nullable
                          java.lang.String version)
                   throws RepositoryException,
                          java.io.IOException
        Creates a new package with the new group, name and version.
        Parameters:
        group - group of the new package
        name - name of the new package
        version - version of the new package; can be null
        Returns:
        a new jcr package
        Throws:
        RepositoryException - if a repository error occurrs
        java.io.IOException - if an I/O exception occurs
        Since:
        2.3
      • extract

        @Nonnull
        PackageId[] extract​(@Nonnull
                            Archive archive,
                            @Nonnull
                            ImportOptions options,
                            boolean replace)
                     throws RepositoryException,
                            PackageException,
                            java.io.IOException
        Extracts a package directly from the given archive without uploading it to the repository first. A package node is created but w/o any content. The resulting package cannot be downloaded, uninstalled or re-installed.

        If the package defines unsatisfied dependencies DependencyHandling might cause the extraction to fail.

        If the package contains sub-packages, they will follow the same behaviour, i.e. they will not be uploaded to the repository but directly installed unless ImportOptions.setNonRecursive(boolean) is set to true, in which case the sub packages will be uploaded.

        The method will throw an ItemExistsException if a package with the same id already exists, unless replace is set to true.

        Parameters:
        archive - the input archive that contains the package.
        options - the import options
        replace - if true existing packages are replaced.
        Returns:
        an array of the package(s) that were extracted.
        Throws:
        RepositoryException - if an error occurs
        java.io.IOException - if an I/O error occurrs
        PackageException - if an internal error occurrs
        java.io.IOException - if an I/O exception occurs
      • remove

        void remove​(@Nonnull
                    JcrPackage pack)
             throws RepositoryException
        Removes a package and its snapshots if present.
        Parameters:
        pack - the package to remove
        Throws:
        RepositoryException - if a repository error occurrs
        Since:
        2.2.7
      • rename

        @Nonnull
        JcrPackage rename​(@Nonnull
                          JcrPackage pack,
                          @Nullable
                          java.lang.String groupId,
                          @Nullable
                          java.lang.String name)
                   throws PackageException,
                          RepositoryException
        Renames the given package with a new group id and name. Please note that the package is moved and the internal 'path' is adjusted in the definition, but the package is not rewrapped.
        Parameters:
        pack - the package to rename
        groupId - the new group id or null
        name - the new name or null
        Returns:
        the renamed package
        Throws:
        RepositoryException - if an error occurs
        PackageException - if the package is not unwrapped.
        Since:
        2.0
      • rename

        @Nonnull
        JcrPackage rename​(@Nonnull
                          JcrPackage pack,
                          @Nullable
                          java.lang.String groupId,
                          @Nullable
                          java.lang.String name,
                          @Nullable
                          java.lang.String version)
                   throws PackageException,
                          RepositoryException
        Renames the given package with a new group id, name and version. Please note that the package is moved and the internal 'path' is adjusted in the definition, but the package is not rewrapped.
        Parameters:
        pack - the package to rename
        groupId - the new group id or null
        name - the new name or null
        version - the new version or null
        Returns:
        the renamed package
        Throws:
        RepositoryException - if an error occurs
        PackageException - if the package is not unwrapped.
        Since:
        2.3
      • getPackageRoot

        @CheckForNull
        Node getPackageRoot​(boolean noCreate)
                     throws RepositoryException
        Returns the configured package root node.
        Parameters:
        noCreate - do not create missing root if true
        Returns:
        the package root node or null if not present and noCreate is true.
        Throws:
        RepositoryException - if an error occurs
      • listPackages

        @Nonnull
        java.util.List<JcrPackage> listPackages​(@Nullable
                                                WorkspaceFilter filter)
                                         throws RepositoryException
        Returns the list of all packages installed below the package root that are included in the filter.
        Parameters:
        filter - filter for packages
        Returns:
        a list of packages
        Throws:
        RepositoryException - if an error occurs
      • listPackages

        @Nonnull
        java.util.List<JcrPackage> listPackages​(@Nullable
                                                java.lang.String group,
                                                boolean built)
                                         throws RepositoryException
        Returns the list of all packages installed below the package root that match the given group. if group is null all packages are returned.
        Parameters:
        group - the group filter
        built - if true only packages with size > 0 are listed
        Returns:
        the list of packages
        Throws:
        RepositoryException - if an error occurs