Esempio n. 1
0
 public boolean processMessage(
     Account account,
     Message message,
     int messageNumber,
     String messageId,
     Folder folder,
     Set<String> storeMessageIds,
     String storeBucket,
     String context,
     StopWatch watch,
     FolderHelper folderHelper,
     EmailProcess emailProcess)
     throws Exception {
   List<MessageValidator> messageValidators =
       getMessageValidators(account, folder, storeMessageIds, storeBucket, context);
   folderHelper.addMessageValidators(messageValidators);
   return processMessage(
           account,
           storeBucket,
           message,
           messageNumber,
           messageId,
           context,
           watch,
           messageValidators,
           emailProcess)
       != null;
 }
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;
  }