Esempio n. 1
0
 public static void doIntercept(HttpServletRequest request, HttpServletResponse response)
     throws IOException {
   String path = request.getRequestURI();
   if (redirect && !path.contains("/admin/") && !redirectUrl.contains(path)) {
     if (redirectUrl != null && redirectStart.isBeforeNow() && redirectEnd.isAfterNow()) {
       response.sendRedirect(redirectUrl);
     }
   }
 }
Esempio n. 2
0
  public static DateTime nextExecution(int hour, int minute) {
    DateTime next =
        new DateTime()
            .withHourOfDay(hour)
            .withMinuteOfHour(minute)
            .withSecondOfMinute(0)
            .withMillisOfSecond(0);

    return (next.isBeforeNow()) ? next.plusHours(24) : next;
  }
Esempio n. 3
0
 @Test
 public void testIndeterminateNowStart() {
   TimePeriod timePeriod = new TimePeriod(null, TimeIndeterminateValue.now, new DateTime(), null);
   DateTime beforeAccess = new DateTime();
   DateTime nowValue = timePeriod.resolveStart();
   assertNotNull("TimePeriod start now value is null", nowValue);
   assertTrue(
       "TimePeriod start now value is too early",
       nowValue.isAfter(beforeAccess) || nowValue.isEqual(beforeAccess));
   assertTrue(
       "TimePeriod start now value is too late", nowValue.isBeforeNow() || nowValue.isEqualNow());
 }
  private boolean validate() {
    if (creator.getInvite() == null) {
      return false;
    } else {
      if (creator.getInvite().date == 0l) {
        String message = "";
        if (creator.getInvite().time == 0l || TextUtils.isEmpty(inviteTitle.getText())) {
          message = getString(R.string.all_fields_error);
        } else {
          message = String.format(getString(R.string.one_field_error), "date");
        }
        Snackbar.make(inviteDetailsCard, message, Snackbar.LENGTH_LONG).show();
        return false;
      }
      if (creator.getInvite().time == 0l) {
        String message = "";
        if (creator.getInvite().date == 0l || TextUtils.isEmpty(inviteTitle.getText())) {
          message = getString(R.string.all_fields_error);
        } else {
          message = String.format(getString(R.string.one_field_error), "time");
        }
        Snackbar.make(inviteDetailsCard, message, Snackbar.LENGTH_LONG).show();
        return false;
      }
      if (TextUtils.isEmpty(inviteTitle.getText())) {
        String message = "";
        if (creator.getInvite().time == 0l || creator.getInvite().date == 0l) {
          message = getString(R.string.all_fields_error);
        } else {
          message = String.format(getString(R.string.one_field_error), "title");
        }
        Snackbar.make(inviteDetailsCard, message, Snackbar.LENGTH_LONG).show();
        return false;
      }

      DateTime time = new DateTime().withMillis(creator.getInvite().time);
      DateTime date = new DateTime().withMillis(creator.getInvite().date);
      DateTime when =
          new DateTime()
              .withYear(date.getYear())
              .withMonthOfYear(date.getMonthOfYear())
              .withDayOfMonth(date.getDayOfMonth())
              .withHourOfDay(time.getHourOfDay())
              .withMinuteOfHour(time.getMinuteOfHour());

      if (when.isBeforeNow()) {
        Snackbar.make(inviteDetailsCard, getString(R.string.wrong_datetime), Snackbar.LENGTH_LONG)
            .show();
        return false;
      }
    }
    return true;
  }
Esempio n. 5
0
  public boolean isOnCurrentPeriod() {
    boolean isOnCurrentPeriod = false;

    if (getCalendarEntry() != null) {
      DateTime beginPeriodDateTime = getCalendarEntry().getBeginPeriodFullDateTime();
      DateTime endPeriodDateTime = getCalendarEntry().getEndPeriodFullDateTime();
      isOnCurrentPeriod =
          (beginPeriodDateTime.isEqualNow() || beginPeriodDateTime.isBeforeNow())
              && endPeriodDateTime.isAfterNow();
    }

    return isOnCurrentPeriod;
  }
  /**
   * Returns true, if the file has expired. Returns false, if the file has not expired or the
   * expiration time-stamp cannot be found.
   *
   * @param fileName the absolute file name
   * @return true, if the file has expired
   */
  public static final boolean isExpired(Path fileName) {
    try {
      DateTime expiresOn = getMetadata(fileName).getExpirationDate();
      if (expiresOn.isBeforeNow()) {
        log.info("{} expired on {}", fileName, expiresOn);
        return true;
      }
    } catch (Exception e) {
      log.error("Failed to get expiration date of file " + fileName, e);
    }

    return false;
  }
 public static void comprobarFechaLimiteJustificacion(Long idSolicitud) {
   try {
     if (FapProperties.get("fap.app.justificacion.fechacierre") != null) {
       String fechaStr = FapProperties.get("fap.app.justificacion.fechacierre");
       DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
       DateTime fechaLimite = formatter.parseDateTime(fechaStr);
       if (fechaLimite.isBeforeNow()) {
         play.Logger.error(
             "La justificaacion de la solicitud "
                 + idSolicitud
                 + " no se ha podido presentar (registrar o firmar). La fecha Límite de Justificación ha expirado: "
                 + fechaStr);
         Messages.keep();
       }
     }
   } catch (Exception e) {
     play.Logger.error(
         "Fallo recuperando y verificando la fecha de cierre de la justificación de la aplicación");
   }
 }
  private synchronized void scheduleRemoval() {

    if (scheduledExpiration != null && scheduledExpiration.isAfterNow()) {
      return;
    }

    DateTime newExpiration = scheduledExpiration;

    do {
      newExpiration = askChatter(DateTime.class, new RemoveAfter(newExpiration));
    } while (newExpiration != null && newExpiration.isBeforeNow());

    scheduledExpiration = newExpiration;

    if (scheduledExpiration != null) {
      autoremover.schedule(
          this,
          scheduledExpiration.getMillis() - System.currentTimeMillis(),
          TimeUnit.MILLISECONDS);
    }
  }
Esempio n. 9
0
  public CacheItem getFromDiskCache(final String url, boolean checkExpiration) {
    CacheItem result = null;

    if (null != mDiskCache) {
      checkNotOnMainThread();

      try {
        final String key = transformUrlForDiskCacheKey(url);
        DiskLruCache.Snapshot snapshot = mDiskCache.get(key);
        if (null != snapshot) {

          Object value = readValueFromDisk(snapshot.getInputStream(0));
          DateTime expiresAt = new DateTime(readExpirationFromDisk(snapshot.getInputStream(1)));

          if (value != null) {

            if (checkExpiration && expiresAt.isBeforeNow()) {
              mDiskCache.remove(key);
              scheduleDiskCacheFlush();
            } else {
              result = new CacheItem(value, expiresAt);
              if (null != mMemoryCache) {
                mMemoryCache.put(url, result);
              }
            }
          } else {
            // If we get here, the file in the cache can't be
            // decoded. Remove it and schedule a flush.
            mDiskCache.remove(key);
            scheduleDiskCacheFlush();
          }
        }
      } catch (IOException e) {
        Timber.e(e, "getFromDiskCache failed.");
      }
    }

    return result;
  }
Esempio n. 10
0
 public boolean isExpired() {
   return expirationTime.isBeforeNow();
 }