Class PackageUtil


  • public class PackageUtil
    extends Object
    Helper methods for Package handling (VLT Package Manager)
    • Constructor Detail

      • PackageUtil

        public PackageUtil()
    • Method Detail

      • getPackageManager

        @Nonnull
        public static org.apache.jackrabbit.vault.packaging.JcrPackageManager getPackageManager​(@Nonnull
                                                                                                org.apache.jackrabbit.vault.packaging.Packaging packaging,
                                                                                                @Nonnull
                                                                                                org.apache.sling.api.SlingHttpServletRequest request)
                                                                                         throws javax.jcr.RepositoryException
        Retrieves a package manager for the JCR session.
        Throws:
        javax.jcr.RepositoryException
      • getPath

        public static String getPath​(org.apache.sling.api.SlingHttpServletRequest request)
      • getResource

        public static org.apache.sling.api.resource.Resource getResource​(org.apache.jackrabbit.vault.packaging.JcrPackageManager manager,
                                                                         org.apache.sling.api.SlingHttpServletRequest request,
                                                                         String path)
                                                                  throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getJcrPackage

        public static org.apache.jackrabbit.vault.packaging.JcrPackage getJcrPackage​(org.apache.jackrabbit.vault.packaging.JcrPackageManager manager,
                                                                                     String group,
                                                                                     String name)
                                                                              throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getJcrPackage

        public static org.apache.jackrabbit.vault.packaging.JcrPackage getJcrPackage​(org.apache.jackrabbit.vault.packaging.JcrPackageManager manager,
                                                                                     org.apache.sling.api.resource.Resource resource)
                                                                              throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getPackagePath

        public static String getPackagePath​(org.apache.jackrabbit.vault.packaging.JcrPackageManager pckgMgr,
                                            org.apache.jackrabbit.vault.packaging.JcrPackage pckg)
      • getPackageId

        @Nullable
        public static org.apache.jackrabbit.vault.packaging.PackageId getPackageId​(@Nullable
                                                                                   org.apache.jackrabbit.vault.packaging.JcrPackage pckg)
        Returns the PackageId; null in case of errors.
      • getViewType

        public static PackageUtil.ViewType getViewType​(com.composum.sling.core.BeanContext context,
                                                       org.apache.sling.api.SlingHttpServletRequest request,
                                                       String path)
      • getGroupPath

        @Nullable
        public static String getGroupPath​(@Nullable
                                          org.apache.jackrabbit.vault.packaging.JcrPackage pckg)
                                   throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getGroupPath

        @Nullable
        public static String getGroupPath​(@Nullable
                                          org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef)
      • isGroup

        public static boolean isGroup​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef,
                                      String group)
      • isName

        public static boolean isName​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef,
                                     String name)
      • isVersion

        public static boolean isVersion​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef,
                                        String version)
      • equals

        public static boolean equals​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef,
                                     String key,
                                     String value)
      • getFilename

        public static String getFilename​(org.apache.jackrabbit.vault.packaging.JcrPackage pckg)
      • getDownloadUrl

        public static String getDownloadUrl​(org.apache.jackrabbit.vault.packaging.JcrPackage pckg)
      • getDefAttr

        public static <T> T getDefAttr​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef,
                                       String key,
                                       T defaultValue)
      • getLastModified

        public static Calendar getLastModified​(org.apache.jackrabbit.vault.packaging.JcrPackage pckg)
      • setLastModified

        public static void setLastModified​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef,
                                           Calendar time)
      • setLastModified

        public static void setLastModified​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef)
      • getLastModifiedBy

        public static String getLastModifiedBy​(org.apache.jackrabbit.vault.packaging.JcrPackage pckg)
      • getCreated

        public static Calendar getCreated​(org.apache.jackrabbit.vault.packaging.JcrPackage pckg)
      • getCreatedBy

        public static String getCreatedBy​(org.apache.jackrabbit.vault.packaging.JcrPackage pckg)
      • getCoverage

        public static void getCoverage​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef,
                                       javax.jcr.Session session,
                                       org.apache.jackrabbit.vault.fs.api.ProgressTrackerListener listener)
      • getFilter

        public static org.apache.jackrabbit.vault.fs.api.WorkspaceFilter getFilter​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef)
                                                                            throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getFilterList

        public static List<org.apache.jackrabbit.vault.fs.api.PathFilterSet> getFilterList​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef)
                                                                                    throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getThumbnailPath

        public static String getThumbnailPath​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef)
                                       throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • setThumbnail

        public static void setThumbnail​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef,
                                        org.apache.sling.api.resource.ResourceResolver resolver,
                                        InputStream pngStream)
                                 throws org.apache.sling.api.resource.PersistenceException,
                                        javax.jcr.RepositoryException
        Throws:
        org.apache.sling.api.resource.PersistenceException
        javax.jcr.RepositoryException
      • getTreeNode

        public static TreeNode getTreeNode​(org.apache.jackrabbit.vault.packaging.JcrPackageManager manager,
                                           org.apache.sling.api.SlingHttpServletRequest request)
                                    throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • toJson

        public static void toJson​(@Nonnull
                                  com.google.gson.stream.JsonWriter writer,
                                  @Nonnull
                                  org.apache.jackrabbit.vault.packaging.JcrPackage jcrPackage,
                                  @Nullable
                                  Map<String,​Object> additionalAttributes)
                           throws javax.jcr.RepositoryException,
                                  IOException
        Throws:
        javax.jcr.RepositoryException
        IOException
      • toJson

        public static void toJson​(com.google.gson.stream.JsonWriter writer,
                                  org.apache.jackrabbit.vault.packaging.JcrPackageDefinition definition)
                           throws IOException
        Throws:
        IOException
      • packageToXMLResponse

        public static String packageToXMLResponse​(org.apache.jackrabbit.vault.packaging.JcrPackage jcrPackage)
                                           throws javax.jcr.RepositoryException
        Throws:
        javax.jcr.RepositoryException
      • getMultiProperty

        public static String[] getMultiProperty​(org.apache.jackrabbit.vault.packaging.JcrPackageDefinition pckgDef,
                                                String key)