Class ServerQuirkSummary

java.lang.Object
org.exoplatform.caldav.utils.ServerQuirkSummary

public final class ServerQuirkSummary extends Object
Reads and writes the rolling summary of what a server has been seen doing, stored as one string on its registration row.

The format is deliberately trivial — DIRECTION:PROPERTY=COUNT@LASTSEEN, entries separated by ;, where the stamp is an epoch day. It has to be read by whoever opens the row in a database client while diagnosing a server, and a JSON blob in a column is read by nobody. It also has to survive being written by an older build and read by a newer one, which it does the only way a format this small can: an entry that cannot be read is dropped and the rest of the summary still parses. An entry written before the stamp existed simply has none, and ServerQuirkSummary.Tally.UNKNOWN_DAY says so rather than pretending to a date.

Bounded, because a column is not a log. At most MAX_ENTRIES entries survive a write, the largest counts first, so a server producing a new proprietary property on every copy cannot grow the row without limit. Property names are truncated to MAX_PROPERTY — a name longer than that is not a property name anybody will act on, and the column has a length.

  • Field Details

    • MAX_ENTRIES

      public static final int MAX_ENTRIES
      How many observations one server's summary keeps.
      See Also:
    • MAX_PROPERTY

      public static final int MAX_PROPERTY
      How much of a property name is kept.
      See Also:
  • Method Details

    • parse

      Reads a stored summary.

      Never throws: this parses a value a previous build wrote, and a summary that cannot be read must leave the drawer showing less rather than leave the registration unreadable. An unreadable entry is dropped on its own.

      Parameters:
      summary - the stored value, may be null or blank
      Returns:
      the observations and their counts, in the order they were stored, never null
    • format

      public static String format(Map<ServerQuirkSummary.Observation,ServerQuirkSummary.Tally> observations)
      Writes a summary back, largest counts first and bounded in both directions.
      Parameters:
      observations - the observations and their counts
      Returns:
      the value to store, null when there is nothing to store