List of usage examples for javax.mail.search FlagTerm FlagTerm
public FlagTerm(Flags flags, boolean set)
From source file:org.apache.hupa.server.handler.FetchRecentMessagesHandler.java
@Override protected MessageConvertArray getMessagesToConvert(com.sun.mail.imap.IMAPFolder f, FetchRecentMessages action) throws MessagingException { Message[] messages = f.search(new FlagTerm(new Flags(Flag.RECENT), true)); return new MessageConvertArray(messages.length, messages); }
From source file:org.exist.xquery.modules.mail.MessageListFunctions.java
private SearchTerm parseFlagTerm(Node terms) throws XPathException { SearchTerm st = null;/* w w w. ja va 2 s . c om*/ String flag = ((Element) terms).getAttribute("flag"); String value = ((Element) terms).getAttribute("value"); if (StringUtils.isEmpty(value)) { throw (new XPathException(this, "value not specified for term with type: " + ((Element) terms).getAttribute("type"))); } if (flag != null && flag.length() > 0) { Flags flags = null; if (flag.equalsIgnoreCase("answered")) { flags = new Flags(Flags.Flag.ANSWERED); } else if (flag.equalsIgnoreCase("deleted")) { flags = new Flags(Flags.Flag.DELETED); } else if (flag.equalsIgnoreCase("draft")) { flags = new Flags(Flags.Flag.DRAFT); } else if (flag.equalsIgnoreCase("recent")) { flags = new Flags(Flags.Flag.RECENT); } else if (flag.equalsIgnoreCase("seen")) { flags = new Flags(Flags.Flag.SEEN); } else { throw (new XPathException(this, "Invalid flag: " + flag + ", for term with type: " + ((Element) terms).getAttribute("type"))); } st = new FlagTerm(flags, value.equalsIgnoreCase("true")); } else { throw (new XPathException(this, "flag attribute must be specified for term with type: " + ((Element) terms).getAttribute("type"))); } return (st); }
From source file:org.nuxeo.cm.event.MailInjectionListener.java
public void handleEvent(Event event) throws ClientException { MailService mailService = Framework.getService(MailService.class); MessageActionPipe pipe = mailService.getPipe(MAILBOX_PIPE); Visitor visitor = new Visitor(pipe); Thread.currentThread().setContextClassLoader(Framework.class.getClassLoader()); Folder rootFolder = null;/* ww w .ja v a 2 s.co m*/ try (CoreSession session = CoreInstance.openCoreSessionSystem(null)) { // initialize context ExecutionContext initialExecutionContext = new ExecutionContext(); initialExecutionContext.put(AbstractCaseManagementMailAction.CORE_SESSION_KEY, session); initialExecutionContext.put(AbstractCaseManagementMailAction.MIMETYPE_SERVICE_KEY, Framework.getService(MimetypeRegistry.class)); initialExecutionContext.put(AbstractCaseManagementMailAction.CASEMANAGEMENT_SERVICE_KEY, Framework.getService(CaseDistributionService.class)); // open store Store store = mailService.getConnectedStore(IMPORT_MAILBOX); rootFolder = store.getFolder(INBOX); rootFolder.open(Folder.READ_WRITE); Flags flags = new Flags(); flags.add(Flag.SEEN); SearchTerm term = new FlagTerm(flags, false); Message[] unreadMessages = rootFolder.search(term); // perform import visitor.visit(unreadMessages, initialExecutionContext); // save session session.save(); if (rootFolder.isOpen()) { try { rootFolder.close(true); } catch (MessagingException e) { log.error(e.getMessage(), e); } } } catch (MessagingException e) { log.error(e, e); } }
From source file:org.pentaho.di.job.entries.getpop.MailConnection.java
public void setFlagTermNew() { addSearchTerm(new FlagTerm(new Flags(Flags.Flag.RECENT), true)); }
From source file:org.pentaho.di.job.entries.getpop.MailConnection.java
public void setFlagTermOld() { addSearchTerm(new FlagTerm(new Flags(Flags.Flag.RECENT), false)); }
From source file:org.pentaho.di.job.entries.getpop.MailConnection.java
public void setFlagTermRead() { addSearchTerm(new FlagTerm(new Flags(Flags.Flag.SEEN), true)); }
From source file:org.pentaho.di.job.entries.getpop.MailConnection.java
public void setFlagTermUnread() { addSearchTerm(new FlagTerm(new Flags(Flags.Flag.SEEN), false)); }
From source file:org.pentaho.di.job.entries.getpop.MailConnection.java
public void setFlagTermFlagged() { addSearchTerm(new FlagTerm(new Flags(Flags.Flag.FLAGGED), true)); }
From source file:org.pentaho.di.job.entries.getpop.MailConnection.java
public void setFlagTermNotFlagged() { addSearchTerm(new FlagTerm(new Flags(Flags.Flag.FLAGGED), false)); }
From source file:org.pentaho.di.job.entries.getpop.MailConnection.java
public void setFlagTermDraft() { addSearchTerm(new FlagTerm(new Flags(Flags.Flag.DRAFT), true)); }