Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Identifying dam event of copy

Avatar

Level 1

Hello to everyone 

 

I'm facing a problem when i try to identify when dam events my requirement is that when an asset is being copied, moved or created we need to add a new property into the metadata of that asset, the method that i have is the next one, this method is in a class that implements EventHandler, DAMEventService.

public void handleEvent(Event event) {

DamEvent damEvent = DamEvent.fromEvent(event);

LOGGER.debug("********** EventType=" + damEvent.getType() + " === " + damEvent.getAssetPath());

/* Use case when Creating Assets and Versioning Assets after DAM Update Asset Workflow finished processing */
if(DamEvent.Type.DAM_UPDATE_ASSET_WORKFLOW_COMPLETED == damEvent.getType() ||
/* Use case when Moving and Copying Assets after DAM Update Asset Workflow finished processing */
DamEvent.Type.DAM_METADATA_WRITEBACK_WORKFLOW_COMPLETED == damEvent.getType() ||
DamEvent.Type.ASSET_CREATED == damEvent.getType() ||
DamEvent.Type.ASSET_MOVED == damEvent.getType() ||
DamEvent.Type.VERSIONED == damEvent.getType()){

this.callProcessNodeFromPath(damEvent);

}

}

the workflows events are used to identify when an asset is begin uploaded and it was processed by DAM Update Asset workflow, but there is not a specific case for copy so I add create but that create a new problem, because asset_created is also trigger when an asset is uploaded and that is a problem because my listener and the workflow is trying to write the metadata properties at the same time and I get an exception.

 

javax.jcr.InvalidItemStateException: OakState0001: Unresolved conflicts in /content/dam/path/imagename.jpg/jcr:content/metadata
 
my method to write the metadata is the nextone
metadataNode.setProperty(metadata_field, Value);
session.save();

if I delete the ASSET_CREATED everything works fine but that leaves out of the scope the copied and this is required in my development.

I also try a refresh on my session but and it didn't work and that would only solve the problem with two classes writing at the same time but not my problem identifying the copy case.

so my question are 

 

  • is there a way to detect that an asset is being copied without using the asset_created flag?
  • do you know a different way to solve this problem
  • anyone has face a similar problem that could help me?

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @arturoar ,

 

One way would be that instead of creating a handler, you can customize the DAM update Asset workflow model to add custom process. You can add another process to add the custom property once the asset workflow completes its work.

Notably, The default workflow DAM Asset Update is no longer available in Asset as a cloud Service, in case if there is any future plan to use.

 

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/assets/assets-cloud-changes...

BTW, it is always recommended to have either a listener or workflow configured on a node else synchronization problem might occur.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @arturoar ,

 

One way would be that instead of creating a handler, you can customize the DAM update Asset workflow model to add custom process. You can add another process to add the custom property once the asset workflow completes its work.

Notably, The default workflow DAM Asset Update is no longer available in Asset as a cloud Service, in case if there is any future plan to use.

 

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/assets/assets-cloud-changes...

BTW, it is always recommended to have either a listener or workflow configured on a node else synchronization problem might occur.

Avatar

Level 1
But the copy is not begin processed by the DAM Asset Update, that one of my main problems and when I copied an asset I need all the renditions on the asset but those are not ready and I haven't found a way to identify when the copy process finished and all the information is complete on the asset. do you have any suggestions?