Class CalendarButtonService
java.lang.Object
fr.paris.lutece.plugins.appointment.service.CalendarButtonService
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 Summary
Modifier and TypeMethodDescriptionstatic StringbuildIcs(String strUid, String strTitle, LocalDateTime dateStart, LocalDateTime dateEnd, String strLocation, String strDescription, String strAvailability) Build the iCalendar file (RFC 5545) of an eventbuildLinks(CalendarButtonConfig config, String strTitle, LocalDateTime dateStart, LocalDateTime dateEnd, String strLocation, String strDescription, String strIcsUrl) Build the links of the calendars proposed by the options.static CalendarButtonConfigRead the options stored as JSONThe values an administrator can choose, by optionstatic StringgetLocation(CalendarButtonConfig config, String strFormAddress) The location of the event: the one of the options, or the address of the formstatic voidsanitize(CalendarButtonConfig config) Bring every option back to an allowed value: unknown calendars are dropped, an unknown color or availability takes the defaultstatic StringtoJson(CalendarButtonConfig config) Write the options as JSONstatic StringtoPlainText(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
-
Method Details
-
fromJson
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
Write the options as JSON- Parameters:
config- the options, may be null- Returns:
- the JSON, null when there are no options
-
sanitize
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
The values an administrator can choose, by option- Returns:
- the lists of values, keyed by option name
-
getLocation
The location of the event: the one of the options, or the address of the form- Parameters:
config- the optionsstrFormAddress- 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 optionsstrTitle- the title of the eventdateStart- the start of the event, in the time zone of the serverdateEnd- the end of the event, in the time zone of the serverstrLocation- the location of the event, may be emptystrDescription- the description of the event, plain text, may be emptystrIcsUrl- 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 eventstrTitle- the title of the eventdateStart- the start of the event, in the time zone of the serverdateEnd- the end of the event, in the time zone of the serverstrLocation- the location of the event, may be emptystrDescription- the description of the event, plain text, may be emptystrAvailability- busy, free or empty- Returns:
- the content of the file
-
toPlainText
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
-