Search in sources :

Example 41 with PropertyList

use of net.fortuna.ical4j.model.PropertyList in project openolat by klemens.

the class ICalServlet method updateUrlProperties.

private void updateUrlProperties(Calendar calendar) {
    for (Iterator<?> eventIter = calendar.getComponents().iterator(); eventIter.hasNext(); ) {
        Object comp = eventIter.next();
        if (comp instanceof VEvent) {
            VEvent event = (VEvent) comp;
            PropertyList ooLinkProperties = event.getProperties(CalendarManager.ICAL_X_OLAT_LINK);
            if (ooLinkProperties.isEmpty()) {
                continue;
            }
            Url currentUrl = event.getUrl();
            if (currentUrl != null) {
                continue;
            }
            for (Iterator<?> iter = ooLinkProperties.iterator(); iter.hasNext(); ) {
                XProperty linkProperty = (XProperty) iter.next();
                if (linkProperty != null) {
                    String encodedLink = linkProperty.getValue();
                    StringTokenizer st = new StringTokenizer(encodedLink, "ยง", false);
                    if (st.countTokens() >= 4) {
                        // provider
                        st.nextToken();
                        // id
                        st.nextToken();
                        // displayname
                        st.nextToken();
                        String uri = st.nextToken();
                        try {
                            Url urlProperty = new Url();
                            urlProperty.setValue(uri);
                            event.getProperties().add(urlProperty);
                            break;
                        } catch (URISyntaxException e) {
                            log.error("Invalid URL:" + uri);
                        }
                    }
                }
            }
        }
    }
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) StringTokenizer(java.util.StringTokenizer) PropertyList(net.fortuna.ical4j.model.PropertyList) XProperty(net.fortuna.ical4j.model.property.XProperty) URISyntaxException(java.net.URISyntaxException) Url(net.fortuna.ical4j.model.property.Url)

Aggregations

PropertyList (net.fortuna.ical4j.model.PropertyList)41 VEvent (net.fortuna.ical4j.model.component.VEvent)17 Property (net.fortuna.ical4j.model.Property)13 XProperty (net.fortuna.ical4j.model.property.XProperty)12 DateTime (net.fortuna.ical4j.model.DateTime)11 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)11 DtStart (net.fortuna.ical4j.model.property.DtStart)9 Uid (net.fortuna.ical4j.model.property.Uid)9 URISyntaxException (java.net.URISyntaxException)8 Calendar (net.fortuna.ical4j.model.Calendar)8 Description (net.fortuna.ical4j.model.property.Description)8 Date (java.util.Date)7 Period (net.fortuna.ical4j.model.Period)7 DtEnd (net.fortuna.ical4j.model.property.DtEnd)7 Duration (net.fortuna.ical4j.model.property.Duration)7 RecurrenceId (net.fortuna.ical4j.model.property.RecurrenceId)7 Parameter (net.fortuna.ical4j.model.Parameter)6 PeriodList (net.fortuna.ical4j.model.PeriodList)6 VFreeBusy (net.fortuna.ical4j.model.component.VFreeBusy)6 VTimeZone (net.fortuna.ical4j.model.component.VTimeZone)6