Example #1
0
 protected List<MessageValidator> getMessageValidators(
     final Account account,
     final Folder folder,
     final Set<String> storeMessageIds,
     final String storeBucket,
     final String context) {
   ArrayList<MessageValidator> messageValidators = new ArrayList<MessageValidator>();
   messageValidators.add(
       new DoNothingOnFailureMessageValidator() {
         public Message validate(Message message, int messageNumber, String messageId)
             throws Exception {
           if (isMessageAlreadyProcessed(messageId, account, storeBucket, storeMessageIds)) {
             return null;
           }
           return message;
         }
       });
   messageValidators.add(
       new MessageValidator() {
         public Message validate(Message message, int messageNumber, String messageId)
             throws Exception {
           if (isSentMessage(account, message)) {
             return null;
           }
           return message;
         }
       });
   messageValidators.add(
       new MessageValidator() {
         public Message validate(Message message, int messageNumber, String messageId)
             throws Exception {
           if (isMessageTooOld(account, message, context)) {
             return null;
           }
           return message;
         }
       });
   messageValidators.add(
       new MessageValidator() {
         public Message validate(Message message, int messageNumber, String messageId)
             throws Exception {
           message = getFullyLoad(message, folder, context);
           if (isMessageTooBig(folder, account, message, messageNumber)) {
             return null;
           }
           return message;
         }
       });
   return messageValidators;
 }
  public ArrayList<Account> getAccountList() {
    Connection connect = null;

    try {
      ArrayList<Account> accounts = new ArrayList<>();
      connect = DBConnection.getConnection();

      String sql = "SELECT * FROM account" + "ORDER BY name desc";

      ResultSet result = Utility.queryOperation(connect, sql);
      Account temp = new Account();
      while (result.next()) {
        temp.setName(result.getString("name"));
        temp.setEmail(result.getString("email"));
        temp.setSecondaryEmail(result.getString("secondaryEmail"));
        temp.setTypeAccount(result.getString("typeAccount"));
        temp.setPassword(result.getString("password"));
        temp.setAdmin(result.getBoolean("isAdministrator"));
        accounts.add(temp);
      }
      return accounts;

    } catch (SQLException ex) {
      Logger.getLogger(AccountManager.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      DBConnection.releaseConnection(connect);
    }
    return null;
  }
  public ArrayList<Account> searchUser(String search, String type) throws SQLException {
    Connection connect = null;
    ArrayList<Account> accounts;

    String sql =
        "SELECT * from account WHERE "
            + "name LIKE '%"
            + search
            + "%'"
            + "AND typeAccount = '"
            + type
            + "'";
    String sql2 = "SELECT * from account WHERE " + "typeAccount ='" + type + "'";
    try {
      connect = DBConnection.getConnection();
      accounts = new ArrayList<>();
      if (search.isEmpty()) {
        ResultSet result = Utility.queryOperation(connect, sql2);
        Account temp = new Account();
        while (result.next()) {
          temp.setName(result.getString("name"));
          temp.setEmail(result.getString("email"));
          temp.setSecondaryEmail(result.getString("secondaryEmail"));
          temp.setTypeAccount(result.getString("typeAccount"));
          temp.setPassword(result.getString("password"));
          temp.setAdmin(result.getBoolean("isAdministrator"));
          accounts.add(temp);
        }
      } else {
        ResultSet result = Utility.queryOperation(connect, sql);
        Account temp = new Account();
        while (result.next()) {
          temp.setName(result.getString("name"));
          temp.setEmail(result.getString("email"));
          temp.setSecondaryEmail(result.getString("secondaryEmail"));
          temp.setTypeAccount(result.getString("typeAccount"));
          temp.setPassword(result.getString("password"));
          temp.setAdmin(result.getBoolean("isAdministrator"));
          accounts.add(temp);
        }
      }

    } finally {
      DBConnection.releaseConnection(connect);
    }
    return accounts;
  }
Example #4
0
  public void removeMessages(Message[] removedMessages) {
    try {
      // Translate the array of removed Message instances into a list of all the row indexes to be
      // removed from the model.
      // Assumes the list of removed messages is small.
      ArrayList<Integer> deadIndexes = new ArrayList<Integer>();
      for (Message message : removedMessages) {
        int deadIndex = messages.indexOf(message);
        if (deadIndex != -1) {
          deadIndexes.add(deadIndex);
        }
      }

      // Actually remove the rows, notifying the listeners as we go (rather than bother trying to
      // coalesce).
      for (int i = deadIndexes.size() - 1; i >= 0; --i) {
        int deadIndex = deadIndexes.get(i);
        messages.remove(deadIndex);
        fireTableRowsDeleted(deadIndex, deadIndex);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Example #5
0
 public void addBcc(String bcc) throws MessagingException {
   bccList.add(new InternetAddress(bcc));
 }
Example #6
0
 public void addCc(String cc) throws MessagingException {
   ccList.add(new InternetAddress(cc));
 }
Example #7
0
 public void addTo(String to) throws MessagingException {
   toList.add(new InternetAddress(to));
 }