Class CalendarButtonService

java.lang.Object
fr.paris.lutece.plugins.appointment.service.CalendarButtonService

public final class CalendarButtonService extends Object
Service class for the "add to calendar" button: options stored as JSON, links to the online calendars and iCalendar (RFC 5545) file. Link formats: https://github.com/InteractionDesignFoundation/add-event-to-calendar-docs
  • Method Details

    • fromJson

      public static CalendarButtonConfig fromJson(String strJson)
      Read the options stored as JSON
      Parameters:
      strJson - the JSON, may be null
      Returns:
      the options, the defaults when the JSON is empty or unreadable
    • toJson

      public static String toJson(CalendarButtonConfig config)
      Write the options as JSON
      Parameters:
      config - the options, may be null
      Returns:
      the JSON, null when there are no options
    • sanitize

      public static void sanitize(CalendarButtonConfig config)
      Bring every option back to an allowed value: unknown calendars are dropped, an unknown color or availability takes the default
      Parameters:
      config - the options to clean
    • getChoices

      public static Map<String,List<String>> getChoices()
      The values an administrator can choose, by option
      Returns:
      the lists of values, keyed by option name
    • getLocation

      public static String getLocation(CalendarButtonConfig config, String strFormAddress)
      The location of the event: the one of the options, or the address of the form
      Parameters:
      config - the options
      strFormAddress - the address of the form, may be null
      Returns:
      the location, empty when there is none
    • buildLinks

      public static Map<String,String> buildLinks(CalendarButtonConfig config, String strTitle, LocalDateTime dateStart, LocalDateTime dateEnd, String strLocation, String strDescription, String strIcsUrl)
      Build the links of the calendars proposed by the options. Yahoo has no time zone and ignores the Z suffix: it receives the local time of the appointment, the other calendars receive UTC. Microsoft Teams has no location: it opens the content of the meeting. Apple and the iCal file both download the iCalendar file.
      Parameters:
      config - the options
      strTitle - the title of the event
      dateStart - the start of the event, in the time zone of the server
      dateEnd - the end of the event, in the time zone of the server
      strLocation - the location of the event, may be empty
      strDescription - the description of the event, plain text, may be empty
      strIcsUrl - the URL of the iCalendar file of the event
      Returns:
      the links, keyed by calendar, in the order of the options
    • buildIcs

      public static String buildIcs(String strUid, String strTitle, LocalDateTime dateStart, LocalDateTime dateEnd, String strLocation, String strDescription, String strAvailability)
      Build the iCalendar file (RFC 5545) of an event
      Parameters:
      strUid - the unique identifier of the event
      strTitle - the title of the event
      dateStart - the start of the event, in the time zone of the server
      dateEnd - the end of the event, in the time zone of the server
      strLocation - the location of the event, may be empty
      strDescription - the description of the event, plain text, may be empty
      strAvailability - busy, free or empty
      Returns:
      the content of the file
    • toPlainText

      public static String toPlainText(String strHtml)
      Turn a rich text into the plain text of a calendar description: tags removed, entities decoded, a line break for each paragraph, line break and list item, spaces collapsed
      Parameters:
      strHtml - the rich text, may be null
      Returns:
      the plain text, empty when there is none