Try calling the MoveAsset method that belongs to this API:
https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/adobe/granite/asset/api/AssetManager.html#moveAs..., java.lang.String)
Parameters:
assetPath - Absolute path of the asset to be moved
destAbsPath - Absolute path at with asset is to be moved
for destAbsPath - specify the new name of the Asset.
To learn how to use the granite AssetManager API - see this article:
https://helpx.adobe.com/experience-manager/using/graniteAPI.html (tested on AEM 6)
Views
Replies
Total Likes
Try calling the MoveAsset method that belongs to this API:
https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/adobe/granite/asset/api/AssetManager.html#moveAs..., java.lang.String)
Parameters:
assetPath - Absolute path of the asset to be moved
destAbsPath - Absolute path at with asset is to be moved
for destAbsPath - specify the new name of the Asset.
To learn how to use the granite AssetManager API - see this article:
https://helpx.adobe.com/experience-manager/using/graniteAPI.html (tested on AEM 6)
Views
Replies
Total Likes
smacdonald2008 wrote...
Try calling the MoveAsset method that belongs to this API:
https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/adobe/granite/asset/api/AssetManager.html#moveAs..., java.lang.String)
Parameters:
assetPath - Absolute path of the asset to be moved
destAbsPath - Absolute path at with asset is to be moved
for destAbsPath - specify the new name of the Asset.
To learn how to use the granite AssetManager API - see this article:
https://helpx.adobe.com/experience-manager/using/graniteAPI.html (tested on AEM 6)
Thank you Scott
Reference link to show one more use of AssetManager :- https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
smacdonald2008 Do AssetManager.moveAsset() method update the asset references as well in all the content or do we need to specifically handle it by writing custom code? When using "Move" option from author instance in Assets, it does update the content references of that particular asset which is moved, so wanted to confirm does API handle it automatically as well?
If you mean does it update in all pages referencing it - the answer is no. That is -- if you have a page referencing an asset in the DAM and you change the name - the reference in the page is not updated,
I am actually trying to figure what AEM uses internally when "Move" option is used from Assets UI. When the author Move an asset from Assets UI to a new destination, then all the pages where that asset was referenced, are automatically updated by AEM with the new destination path of the Asset. I need to do this Move from through a script, so thought of confirming if any API is there, which does update the references automatically or will I have to run queries to find all references and then update those references manually.
You can use CopyMoveCommandBuilder.java from package "com.day.cq.wcm.command.api" on 6.4.
e.g. :
@Reference
CommandBuilderFactory commandBuilderFactory;
CopyMoveCommandBuilder copyMoveCommandBuilder= commandBuilderFactory.createCommandBuilder(CopyMoveCommandBuilder.class).withCopy(false);
CopyMoveCommandPathArgument copyMoveCmdPathArg =
(CopyMoveCommandPathArgument) copyMoveCommandBuilder.createPathArgumentBuilder()
.withSrcPath(srcPath)
.withDstPath(dstPath)
.withAdjustRefPaths(adjustRefs)
.withPublishPaths(publishRefs)
.build();
copyMoveCommandBuilder.withResourceResolver(resolver)
.withAssetReferenceResolver(assetRefResolver)
.withRetrieveAllRefs(true).withShallow(true)
.withCheckIntegrity(true).withBeforeName(before)
.withPathArgument(copyMoveCmdPathArg);
}
Command cmd = copyMoveCommandBuilder.build();
CopyMoveCommandResult result = (CopyMoveCommandResult)cmd.execute();
You need collect all the references and provide to this.
asset reference resolver is null and
throws exception in commandbuilder
Is there a solution to this?
All the links are expired. Is there an endpoint in the HTTP API to change asset name? Or is it possible to access the granite AssetManager API via things like postman?
Views
Replies
Total Likes