Beispiel #1
0
  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;
  }