Interface ResourceManager


@ConsumerType public interface ResourceManager
The ResourceManager defines the API which might be asked to find, copy, move and delete specific resources.

Implementors should ensure that a ResourceManager can be retrieved adapting a SlingHttpServletRequest by implementing an AdapterFactory.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    copy(Resource resource, String destUri, int depth)
    Copies all properties and resources of the implementor to the destUri.
    find(Resource resource, String query)
    Returns the query result from the provided query statement as a List.
    boolean
    move(Resource resource, String destUri)
    Moves all properties and resources of the implementor to the destUri.
  • Method Details

    • copy

      boolean copy(Resource resource, String destUri, int depth) throws UnsupportedOperationException, RequestException, RestException
      Copies all properties and resources of the implementor to the destUri. The method expects the destUri to be a non-remote URI, absolute, normalized and within the same name space as the resource.

      The method should throw a RequestException with a HTTP status 403 if the destination is not part of the resources ResourceProvider name space. If the parent resource of the destination does not exist the method should throw a RequestException with the HTTP status code 412. In case an error occurs while copying one of the resources child elements a RequestException with HTTP status code 207 pointing to the failing resource should be thrown.

      Parameters:
      resource - Resource to copy
      destUri - Destination URI to copy resource to
      depth - Depth value indicating the depth of the copy. A value of -1 is equal to infinite, a value of 0 indicates that only the resource itself and its properties should be copied but no children.
      Returns:
      true if destination has been created, false if it has been overwritten.
      Throws:
      UnsupportedOperationException - If the operation is not supported for the resource
      RequestException - if a precondition for the operation is not met
      RestException - if an error occurs during the operation
    • move

      boolean move(Resource resource, String destUri) throws UnsupportedOperationException, RequestException, RestException
      Moves all properties and resources of the implementor to the destUri. The method expects the destUri to be a non-remote URI, absolute, normalized and within the same name space as the resource. The method should throw a RequestException with a HTTP status 403 if the destination is not part of the resources ResourceProvider name space. If the parent resource of the destination does not exist the method should throw a RequestException with the HTTP status code 412. In case an error occurs while copying one of the resources child elements a RequestException with HTTP status code 207 pointing to the failing resource should be thrown.
      Parameters:
      resource - Resource to move
      destUri - Destination URI to move resource to
      Returns:
      true if destination has been created, false if it has been overwritten.
      Throws:
      UnsupportedOperationException - If the operation is not supported for the resource
      RequestException - if a precondition for the operation is not met
      RestException - if an error occurs during the operation
    • find

      Returns the query result from the provided query statement as a List.
      Parameters:
      resource - Base resource. Is used as a starting point in the tree to search from.
      query - Query statement
      Returns:
      A List of resources found matching the query
      Throws:
      UnsupportedOperationException - If the operation is not supported for the resource
      RequestException - if a precondition for the operation is not met
      RestException - if an error occurs during the search