Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

337
Vistas
Alfresco Share Javascript API - check for race condition on document node

This should be a simple answer, and I would have thought quite a common issue although I've not found anything myself, hence the question!

Using Alfresco Share-side Javascript (in a script executed by a folder rule) I want to update a shared document by checking it out, updating and then checking in again. The whole process only takes milliseconds but it is in theory possible that this script might be executed by more than one user at the same time. However vanishingly small that possibility I still want to eliminate it. So I want to check to see if the document is locked, and if it is wait until it is free again. Basic transactional behaviour.

Using the Alfresco Javascript Console I've created this code that demonstrates what I am trying to do:

var n1 = search.findNode(document.nodeRef);

var l1 = n1.isLocked;
while(l1 == true){
    print("locked");
    java.lang.Thread.sleep(1000);
    var n2 = search.findNode(n1.nodeRef);
    var l1 = n2.isLocked;
}

print("unlocked");

(Don't worry I don't loop indefinitely this is just an example!).

My problem is that if the isLocked property is true once the script starts executing then it never seems to become false. I've tried various ways of writing the JS code (including just checking document.isLocked every iteration) but it seems that the script's process never seems to register that the lock has disappeared. If I unlock the document half way through execution then the script just carries on waiting. If I run the script again it sees that the file is now unlocked.

My question is, how do I resolve this, and is it even possible? I know that Alfresco JS is Rhino Javascript, so might the problem be something to do with the underlying Java process?

I can of course simply fail the script and stop the action by throwing an exception if the document is locked (or at least I hope I can - I've not tried that yet!), but that doesn't exactly give a great user experience.

Any help or gleeful pointing out a schoolboy error appreciated!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda