mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.0/Cloud)
87701: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud) 86502: Merged DEV to V4.2-BUG-FIX (4.2.4) 86291: MNT-12303 : Renaming a folder containing a document that is locked due to online editing causes a duplicate folder and file with no content to be created - Refresh lock request should not create new empty resource. - Unit test added. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94540 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -261,6 +261,26 @@ public class LockMethod extends WebDAVMethod
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
if (m_conditions != null)
|
||||
{
|
||||
// MNT-12303 fix, check whether this is a refresh lock request
|
||||
for (Condition condition : m_conditions)
|
||||
{
|
||||
List<String> lockTolensMatch = condition.getLockTokensMatch();
|
||||
List<String> etagsMatch = condition.getETagsMatch();
|
||||
|
||||
if (m_request.getContentLength() == -1 &&
|
||||
(lockTolensMatch != null && !lockTolensMatch.isEmpty()) ||
|
||||
(etagsMatch != null && !etagsMatch.isEmpty()))
|
||||
{
|
||||
// LOCK method with If header and without body was sent, according to RFC 2518 section 7.8
|
||||
// this form of LOCK MUST only be used to "refresh" a lock. However resource doesn't exist ->
|
||||
// so there is nothing to refresh. Return 403 Forbidden as original SharePoint Server.
|
||||
throw new WebDAVServerException(HttpServletResponse.SC_FORBIDDEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// need to create it
|
||||
String[] splitPath = getDAVHelper().splitPath(path);
|
||||
// check
|
||||
|
@@ -85,6 +85,9 @@ public class LockMethodTest
|
||||
*/
|
||||
private static final String CONTENT_1 = "This is some content";
|
||||
private static final String TEST_FILE_NAME = "file" + GUID.generate();
|
||||
private static final String TEST_NEW_FILE_NAME = "new_file" + GUID.generate();
|
||||
private static final String TEST_FOLDER_NAME = "folder" + GUID.generate();
|
||||
private static final String TEST_NEW_FOLDER_NAME = "new_folder" + GUID.generate();
|
||||
|
||||
/**
|
||||
* Data used by the tests
|
||||
@@ -130,7 +133,7 @@ public class LockMethodTest
|
||||
|
||||
// create test file in test folder
|
||||
folderNodeRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("test"), ContentModel.TYPE_FOLDER,
|
||||
Collections.<QName, Serializable> singletonMap(ContentModel.PROP_NAME, "folder")).getChildRef();
|
||||
Collections.<QName, Serializable> singletonMap(ContentModel.PROP_NAME, TEST_FOLDER_NAME)).getChildRef();
|
||||
fileNodeRef = nodeService.createNode(folderNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("test"), ContentModel.TYPE_CONTENT,
|
||||
Collections.<QName, Serializable> singletonMap(ContentModel.PROP_NAME, TEST_FILE_NAME)).getChildRef();
|
||||
ContentWriter contentWriter = contentService.getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true);
|
||||
@@ -373,4 +376,41 @@ public class LockMethodTest
|
||||
// try to refresh lock for non-locked node
|
||||
this.transactionService.getRetryingTransactionHelper().doInTransaction(lockExecuteImplCallBack);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMNT_12425() throws Exception
|
||||
{
|
||||
MockHttpServletRequest lockRequest = new MockHttpServletRequest();
|
||||
MockHttpServletResponse lockResponse = new MockHttpServletResponse();
|
||||
|
||||
// refresh lock set to 1 hour
|
||||
lockRequest.addHeader(WebDAV.HEADER_TIMEOUT, WebDAV.SECOND + 3600);
|
||||
lockRequest.addHeader(WebDAV.HEADER_IF, "(<" + WebDAV.makeLockToken(fileNodeRef, userName) + ">)");
|
||||
// specify path to non-existing file
|
||||
lockRequest.setRequestURI("/" + TEST_NEW_FOLDER_NAME + "/" + TEST_NEW_FILE_NAME);
|
||||
|
||||
lockMethod.setDetails(lockRequest, lockResponse, davHelper, folderNodeRef);
|
||||
lockMethod.parseRequestHeaders();
|
||||
|
||||
RetryingTransactionCallback<Void> lockExecuteImplCallBack = new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
lockMethod.executeImpl();
|
||||
fail("Refresh lock for non-exisitent resource should fail.");
|
||||
}
|
||||
catch (WebDAVServerException e)
|
||||
{
|
||||
assertEquals(HttpServletResponse.SC_FORBIDDEN, e.getHttpStatusCode());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// try to lock non-existent file
|
||||
this.transactionService.getRetryingTransactionHelper().doInTransaction(lockExecuteImplCallBack);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user