java.lang.Object
org.apache.sling.discovery.commons.providers.util.ResourceHelper

public class ResourceHelper extends Object
Some helper methods surrounding resources
  • Constructor Details

    • ResourceHelper

      public ResourceHelper()
  • Method Details

    • getOrCreateResource

      public static org.apache.sling.api.resource.Resource getOrCreateResource(org.apache.sling.api.resource.ResourceResolver resourceResolver, String path) throws org.apache.sling.api.resource.PersistenceException
      Throws:
      org.apache.sling.api.resource.PersistenceException
    • deleteResource

      public static boolean deleteResource(org.apache.sling.api.resource.ResourceResolver resourceResolver, String path) throws org.apache.sling.api.resource.PersistenceException
      Throws:
      org.apache.sling.api.resource.PersistenceException
    • getPropertiesForLogging

      public static StringBuilder getPropertiesForLogging(org.apache.sling.api.resource.Resource resource)
      Compile a string builder containing the properties of a resource - used for logging
    • moveResource

      public static void moveResource(org.apache.sling.api.resource.Resource res, String path) throws org.apache.sling.api.resource.PersistenceException
      Move resource to given path. Try to do it optimized via JCR API. If JCR is not available, fallback to Sling Resource API.
      Parameters:
      res - Source resource
      path - Target path
      Throws:
      org.apache.sling.api.resource.PersistenceException