Hi,I'm writing a backend web script to lock/unlock nodes.Before trying to lock or unlock a given node, I want to check the current lock status.The lockService.getLockStatus(nodeRef) does NOT return the actual state of the node.For testing, I'm locking a file from Share interface (edit offline), and the Web Script returns NO_LOCK.After some time, it may return LOCK (or not…..).I think I must have missed or misunderstand something …..Could you please advise ?my code:
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
{
try
{
// —- get node ref —-
String reference = "workspace/SpacesStore/company_home/" + model.get("nodePath");
nodeRef = repository.findNodeRef("path", reference.split("/"));
if (nodeRef == null)
{
logger.info(ERR_MSG_NODEREF_PATH);
throw new WebScriptException(ERR_CODE_NODEREF_PATH, ERR_MSG_NODEREF_PATH);
}
logger.info("Done: " + nodeRef);
AuthenticationUtil.RunAsWork<Object> work = new AuthenticationUtil.RunAsWork<Object>()
{
public Object doWork() throws Exception
{
LockStatus lockStatus = lockService.getLockStatus(nodeRef, AuthenticationUtil.getRunAsUser());
if (LockStatus.LOCKED.equals(lockStatus))
logger.debug("— node already locked");
else
{
logger.debug("— locking node…");
LockType lockType = null;
lockService.lock(nodeRef, lockType.READ_ONLY_LOCK);
logger.debug("— done.");
}
return(lockStatus);
}
};
}
catch(WebScriptException e)
{
logger.debug("Error message:" + e.getMessage());
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND,
e.getMessage());
}
return model;
}
Thanks for your help !Vincent