Package com.adobe.granite.asset.api
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 Summary
Modifier and TypeMethodDescriptionbooleanassetExists(String assetPath) Checks for the existence of anAsset.voidCopy Asset to the desired location.createAsset(String path) Creates a newAssetat the givenpath.GetAssetat the givenassetPath.GetAssetspecified by the givenIdentifier.voidMove Asset to the desired location.voidremoveAsset(String assetPath) RemoveAssetif exists.
-
Method Details
-
createAsset
Creates a newAssetat the givenpath.- 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
GetAssetat the givenassetPath.- 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
GetAssetspecified by the givenIdentifier.- Parameters:
id- Asset identifier- Returns:
- Asset if found otherwise null
- Throws:
AssetException- If an error occurs trying to load the Asset object
-
assetExists
Checks for the existence of anAsset.- Parameters:
assetPath- Absolute path of the asset to be checked- Returns:
- true if the Asset exist at the specified path
-
removeAsset
RemoveAssetif exists.- Parameters:
assetPath- Absolute path of the asset to be removed- Throws:
AssetException- If asset does not exist or cant be removed
-
copyAsset
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 copieddestAbsPath- Absolute path at with asset is to be copied- Throws:
AssetException- If an error occurs while copying
-
moveAsset
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 moveddestAbsPath- Absolute path at with asset is to be moved- Throws:
AssetException- If an error occurs while moving
-