java.lang.Object
org.apache.openmeetings.service.calendar.caldav.IcalUtils

@Component public class IcalUtils extends Object
Class which provides iCalendar Utilities. This class's functions could be made static, as they are not instantiated anyway.
  • Field Details

  • Constructor Details

    • IcalUtils

      public IcalUtils()
  • Method Details

    • parseCalendartoAppointment

      public Appointment parseCalendartoAppointment(net.fortuna.ical4j.model.Calendar calendar, String href, String etag, OmCalendar omCalendar)
      Parses the Calendar from the CalDAV server, to a new Appointment.
      Parameters:
      calendar - iCalendar Representation.
      href - Location of the Calendar on the server
      etag - ETag of the calendar.
      omCalendar - The Parent OmCalendar, to which the Appointment belongs.
      Returns:
      Appointment after parsing.
    • parseCalendartoAppointments

      public List<Appointment> parseCalendartoAppointments(net.fortuna.ical4j.model.Calendar calendar, Long ownerId)
      Parses a Calendar with multiple VEvents into Appointments
      Parameters:
      calendar - Calendar to Parse
      ownerId - Owner of the Appointments
      Returns:
      List of Appointments
    • parseCalendartoAppointment

      public Appointment parseCalendartoAppointment(Appointment a, net.fortuna.ical4j.model.Calendar calendar, String etag)
      Updating Appointments which already exist, by parsing the Calendar. And updating etag. Doesn't work with complex Recurrences. Note: Hasn't been tested to acknowledge DST, timezones should acknowledge this.
      Parameters:
      a - Appointment to be updated.
      calendar - iCalendar Representation.
      etag - The ETag of the calendar.
      Returns:
      Updated Appointment.
    • parseTimeZone

      public TimeZone parseTimeZone(net.fortuna.ical4j.model.Calendar calendar, User owner)
      Parses the VTimezone Component of the given Calendar. If no, VTimezone component is found the User Timezone is used
      Parameters:
      calendar - Calendar to parse
      owner - Owner of the Calendar
      Returns:
      Parsed TimeZone
    • parseDate

      public Date parseDate(net.fortuna.ical4j.model.Property dt, TimeZone timeZone)
      Convenience function to parse date from Property to Date
      Parameters:
      dt - DATE-TIME Property from which we parse.
      timeZone - Timezone of the Date.
      Returns:
      Date representation of the iCalendar value.
    • parseDate

      public Date parseDate(String str, TimeZone inTimeZone)
      Adapted from DateUtils to support Timezones, and parse ical dates into Date. Note: Replace FastDateFormat to java.time, when shifting to Java 8 or higher.
      Parameters:
      str - Date representation in String.
      inTimeZone - Timezone of the Date.
      Returns:
      java.util.Date representation of string or null if the Date could not be parsed.
    • addTimetoDate

      public Date addTimetoDate(Date date, int field, int amount)
      Adds a specified amount of time to a Date.
      Parameters:
      date - Date to which time is added
      field - Date Field to which the Amount is added
      amount - Amount to be Added
      Returns:
      New Date
    • parseAppointmenttoCalendar

      public net.fortuna.ical4j.model.Calendar parseAppointmenttoCalendar(Appointment appointment)
      Methods to parse Appointment to iCalendar according RFC 2445
      Parameters:
      appointment - to be converted to iCalendar
      Returns:
      iCalendar representation of the Appointment
    • parseAppointmentstoCalendar

      public net.fortuna.ical4j.model.Calendar parseAppointmentstoCalendar(List<Appointment> appointments, Long ownerId)
      Parses a List of Appointments into a VCALENDAR component.
      Parameters:
      appointments - List of Appointments for the Calendar
      ownerId - Owner of the Appointments
      Returns:
      VCALENDAR representation of the Appointments