public boolean isAccountBeingUsed(Account account) { if (log.isDebugEnabled()) log.debug( String.format( "Checking account %s, user_id %s for last registration with location service", account.getId(), account.getUser_id())); IPeekLocationService locationService = new PeekLocationService(); Date lastUpdated = null; try { lastUpdated = locationService.getLastUpdatedTimestamp(account.getUser_id()); } catch (DALException e) { log.error(UtilsTools.getExceptionStackTrace(e)); } if (lastUpdated == null) { log.debug("Last updated value not found, so we should still check this account"); return true; } Date now = new Date(); Long interval = dayMultiplier * mailcheckDisableIntervalInHours; Long sinceLastConnection = now.getTime() - lastUpdated.getTime(); if (sinceLastConnection > interval) { if (log.isDebugEnabled()) log.debug( String.format( "Last mail check was %s hours ago, > %s hour interval , we will not check this account", sinceLastConnection / dayMultiplier, interval / dayMultiplier)); return false; } return true; }
private static MimeMessage createMsg( String to, String from, String cc, String bcc, String message, String subject, Session session) throws Exception { if (logger.isTraceEnabled()) logger.trace( String.format( "createMsg(to=%s, from=%s, cc=%s, bcc=%s, message=%s, subject=%s)", String.valueOf(to), String.valueOf(from), String.valueOf(cc), String.valueOf(bcc), String.valueOf(message), String.valueOf(subject))); MimeMessage msg = new MimeMessage(session); msg.setFrom(tranFromAddr(from)); if (to != null && !"".equals(to.trim())) { msg.setRecipients(Message.RecipientType.TO, UtilsTools.tranAddr(to.trim())); } if (cc != null && !"".equals(cc.trim())) { msg.setRecipients(Message.RecipientType.CC, UtilsTools.tranAddr(cc.trim())); } if (bcc != null && !"".equals(bcc.trim())) { msg.setRecipients(Message.RecipientType.BCC, UtilsTools.tranAddr(bcc.trim())); } msg.setSubject(subject); msg.setText(message); msg.saveChanges(); return msg; }