ALF-12866: WebDAV in-memory locking. Exclusive lock should be unlocked only by owner.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@34174 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2012-02-22 17:36:30 +00:00
parent bb1ffbd967
commit 8534a6e2b9

View File

@@ -151,21 +151,32 @@ public class UnlockMethod extends WebDAVMethod
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT); m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
removeNoContentAspect(nodeRef); removeNoContentAspect(nodeRef);
} }
else if (lockInfo.isExclusive() /* && user is lock-owner */) else if (lockInfo.isExclusive())
{
String currentUser = getAuthenticationService().getCurrentUserName();
if (currentUser.equals(lockInfo.getOwner()))
{ {
getLockStore().remove(nodeRef); getLockStore().remove(nodeRef);
// Indicate that the unlock was successful // Indicate that the unlock was successful
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT); m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
removeNoContentAspect(nodeRef); removeNoContentAspect(nodeRef);
// DEBUG
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug("Unlock token=" + getLockToken() + " Successful"); logger.debug("Unlock token=" + getLockToken() + " Successful");
} }
} }
else
{
if (logger.isDebugEnabled())
{
logger.debug("Unlock token=" + getLockToken() + " Not lock owner");
}
// Node is not locked
throw new WebDAVServerException(HttpServletResponse.SC_PRECONDITION_FAILED);
}
}
else if (lockInfo.isShared()) else if (lockInfo.isShared())
{ {
Set<String> sharedLocks = lockInfo.getSharedLockTokens(); Set<String> sharedLocks = lockInfo.getSharedLockTokens();