mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.1.N (5.1.1) to HEAD (5.2)
122553 aleahu: Merged 5.0.N (5.0.4) to 5.1.N (5.1.1) 122494 amorarasu: Merged V4.2-BUG-FIX (4.2.7) to 5.0.N (5.0.4) 122434 rneamtu: Merged V4.2.6 (4.2.6) to V4.2-BUG-FIX (4.2.7) 122333 amorarasu: Merged DEV to V4.2.6 (4.2.6) 121922 122190 122271 122292 amorarasu: MNT-13739: Site consumers are able to lock documents (they did not create) via WebDAV - Went back to using the secured lock service - Unlock resource after MOVE only if the it was locked git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@123676 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
<bean id="webDAVLockService" class="org.alfresco.repo.webdav.WebDAVLockServiceImpl">
|
<bean id="webDAVLockService" class="org.alfresco.repo.webdav.WebDAVLockServiceImpl">
|
||||||
<property name="lockService">
|
<property name="lockService">
|
||||||
<!-- TODO: change from LockService to lockService to be reviewed -->
|
<ref bean="LockService" />
|
||||||
<ref bean="lockService" />
|
|
||||||
</property>
|
</property>
|
||||||
<property name="nodeService">
|
<property name="nodeService">
|
||||||
<ref bean="NodeService" />
|
<ref bean="NodeService" />
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
* Copyright (C) 2005-2016 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -23,7 +23,8 @@ import java.util.List;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||||
@@ -31,9 +32,6 @@ import org.alfresco.service.cmr.repository.ContentReader;
|
|||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.dom4j.DocumentHelper;
|
|
||||||
import org.dom4j.io.XMLWriter;
|
|
||||||
import org.xml.sax.Attributes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the WebDAV MOVE method
|
* Implements the WebDAV MOVE method
|
||||||
@@ -192,9 +190,10 @@ public class MoveMethod extends HierarchicalMethod
|
|||||||
throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
|
throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LockInfo lockInfo = null;
|
||||||
if (isMove)
|
if (isMove)
|
||||||
{
|
{
|
||||||
checkNode(sourceFileInfo);
|
lockInfo = checkNode(sourceFileInfo);
|
||||||
}
|
}
|
||||||
// ALF-7079 fix, if destination exists then its content is updated with source content and source is deleted if
|
// ALF-7079 fix, if destination exists then its content is updated with source content and source is deleted if
|
||||||
// this is a move
|
// this is a move
|
||||||
@@ -210,7 +209,7 @@ public class MoveMethod extends HierarchicalMethod
|
|||||||
// don't delete source that is node with version history
|
// don't delete source that is node with version history
|
||||||
fileFolderService.setHidden(sourceNodeRef, true);
|
fileFolderService.setHidden(sourceNodeRef, true);
|
||||||
// As per the WebDAV spec, we make sure the node is unlocked once moved
|
// As per the WebDAV spec, we make sure the node is unlocked once moved
|
||||||
getDAVHelper().getLockService().unlock(sourceNodeRef);
|
unlock(sourceNodeRef, lockInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -243,7 +242,7 @@ public class MoveMethod extends HierarchicalMethod
|
|||||||
fileFolderService.setHidden(sourceNodeRef, true);
|
fileFolderService.setHidden(sourceNodeRef, true);
|
||||||
|
|
||||||
// As per the WebDAV spec, we make sure the node is unlocked once moved
|
// As per the WebDAV spec, we make sure the node is unlocked once moved
|
||||||
getDAVHelper().getLockService().unlock(sourceNodeRef);
|
unlock(sourceNodeRef, lockInfo);
|
||||||
}
|
}
|
||||||
else if (sourceParentNodeRef.equals(destParentNodeRef))
|
else if (sourceParentNodeRef.equals(destParentNodeRef))
|
||||||
{
|
{
|
||||||
@@ -268,7 +267,7 @@ public class MoveMethod extends HierarchicalMethod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// As per the WebDAV spec, we make sure the node is unlocked once moved
|
// As per the WebDAV spec, we make sure the node is unlocked once moved
|
||||||
getDAVHelper().getLockService().unlock(sourceNodeRef);
|
unlock(sourceNodeRef, lockInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -287,7 +286,7 @@ public class MoveMethod extends HierarchicalMethod
|
|||||||
fileFolderService.moveFrom(sourceNodeRef, sourceParentNodeRef, destParentNodeRef, name);
|
fileFolderService.moveFrom(sourceNodeRef, sourceParentNodeRef, destParentNodeRef, name);
|
||||||
|
|
||||||
// As per the WebDAV spec, we make sure the node is unlocked once moved
|
// As per the WebDAV spec, we make sure the node is unlocked once moved
|
||||||
getDAVHelper().getLockService().unlock(sourceNodeRef);
|
unlock(sourceNodeRef, lockInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,4 +310,31 @@ public class MoveMethod extends HierarchicalMethod
|
|||||||
contentWriter.putContent(reader);
|
contentWriter.putContent(reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlock only if the node was locked in the first place.
|
||||||
|
*/
|
||||||
|
private void unlock(final NodeRef nodeRef, LockInfo lockInfo)
|
||||||
|
{
|
||||||
|
if (lockInfo != null && lockInfo.isLocked())
|
||||||
|
{
|
||||||
|
if (lockInfo.isExpired())
|
||||||
|
{
|
||||||
|
// If the lock expired unlock as system user
|
||||||
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
|
{
|
||||||
|
public Void doWork() throws Exception
|
||||||
|
{
|
||||||
|
getDAVHelper().getLockService().unlock(nodeRef);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
}
|
||||||
|
// else unlock as current user
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getDAVHelper().getLockService().unlock(nodeRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user