Hi All,
We are trying to move asset from folder A to folder B , as folder B already contains the asset of same name so we need to update /create the version .
But in current scenario it is replacing the asset rather then creating the version.
Did anyone implemented version creation while moving the asset?
Thanks
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @kautuk_sahni ,
We created the custom process using asset version manager to achieve the same.
Thanks
You can try using workflow and building custom workflow steps.
Use com.day.cq.dam.api.asset.Asset API to retrieve the existing asset
Use com.day.cq.dam.api.VersionManager API to create a new version
Use com.day.cq.dam.api.services.move API to move the asset to the target folder
Hi @Himanshu_Jain ,
Can check the following steps:
Check Versioning Support: Ensure that your file management system or version control system supports versioning of files. Many modern document management systems and version control systems offer this feature out of the box.
Move the Asset: Move the asset from folder A to folder B using the appropriate functionality provided by your file management system. This may involve using a "Move" or "Copy" operation, depending on how your system handles file movements.
Check for Existing Asset in Folder B: Before moving the asset, check if an asset with the same name already exists in folder B. If it does, determine whether it has any associated versions.
Create a New Version: If an asset with the same name already exists in folder B and versioning is supported, create a new version of the asset rather than replacing it outright. This may involve invoking a specific command or API provided by your file management system to create a new version of the asset.
Update Metadata: If your system supports metadata for assets, update any relevant metadata to reflect the new version of the asset and its associated history.
Notify Stakeholders: Notify relevant stakeholders about the asset movement and the creation of a new version, if applicable. This helps ensure transparency and awareness of changes.
Test and Validate: After moving the asset and creating a new version, test and validate that everything is working as expected. Make sure that links, references, and dependencies are updated correctly to point to the latest version of the asset.
Document the Versioning Process: Document the process for creating versions when moving assets between folders, including any specific steps or considerations that need to be taken into account.
Hi @HrishikeshKa ,
Have you implemented this before ?
Did you check the OOTB behavior in AEMasCS for move operation? If yes , kindly let us know are you able to create the version of asset while moving.
Thanks
Hi @Himanshu_Jain ,
1. Delete the existing asset on the target folder first
2. Create a version of the asset to be moved
3. Move the asset to the target folder
Considering you will have all the necessary updates on the asset you intend to move, there would be no change in metadata.
I haven't implemented such a use case, but you can give it a try and see if it works. You can write a workflow step or servlet and play around with the below code sample code
String sourcePath = "/content/dam/source/wal.jpg";
String destinationPath = "/content/dam/destination/wal.jpg";
AssetManager assetManager = request.getResourceResolver().adaptTo(AssetManager.class);
Session session = request.getResourceResolver().adaptTo(Session.class);
if (assetManager != null && session != null) {
Asset asset = assetManager.getAsset(destinationPath);
if (asset != null) {
// Asset with the same name exists, create a version
VersionManager versionManager = session.getWorkspace().getVersionManager();
versionManager.checkpoint(destinationPath);
// Now move the asset from the source to the destination
assetManager.moveAsset(sourcePath, destinationPath);
response.getWriter().write("Asset moved and versioned successfully.");
} else {
// No asset with the same name exists, proceed with move
assetManager.moveAsset(sourcePath, destinationPath);
response.getWriter().write("Asset moved successfully.");
}
@Himanshu_Jain Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
Hi @kautuk_sahni ,
We created the custom process using asset version manager to achieve the same.
Thanks
Views
Likes
Replies
Views
Like
Replies