private void compareActionRecords(ActionLogRecord expected, ActionLogRecord received) {
   assertEquals(expected.getId(), received.getId());
   assertEquals(expected.getUsername(), received.getUsername());
   assertEquals(expected.getActionName(), received.getActionName());
   assertEquals(expected.getNamespace(), received.getNamespace());
   assertEquals(expected.getParameters(), received.getParameters());
   assertEquals(
       DateConverter.getFormattedDate(expected.getActionDate(), "ddMMyyyyHHmm"),
       DateConverter.getFormattedDate(received.getActionDate(), "ddMMyyyyHHmm"));
 }
 public List<AttributeFieldError> validate(
     AttributeInterface attribute, AttributeTracer tracer, ILangManager langManager) {
   List<AttributeFieldError> errors = super.validate(attribute, tracer, langManager);
   if (this.isEmpty()) return errors;
   try {
     Date attributeValue = ((DateAttribute) attribute).getDate();
     if (null == attributeValue) return errors;
     Date startValue =
         (this.getRangeStart() != null)
             ? (Date) this.getRangeStart()
             : this.getOtherAttributeValue(attribute, this.getRangeStartAttribute());
     if (null != startValue && attributeValue.before(startValue)) {
       AttributeFieldError error =
           new AttributeFieldError(attribute, FieldError.LESS_THAN_ALLOWED, tracer);
       String allowedDate = DateConverter.getFormattedDate(startValue, DATE_PATTERN);
       error.setMessage("Date less than " + allowedDate);
       errors.add(error);
     }
     Date endValue =
         (this.getRangeEnd() != null)
             ? (Date) this.getRangeEnd()
             : this.getOtherAttributeValue(attribute, this.getRangeEndAttribute());
     if (null != endValue && attributeValue.after(endValue)) {
       AttributeFieldError error =
           new AttributeFieldError(attribute, FieldError.GREATER_THAN_ALLOWED, tracer);
       String allowedDate = DateConverter.getFormattedDate(endValue, DATE_PATTERN);
       error.setMessage("Date greater than " + allowedDate);
       errors.add(error);
     }
     Date value =
         (this.getValue() != null)
             ? (Date) this.getValue()
             : this.getOtherAttributeValue(attribute, this.getValueAttribute());
     if (null != value && !attributeValue.equals(value)) {
       AttributeFieldError error =
           new AttributeFieldError(attribute, FieldError.NOT_EQUALS_THAN_ALLOWED, tracer);
       String allowedDate = DateConverter.getFormattedDate(value, DATE_PATTERN);
       error.setMessage("Date not equals than " + allowedDate);
       errors.add(error);
     }
   } catch (Throwable t) {
     ApsSystemUtils.logThrowable(
         t, this, "validate", "Error validating Attribute '" + attribute.getName() + "'");
     throw new RuntimeException("Error validating Attribute '" + attribute.getName() + "'", t);
   }
   return errors;
 }
 /**
  * Costruttore dello scheduler
  *
  * @param task Task da eseguire.
  * @param start Data di partenza dello scheduler
  * @param delay Intervallo di schedulazione in millisecondi
  */
 public Scheduler(Task task, Date start, long delay) {
   this._timer = new Timer();
   this._task = task;
   this._timer.schedule(this, start, delay);
   ApsSystemUtils.getLogger()
       .trace(
           "jpcontentworkflow: Scheduler - StartTime: "
               + DateConverter.getFormattedDate(start, "dd/MM/yyyy HH:mm:ss")
               + " - Delay: "
               + delay);
 }
 /** Generated random token */
 protected String createToken(String word) throws NoSuchAlgorithmException {
   Random random = new Random();
   StringBuffer salt = new StringBuffer();
   long rndLong = random.nextLong();
   salt.append(rndLong);
   String date = DateConverter.getFormattedDate(new Date(), "SSSmmyyyy-SSS-MM:ssddmmHHmmEEE");
   salt.append(date);
   rndLong = random.nextLong();
   salt.append(rndLong);
   // genero il token in base a username e salt
   String token = ShaEncoder.encodeWord(word, salt.toString());
   return token;
 }
 private String toStringValue(Object value) {
   if (null == value) return null;
   Date date = null;
   if (value instanceof XMLGregorianCalendar) {
     XMLGregorianCalendar grCal = (XMLGregorianCalendar) value;
     Calendar calendar = Calendar.getInstance();
     calendar.set(Calendar.DAY_OF_MONTH, grCal.getDay());
     calendar.set(Calendar.MONTH, grCal.getMonth() - 1);
     calendar.set(Calendar.YEAR, grCal.getYear());
     date = calendar.getTime();
   } else if (value instanceof Date) {
     date = (Date) value;
   }
   if (null != date) {
     return DateConverter.getFormattedDate(date, DATE_PATTERN);
   }
   return null;
 }
 private void deleteStatsRecord() throws ApsSystemException {
   String today = DateConverter.getFormattedDate(new Date(), "dd/MM/yyyy");
   Calendar start = CalendarConverter.getCalendarDay(today, 0, 0, 0, 0);
   Calendar end = CalendarConverter.getCalendarDay(today, 23, 59, 59, 999);
   _statsManager.deleteStatsRecord(start.getTime(), end.getTime());
 }