Class ResourceHelper
java.lang.Object
org.apache.sling.discovery.commons.providers.util.ResourceHelper
Some helper methods surrounding resources
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
deleteResource
(org.apache.sling.api.resource.ResourceResolver resourceResolver, String path) static org.apache.sling.api.resource.Resource
getOrCreateResource
(org.apache.sling.api.resource.ResourceResolver resourceResolver, String path) static StringBuilder
getPropertiesForLogging
(org.apache.sling.api.resource.Resource resource) Compile a string builder containing the properties of a resource - used for loggingstatic void
moveResource
(org.apache.sling.api.resource.Resource res, String path) Move resource to given path.
-
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 resourcepath
- Target path- Throws:
org.apache.sling.api.resource.PersistenceException
-