Esempio n. 1
0
 public Date getMessageDate(Message message) throws MessagingException {
   Date messageDate = message.getReceivedDate();
   if (message.getReceivedDate() == null) {
     if (message.getSentDate() != null) {
       messageDate = message.getSentDate();
     }
   }
   return messageDate;
 }
Esempio n. 2
0
  public int handleFirstTime(
      Account account,
      FolderHelper folderHelper,
      int folderDepth,
      String messageStoreBucket,
      Set<String> storedMessageIds,
      String context,
      StopWatch watch)
      throws Exception {
    int newMessages = 0;
    Date lastMessageReceivedDate = null;
    log.info(String.format("handling first mailcheck for %s", context));

    Folder folder;
    while ((folder = folderHelper.next()) != null) {
      String folderContext = context + " ,folderName=" + folder.getFullName();
      IMAPFolder imapFolder = (IMAPFolder) folder;

      Collection<Integer> messages = getFirstTimeMessages(imapFolder, folderContext);

      if (messages.size() > 0) {
        storedMessageIds = new HashSet<String>();

        for (Integer messageNumber : messages) {
          Message message = imapFolder.getMessage(messageNumber);

          if (lastMessageReceivedDate == null
              || lastMessageReceivedDate.before(message.getReceivedDate())) {
            lastMessageReceivedDate = message.getReceivedDate();
          }

          String messageId = getId(account, imapFolder, message);

          if (processMessage(
              account,
              message,
              messageNumber,
              messageId,
              imapFolder,
              storedMessageIds,
              messageStoreBucket,
              folderContext,
              watch,
              folderHelper)) {
            newMessages++;
          }
        }
      }
    }
    updateAccount(account, null, 0, folderDepth, lastMessageReceivedDate);
    return newMessages;
  }
Esempio n. 3
0
 private Date getDateToDetermineOrder(Message message) throws MessagingException {
   return message instanceof IMAPMessage ? message.getReceivedDate() : message.getSentDate();
 }