Package javax.mail

Examples of javax.mail.Flags


        startElement("message-number", attributes);
        characters(String.valueOf(message.getMessageNumber()));
        endElement("message-number");

        // FLAGS:
        Flags flags = message.getFlags();
        Flags.Flag[] sf = flags.getSystemFlags();
        // get the system flags

        attributes.clear();
        for (int i = 0; i < sf.length; i++) {
            Flags.Flag flag = sf[i];
            if (flag == Flags.Flag.ANSWERED) {
                addAttribute("answered", "yes");
            } else if (flag == Flags.Flag.DELETED) {
                addAttribute("deleted", "yes");
            } else if (flag == Flags.Flag.DRAFT) {
                addAttribute("draft", "yes");
            } else if (flag == Flags.Flag.FLAGGED) {
                addAttribute("flagged", "yes");
            } else if (flag == Flags.Flag.RECENT) {
                addAttribute("recent", "yes");
            } else if (flag == Flags.Flag.SEEN) {
                addAttribute("seen", "yes");
            }
        }
        startElement("flags", attributes);
        endElement("flags");

        String[] uf = flags.getUserFlags();
        // get the user flag strings
        for (int i = 0; i < uf.length; i++) {
            attributes.clear();
            startElement("user-flags", attributes);
            characters(uf[i]);
View Full Code Here


            if (count > 0) {
                Message[] messages;

                // should we process all messages or only unseen messages
                if (getEndpoint().getConfiguration().isUnseen()) {
                    messages = folder.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
                } else {
                    messages = folder.getMessages();
                }

                polledMessages = processBatch(CastUtils.cast(createExchanges(messages)));
View Full Code Here

   
    public MaildirMessage(Mailbox<Integer> mailbox, long uid, MaildirMessageName messageName) throws IOException {
        this.mailbox = mailbox;
        setUid(uid);
        setModSeq(messageName.getFile().lastModified());
        Flags flags = messageName.getFlags();
       
        // Set the flags for the message and respect if its RECENT
        // See MAILBOX-84
        File file = messageName.getFile();
        if (!file.exists()) {
            throw new FileNotFoundException("Unable to read file " + file.getAbsolutePath() + " for the message");
        } else {
            // if the message resist in the new folder its RECENT
            if (file.getParentFile().getName().equals(MaildirFolder.NEW)) {
                flags.add(Flags.Flag.RECENT);
            }
        }
        setFlags(flags);
        this.messageName = messageName;
    }
View Full Code Here

    @Override
    public String toString() {
        StringBuffer theString = new StringBuffer("MaildirMessage ");
        theString.append(getUid());
        theString.append(" {");
        Flags flags = createFlags();
        if (flags.contains(Flags.Flag.DRAFT))
            theString.append(MaildirMessageName.FLAG_DRAFT);
        if (flags.contains(Flags.Flag.FLAGGED))
            theString.append(MaildirMessageName.FLAG_FLAGGED);
        if (flags.contains(Flags.Flag.ANSWERED))
            theString.append(MaildirMessageName.FLAG_ANSWERD);
        if (flags.contains(Flags.Flag.SEEN))
            theString.append(MaildirMessageName.FLAG_SEEN);
        if (flags.contains(Flags.Flag.DELETED))
            theString.append(MaildirMessageName.FLAG_DELETED);
        theString.append("} ");
        theString.append(getInternalDate());
        return theString.toString();
    }
View Full Code Here

            MailboxSession session = manager.createSystemSession(user, LoggerFactory.getLogger("Test"));
            manager.createMailbox(new MailboxPath(MailboxConstants.USER_NAMESPACE, user, "Trash"), session);
            manager.createMailbox(new MailboxPath(MailboxConstants.USER_NAMESPACE, user, "INBOX.testfolder"), session);
           
            // this threw NPE
            manager.getMailbox(MailboxPath.inbox(session), session).appendMessage(new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), session, false, new Flags());

        }

    }
View Full Code Here

     * into a {@link Flags} object.
     * @param flagsString The String with the flags
     * @return A Flags object containing the flags read form the String
     */
    public Flags decodeFlags(String flagsString) {
        Flags flags = new Flags();
        if (flagsString.contains(FLAG_DRAFT))
            flags.add(Flags.Flag.DRAFT);
        if (flagsString.contains(FLAG_FLAGGED))
            flags.add(Flags.Flag.FLAGGED);
        if (flagsString.contains(FLAG_ANSWERD))
            flags.add(Flags.Flag.ANSWERED);
        if (flagsString.contains(FLAG_SEEN))
            flags.add(Flags.Flag.SEEN);
        if (flagsString.contains(FLAG_DELETED))
            flags.add(Flags.Flag.DELETED);
        return flags;
    }
View Full Code Here

     * (non-Javadoc)
     * @see org.apache.james.mailbox.store.mail.AbstractMessageMapper#copy(org.apache.james.mailbox.store.mail.model.Mailbox, long, long, org.apache.james.mailbox.store.mail.model.Message)
     */
    protected MessageMetaData copy(Mailbox<Integer> mailbox, long uid, long modSeq, Message<Integer> original) throws MailboxException {
        SimpleMessage<Integer> theCopy = new SimpleMessage<Integer>(mailbox, original);
        Flags flags = theCopy.createFlags();
        flags.add(Flag.RECENT);
        theCopy.setFlags(flags);
        return save(mailbox, theCopy);       
    }
View Full Code Here

        findInMailbox(mailbox, set, FetchType.Metadata, new MessageCallback<Integer>() {

            public void onMessages(List<Message<Integer>> members) throws MailboxException {
                for (final Message<Integer> member : members) {
                    Flags originalFlags = member.createFlags();
                    if (replace) {
                        member.setFlags(flags);
                    } else {
                        Flags current = member.createFlags();
                        if (value) {
                            current.add(flags);
                        } else {
                            current.remove(flags);
                        }
                        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)) {
                            // message is recent so save it in the new folder
                            newMessageFile = new File(folder.getNewFolder(), newMessageName);
                        } else {
                            newMessageFile = new File(folder.getCurFolder(), newMessageName);
                        }
View Full Code Here

    public UpdatedFlags(long uid, long modSeq, Flags oldFlags, Flags newFlags) {
       this.uid = uid;
       this.modSeq = modSeq;
       this.oldFlags = oldFlags;
       this.newFlags = newFlags;
       this.modifiedFlags = new Flags();
       addModifiedSystemFlags(oldFlags, newFlags, modifiedFlags);
       addModifiedUserFlags(oldFlags, newFlags, modifiedFlags);
    }
View Full Code Here

    public long getModSeq() {
        return modSeq;
    }
   
    public static boolean flagsChanged(Flags flagsOld, Flags flagsNew) {
        Flags modifiedFlags = new Flags();
        addModifiedSystemFlags(flagsOld, flagsNew, modifiedFlags);
        addModifiedUserFlags(flagsOld, flagsNew, modifiedFlags);
        if (modifiedFlags.getSystemFlags().length > 0 || modifiedFlags.getUserFlags().length > 0) {
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

TOP

Related Classes of javax.mail.Flags

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.