@Override public String serialize(Object input) { if (input instanceof LocalDateTime) { return Time.forStorage((LocalDateTime) input); } else if (input instanceof String) { return (String) input; } else { return null; } }
private LocalDateTime toDateTime(Date date) { if (date == null) { return null; } else { return Time.from(date, null); } }
/** * Parses the date defined in the application configuration properties as <code>ontrack.version.date</code>. */ public static LocalDateTime parseDate(String value) { if (StringUtils.isBlank(value)) { logger.info("[version-info] No date defined, using current date."); return Time.now(); } else { try { return LocalDateTime.parse(value, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")); } catch (DateTimeParseException ex) { logger.warn("[version-info] Wrong date format, using current date: " + value); return Time.now(); } } } }
@Override public LocalDateTime parseValue(Object input) { if (input instanceof LocalDateTime) { return (LocalDateTime) input; } else if (input instanceof String) { return Time.fromStorage((String) input); } else { return null; } }
protected static LocalDateTime dateTimeFromDB(String value) { return Time.fromStorage(value); }
public Signature withTime(LocalDateTime dateTime) { return new Signature(dateTime != null ? dateTime : Time.now(), user); } }
@Override public LocalDateTime getUpdateTime() { return Time.from(gitlabIssue.getUpdatedAt(), null); }
protected static String dateTimeForDB(LocalDateTime time) { return Time.forStorage(time); }
public static Signature of(String name) { return of(Time.now(), name); }
private SVNChangeLogRevision createChangeLogRevision(SVNRepository repository, String path, int level, SVNLogEntry svnEntry) { return SVNServiceUtils.createChangeLogRevision( repository, path, level, svnEntry.getRevision(), svnEntry.getMessage(), svnEntry.getAuthor(), Time.from(svnEntry.getDate(), null) ); }
private synchronized void doLog(ApplicationLogEntry entry) { // Logging logger.error( String.format( "[%s] name=%s,authentication=%s,timestamp=%s,%s%nStacktrace: %s", entry.getLevel(), entry.getType().getName(), entry.getAuthentication(), Time.forStorage(entry.getTimestamp()), entry.getDetailList().stream() .map(nd -> String.format("%s=%s", nd.getName(), nd.getDescription())) .collect(Collectors.joining(",")), entry.getStacktrace() ) ); // Storing in database entriesRepository.log(entry); // Metrics meterRegistry.counter( "ontrack_error", "type", entry.getType().getName() ).increment(); }
private static ApplicationLogEntry create(ApplicationLogEntryLevel level, Throwable exception, NameDescription type, String information) { return new ApplicationLogEntry( level, Time.now(), null, type, information, null, Collections.emptyMap() ).withStacktrace(ExceptionUtils.getStackTrace(exception)); }
private SVNReference getReference(SVNRepository repository, String path, SVNRevision revision) { String url = repository.getUrl(path); SVNURL svnurl = SVNUtils.toURL(url); SVNInfo info = getInfo(repository, svnurl, revision); return new SVNReference( path, url, info.getRevision().getNumber(), Time.from(info.getCommittedDate(), null) ); }
public static Signature none() { return new Signature( Time.now(), User.anonymous() ); }
@Override public void cleanup(int retentionDays) { LocalDateTime pivotDate = Time.now().minus(retentionDays, ChronoUnit.DAYS); getNamedParameterJdbcTemplate().update( "DELETE FROM APPLICATION_LOG_ENTRIES WHERE TIMESTAMP < :date", params("date", dateTimeForDB(pivotDate)) ); }