Merged HEAD-QA to HEAD (4.2) (including moving test classes into separate folders)

51903 to 54309 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54310 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Samuel Langlois
2013-08-20 17:17:31 +00:00
parent a91f6e2535
commit 788d3c9c89
777 changed files with 77820 additions and 23746 deletions

View File

@@ -27,6 +27,8 @@ import org.alfresco.service.cmr.lock.UnableToReleaseLockException;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.service.cmr.rule.RuleType;
/**
* Implements the WebDAV UNLOCK method
@@ -114,6 +116,27 @@ public class UnlockMethod extends WebDAVMethod
* @exception WebDAVServerException
*/
protected void executeImpl() throws WebDAVServerException
{
RuleService ruleService = getServiceRegistry().getRuleService();
try
{
// Temporarily disable update rules.
ruleService.disableRuleType(RuleType.UPDATE);
attemptUnlock();
}
finally
{
// Re-instate update rules.
ruleService.enableRuleType(RuleType.UPDATE);
}
}
/**
* The main unlock implementation.
*
* @throws WebDAVServerException
*/
protected void attemptUnlock() throws WebDAVServerException
{
if (logger.isDebugEnabled())
{
@@ -151,87 +174,80 @@ public class UnlockMethod extends WebDAVMethod
throw new WebDAVServerException(HttpServletResponse.SC_PRECONDITION_FAILED);
}
lockInfo.getRWLock().writeLock().lock();
try
if (!lockInfo.isLocked())
{
if (!lockInfo.isLocked())
if (logger.isDebugEnabled())
{
if (logger.isDebugEnabled())
{
logger.debug("Unlock token=" + getLockToken() + " Not locked");
}
// Node is not locked
throw new WebDAVServerException(HttpServletResponse.SC_PRECONDITION_FAILED);
logger.debug("Unlock token=" + getLockToken() + " Not locked");
}
else if (lockInfo.isExpired())
// Node is not locked
throw new WebDAVServerException(HttpServletResponse.SC_PRECONDITION_FAILED);
}
else if (lockInfo.isExpired())
{
if (logger.isDebugEnabled())
{
if (logger.isDebugEnabled())
logger.debug("Unlock token=" + getLockToken() + " Lock expired");
}
// Return a success status
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
removeNoContentAspect(nodeRef);
}
else if (lockInfo.isExclusive())
{
String currentUser = getAuthenticationService().getCurrentUserName();
if (currentUser.equals(lockInfo.getOwner()))
{
try
{
logger.debug("Unlock token=" + getLockToken() + " Lock expired");
getDAVLockService().unlock(nodeRef);
}
// Return a success status
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
catch (UnableToReleaseLockException e)
{
throw new WebDAVServerException(HttpServletResponse.SC_PRECONDITION_FAILED, e);
}
// Indicate that the unlock was successful
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
removeNoContentAspect(nodeRef);
}
else if (lockInfo.isExclusive())
{
String currentUser = getAuthenticationService().getCurrentUserName();
if (currentUser.equals(lockInfo.getOwner()))
if (logger.isDebugEnabled())
{
try
{
getDAVLockService().unlock(nodeRef);
}
catch (UnableToReleaseLockException e)
{
throw new WebDAVServerException(HttpServletResponse.SC_PRECONDITION_FAILED, e);
}
// Indicate that the unlock was successful
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
removeNoContentAspect(nodeRef);
if (logger.isDebugEnabled())
{
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())
{
Set<String> sharedLocks = lockInfo.getSharedLockTokens();
if (sharedLocks.contains(m_strLockToken))
{
sharedLocks.remove(m_strLockToken);
// Indicate that the unlock was successful
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
removeNoContentAspect(nodeRef);
// DEBUG
if (logger.isDebugEnabled())
{
logger.debug("Unlock token=" + getLockToken() + " Successful");
}
logger.debug("Unlock token=" + getLockToken() + " Successful");
}
}
else
{
throw new IllegalStateException("Invalid LockInfo state: " + lockInfo);
if (logger.isDebugEnabled())
{
logger.debug("Unlock token=" + getLockToken() + " Not lock owner");
}
// Node is not locked
throw new WebDAVServerException(HttpServletResponse.SC_PRECONDITION_FAILED);
}
}
finally
else if (lockInfo.isShared())
{
lockInfo.getRWLock().writeLock().unlock();
Set<String> sharedLocks = lockInfo.getSharedLockTokens();
if (sharedLocks.contains(m_strLockToken))
{
sharedLocks.remove(m_strLockToken);
// Indicate that the unlock was successful
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
removeNoContentAspect(nodeRef);
// DEBUG
if (logger.isDebugEnabled())
{
logger.debug("Unlock token=" + getLockToken() + " Successful");
}
}
}
else
{
throw new IllegalStateException("Invalid LockInfo state: " + lockInfo);
}
}