Interface AssetManager


@ProviderType public interface AssetManager
AssetManager is a primary interface which provides methods to manage Assets.

AssetManager is created by adapting ResourceResolver to AssetManager

     AssetManager assetManager = resolver.adaptTo(AssetManager.class);
 
  • Method Details

    • createAsset

      Asset createAsset(String path)
      Creates a new Asset at the given path.
      Parameters:
      path - Absolute path at which asset is to be created.
      Returns:
      The newly created asset
      Throws:
      AssetException - If error occurs while creating an Asset or if Asset already exists
    • getAsset

      Asset getAsset(String assetPath)
      Get Asset at the given assetPath.
      Parameters:
      assetPath - An absolute path of the Asset
      Returns:
      Asset if found otherwise null
      Throws:
      AssetException - If an error occurs trying to load the Asset object
    • getAssetByIdentifier

      Asset getAssetByIdentifier(String id)
      Get Asset specified by the given Identifier.
      Parameters:
      id - Asset identifier
      Returns:
      Asset if found otherwise null
      Throws:
      AssetException - If an error occurs trying to load the Asset object
    • assetExists

      boolean assetExists(String assetPath)
      Checks for the existence of an Asset.
      Parameters:
      assetPath - Absolute path of the asset to be checked
      Returns:
      true if the Asset exist at the specified path
    • removeAsset

      void removeAsset(String assetPath)
      Remove Asset if exists.
      Parameters:
      assetPath - Absolute path of the asset to be removed
      Throws:
      AssetException - If asset does not exist or cant be removed
    • copyAsset

      void copyAsset(String assetPath, String destAbsPath)
      Copy Asset to the desired location.
           
           Eg:
           //To copy Asset from /document/somedocument.pdf to /document/legal with name document.pdf
           AssetManager#copy("/document/somedocument.pdf", "/document/legal/document.pdf");
           
       
      Parameters:
      assetPath - Absolute path of the asset to be copied
      destAbsPath - Absolute path at with asset is to be copied
      Throws:
      AssetException - If an error occurs while copying
    • moveAsset

      void moveAsset(String assetPath, String destAbsPath)
      Move Asset to the desired location.
           
           Eg:
           // To move Asset from /document/somedocument.pdf to /document/legal with name document.pdf
           AssetManager#move("/document/somedocument.pdf", "/document/legal/document.pdf");
           
       
      Parameters:
      assetPath - Absolute path of the asset to be moved
      destAbsPath - Absolute path at with asset is to be moved
      Throws:
      AssetException - If an error occurs while moving