I have a rather simple behaviour/policy implementation. When an aspect "signedDateAspect" is added to a document, check and set the value for the property "signedDate". The code (relevant part) is below.
public class SignedDateAspectPolicy implements NodeServicePolicies.OnAddAspectPolicy {
public void init() {
this.onAddAspectBehavior = new JavaBehaviour(this, "onAddAspect", NotificationFrequency.TRANSACTION_COMMIT);
this.policyComponent.bindClassBehaviour(NodeServicePolicies.OnAddAspectPolicy.QNAME,
MycContentModel.ASPECT_SIGNED_DATE, this.onAddAspectBehavior);
}
@Override
public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName) {
Serializable propSignedDate = this.nodeService.getProperty(nodeRef, MycContentModel.PROP_SIGNED_DATE);
if (propSignedDate == null) {
Date propModified = (Date) this.nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIED);
this.nodeService.setProperty(nodeRef, MycContentModel.PROP_SIGNED_DATE, propModified);
}
}
}
It works fine until a new version of the document is uploaded. Steps to replicate:
1. Upload a document - pass
2. Add the aspect - pass
3. Upload a new version - fail
The error in log is
Caused by: org.alfresco.service.cmr.repository.InvalidNodeRefException: Node does not exist: workspace://SpacesStore/e3a32cce-de90-4957-b026-7ef683e8a713 (status
tatus[id=12279changeTxnId=3cc18e2f-c628-40cd-9f71-640a86de9d39, dbTxnId=4550, deleted=true])
I had to add a check at the beginning of onAddAspect method.
if (!this.nodeService.exists(nodeRef)) {
return;
}
What is the node "workspace://SpacesStore/e3a32cce-de90-4957-b026-7ef683e8a713" that is created in this process? Why doesn't it exist (did it get deleted)? Could someone explain the inner working of how a new version is created in Alfresco? Thanks.