Package org.apache.james.mailbox.maildir

Examples of org.apache.james.mailbox.maildir.MaildirMessageName


    private List<Message<Integer>> findMessageInMailboxWithUID(Mailbox<Integer> mailbox, long uid)
    throws MailboxException {
        MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
        try {
            MaildirMessageName messageName = folder.getMessageNameByUid(mailboxSession, uid);
       
             ArrayList<Message<Integer>> messages = new ArrayList<Message<Integer>>();
             if (messageName != null) {
                 messages.add(new MaildirMessage(mailbox, uid, messageName));
             }
View Full Code Here


    private List<Message<Integer>> findDeletedMessageInMailboxWithUID(
            Mailbox<Integer> mailbox, long uid) throws MailboxException {
        MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
        try {
            MaildirMessageName messageName = folder.getMessageNameByUid(mailboxSession, uid);
             ArrayList<Message<Integer>> messages = new ArrayList<Message<Integer>>();
             if (MaildirMessageName.FILTER_DELETED_MESSAGES.accept(null, messageName.getFullName())) {
                 messages.add(new MaildirMessage(mailbox, uid, messageName));
             }
             return messages;

        } catch (IOException e) {
View Full Code Here

        // random number generator returns the same number.
        // In order to prevent this case we would need to check ALL files in
        // all folders and compare
        // them to this message name. We rather let this happen once in a
        // billion years...
        MaildirMessageName messageName = MaildirMessageName.createUniqueName(folder, message.getFullContentOctets());
        File messageFile = new File(tmpFolder, messageName.getFullName());
        FileOutputStream fos = null;
        InputStream input = null;
        try {
            messageFile.createNewFile();
            fos = new FileOutputStream(messageFile);
            input = ResultUtils.toInput(message);
            byte[] b = new byte[BUF_SIZE];
            int len = 0;
            while ((len = input.read(b)) != -1)
                fos.write(b, 0, len);
        } catch (IOException ioe) {
            throw new MailboxException("Failure while save Message " + message + " in Mailbox " + mailbox, ioe);
        } finally {
            try {
                if (fos != null)
                    fos.close();
            } catch (IOException e) {
            }
            try {
                if (input != null)
                    input.close();
            } catch (IOException e) {
            }
        }
        File newMessageFile = null;
        // delivered via SMTP, goes to ./new without flags
        if (message.isRecent()) {
            messageName.setFlags(message.createFlags());
            newMessageFile = new File(folder.getNewFolder(), messageName.getFullName());
            // System.out.println("save new recent " + message + " as " +
            // newMessageFile.getName());
        }
        // appended via IMAP (might already have flags etc, goes to ./cur
        // directly)
        else {
            messageName.setFlags(message.createFlags());
            newMessageFile = new File(folder.getCurFolder(), messageName.getFullName());
            // System.out.println("save new not recent " + message + " as "
            // + newMessageFile.getName());
        }
        try {
            FileUtils.moveFile(messageFile, newMessageFile);
View Full Code Here

                        member.setFlags(current);
                    }
                    Flags newFlags = member.createFlags();

                    try {
                        MaildirMessageName messageName = folder.getMessageNameByUid(mailboxSession, member.getUid());
                        File messageFile = messageName.getFile();
                        // System.out.println("save existing " + message +
                        // " as " + messageFile.getName());
                        messageName.setFlags(member.createFlags());
                        // this automatically moves messages from new to cur if
                        // needed
                        String newMessageName = messageName.getFullName();

                        File newMessageFile;
                       
                        // See MAILBOX-57
                        if (newFlags.contains(Flag.RECENT)) {
View Full Code Here

    }

    private List<Message<Integer>> findMessageInMailboxWithUID(Mailbox<Integer> mailbox, long uid)
    throws MailboxException {
        MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
        MaildirMessageName messageName = null;
        try {
             messageName = folder.getMessageNameByUid(uid);
        } catch (IOException e) {
            throw new MailboxException("Failure while search for Message with uid " + uid + " in Mailbox " + mailbox, e );
        }
View Full Code Here

    }

    private List<Message<Integer>> findDeletedMessageInMailboxWithUID(
            Mailbox<Integer> mailbox, long uid) throws MailboxException {
        MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
        MaildirMessageName messageName = null;
        try {
             messageName = folder.getMessageNameByUid(uid);
        } catch (IOException e) {
            throw new MailboxException("Failure while search for Messages in Mailbox " + mailbox, e );
        }
        ArrayList<Message<Integer>> messages = new ArrayList<Message<Integer>>();
        if (MaildirMessageName.FILTER_DELETED_MESSAGES.accept(null, messageName.getFullName())) {
            messages.add(new LazyLoadingMaildirMessage(mailbox, uid, messageName));
        }
        return messages;
    }
View Full Code Here

            // has been set backwards, then the server is restarted with the same pid, delivers the same
            // number of messages since its start in the exact same millisecond as done before and the
            // random number generator returns the same number.
            // In order to prevent this case we would need to check ALL files in all folders and compare
            // them to this message name. We rather let this happen once in a billion years...
            MaildirMessageName messageName = MaildirMessageName.createUniqueName(folder,
                    message.getFullContentOctets());
            File messageFile = new File(tmpFolder, messageName.getFullName());
            FileOutputStream fos = null;
            InputStream input = null;
            try {
                messageFile.createNewFile();
                fos = new FileOutputStream(messageFile);
                input = message.getFullContent();
                byte[] b = new byte[BUF_SIZE];
                int len = 0;
                while ((len = input.read(b)) != -1)
                    fos.write(b, 0, len);
            }
            catch (IOException ioe) {
                throw new MailboxException("Failure while save Message " + message + " in Mailbox " + mailbox, ioe );
            }
            finally {
                try {
                    if (fos != null)
                        fos.close();
                } catch (IOException e) {
                }
                try {
                    if (input != null)
                        input.close();
                } catch (IOException e) {
                }
            }
            File newMessageFile = null;
            // delivered via SMTP, goes to ./new without flags
            if (maildirMessage.isRecent()) {
                messageName.setFlags(message.createFlags());
                newMessageFile = new File(folder.getNewFolder(), messageName.getFullName());
                //System.out.println("save new recent " + message + " as " + newMessageFile.getName());
            }
            // appended via IMAP (might already have flags etc, goes to ./cur directly)
            else {
                messageName.setFlags(message.createFlags());
                newMessageFile = new File(folder.getCurFolder(), messageName.getFullName());
                //System.out.println("save new not recent " + message + " as " + newMessageFile.getName());
            }
            try {
                FileUtils.moveFile(messageFile, newMessageFile);
            } catch (IOException e) {
View Full Code Here

                    }
                    Flags newFlags = member.createFlags();

                    try {
                        AbstractMaildirMessage maildirMessage = (AbstractMaildirMessage) member;
                        MaildirMessageName messageName = folder.getMessageNameByUid(maildirMessage.getUid());
                        File messageFile = messageName.getFile();
                        // System.out.println("save existing " + message +
                        // " as " + messageFile.getName());
                        messageName.setFlags(maildirMessage.createFlags());
                        // this automatically moves messages from new to cur if
                        // needed
                        String newMessageName = messageName.getFullName();

                        File newMessageFile;
                       
                        // See MAILBOX-57
                        if (newFlags.contains(Flag.RECENT)) {
View Full Code Here

                member.setFlags(current);
            }
            Flags newFlags = member.createFlags();

            try {
                MaildirMessageName messageName = folder.getMessageNameByUid(mailboxSession, member.getUid());
                if (messageName != null) {
                    File messageFile = messageName.getFile();
                    // System.out.println("save existing " + message +
                    // " as " + messageFile.getName());
                    messageName.setFlags(member.createFlags());
                    // this automatically moves messages from new to cur if
                    // needed
                    String newMessageName = messageName.getFullName();

                    File newMessageFile;

                    // See MAILBOX-57
                    if (newFlags.contains(Flag.RECENT)) {
View Full Code Here

        // random number generator returns the same number.
        // In order to prevent this case we would need to check ALL files in
        // all folders and compare
        // them to this message name. We rather let this happen once in a
        // billion years...
        MaildirMessageName messageName = MaildirMessageName.createUniqueName(folder, message.getFullContentOctets());
        File messageFile = new File(tmpFolder, messageName.getFullName());
        FileOutputStream fos = null;
        InputStream input = null;
        try {
            if (!messageFile.createNewFile())
                throw new IOException("Could not create file " + messageFile);
            fos = new FileOutputStream(messageFile);
            input = message.getFullContent();
            byte[] b = new byte[BUF_SIZE];
            int len = 0;
            while ((len = input.read(b)) != -1)
                fos.write(b, 0, len);
        } catch (IOException ioe) {
            throw new MailboxException("Failure while save Message " + message + " in Mailbox " + mailbox, ioe);
        } finally {
            try {
                if (fos != null)
                    fos.close();
            } catch (IOException e) {
            }
            try {
                if (input != null)
                    input.close();
            } catch (IOException e) {
            }
        }
        File newMessageFile = null;
        // delivered via SMTP, goes to ./new without flags
        if (message.isRecent()) {
            messageName.setFlags(message.createFlags());
            newMessageFile = new File(folder.getNewFolder(), messageName.getFullName());
            // System.out.println("save new recent " + message + " as " +
            // newMessageFile.getName());
        }
        // appended via IMAP (might already have flags etc, goes to ./cur
        // directly)
        else {
            messageName.setFlags(message.createFlags());
            newMessageFile = new File(folder.getCurFolder(), messageName.getFullName());
            // System.out.println("save new not recent " + message + " as "
            // + newMessageFile.getName());
        }
        try {
            FileUtils.moveFile(messageFile, newMessageFile);
View Full Code Here

TOP

Related Classes of org.apache.james.mailbox.maildir.MaildirMessageName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.