Hi all!I'm using alfresco 3.4.3 in linux…When a user creates a document that is numbered. To avoid duplication in numbering I have a counter and I'm using lockService as follows:(quite simply, I think!)import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.lock.LockType;
//…
private LockService lockService;
//…
if (counterRef != null)
{
// lock counter
boolean locked = false;
while (!locked)
{
try
{
lockService.lock(counterRef, LockType.WRITE_LOCK);
locked = true;
}
catch (Exception e)
{
try
{
wait(500);
}
catch (Exception ex)
{
}
}
}
// get the value
Integer count = (Integer)nodeService.getProperty(counterRef, CustomContentModel.PROP_OUTPUTNUMBER);
// add one
count++;
// save the value
nodeService.setProperty(counterRef, CustomContentModel.PROP_OUTPUTNUMBER, count);
// unlock counter
lockService.unlock(counterRef);
return count;
}
//…… so far users have created about 3,000 documents… FIVE of them with duplicated number… … I can't understand why!?!Is this the right way to use lockService?Am I missing something here?Is there a problem with lockserice in version 3.4.3?Thanks in advance,João