Class IcalUtils
- 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.
-
-
Constructor Summary
Constructors Constructor Description IcalUtils()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DateaddTimetoDate(Date date, int field, int amount)Adds a specified amount of time to a Date.net.fortuna.ical4j.model.CalendarparseAppointmentstoCalendar(List<Appointment> appointments, Long ownerId)Parses a List of Appointments into a VCALENDAR component.net.fortuna.ical4j.model.CalendarparseAppointmenttoCalendar(Appointment appointment)Methods to parse Appointment to iCalendar according RFC 2445AppointmentparseCalendartoAppointment(net.fortuna.ical4j.model.Calendar calendar, String href, String etag, OmCalendar omCalendar)Parses the Calendar from the CalDAV server, to a new Appointment.AppointmentparseCalendartoAppointment(Appointment a, net.fortuna.ical4j.model.Calendar calendar, String etag)Updating Appointments which already exist, by parsing the Calendar.List<Appointment>parseCalendartoAppointments(net.fortuna.ical4j.model.Calendar calendar, Long ownerId)Parses a Calendar with multiple VEvents into AppointmentsDateparseDate(String str, TimeZone inTimeZone)Adapted from DateUtils to support Timezones, and parse ical dates intoDate.DateparseDate(net.fortuna.ical4j.model.Property dt, TimeZone timeZone)Convenience function to parse date fromPropertytoDateTimeZoneparseTimeZone(net.fortuna.ical4j.model.Calendar calendar, User owner)Parses the VTimezone Component of the given Calendar.
-
-
-
Field Detail
-
PROD_ID
public static final String PROD_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
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 serveretag- 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 ParseownerId- Owner of the Appointments- Returns:
Listof 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 parseowner- Owner of the Calendar- Returns:
- Parsed TimeZone
-
parseDate
public Date parseDate(net.fortuna.ical4j.model.Property dt, TimeZone timeZone)
Convenience function to parse date fromPropertytoDate- Parameters:
dt- DATE-TIME Property from which we parse.timeZone- Timezone of the Date.- Returns:
Daterepresentation of the iCalendar value.
-
parseDate
public Date parseDate(String str, TimeZone inTimeZone)
Adapted from DateUtils to support Timezones, and parse ical dates intoDate. Note: Replace FastDateFormat to java.time, when shifting to Java 8 or higher.- Parameters:
str- Date representation in String.patterns- Patterns to parse the date againstinTimeZone- Timezone of the Date.- Returns:
java.util.Daterepresentation of string ornullif 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 addedfield- Date Field to which the Amount is addedamount- 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 CalendarownerId- Owner of the Appointments- Returns:
- VCALENDAR representation of the Appointments
-
-