mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
68118: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud) 67153: Merged DEV to V4.2-BUG-FIX (4.2.3) 67111 : MNT-10873 : Renaming folders while editing documents using webdav and Windows 7 can lead to 0k (empty) documents created in the trash can. - Empty documents are not archived eny more if were created in response to LOCK webdav method. - Unit test was implemented. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@68405 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.webdav;
|
package org.alfresco.repo.webdav;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -322,7 +321,6 @@ public class LockMethod extends WebDAVMethod
|
|||||||
{
|
{
|
||||||
public String execute() throws Throwable
|
public String execute() throws Throwable
|
||||||
{
|
{
|
||||||
getNodeService().removeAspect(nodeRef, ContentModel.ASPECT_WEBDAV_NO_CONTENT);
|
|
||||||
getNodeService().deleteNode(nodeRef);
|
getNodeService().deleteNode(nodeRef);
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
|
@@ -26,6 +26,8 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
@@ -81,14 +83,11 @@ public class LockMethodTest
|
|||||||
* Types and properties used by the tests
|
* Types and properties used by the tests
|
||||||
*/
|
*/
|
||||||
private static final String CONTENT_1 = "This is some content";
|
private static final String CONTENT_1 = "This is some content";
|
||||||
private static final String TEST_STORE_IDENTIFIER = "test_store-" + System.currentTimeMillis();
|
private static final String TEST_FILE_NAME = "file" + GUID.generate();
|
||||||
private static final String TEST_FILE_NAME = "file";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data used by the tests
|
* Data used by the tests
|
||||||
*/
|
*/
|
||||||
private StoreRef storeRef;
|
|
||||||
private NodeRef rootNodeRef;
|
|
||||||
private NodeRef folderNodeRef;
|
private NodeRef folderNodeRef;
|
||||||
private NodeRef fileNodeRef;
|
private NodeRef fileNodeRef;
|
||||||
|
|
||||||
@@ -120,13 +119,7 @@ public class LockMethodTest
|
|||||||
@Override
|
@Override
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
// Create the store and get the root node reference
|
NodeRef rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
|
||||||
storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, TEST_STORE_IDENTIFIER);
|
|
||||||
if (!nodeService.exists(storeRef))
|
|
||||||
{
|
|
||||||
storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, TEST_STORE_IDENTIFIER);
|
|
||||||
}
|
|
||||||
rootNodeRef = nodeService.getRootNode(storeRef);
|
|
||||||
|
|
||||||
// Create and authenticate the user
|
// Create and authenticate the user
|
||||||
userName = "webdavLockTest" + GUID.generate();
|
userName = "webdavLockTest" + GUID.generate();
|
||||||
@@ -162,19 +155,19 @@ public class LockMethodTest
|
|||||||
|
|
||||||
// delete test store as system user
|
// delete test store as system user
|
||||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
this.authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
RetryingTransactionCallback<Void> deleteStoreCallback = new RetryingTransactionCallback<Void>()
|
RetryingTransactionCallback<Void> deleteTestFolderCallback = new RetryingTransactionCallback<Void>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Void execute() throws Throwable
|
public Void execute() throws Throwable
|
||||||
{
|
{
|
||||||
if (nodeService.exists(storeRef))
|
if (nodeService.exists(folderNodeRef))
|
||||||
{
|
{
|
||||||
nodeService.deleteStore(storeRef);
|
nodeService.deleteNode(folderNodeRef);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.transactionService.getRetryingTransactionHelper().doInTransaction(deleteStoreCallback);
|
this.transactionService.getRetryingTransactionHelper().doInTransaction(deleteTestFolderCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -289,4 +282,60 @@ public class LockMethodTest
|
|||||||
// check that lock information is not there for expired lock
|
// check that lock information is not there for expired lock
|
||||||
assertTrue("Propfind response should not conatain information about expired lock", response.indexOf("lockdiscovery") == -1);
|
assertTrue("Propfind response should not conatain information about expired lock", response.indexOf("lockdiscovery") == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMNT_10873() throws Exception
|
||||||
|
{
|
||||||
|
String fileName = TEST_FILE_NAME + GUID.generate();
|
||||||
|
final MockHttpServletRequest lockRequest = new MockHttpServletRequest();
|
||||||
|
MockHttpServletResponse lockResponse = new MockHttpServletResponse();
|
||||||
|
lockRequest.addHeader(WebDAV.HEADER_TIMEOUT, WebDAV.SECOND + 5);
|
||||||
|
// set request uri to point to non-existent file
|
||||||
|
lockRequest.setRequestURI("/" + fileName);
|
||||||
|
|
||||||
|
String content = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:lockinfo xmlns:D=\"DAV:\"><D:lockscope xmlns:D=\"DAV:\">" +
|
||||||
|
"<D:exclusive xmlns:D=\"DAV:\"/></D:lockscope><D:locktype xmlns:D=\"DAV:\"><D:write xmlns:D=\"DAV:\"/></D:locktype>" +
|
||||||
|
"<D:owner xmlns:D=\"DAV:\">" + userName + "</D:owner></D:lockinfo>";
|
||||||
|
|
||||||
|
lockRequest.setContent(content.getBytes("UTF-8"));
|
||||||
|
|
||||||
|
lockMethod.setDetails(lockRequest, lockResponse, davHelper, folderNodeRef);
|
||||||
|
lockMethod.parseRequestHeaders();
|
||||||
|
lockMethod.parseRequestBody();
|
||||||
|
|
||||||
|
RetryingTransactionCallback<Void> lockExecuteImplCallBack = new RetryingTransactionCallback<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void execute() throws Throwable
|
||||||
|
{
|
||||||
|
lockMethod.executeImpl();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// lock node for 5 seconds
|
||||||
|
this.transactionService.getRetryingTransactionHelper().doInTransaction(lockExecuteImplCallBack);
|
||||||
|
|
||||||
|
assertEquals("Unexpected response status code.", HttpServletResponse.SC_CREATED, lockResponse.getStatus());
|
||||||
|
|
||||||
|
RetryingTransactionCallback<NodeRef> getNodeRefCallback = new RetryingTransactionCallback<NodeRef>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public NodeRef execute() throws Throwable
|
||||||
|
{
|
||||||
|
return lockMethod.getNodeForPath(folderNodeRef, lockRequest.getRequestURI()).getNodeRef();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NodeRef nodeRef = this.transactionService.getRetryingTransactionHelper().doInTransaction(getNodeRefCallback);
|
||||||
|
|
||||||
|
assertTrue("NodeRef should exists.", nodeService.exists(nodeRef));
|
||||||
|
assertTrue("sys:webdavNoContent aspect should be applied on node.", nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WEBDAV_NO_CONTENT));
|
||||||
|
|
||||||
|
// sleep for 6 seconds to ensure that timer was triggered
|
||||||
|
Thread.sleep(6000);
|
||||||
|
|
||||||
|
assertFalse("File should note exist in repo any more.", nodeService.exists(nodeRef));
|
||||||
|
assertFalse("File should note exist in trashcan.", nodeService.exists(new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, nodeRef.getId())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user