Java Code Examples for javax.mail.Flags.Flag#DELETED

The following examples show how to use javax.mail.Flags.Flag#DELETED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractCombinationManagerTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
void setFlagsToDeleteThenExpungeFromMessageManagerThenGetMessageFromMessageIdManagerShouldNotReturnAnything() throws Exception {
    Flags deleted = new Flags(Flag.DELETED);
    MessageId messageId = messageManager1.appendMessage(MessageManager.AppendCommand.from(mailContent), session)
        .getId().getMessageId();

    messageManager1.setFlags(deleted, FlagsUpdateMode.ADD, MessageRange.all(), session);
    messageManager1.expunge(MessageRange.all(), session);

    assertThat(messageIdManager.getMessage(messageId, FetchGroup.MINIMAL, session)).isEmpty();
}
 
Example 2
Source File: AbstractCombinationManagerTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
void expungeFromMessageManagerShouldWorkWhenSetFlagsToDeletedWithMessageIdManager() throws Exception {
    Flags deleted = new Flags(Flag.DELETED);
    ComposedMessageId messageId = messageManager1.appendMessage(MessageManager.AppendCommand.from(mailContent), session).getId();

    messageIdManager.setFlags(deleted, FlagsUpdateMode.ADD, messageId.getMessageId(), ImmutableList.of(mailbox1.getMailboxId()), session);

    assertThat(messageManager1.expunge(MessageRange.all(), session))
        .toIterable()
        .containsOnly(messageId.getUid());
}
 
Example 3
Source File: AbstractCombinationManagerTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
void expungeFromMessageManagerShouldWorkWhenSetInMailboxesAMessageWithDeletedFlag() throws Exception { //I can mark as DELETED + expunge an mail with setInMbxs
    Flags deleted = new Flags(Flag.DELETED);
    ComposedMessageId messageId = messageManager1.appendMessage(
        MessageManager.AppendCommand.builder()
            .withFlags(deleted)
            .build(mailContent), session).getId();

    messageIdManager.setInMailboxes(messageId.getMessageId(), ImmutableList.of(mailbox1.getMailboxId()), session);

    assertThat(messageManager1.expunge(MessageRange.all(), session))
        .toIterable()
        .containsOnly(messageId.getUid());
}
 
Example 4
Source File: ImapServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void setFlag(NodeRef nodeRef, Flag flag, boolean value)
{
    String permission = (flag == Flag.DELETED ? PermissionService.DELETE_NODE : PermissionService.WRITE_PROPERTIES);
    
    
    AccessStatus status = permissionService.hasPermission(nodeRef, permission);
    if (status == AccessStatus.DENIED)
    {
        if(flag == Flag.DELETED)
        {
            logger.debug("[setFlag] Access denied to set DELETED FLAG:" + nodeRef);
            throw new AccessDeniedException("No permission to set DELETED flag");
        }
        if(flag == Flag.SEEN)
        {
            logger.debug("[setFlag] Access denied to set SEEN FLAG:" + nodeRef);
            //TODO - should we throw an exception here?
            //throw new AccessDeniedException("No permission to set DELETED flag");
        }
        else
        {
           
            logger.debug("[setFlag] Access denied to set flag:" + nodeRef);
            throw new AccessDeniedException("No permission to set flag:" + flag.toString());
        }
    }
    else
    {
        checkForFlaggableAspect(nodeRef);
        policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
        policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE);
        try
        {                    
            if(logger.isDebugEnabled())
            {
                logger.debug("set flag nodeRef:" + nodeRef + ",flag:" + flagToQname.get(flag) + ", value:" + value);
            }
            nodeService.setProperty(nodeRef, flagToQname.get(flag), value);
            messageCache.remove(nodeRef);
        }
        finally
        {
            policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
            policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE);                
        }
    }
}