Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.0/Cloud)

85565: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud)
      85433: Merged DEV to V4.2-BUG-FIX (4.1.4) with unit test
         84722: MNT-12420: Outlook 2011 (MacOS) implements an IMAP move as an APPEND leading to the creation of an EML file
            - Perform copy instead of create on APPEND request when existing node with provided message-id or X-Alfresco-NodeRef-ID can be found 
            - Add Unit test.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94502 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-01-31 09:31:26 +00:00
parent 5716fe7cfa
commit f3928a21cd
2 changed files with 88 additions and 3 deletions

View File

@@ -921,6 +921,56 @@ public class ImapServiceImplTest extends TestCase
assertEquals("There should be only one node in the destination folder", 1, nodeService.getChildAssocs(destinationNode.getNodeRef()).size());
}
/**
* Test for MNT-12420
*
* @throws Exception
*/
public void testMoveViaAppendAndDelete() throws Exception
{
AlfrescoImapUser poweredUser = new AlfrescoImapUser((USER_NAME + "@alfresco.com"), USER_NAME, USER_PASSWORD);
String fileName = "testfile" + GUID.generate();
String destinationName = "testFolder" + GUID.generate();
String destinationPath = IMAP_ROOT + AlfrescoImapConst.HIERARCHY_DELIMITER + destinationName;
String nodeContent = "test content";
NodeRef root = findCompanyHomeNodeRef();
AuthenticationUtil.setRunAsUserSystem();
// Create node and destination folder
FileInfo origFile = fileFolderService.create(root, fileName, ContentModel.TYPE_CONTENT);
ContentWriter contentWriter = contentService.getWriter(origFile.getNodeRef(), ContentModel.PROP_CONTENT, true);
contentWriter.setMimetype("text/plain");
contentWriter.setEncoding("UTF-8");
contentWriter.putContent(nodeContent);
FileInfo destinationNode = fileFolderService.create(root, destinationName, ContentModel.TYPE_FOLDER);
nodeService.addAspect(origFile.getNodeRef(), ImapModel.ASPECT_IMAP_CONTENT, null);
nodeService.addAspect(origFile.getNodeRef(), ContentModel.ASPECT_TAGGABLE, null);
// Save the message and set X-Alfresco-NodeRef-ID header
SimpleStoredMessage origMessage = imapService.getMessage(origFile);
origMessage.getMimeMessage().addHeader(AlfrescoImapConst.X_ALF_NODEREF_ID, origFile.getNodeRef().getId());
origMessage.getMimeMessage().saveChanges();
// Append the message to destination
AlfrescoImapFolder destinationMailbox = imapService.getOrCreateMailbox(poweredUser, destinationPath, true, false);
long uuid = destinationMailbox.appendMessage(origMessage.getMimeMessage(), flags, null);
// Delete the node
imapService.setFlag(origFile, Flags.Flag.DELETED, true);
imapService.expungeMessage(origFile);
// Check the destination has copy of original file and only this file
FileInfo copiedNode = fileFolderService.getFileInfo(nodeService.getNodeRef(uuid));
assertNotNull("The file should exist.", copiedNode);
assertEquals("The file name should not change.", fileName, copiedNode.getName());
NodeRef copiedParentNodeRef = nodeService.getPrimaryParent(copiedNode.getNodeRef()).getParentRef();
assertEquals("The parent should change to destination.", destinationNode.getNodeRef(), copiedParentNodeRef);
assertEquals("There should be only one node in the destination folder", 1, nodeService.getChildAssocs(destinationNode.getNodeRef()).size());
assertTrue("New node should have original node aspects", nodeService.hasAspect(copiedNode.getNodeRef(), ContentModel.ASPECT_TAGGABLE));
}
/**
* @param mailbox - {@link AlfrescoImapFolder} instance which should be checked
*/