mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
84028: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud) 83341: Merged DEV to V4.2-BUG-FIX (4.2.4) 82263: MNT-12259 : Outlook 2013 implements an IMAP move as a \Deleted + APPEND leading to corrupt files Implemented a complex move operation to support Outlook 2013. 82465: MNT-12259 : Outlook 2013 implements an IMAP move as a \Deleted + APPEND leading to misleading copy of alfresco dummy file Modified the fix to use the message id to determine the complex move operation. Added JUnit test. 83420: MNT-12259 : Outlook 2013 implements an IMAP move as a \Deleted + APPEND leading to misleading copy of alfresco dummy file Added an addition check for node existence to correctly handle invalid nodeRefs in message id. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@84619 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -34,6 +34,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
@@ -158,6 +160,8 @@ public class ImapServiceImpl implements ImapService, OnRestoreNodePolicy, OnCrea
|
||||
private final static Map<QName, Flags.Flag> qNameToFlag;
|
||||
private final static Map<Flags.Flag, QName> flagToQname;
|
||||
|
||||
private static final Timer deleteDelayTimer = new Timer();
|
||||
|
||||
private boolean imapServerEnabled = false;
|
||||
|
||||
static
|
||||
@@ -538,11 +542,71 @@ public class ImapServiceImpl implements ImapService, OnRestoreNodePolicy, OnCrea
|
||||
Flags flags = getFlags(fileInfo);
|
||||
if (flags.contains(Flags.Flag.DELETED))
|
||||
{
|
||||
fileFolderService.delete(fileInfo.getNodeRef());
|
||||
// See MNT-12259
|
||||
//fileFolderService.delete(fileInfo.getNodeRef());
|
||||
hideAndDelete(fileInfo.getNodeRef());
|
||||
messageCache.remove(fileInfo.getNodeRef());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Workaround for MNT-12259
|
||||
* @param nodeRef
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private void hideAndDelete(final NodeRef nodeRef)
|
||||
{
|
||||
FileFilterMode.setClient(FileFilterMode.Client.imap);
|
||||
fileFolderService.setHidden(nodeRef, true);
|
||||
{
|
||||
// Get the current user
|
||||
final String deleteDelayUser = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
// Add a timed task to really delete the file
|
||||
TimerTask deleteDelayTask = new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
RunAsWork<Void> deleteDelayRunAs = new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// Ignore if it is NOT hidden: the shuffle may have finished; the operation may have failed
|
||||
if (!nodeService.exists(nodeRef) || !fileFolderService.isHidden(nodeRef))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Since this will run in a different thread, the client thread-local must be set
|
||||
// or else unhiding the node will not unhide it for IMAP.
|
||||
FileFilterMode.setClient(FileFilterMode.Client.imap);
|
||||
|
||||
// Unhide the node, e.g. for archiving
|
||||
fileFolderService.setHidden(nodeRef, false);
|
||||
|
||||
// This is the transaction-aware service
|
||||
fileFolderService.delete(nodeRef);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
try
|
||||
{
|
||||
AuthenticationUtil.runAs(deleteDelayRunAs, deleteDelayUser);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// consume exception to avoid it leaking from the TimerTask and causing the Timer to
|
||||
// no longer accept tasks to be scheduled.
|
||||
logger.info("Exception thrown during IMAP delete timer task.", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Schedule a real delete 5 seconds after the current time
|
||||
deleteDelayTimer.schedule(deleteDelayTask, 5000L);
|
||||
}
|
||||
}
|
||||
|
||||
public AlfrescoImapFolder getOrCreateMailbox(AlfrescoImapUser user, String mailboxName, boolean mayExist, boolean mayCreate)
|
||||
{
|
||||
if (mailboxName == null)
|
||||
|
Reference in New Issue
Block a user