Expand my Community achievements bar.

Trash Can layer for AEM Assets

Avatar

Level 3

Hi,

We have a requirement to implement a trash can layer for AEM Assets. This needs to be functional from both Touch UI and AEM Desktop App.

When users delete any assets(either from Touch UI or Desktop App), assets should be moved to a trash layer/folder in DAM(Copy to trash layer and delete asset in the current location). Our DAM users have delete permissions given on all asset folders.

Is there any recommended way to achieve this for both Touch UI and Desktop App? Appreciate your help!

Thanks,

Ramya

14 Replies

Avatar

Employee Advisor

Hi,

as Scott already mentioned that's something one would implement as workflow and use the Sling API to move the resource tree of the asset to a different location.

On the other hand be aware that there might be versions already available for an asset, so technically you could use this versioning information to restore the asset if needed. That's probably a bit harder to implement (you don't have a specific "trash" folder etc) but something to consider.

Jörg

Avatar

Level 3

Hi Jörg & smacdonald2008​,

I used a workflow launcher to trigger a custom workflow process for 'Remove' event type on dam:Asset type, to copy the asset to the trash folder. But by the time this workflow process is executed, the asset is already deleted and I am getting a null pointer exception.

I guess there would be a similar error if I use an event listener.

Am I missing something?

Thanks for your help!

Ramya

Avatar

Level 10

Post a pic of your workflow model. Lets see if he can help improve it.

Avatar

Level 3

Hi smacdonald2008​,

Here are the worklfow launcher and workflow modal created. The workflow modal includes a process step which does copy of asset to trash folder in DAM. This workflow is triggered when any DAM users delete any assets in the DAM. The issue is that the assets gets deleted already before it is copied to the trash folder, since this workflow is triggered on Remove event type. Is there any other way to overcome this issue?

trashcan-workflow-launcher.PNG

workflow-modal-trashcan.PNG

Thanks,

Ramya

Avatar

Level 10

You need to redefine the Model. Make the model something like this:

1- Move Asset

2- Delete Asset

That way - the asset will be there when step 1 moves it. Run the WF on the Asset --

RunWFOnAsset.png

Avatar

Level 10

I am going to code this in a WF - if you want to move the asset to another folder (maybe a copy of the asset). Then  delete the original in the workflow.

Avatar

Employee Advisor

The problem is that the workflow is triggered after the asset has been already removed. At that time it simply does not exist anymore.

You cannot rely on the workflow trigger, but you need to activly trigger the workflow (instead of just deleting the asset). The easiest way is to remove the "delete" privilege for all users and change the "request for deletion" to your needs.

Jörg

Avatar

Level 3

Hi Jörg,

Thanks for your inputs! The issue is we cannot deny delete permissions on assets for these DAM users, since that would restrict lot of other Assets functionality for them(like deleting comments, share link, relate/unrelate etc).

We are expecting that when the users delete assets (either from UI or Desktop App), they should be moved to a trash folder. Handling this from the UI can probably be done by customizing the Delete button. But this seems to be a challenge when users use Desktop app to delete any assets.

Can we overlay the OOTB Delete servlet to achieve this?

Thanks,

Ramya

Avatar

Level 10

The solution is a workflow - step A for the payload - make a copy and move it the Trash folder and Step B is to delete the original payload. There is no need to modify the Delete button - not even sure how you would do that.

Therefore you would have your users run the workflow on the Asset when they want to delete it.

Avatar

Level 10

Here is the Model for  your use case - this will work.

Model.png

We are working on a HELPX Article for this use case. This is a really nice use case in terms of using a custom workflow step and the workflow APIs to achieve this. OOTB - there is no MOVE Asset step. Therefore -  how do you do it. The answer is you have to program a custom step that can get the InputStream of the Asset Payload and then create a new Asset in the Trash folder under /DAM/TRASH.  You can use the AssetManager API for this task.

Also - this made me realize that we need to explore the AEM Workflow APIs in a more detailed way. As a result -  we will be doing this month (FEB 2018) Ask the AEM Community Experts on this subject - sign up soon.

Article -- Scott's Digital Community: Modifying Digital Assets using Adobe Experience Manager Workflows

Avatar

Level 10

After testing - this is the model that works. Notice the last step - its Delete Node as opposed to Delete Asset (Delete Node deletes the asset). This workflow does exactly what you want. It moves the Asset to /DAM/Trash and then deletes the original asset.

Model.png

Notice that the asset is in Trash folder.

Trash.png

Avatar

Level 3

Hi smacdonald2008​,

Thanks for your reply and for working on this usecase.

The workflow with the above steps mentioned is not suitable for our requirement. Our DAM users can run this workflow to achieve this functionality, but our users are not expected to run any workflow. Also, this does not cover the usecase when users click on Delete button or delete assets from Desktop app. Since our DAM users will have delete permissions on assets, we need to move assets to trash folder whenever they click on Delete button in UI or whenever they delete from Desktop App. Moving to trash folder should automatically happen whenever users delete assets from DAM.

I have also explored using a workflow launcher, but that does not work either(See my above posts).

Thanks,

Ramya

Avatar

Level 10

You should have your users that can delete asset belong to a workflow user group so they can invoke WFs.  As Far as the Delete button, you need to document to your users to invoke the TrashAsset workflow to remove assets, not use the Delete button.

To delete assets using this WF - you need to have a user select the asset from the Asset view.

Asset.png

Select the Workflow button - not Delete button and select the specific workflow.

WFF.png

Once done, the Asset is placed into the Trash folder.

TrashFolderView.png

and the original asset is deleted.

This is the best way to achieve your requirements. Adobe does not recommend trying to reverse eng the Delete button, etc, This would not be supported if something broke. This is exactly why Workflows were added to the product. Use the tooling that is part of AEM.

Avatar

Employee Advisor

Hi,

if you need to work it via the Desktop App as well, the best way to deal with it is to talk to Adobe Support and see if and how it can be done. I am not an expert with the Desktop App.

Jörg