Package org.apache.sling.discovery.commons.providers.util

# Class ResourceHelper

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

public class ResourceHelper extends Object
Some helper methods surrounding resources

## Constructor Summary

Constructors
Constructor
Description
`ResourceHelper()`

## Method Summary

Modifier and Type
Method
Description
`static 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 logging
`static void`
`moveResource(org.apache.sling.api.resource.Resource res, String path)`
Move resource to given path.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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`