Class CalendarFeedParser

java.lang.Object
org.exoplatform.agenda.util.CalendarFeedParser

public final class CalendarFeedParser extends Object
Reads an iCalendar document into the occurrences a subscription imports (EXO-90278).

Occurrences, not series. A recurring event is expanded by ical4j — RRULE, RDATE and EXDATE, in the event's own time zone, daylight saving included — within the window, and each instance a RECURRENCE-ID override replaces is taken from the override. Agenda's recurrence model cannot hold every rule a feed may carry, and an expansion is one truthful path for all of them. Every occurrence is identified by its UID and the instant it was originally scheduled at, so a refresh finds the same occurrence again.

What is kept: title, location and description as plain text, the times, whether the event is all-day, and its transparency. A cancelled event or instance is left out. Organizers, attendees, alarms, attachments and URLs are never read.

Bounds: rules repeating by the second or the minute are not expanded, the expansion stops once it has produced four times the number of occurrences kept, and only the earliest maxEvents occurrences are kept.

  • Field Details

    • MAX_TEXT

      public static final int MAX_TEXT
      Longest title or location kept.
      See Also:
    • MAX_DESCRIPTION

      public static final int MAX_DESCRIPTION
      Longest description kept, in characters of plain text.
      See Also:
    • MAX_NAME

      public static final int MAX_NAME
      Longest calendar name kept.
      See Also:
  • Method Details

    • parse

      public static CalendarFeedParser.ParsedCalendar parse(byte[] body, Instant windowStart, Instant windowEnd, int maxEvents) throws CalendarFeedException
      Reads a document.
      Parameters:
      body - the bytes read, UTF-8
      windowStart - occurrences ending at or before this instant are left out
      windowEnd - occurrences starting at or after this instant are left out
      maxEvents - most occurrences kept
      Returns:
      the document read
      Throws:
      CalendarFeedException - when the body is not an iCalendar document, or cannot be read as one
    • descriptionMarkup

      public static String descriptionMarkup(String text)
      Turns a plain-text description into the markup agenda renders a description with: escaped, line breaks kept.
      Parameters:
      text - plain text, may be null
      Returns:
      the markup, null for no text