Identifying dam event of copy
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.
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?