Java Code Examples for javax.mail.Flags#getUserFlags()
The following examples show how to use
javax.mail.Flags#getUserFlags() .
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: LuceneMessageSearchIndex.java From james-project with Apache License 2.0 | 6 votes |
/** * Add the given {@link Flags} to the {@link Document} */ private void indexFlags(Document doc, Flags f) { List<String> fString = new ArrayList<>(); Flag[] flags = f.getSystemFlags(); for (Flag flag : flags) { fString.add(toString(flag)); doc.add(new Field(FLAGS_FIELD, toString(flag), Store.YES, Index.NOT_ANALYZED)); } String[] userFlags = f.getUserFlags(); for (String userFlag : userFlags) { doc.add(new Field(FLAGS_FIELD, userFlag, Store.YES, Index.NOT_ANALYZED)); } // if no flags are there we just use a empty field if (flags.length == 0 && userFlags.length == 0) { doc.add(new Field(FLAGS_FIELD, "",Store.NO, Index.NOT_ANALYZED)); } }
Example 2
Source File: SimpleMailboxMessage.java From james-project with Apache License 2.0 | 6 votes |
public SimpleMailboxMessage(MessageId messageId, Date internalDate, long size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, MailboxId mailboxId, List<MessageAttachmentMetadata> attachments, boolean hasAttachment) { super(new SimpleMessage( messageId, content, size, internalDate, propertyBuilder.getSubType(), propertyBuilder.getMediaType(), bodyStartOctet, propertyBuilder.getTextualLineCount(), propertyBuilder.toProperties(), attachments, hasAttachment)); setFlags(flags); this.mailboxId = mailboxId; this.userFlags = flags.getUserFlags(); }
Example 3
Source File: StoreMessageManager.java From james-project with Apache License 2.0 | 6 votes |
/** * Check if the given {@link Flags} contains {@link Flags} which are not * included in the returned {@link Flags} of * {@link #getPermanentFlags(MailboxSession)}. If any are found, these are * removed from the given {@link Flags} instance. The only exception is the * {@link Flag#RECENT} flag. * * This flag is never removed! */ private void trimFlags(Flags flags, MailboxSession session) { Flags permFlags = getPermanentFlags(session); Flag[] systemFlags = flags.getSystemFlags(); for (Flag f : systemFlags) { if (f != Flag.RECENT && permFlags.contains(f) == false) { flags.remove(f); } } // if the permFlags contains the special USER flag we can skip this as // all user flags are allowed if (permFlags.contains(Flags.Flag.USER) == false) { String[] uFlags = flags.getUserFlags(); for (String uFlag : uFlags) { if (permFlags.contains(uFlag) == false) { flags.remove(uFlag); } } } }
Example 4
Source File: MessageFlags.java From james-project with Apache License 2.0 | 5 votes |
/** * Returns IMAP formatted String naming flags. * * @return <code>Collection</code> of <code>String</code>'s naming the * flags. */ public static Collection<String> names(Flags flags) { final Collection<String> results = new ArrayList<>(); if (flags.contains(Flags.Flag.ANSWERED)) { results.add(ANSWERED_OUTPUT_CAPITALISED); } if (flags.contains(Flags.Flag.DELETED)) { results.add(DELETED_OUTPUT_CAPITALISED); } if (flags.contains(Flags.Flag.DRAFT)) { results.add(DRAFT_OUTPUT_CAPITALISED); } if (flags.contains(Flags.Flag.FLAGGED)) { results.add(FLAGGED_OUTPUT_CAPITALISED); } if (flags.contains(Flags.Flag.RECENT)) { results.add(RECENT_OUTPUT_CAPITALISED); } if (flags.contains(Flags.Flag.SEEN)) { results.add(SEEN_OUTPUT_CAPITALISED); } // Add user flags String[] userFlags = flags.getUserFlags(); Collections.addAll(results, userFlags); if (flags.contains(Flags.Flag.USER)) { results.add(USER_OUTPUT_CAPITALISED); } return results; }
Example 5
Source File: UpdatedFlags.java From james-project with Apache License 2.0 | 5 votes |
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; } }
Example 6
Source File: AbstractJPAMailboxMessage.java From james-project with Apache License 2.0 | 5 votes |
@Override public void setFlags(Flags flags) { answered = flags.contains(Flags.Flag.ANSWERED); deleted = flags.contains(Flags.Flag.DELETED); draft = flags.contains(Flags.Flag.DRAFT); flagged = flags.contains(Flags.Flag.FLAGGED); recent = flags.contains(Flags.Flag.RECENT); seen = flags.contains(Flags.Flag.SEEN); String[] userflags = flags.getUserFlags(); userFlags.clear(); for (String userflag : userflags) { userFlags.add(new JPAUserFlag(userflag)); } }
Example 7
Source File: SimpleMailboxMessage.java From james-project with Apache License 2.0 | 5 votes |
@Override public synchronized void setFlags(Flags flags) { answered = flags.contains(Flags.Flag.ANSWERED); deleted = flags.contains(Flags.Flag.DELETED); draft = flags.contains(Flags.Flag.DRAFT); flagged = flags.contains(Flags.Flag.FLAGGED); recent = flags.contains(Flags.Flag.RECENT); seen = flags.contains(Flags.Flag.SEEN); userFlags = flags.getUserFlags(); }
Example 8
Source File: MessageFlags.java From greenmail with Apache License 2.0 | 5 votes |
/** * Returns IMAP formatted String of MessageFlags for named user * * @return IMAP formatted MessageFlag */ public static String format(Flags flags) { StringBuilder buf = new StringBuilder(); buf.append('('); if (flags.contains(Flags.Flag.ANSWERED)) { buf.append("\\Answered "); } if (flags.contains(Flags.Flag.DELETED)) { buf.append("\\Deleted "); } if (flags.contains(Flags.Flag.DRAFT)) { buf.append("\\Draft "); } if (flags.contains(Flags.Flag.FLAGGED)) { buf.append("\\Flagged "); } if (flags.contains(Flags.Flag.RECENT)) { buf.append("\\Recent "); } if (flags.contains(Flags.Flag.SEEN)) { buf.append("\\Seen "); } String[] userFlags = flags.getUserFlags(); if(null!=userFlags) { for(String uf: userFlags) { buf.append(uf).append(' '); } } // Remove the trailing space, if necessary. if (buf.length() > 1) { buf.setLength(buf.length() - 1); } buf.append(')'); return buf.toString(); }
Example 9
Source File: IMAPUtils.java From elasticsearch-imap with Apache License 2.0 | 5 votes |
public static String[] toStringArray(final Flags flags) { final List<String> flagsL = new ArrayList<String>(10); if (flags.contains(Flags.Flag.DELETED)) { flagsL.add("Deleted"); } if (flags.contains(Flags.Flag.ANSWERED)) { flagsL.add("Answered"); } if (flags.contains(Flags.Flag.DRAFT)) { flagsL.add("Draft"); } if (flags.contains(Flags.Flag.FLAGGED)) { flagsL.add("Flagged"); } if (flags.contains(Flags.Flag.RECENT)) { flagsL.add("Recent"); } if (flags.contains(Flags.Flag.SEEN)) { flagsL.add("Seen"); } if (flags.contains(Flags.Flag.USER)) { final String[] userFlags = flags.getUserFlags(); for (int j = 0; j < userFlags.length; j++) { flagsL.add(userFlags[j]); } } return flagsL.toArray(new String[flagsL.size()]); }