Alfresco tip: checking if a node is (b)locked

Once a new document or version has been updated in Alfresco, some background processes are launched asynchronously. These processes generate the preview node, the thumbnail one and some other internal resources. Alfresco is locking original document node for this operations.

If we’re developing an action or behavior working with nodes which require a locking (as for delete association operations), a previous single locking condition can be included.

// Lock node to test if is out there any other 
// transaction locking it (rendition, transformation...)
try {
    lockService.lock(actionedUponNodeRef, LockType.READ_ONLY_LOCK);
} catch (Throwable t) {
    throw new RuntimeException("NodeRef is locked by another process", t);

So we can abort the process and tell the user to retry the operation later, once the rendition and interpretation operations on the node have been finished.

Someone has just asked me: Why not to use lockService.getLockStatus(…) instead of? Because Alfresco does not lock nodes on every exclusive operation but to perform a lock on a node exclusive access it’s required.



Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )


Conectando a %s