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; }
/* * Only keep text containing the given string. */ public static List<String> filterProperties(String[] props, String containing) { final ArrayList<String> list = new ArrayList<String>(Arrays.asList(props)); Iterator<String> it = list.iterator(); while (it.hasNext()) { String foo = it.next(); if (!foo.contains(containing)) it.remove(); } return list; }
public void sendEmail() throws MessagingException { if (msg.getFrom() == null) msg.setFrom(new InternetAddress("*****@*****.**")); msg.setHeader("X-mailer", "msgsend"); msg.setRecipients(Message.RecipientType.TO, (Address[]) toList.toArray(new Address[0])); msg.setRecipients(Message.RecipientType.CC, (Address[]) ccList.toArray(new Address[0])); msg.setRecipients(Message.RecipientType.BCC, (Address[]) bccList.toArray(new Address[0])); msg.setSentDate(new Date()); if (!toList.isEmpty()) Transport.send(msg); }
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> 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; }
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(); } }
public void addBcc(String bcc) throws MessagingException { bccList.add(new InternetAddress(bcc)); }
public void addCc(String cc) throws MessagingException { ccList.add(new InternetAddress(cc)); }
public void addTo(String to) throws MessagingException { toList.add(new InternetAddress(to)); }