Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)

58157: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3)
      57990: Merged DEV to V4.2-BUG-FIX (4.2.1)
         57207 : MNT-9777 : MS Office Documents Edited and attempted to save with MS Office 2011 for Mac apps over WebDAV causes Word to Crash
            - Changing check `is sourceParentNodeRef not equals to destParentNodeRef` to` is sourceFileInfo not euqals to destFileInfo`
         57592 : MNT-9777 : MS Office Documents Edited and attempted to save with MS Office 2011 for Mac apps over WebDAV causes Word to Crash
            - Added test for Shuffle WebDAV move within the same folder . Also added test for MNT-6480 fix


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61922 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-02-11 22:39:45 +00:00
parent e655441df0
commit 7067a8e2e8
2 changed files with 111 additions and 1 deletions

View File

@@ -198,7 +198,7 @@ public class MoveMethod extends HierarchicalMethod
} }
// 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
if (!sourceFileInfo.isFolder() && destFileInfo != null && !sourceParentNodeRef.equals(destParentNodeRef)) if (!sourceFileInfo.isFolder() && destFileInfo != null && !sourceFileInfo.equals(destFileInfo))
{ {
copyContentOnly(sourceFileInfo, destFileInfo, fileFolderService); copyContentOnly(sourceFileInfo, destFileInfo, fileFolderService);
fileFolderService.setHidden(destFileInfo.getNodeRef(), false); fileFolderService.setHidden(destFileInfo.getNodeRef(), false);

View File

@@ -34,6 +34,9 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
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.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
@@ -82,6 +85,7 @@ public class MoveMethodTest
private FileFolderService fileFolderService; private FileFolderService fileFolderService;
private NodeService nodeService; private NodeService nodeService;
private TransactionService transactionService; private TransactionService transactionService;
private ContentService contentService;
private WebDAVHelper webDAVHelper; private WebDAVHelper webDAVHelper;
private NodeRef companyHomeNodeRef; private NodeRef companyHomeNodeRef;
@@ -165,6 +169,7 @@ public class MoveMethodTest
fileFolderService = ctx.getBean("FileFolderService", FileFolderService.class); fileFolderService = ctx.getBean("FileFolderService", FileFolderService.class);
nodeService = ctx.getBean("NodeService", NodeService.class); nodeService = ctx.getBean("NodeService", NodeService.class);
transactionService = ctx.getBean("transactionService", TransactionService.class); transactionService = ctx.getBean("transactionService", TransactionService.class);
contentService = ctx.getBean("contentService", ContentService.class);
webDAVHelper = ctx.getBean("webDAVHelper", WebDAVHelper.class); webDAVHelper = ctx.getBean("webDAVHelper", WebDAVHelper.class);
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
@@ -255,4 +260,109 @@ public class MoveMethodTest
} }
}); });
} }
@Test
public void testMNT_6480()
{
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
@Override
public Object execute() throws Throwable
{
// create test file with name that doesn't match getDAVHelper().isRenameShuffle()
String originalFileName = "content-" + GUID.generate() + ".txt";
FileInfo testFileInfo = fileFolderService.create(companyHomeNodeRef, originalFileName, ContentModel.TYPE_CONTENT);
// rename source file to file with upper case name
String newFileName = originalFileName.toUpperCase();
req = new MockHttpServletRequest(WebDAV.METHOD_MOVE, "/alfresco/webdav/" + testFileInfo.getName());
req.setServerPort(8080);
req.setContextPath("/alfresco");
req.setServletPath("/webdav");
req.addHeader(WebDAV.HEADER_DESTINATION, "http://localhost:8080/alfresco/webdav/" + newFileName);
resp = new MockHttpServletResponse();
moveMethod = new MoveMethod();
moveMethod.setDetails(req, resp, webDAVHelper, companyHomeNodeRef);
try
{
moveMethod.execute();
// MNT-6480 - File should be renamed but not deleted
assertTrue(nodeService.exists(testFileInfo.getNodeRef()));
assertEquals(newFileName, nodeService.getProperty(testFileInfo.getNodeRef(), ContentModel.PROP_NAME));
}
catch (WebDAVServerException e)
{
fail("Fail to rename node: " + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
}
finally
{
nodeService.deleteNode(testFileInfo.getNodeRef());
}
return null;
}
});
}
@Test
public void testMNT_9777()
{
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
@Override
public Object execute() throws Throwable
{
// create test file with name that does match getDAVHelper().isRenameShuffle()
String originalFileName = "tempfile-" + GUID.generate() + ".tmp";
// destination within same folder
String newFileName = "destfile-" + GUID.generate() + ".txt";
FileInfo sourceFileInfo = fileFolderService.create(companyHomeNodeRef, originalFileName, ContentModel.TYPE_CONTENT);
FileInfo newFileInfo = fileFolderService.create(companyHomeNodeRef, newFileName, ContentModel.TYPE_CONTENT);
String newContent = GUID.generate();
ContentWriter writer;
writer = contentService.getWriter(sourceFileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true);
writer.putContent(newContent);
req = new MockHttpServletRequest(WebDAV.METHOD_MOVE, "/alfresco/webdav/" + sourceFileInfo.getName());
resp = new MockHttpServletResponse();
req.setServerPort(8080);
req.setContextPath("/alfresco");
req.setServletPath("/webdav");
moveMethod = new MoveMethod();
moveMethod.setDetails(req, resp, webDAVHelper, companyHomeNodeRef);
String destPath = "http://localhost:8080/alfresco/webdav/" + newFileName;
req.addHeader(WebDAV.HEADER_DESTINATION, destPath);
try
{
moveMethod.execute();
// MNT-9777 - Source node should be deleted
assertTrue(!nodeService.exists(sourceFileInfo.getNodeRef()));
// Content should be updated
ContentReader reader = contentService.getReader(newFileInfo.getNodeRef(), ContentModel.PROP_CONTENT);
assertEquals(newContent, reader.getContentString());
}
catch (WebDAVServerException e)
{
fail("Fail to move node: " + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
}
finally
{
nodeService.deleteNode(newFileInfo.getNodeRef());
}
return null;
}
});
}
} }