Interface PackageHelper


@ProviderType public interface PackageHelper
Helper interface for dynamic package creation.
  • Field Details

    • DEFAULT_PACKAGE_THUMBNAIL_RESOURCE_PATH

      static final String DEFAULT_PACKAGE_THUMBNAIL_RESOURCE_PATH
      JCR Path to default ACS thumbnail resource.
      See Also:
  • Method Details

    • addThumbnail

      void addThumbnail(org.apache.jackrabbit.vault.packaging.JcrPackage jcrPackage, org.apache.sling.api.resource.Resource thumbnailResource)
      Adds the thumbnail resource to the package as the package thumbnail. If the thumbnailResource is null or not a valid thumbnail resource, a default ACS Package thumbnail will be used.
      Parameters:
      jcrPackage - The package to add the thumbnail to.
      thumbnailResource - The JCR resource that is the thumbnail to be used as the package's thumbnail
    • getNextVersion

      org.apache.jackrabbit.vault.packaging.Version getNextVersion(org.apache.jackrabbit.vault.packaging.JcrPackageManager jcrPackageManager, String groupName, String name, String version) throws javax.jcr.RepositoryException
      Derives the next package version to use based on the input params and the existing package versions matching the input Package group and name. Next version increments "minor" version only. Ex. 1.0.0 ~> 1.1.0 3.22.0 ~> 3.23.0 If the param version's major is greater than the largest existing package version in jcr, then the param version will be used. Ex. param ~> 2.0.0, largest in jcr ~> 1.40.0; returned version will be 2.0.0
      Parameters:
      jcrPackageManager - JcrPackageManager object
      groupName - package group name
      name - package name
      version - package version
      Returns:
      the next version based on existing versions in the jcr
      Throws:
      javax.jcr.RepositoryException
    • removePackage

      void removePackage(org.apache.jackrabbit.vault.packaging.JcrPackageManager jcrPackageManager, String groupName, String name, String version) throws javax.jcr.RepositoryException
      Deletes the package node from the repository. This does NOT uninstall the package, rather deletes the package node under /etc/packages/[package-group]
      Parameters:
      jcrPackageManager - JcrPackageManager object
      groupName - package group name
      name - package name
      version - package version
      Throws:
      javax.jcr.RepositoryException
    • createPackageFromPathFilterSets

      org.apache.jackrabbit.vault.packaging.JcrPackage createPackageFromPathFilterSets(Collection<org.apache.jackrabbit.vault.fs.api.PathFilterSet> pathFilterSets, javax.jcr.Session session, String groupName, String name, String version, PackageHelper.ConflictResolution conflictResolution, Map<String,String> packageDefinitionProperties) throws IOException, javax.jcr.RepositoryException
      Parameters:
      pathFilterSets - the pathFilterSets that define package
      session - JCR Session obj; must have access to create packages under /etc/packages
      groupName - package group name
      name - package name
      version - package version
      conflictResolution - determines how package creation will be handled in the event of an existing package of the same package group, package name, and version class
      packageDefinitionProperties - properties that will be added to the package definition
      Returns:
      the jcr package that was created, or null
      Throws:
      IOException
      javax.jcr.RepositoryException
    • createPackage

      org.apache.jackrabbit.vault.packaging.JcrPackage createPackage(Collection<org.apache.sling.api.resource.Resource> resources, javax.jcr.Session session, String groupName, String name, String version, PackageHelper.ConflictResolution conflictResolution, Map<String,String> packageDefinitionProperties) throws IOException, javax.jcr.RepositoryException
      Parameters:
      resources - the resources to include in the package
      session - JCR Session obj; must have access to create packages under /etc/packages
      groupName - package group name
      name - package name
      version - package version
      conflictResolution - determines how package creation will be handled in the event of an existing package of the same package group, package name, and version class
      packageDefinitionProperties - properties that will be added to the package definition
      Returns:
      the jcr package that was created, or null
      Throws:
      IOException
      javax.jcr.RepositoryException
    • getContents

      List<String> getContents(org.apache.jackrabbit.vault.packaging.JcrPackage jcrPackage) throws IOException, javax.jcr.RepositoryException, org.apache.jackrabbit.vault.packaging.PackageException
      returns a list of the JCR resource paths includes in the built JcrPackage
      Parameters:
      jcrPackage - the jcr package
      Returns:
      a list of absolute (starting with /) paths of the JCR resources included in the package
      Throws:
      IOException
      javax.jcr.RepositoryException
      org.apache.jackrabbit.vault.packaging.PackageException
    • getSuccessJSON

      String getSuccessJSON(org.apache.jackrabbit.vault.packaging.JcrPackage jcrPackage) throws javax.jcr.RepositoryException
      Returns the JSON to return in the event of a successful packaging.
      Parameters:
      jcrPackage - the successfully created jcr package
      Returns:
      a string representation of JSON to write to response
      Throws:
      javax.jcr.RepositoryException
    • getPreviewJSON

      String getPreviewJSON(Collection<org.apache.sling.api.resource.Resource> resources)
      Returns the JSON to return reporting what the packager definition will include for filterSet roots.
      Parameters:
      resources - the resources that represent the filterSet roots
      Returns:
      a string representation of JSON to write to response
    • getPathFilterSetPreviewJSON

      String getPathFilterSetPreviewJSON(Collection<org.apache.jackrabbit.vault.fs.api.PathFilterSet> pathFilterSets)
      Returns the JSON to return reporting what the packager definition will include for the filterSets.
      Parameters:
      pathFilterSets - the pathFilterSets of the package
      Returns:
      a string representation of JSON to write to response
    • getErrorJSON

      String getErrorJSON(String msg)
      Returns the JSON to return in the event of an unsuccessful packaging.
      Parameters:
      msg - the error message to display
      Returns:
      a string representation of JSON to write to response
    • getPreviewJSONForPaths

      String getPreviewJSONForPaths(Collection<String> paths)
      Returns the JSON to return reporting what the packager definition will include for filterSet roots.
      Parameters:
      paths - the paths that represent the filterSet roots
      Returns:
      a string representation of JSON to write to response
    • createPackageForPaths

      org.apache.jackrabbit.vault.packaging.JcrPackage createPackageForPaths(Collection<String> paths, javax.jcr.Session session, String groupName, String name, String version, PackageHelper.ConflictResolution conflictResolution, Map<String,String> packageDefinitionProperties) throws IOException, javax.jcr.RepositoryException
      Parameters:
      paths - the resources to include in the package
      session - JCR Session obj; must have access to create packages under /etc/packages
      groupName - package group name
      name - package name
      version - package version
      conflictResolution - determines how package creation will be handled in the event of an existing package of the same package group, package name, and version class
      packageDefinitionProperties - properties that will be added to the package definition
      Returns:
      the jcr package that was created, or null
      Throws:
      IOException
      javax.jcr.RepositoryException