cancel
Showing results for 
Search instead for 
Did you mean: 

Abort in onUpdateNode()

hbf
Champ on-the-rise
Champ on-the-rise
Hi,

I've added a onUpdateNode behaviour to my node type. Under certain circumstances my code in onUpdateNote() needs to abort the update. Is it possible to abort the current transaction?

I see that onUpdateNode() does not throw exceptions which seems to indicate that the transaction cannot be aborted?

Many thanks,
Kaspar
2 REPLIES 2

kevinr
Star Contributor
Star Contributor
If you throw any AlfrescoRuntimeException (or derived) it will cause the txn to be aborted.

Kevin

hbf
Champ on-the-rise
Champ on-the-rise
  public void onUpdateNode(NodeRef nodeRef)
  {
    if (nodeService.exists(nodeRef))
    try {
      // …
    }
    catch (Exception e) {
      String msg = "onUpdateNode for property "+"" +" failed.";
      logger.fatal(msg);
      throw new AlfrescoRuntimeException(msg, e);
    }
  }
}

Works like a charm. Thanks a lot!