Search in sources :

Example 1 with Description

use of net.fortuna.ical4j.model.property.Description in project LAMSADE-tools by LAntoine.

the class Conference method generateCalendarFile.

/**
	 * Generates a vcal file with the conference details with this object's data
	 *
	 * @param filename:
	 *            the path including the name of the file to be generated
	 * @throws IOException
	 * @throws ValidationException
	 * @throws ParserException
	 *
	 * @author Javier Martínez
	 */
public void generateCalendarFile(String filename) throws IOException, ValidationException, ParserException {
    String calFile = filename;
    // start time
    java.util.Calendar startCal = java.util.Calendar.getInstance();
    startCal.setTime(java.sql.Date.valueOf(getStart_date()));
    // end time
    java.util.Calendar endCal = java.util.Calendar.getInstance();
    endCal.setTime(java.sql.Date.valueOf(getEnd_date()));
    String subject = "Conference";
    String description = "A conference with a fee of " + getEntry_fee();
    String hostEmail = "";
    // Creating a new calendar
    net.fortuna.ical4j.model.Calendar calendar = new net.fortuna.ical4j.model.Calendar();
    calendar.getProperties().add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN"));
    calendar.getProperties().add(Version.VERSION_2_0);
    calendar.getProperties().add(CalScale.GREGORIAN);
    SimpleDateFormat sdFormat = new SimpleDateFormat("yyyyMMdd'T'hhmmss'Z'");
    String strDate = sdFormat.format(startCal.getTime());
    net.fortuna.ical4j.model.Date startDt = null;
    try {
        startDt = new net.fortuna.ical4j.model.Date(strDate);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    long diff = endCal.getTimeInMillis() - startCal.getTimeInMillis();
    int min = (int) (diff / (1000 * 60));
    Dur dur = new Dur(0, 0, min, 0);
    // Creating a meeting event
    VEvent meeting = new VEvent(startDt, dur, subject);
    // This is where you would add a location if there was one
    // meeting.getProperties().add(new Location(location));
    meeting.getProperties().add(new Description());
    try {
        meeting.getProperties().getProperty(Property.DESCRIPTION).setValue(description);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    calendar.getComponents().add(meeting);
    FileOutputStream fout = null;
    try {
        fout = new FileOutputStream(calFile);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    CalendarOutputter outputter = new CalendarOutputter();
    outputter.setValidating(false);
    try {
        outputter.output(calendar, fout);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ValidationException e) {
        e.printStackTrace();
    }
    System.out.println(meeting);
}
Also used : Dur(net.fortuna.ical4j.model.Dur) VEvent(net.fortuna.ical4j.model.component.VEvent) Description(net.fortuna.ical4j.model.property.Description) ValidationException(net.fortuna.ical4j.model.ValidationException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) ProdId(net.fortuna.ical4j.model.property.ProdId) FileOutputStream(java.io.FileOutputStream) ParseException(java.text.ParseException) CalendarOutputter(net.fortuna.ical4j.data.CalendarOutputter) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with Description

use of net.fortuna.ical4j.model.property.Description in project openmeetings by apache.

the class IcalUtils method addVEventpropsfromAppointment.

/**
 * Adds the Appointment Properties to the given VEvent
 *
 * @param appointment Appointment whose properties are taken
 * @param meeting     VEvent of the Appointment
 * @return Updated VEvent
 */
private static VEvent addVEventpropsfromAppointment(Appointment appointment, VEvent meeting) {
    if (appointment.getLocation() != null) {
        meeting.getProperties().add(new Location(appointment.getLocation()));
    }
    meeting.getProperties().add(new Description(appointment.getDescription()));
    meeting.getProperties().add(new Sequence(0));
    meeting.getProperties().add(Transp.OPAQUE);
    String uid = appointment.getIcalId();
    Uid ui;
    if (uid == null || uid.length() < 1) {
        UUID uuid = UUID.randomUUID();
        appointment.setIcalId(uuid.toString());
        ui = new Uid(uuid.toString());
    } else {
        ui = new Uid(uid);
    }
    meeting.getProperties().add(ui);
    if (appointment.getMeetingMembers() != null) {
        for (MeetingMember meetingMember : appointment.getMeetingMembers()) {
            Attendee attendee = new Attendee(URI.create("mailto:" + meetingMember.getUser().getAddress().getEmail()));
            attendee.getParameters().add(Role.REQ_PARTICIPANT);
            attendee.getParameters().add(new Cn(meetingMember.getUser().getLogin()));
            meeting.getProperties().add(attendee);
        }
    }
    URI orgUri = URI.create("mailto:" + appointment.getOwner().getAddress().getEmail());
    Attendee orgAtt = new Attendee(orgUri);
    orgAtt.getParameters().add(Role.CHAIR);
    Cn orgCn = new Cn(appointment.getOwner().getLogin());
    orgAtt.getParameters().add(orgCn);
    meeting.getProperties().add(orgAtt);
    Organizer organizer = new Organizer(orgUri);
    organizer.getParameters().add(orgCn);
    meeting.getProperties().add(organizer);
    return meeting;
}
Also used : Uid(net.fortuna.ical4j.model.property.Uid) Description(net.fortuna.ical4j.model.property.Description) Organizer(net.fortuna.ical4j.model.property.Organizer) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) Sequence(net.fortuna.ical4j.model.property.Sequence) Cn(net.fortuna.ical4j.model.parameter.Cn) UUID(java.util.UUID) URI(java.net.URI) Attendee(net.fortuna.ical4j.model.property.Attendee) Location(net.fortuna.ical4j.model.property.Location)

Example 3 with Description

use of net.fortuna.ical4j.model.property.Description in project openmeetings by apache.

the class IcalHandler method addNewMeeting.

/**
 * @param startDate
 *            use standard TimeZone!!
 * @param endDate
 *            use standard time zone!!
 * @param name
 *            meeting name
 * @param attendees
 *            List of attendees (use getAttendeeData to retrieve valid records)
 * @param description
 *            containing the meeting description
 * @param organizer
 *            organizer
 * @param uid
 *            (maybe null)
 * @param javaTzId ID of owner's java time zone
 * @return UID of Meeting
 */
// ---------------------------------------------------------------------------------------
public String addNewMeeting(Date startDate, Date endDate, String name, List<Map<String, String>> attendees, String description, Map<String, String> organizer, String uid, String javaTzId) {
    TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
    TimeZone timeZone = registry.getTimeZone(javaTzId);
    if (timeZone == null) {
        throw new NoSuchElementException("Unable to get time zone by id provided: " + javaTzId);
    }
    DateTime start = new DateTime(startDate);
    start.setTimeZone(timeZone);
    DateTime end = new DateTime(endDate);
    end.setTimeZone(timeZone);
    VEvent meeting = new VEvent(start, end, name);
    meeting.getProperties().add(new Description(description));
    meeting.getProperties().add(new Sequence(0));
    meeting.getProperties().add(new Location(""));
    meeting.getProperties().add(Transp.OPAQUE);
    // generate unique identifier (if not submitted)
    Uid ui;
    if (Strings.isEmpty(uid)) {
        ui = new Uid(UUID.randomUUID().toString());
        log.debug("Generating Meeting UID : " + ui.getValue());
    } else {
        ui = new Uid(uid);
        log.debug("Using Meeting UID : " + ui.getValue());
    }
    meeting.getProperties().add(ui);
    for (Map<String, String> att : attendees) {
        Attendee uno = new Attendee(URI.create(att.get("uri")));
        String chair = att.get("chair");
        uno.getParameters().add("0".equals(chair) ? Role.REQ_PARTICIPANT : Role.CHAIR);
        uno.getParameters().add(new Cn(att.get("cn")));
        meeting.getProperties().add(uno);
    }
    Organizer orger = new Organizer(URI.create(organizer.get("uri")));
    orger.getParameters().add(new Cn(organizer.get("cn")));
    meeting.getProperties().add(orger);
    icsCalendar.getComponents().add(timeZone.getVTimeZone());
    icsCalendar.getComponents().add(meeting);
    return ui.getValue();
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) Description(net.fortuna.ical4j.model.property.Description) Organizer(net.fortuna.ical4j.model.property.Organizer) TimeZoneRegistry(net.fortuna.ical4j.model.TimeZoneRegistry) Sequence(net.fortuna.ical4j.model.property.Sequence) Cn(net.fortuna.ical4j.model.parameter.Cn) DateTime(net.fortuna.ical4j.model.DateTime) Attendee(net.fortuna.ical4j.model.property.Attendee) Uid(net.fortuna.ical4j.model.property.Uid) TimeZone(net.fortuna.ical4j.model.TimeZone) NoSuchElementException(java.util.NoSuchElementException) Location(net.fortuna.ical4j.model.property.Location)

Example 4 with Description

use of net.fortuna.ical4j.model.property.Description in project bw-calendar-engine by Bedework.

the class VAlarmUtil method setAlarm.

private static VAlarm setAlarm(final BwEvent ev, final BwAlarm val) throws CalFacadeException {
    try {
        VAlarm alarm = new VAlarm();
        int atype = val.getAlarmType();
        String action;
        if (atype != BwAlarm.alarmTypeOther) {
            action = BwAlarm.alarmTypes[atype];
        } else {
            List<BwXproperty> xps = val.getXicalProperties("ACTION");
            action = xps.get(0).getValue();
        }
        addProperty(alarm, new Action(action));
        if (val.getTriggerDateTime()) {
            DateTime dt = new DateTime(val.getTrigger());
            addProperty(alarm, new Trigger(dt));
        } else {
            Trigger tr = new Trigger(new Dur(val.getTrigger()));
            if (!val.getTriggerStart()) {
                addParameter(tr, Related.END);
            } else {
            // Not required - it's the default - but we fail some Cyrus tests otherwise
            // Apparently Cyrus now handles the default state correctly
            // addParameter(tr, Related.START);
            }
            addProperty(alarm, tr);
        }
        if (val.getDuration() != null) {
            addProperty(alarm, new Duration(new Dur(val.getDuration())));
            addProperty(alarm, new Repeat(val.getRepeat()));
        }
        if (atype == BwAlarm.alarmTypeAudio) {
            if (val.getAttach() != null) {
                addProperty(alarm, new Attach(new URI(val.getAttach())));
            }
        } else if (atype == BwAlarm.alarmTypeDisplay) {
            // checkRequiredProperty(val.getDescription(), "alarm-description");
            if (val.getDescription() != null) {
                addProperty(alarm, new Description(val.getDescription()));
            } else {
                addProperty(alarm, new Description(ev.getSummary()));
            }
        } else if (atype == BwAlarm.alarmTypeEmail) {
            if (val.getAttach() != null) {
                addProperty(alarm, new Attach(new URI(val.getAttach())));
            }
            checkRequiredProperty(val.getDescription(), "alarm-description");
            addProperty(alarm, new Description(val.getDescription()));
            checkRequiredProperty(val.getSummary(), "alarm-summary");
            addProperty(alarm, new Summary(val.getSummary()));
            if (val.getNumAttendees() > 0) {
                for (BwAttendee att : val.getAttendees()) {
                    addProperty(alarm, setAttendee(att));
                }
            }
        } else if (atype == BwAlarm.alarmTypeProcedure) {
            checkRequiredProperty(val.getAttach(), "alarm-attach");
            addProperty(alarm, new Attach(new URI(val.getAttach())));
            if (val.getDescription() != null) {
                addProperty(alarm, new Description(val.getDescription()));
            }
        } else {
            if (val.getDescription() != null) {
                addProperty(alarm, new Description(val.getDescription()));
            }
        }
        if (val.getNumXproperties() > 0) {
            /* This event has x-props */
            IcalUtil.xpropertiesToIcal(alarm.getProperties(), val.getXproperties());
        }
        return alarm;
    } catch (CalFacadeException cfe) {
        throw cfe;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : Dur(net.fortuna.ical4j.model.Dur) Action(net.fortuna.ical4j.model.property.Action) Description(net.fortuna.ical4j.model.property.Description) Attach(net.fortuna.ical4j.model.property.Attach) Duration(net.fortuna.ical4j.model.property.Duration) Repeat(net.fortuna.ical4j.model.property.Repeat) URI(java.net.URI) DateTime(net.fortuna.ical4j.model.DateTime) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) Trigger(net.fortuna.ical4j.model.property.Trigger) BwXproperty(org.bedework.calfacade.BwXproperty) Summary(net.fortuna.ical4j.model.property.Summary) VAlarm(net.fortuna.ical4j.model.component.VAlarm) BwAttendee(org.bedework.calfacade.BwAttendee)

Example 5 with Description

use of net.fortuna.ical4j.model.property.Description in project bw-calendar-engine by Bedework.

the class VEventUtil method toIcalComponent.

/**
 * Make an Icalendar component from a BwEvent object. This may produce a
 * VEvent, VTodo, VJournal or VPoll.
 *
 * @param ei the event
 * @param isOverride - true if event object is an override
 * @param tzreg - timezone registry
 * @param currentPrincipal - href for current authenticated user
 * @return Component
 * @throws CalFacadeException
 */
public static Component toIcalComponent(final EventInfo ei, final boolean isOverride, final TimeZoneRegistry tzreg, final String currentPrincipal) throws CalFacadeException {
    if ((ei == null) || (ei.getEvent() == null)) {
        return null;
    }
    final BwEvent val = ei.getEvent();
    boolean isInstance = false;
    try {
        Component xcomp = null;
        Calendar cal = null;
        final List<BwXproperty> xcompProps = val.getXproperties(BwXproperty.bedeworkIcal);
        if (!Util.isEmpty(xcompProps)) {
            final BwXproperty xcompProp = xcompProps.get(0);
            final String xcompPropVal = xcompProp.getValue();
            if (xcompPropVal != null) {
                final StringBuilder sb = new StringBuilder();
                final Icalendar ic = new Icalendar();
                try {
                    sb.append("BEGIN:VCALENDAR\n");
                    sb.append(Version.VERSION_2_0.toString());
                    sb.append("\n");
                    sb.append(xcompPropVal);
                    if (!xcompPropVal.endsWith("\n")) {
                        sb.append("\n");
                    }
                    sb.append("END:VCALENDAR\n");
                    CalendarBuilder bldr = new CalendarBuilder(new CalendarParserImpl(), ic);
                    UnfoldingReader ufrdr = new UnfoldingReader(new StringReader(sb.toString()), true);
                    cal = bldr.build(ufrdr);
                } catch (Throwable t) {
                    error(t);
                    error("Trying to parse:\n" + xcompPropVal);
                }
            }
        }
        Component comp;
        PropertyList pl = new PropertyList();
        boolean freeBusy = false;
        boolean vavail = false;
        boolean todo = false;
        boolean vpoll = false;
        int entityType = val.getEntityType();
        if (entityType == IcalDefs.entityTypeEvent) {
            comp = new VEvent(pl);
        } else if (entityType == IcalDefs.entityTypeTodo) {
            comp = new VToDo(pl);
            todo = true;
        } else if (entityType == IcalDefs.entityTypeJournal) {
            comp = new VJournal(pl);
        } else if (entityType == IcalDefs.entityTypeFreeAndBusy) {
            comp = new VFreeBusy(pl);
            freeBusy = true;
        } else if (entityType == IcalDefs.entityTypeVavailability) {
            comp = new VAvailability(pl);
            vavail = true;
        } else if (entityType == IcalDefs.entityTypeAvailable) {
            comp = new Available(pl);
        } else if (entityType == IcalDefs.entityTypeVpoll) {
            comp = new VPoll(pl);
            vpoll = true;
        } else {
            throw new CalFacadeException("org.bedework.invalid.entity.type", String.valueOf(entityType));
        }
        if (cal != null) {
            xcomp = cal.getComponent(comp.getName());
        }
        Property prop;
        /* ------------------- RecurrenceID --------------------
       * Done early so we know if this is an instance.
       */
        String strval = val.getRecurrenceId();
        if ((strval != null) && (strval.length() > 0)) {
            isInstance = true;
            pl.add(new RecurrenceId(makeZonedDt(val, strval)));
        }
        /* ------------------- Alarms -------------------- */
        VAlarmUtil.processEventAlarm(val, comp, currentPrincipal);
        /* ------------------- Attachments -------------------- */
        if (val.getNumAttachments() > 0) {
            for (BwAttachment att : val.getAttachments()) {
                pl.add(setAttachment(att));
            }
        }
        /* ------------------- Attendees -------------------- */
        if (!vpoll && (val.getNumAttendees() > 0)) {
            for (BwAttendee att : val.getAttendees()) {
                prop = setAttendee(att);
                mergeXparams(prop, xcomp);
                pl.add(prop);
            }
        }
        if (val.getNumCategories() > 0) {
            // LANG - filter on language - group language in one cat list?
            for (BwCategory cat : val.getCategories()) {
                prop = new Categories();
                TextList cl = ((Categories) prop).getCategories();
                cl.add(cat.getWord().getValue());
                pl.add(langProp(prop, cat.getWord()));
            }
        }
        /* ------------------- Class -------------------- */
        final String pval = val.getClassification();
        if (pval != null) {
            pl.add(new Clazz(pval));
        }
        if (val.getNumComments() > 0) {
            for (final BwString str : val.getComments()) {
                pl.add(langProp(new Comment(str.getValue()), str));
            }
        }
        if ((todo || vpoll) && (val.getCompleted() != null)) {
            prop = new Completed(new DateTime(val.getCompleted()));
            pl.add(prop);
        }
        if (val.getNumContacts() > 0) {
            for (final BwContact c : val.getContacts()) {
                // LANG
                prop = new Contact(c.getCn().getValue());
                final String l = c.getLink();
                if (l != null) {
                    prop.getParameters().add(new AltRep(l));
                }
                pl.add(langProp(uidProp(prop, c.getUid()), c.getCn()));
            }
        }
        if (val.getCost() != null) {
            IcalUtil.addXproperty(pl, BwXproperty.bedeworkCost, null, val.getCost());
        }
        /* ------------------- Created -------------------- */
        prop = new Created(val.getCreated());
        // if (pars.includeDateTimeProperty) {
        // prop.getParameters().add(Value.DATE_TIME);
        // }
        pl.add(prop);
        if (val.getDeleted()) {
            IcalUtil.addXproperty(pl, BwXproperty.bedeworkDeleted, null, String.valueOf(val.getDeleted()));
        }
        /* ------------------- Description -------------------- */
        BwStringBase bwstr = val.findDescription(null);
        if (bwstr != null) {
            pl.add(langProp(new Description(bwstr.getValue()), bwstr));
        }
        if (val.getEndType() == StartEndComponent.endTypeDate) {
            if (todo) {
                Due due = val.getDtend().makeDue(tzreg);
                if (freeBusy | val.getForceUTC()) {
                    due.setUtc(true);
                }
                pl.add(due);
            } else {
                DtEnd dtend = val.getDtend().makeDtEnd(tzreg);
                if (freeBusy | val.getForceUTC()) {
                    dtend.setUtc(true);
                }
                pl.add(dtend);
            }
        } else if (val.getEndType() == StartEndComponent.endTypeDuration) {
            addProperty(comp, new Duration(new Dur(val.getDuration())));
        }
        /* ------------------- DtStamp -------------------- */
        prop = new DtStamp(new DateTime(val.getDtstamp()));
        // if (pars.includeDateTimeProperty) {
        // prop.getParameters().add(Value.DATE_TIME);
        // }
        pl.add(prop);
        if (!val.getNoStart()) {
            DtStart dtstart = val.getDtstart().makeDtStart(tzreg);
            if (freeBusy | val.getForceUTC()) {
                dtstart.setUtc(true);
            }
            pl.add(dtstart);
        }
        if (freeBusy) {
            Collection<BwFreeBusyComponent> fbps = val.getFreeBusyPeriods();
            if (fbps != null) {
                for (BwFreeBusyComponent fbc : fbps) {
                    FreeBusy fb = new FreeBusy();
                    int type = fbc.getType();
                    if (type == BwFreeBusyComponent.typeBusy) {
                        addParameter(fb, FbType.BUSY);
                    } else if (type == BwFreeBusyComponent.typeFree) {
                        addParameter(fb, FbType.FREE);
                    } else if (type == BwFreeBusyComponent.typeBusyUnavailable) {
                        addParameter(fb, FbType.BUSY_UNAVAILABLE);
                    } else if (type == BwFreeBusyComponent.typeBusyTentative) {
                        addParameter(fb, FbType.BUSY_TENTATIVE);
                    } else {
                        throw new CalFacadeException("Bad free-busy type " + type);
                    }
                    PeriodList pdl = fb.getPeriods();
                    for (Period p : fbc.getPeriods()) {
                        // XXX inverse.ca plugin cannot handle durations.
                        Period np = new Period(p.getStart(), p.getEnd());
                        pdl.add(np);
                    }
                    pl.add(fb);
                }
            }
        }
        if (!vpoll) {
            BwGeo bwgeo = val.getGeo();
            if (bwgeo != null) {
                Geo geo = new Geo(bwgeo.getLatitude(), bwgeo.getLongitude());
                pl.add(geo);
            }
        }
        /* ------------------- LastModified -------------------- */
        prop = new LastModified(new DateTime(val.getLastmod()));
        // if (pars.includeDateTimeProperty) {
        // prop.getParameters().add(Value.DATE_TIME);
        // }
        pl.add(prop);
        if (!vpoll) {
            final BwLocation loc = val.getLocation();
            if (loc != null) {
                prop = new Location(loc.getCombinedValues());
                pl.add(langProp(uidProp(prop, loc.getUid()), loc.getAddress()));
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationAddr, null, loc.getAddressField());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationRoom, null, loc.getRoomField());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationAccessible, null, String.valueOf(loc.getAccessible()));
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationSfield1, null, loc.getSubField1());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationSfield2, null, loc.getSubField2());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationGeo, null, loc.getGeouri());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationStreet, null, loc.getStreet());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationCity, null, loc.getCity());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationState, null, loc.getState());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationZip, null, loc.getZip());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationLink, null, loc.getLink());
            }
        }
        /* ------------------- Organizer -------------------- */
        BwOrganizer org = val.getOrganizer();
        if (org != null) {
            prop = setOrganizer(org);
            mergeXparams(prop, xcomp);
            pl.add(prop);
        }
        if (todo) {
            Integer pc = val.getPercentComplete();
            if (pc != null) {
                pl.add(new PercentComplete(pc.intValue()));
            }
        }
        /* ------------------- Priority -------------------- */
        Integer prio = val.getPriority();
        if (prio != null) {
            pl.add(new Priority(prio.intValue()));
        }
        /* ------------------- RDate -below------------------- */
        /* ------------------- RelatedTo -------------------- */
        /* We encode related to (maybe) as triples - reltype, value-type, value */
        String[] info = null;
        BwRelatedTo relto = val.getRelatedTo();
        if (relto != null) {
            info = new String[3];
            info[0] = relto.getRelType();
            // default
            info[1] = "";
            info[2] = relto.getValue();
        } else {
            String relx = val.getXproperty(BwXproperty.bedeworkRelatedTo);
            if (relx != null) {
                info = Util.decodeArray(relx);
            }
        }
        if (info != null) {
            int i = 0;
            while (i < info.length) {
                RelatedTo irelto;
                String reltype = info[i];
                String valtype = info[i + 1];
                String relval = info[i + 2];
                ParameterList rtpl = null;
                if (reltype.length() > 0) {
                    rtpl = new ParameterList();
                    rtpl.add(new RelType(reltype));
                }
                if (valtype.length() > 0) {
                    if (rtpl == null) {
                        rtpl = new ParameterList();
                    }
                    rtpl.add(new Value(valtype));
                }
                if (rtpl != null) {
                    irelto = new RelatedTo(rtpl, relval);
                } else {
                    irelto = new RelatedTo(relval);
                }
                pl.add(irelto);
                i += 3;
            }
        }
        if (val.getNumResources() > 0) {
            /* This event has a resource */
            prop = new Resources();
            TextList rl = ((Resources) prop).getResources();
            for (BwString str : val.getResources()) {
                // LANG
                rl.add(str.getValue());
            }
            pl.add(prop);
        }
        if (val.getSequence() > 0) {
            pl.add(new Sequence(val.getSequence()));
        }
        /* ------------------- Status -------------------- */
        String status = val.getStatus();
        if ((status != null) && !status.equals(BwEvent.statusMasterSuppressed)) {
            pl.add(new Status(status));
        }
        /* ------------------- Summary -------------------- */
        bwstr = val.findSummary(null);
        if (bwstr != null) {
            pl.add(langProp(new Summary(bwstr.getValue()), bwstr));
        }
        if (!todo && !vpoll) {
            strval = val.getPeruserTransparency(currentPrincipal);
            if ((strval != null) && (strval.length() > 0)) {
                pl.add(new Transp(strval));
            }
        }
        /* ------------------- Uid -------------------- */
        pl.add(new Uid(val.getUid()));
        /* ------------------- Url -------------------- */
        strval = val.getLink();
        if (strval != null) {
            // Possibly drop this if we do it on input and check all data
            strval = strval.trim();
        }
        if ((strval != null) && (strval.length() > 0)) {
            URI uri = Util.validURI(strval);
            if (uri != null) {
                pl.add(new Url(uri));
            }
        }
        if (val.getNumXproperties() > 0) {
            try {
                IcalUtil.xpropertiesToIcal(pl, val.getXproperties());
            } catch (Throwable t) {
                // XXX For the moment swallow these.
                error(t);
            }
        }
        if (!vpoll && !isInstance && !isOverride && val.testRecurring()) {
            doRecurring(val, pl);
        }
        if (vavail) {
            if (ei.getNumContainedItems() > 0) {
                final VAvailability va = (VAvailability) comp;
                for (final EventInfo aei : ei.getContainedItems()) {
                    va.getAvailable().add((Available) toIcalComponent(aei, false, tzreg, currentPrincipal));
                }
            }
            /* ----------- Vavailability - busyType ----------------- */
            String s = val.getBusyTypeString();
            if (s != null) {
                pl.add(new BusyType(s));
            }
        }
        if (vpoll) {
            final Integer ival = val.getPollWinner();
            if (ival != null) {
                pl.add(new PollWinner(ival));
            }
            strval = val.getPollAcceptResponse();
            if ((strval != null) && (strval.length() > 0)) {
                pl.add(new AcceptResponse(strval));
            }
            strval = val.getPollMode();
            if ((strval != null) && (strval.length() > 0)) {
                pl.add(new PollMode(strval));
            }
            strval = val.getPollProperties();
            if ((strval != null) && (strval.length() > 0)) {
                pl.add(new PollProperties(strval));
            }
            final Map<String, VVoter> vvoters = parseVpollVvoters(val);
            for (final VVoter vv : vvoters.values()) {
                ((VPoll) comp).getVoters().add(vv);
            }
            final Map<Integer, Component> comps = parseVpollCandidates(val);
            for (final Component candidate : comps.values()) {
                ((VPoll) comp).getCandidates().add(candidate);
            }
        }
        return comp;
    } catch (final CalFacadeException cfe) {
        throw cfe;
    } catch (final Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : FreeBusy(net.fortuna.ical4j.model.property.FreeBusy) VFreeBusy(net.fortuna.ical4j.model.component.VFreeBusy) BwRelatedTo(org.bedework.calfacade.BwRelatedTo) EventInfo(org.bedework.calfacade.svc.EventInfo) BwCategory(org.bedework.calfacade.BwCategory) BwString(org.bedework.calfacade.BwString) VAvailability(net.fortuna.ical4j.model.component.VAvailability) DateTime(net.fortuna.ical4j.model.DateTime) BwDateTime(org.bedework.calfacade.BwDateTime) TextList(net.fortuna.ical4j.model.TextList) LastModified(net.fortuna.ical4j.model.property.LastModified) DtStamp(net.fortuna.ical4j.model.property.DtStamp) AcceptResponse(net.fortuna.ical4j.model.property.AcceptResponse) Available(net.fortuna.ical4j.model.component.Available) BwAttachment(org.bedework.calfacade.BwAttachment) RelatedTo(net.fortuna.ical4j.model.property.RelatedTo) BwRelatedTo(org.bedework.calfacade.BwRelatedTo) VEvent(net.fortuna.ical4j.model.component.VEvent) Status(net.fortuna.ical4j.model.property.Status) BwFreeBusyComponent(org.bedework.calfacade.BwFreeBusyComponent) BwLocation(org.bedework.calfacade.BwLocation) VVoter(net.fortuna.ical4j.model.component.VVoter) Transp(net.fortuna.ical4j.model.property.Transp) Categories(net.fortuna.ical4j.model.property.Categories) Priority(net.fortuna.ical4j.model.property.Priority) BusyType(net.fortuna.ical4j.model.property.BusyType) PeriodList(net.fortuna.ical4j.model.PeriodList) Period(net.fortuna.ical4j.model.Period) Duration(net.fortuna.ical4j.model.property.Duration) BwString(org.bedework.calfacade.BwString) BwContact(org.bedework.calfacade.BwContact) Sequence(net.fortuna.ical4j.model.property.Sequence) Geo(net.fortuna.ical4j.model.property.Geo) BwGeo(org.bedework.calfacade.BwGeo) Uid(net.fortuna.ical4j.model.property.Uid) PollMode(net.fortuna.ical4j.model.property.PollMode) BwXproperty(org.bedework.calfacade.BwXproperty) Value(net.fortuna.ical4j.model.parameter.Value) ParameterList(net.fortuna.ical4j.model.ParameterList) RecurrenceId(net.fortuna.ical4j.model.property.RecurrenceId) Resources(net.fortuna.ical4j.model.property.Resources) BwAttendee(org.bedework.calfacade.BwAttendee) VToDo(net.fortuna.ical4j.model.component.VToDo) CalendarParserImpl(net.fortuna.ical4j.data.CalendarParserImpl) VJournal(net.fortuna.ical4j.model.component.VJournal) Description(net.fortuna.ical4j.model.property.Description) BwGeo(org.bedework.calfacade.BwGeo) AltRep(net.fortuna.ical4j.model.parameter.AltRep) BwEvent(org.bedework.calfacade.BwEvent) URI(java.net.URI) Url(net.fortuna.ical4j.model.property.Url) PollWinner(net.fortuna.ical4j.model.property.PollWinner) Created(net.fortuna.ical4j.model.property.Created) VPoll(net.fortuna.ical4j.model.component.VPoll) Due(net.fortuna.ical4j.model.property.Due) StringReader(java.io.StringReader) PollProperties(net.fortuna.ical4j.model.property.PollProperties) Clazz(net.fortuna.ical4j.model.property.Clazz) StartEndComponent(org.bedework.calfacade.base.StartEndComponent) Component(net.fortuna.ical4j.model.Component) BwFreeBusyComponent(org.bedework.calfacade.BwFreeBusyComponent) DateListProperty(net.fortuna.ical4j.model.property.DateListProperty) Property(net.fortuna.ical4j.model.Property) BwOrganizer(org.bedework.calfacade.BwOrganizer) Dur(net.fortuna.ical4j.model.Dur) Comment(net.fortuna.ical4j.model.property.Comment) RelType(net.fortuna.ical4j.model.parameter.RelType) VFreeBusy(net.fortuna.ical4j.model.component.VFreeBusy) Calendar(net.fortuna.ical4j.model.Calendar) UnfoldingReader(net.fortuna.ical4j.data.UnfoldingReader) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) Contact(net.fortuna.ical4j.model.property.Contact) BwContact(org.bedework.calfacade.BwContact) PropertyList(net.fortuna.ical4j.model.PropertyList) DtStart(net.fortuna.ical4j.model.property.DtStart) BwStringBase(org.bedework.calfacade.base.BwStringBase) PercentComplete(net.fortuna.ical4j.model.property.PercentComplete) Completed(net.fortuna.ical4j.model.property.Completed) Summary(net.fortuna.ical4j.model.property.Summary) DtEnd(net.fortuna.ical4j.model.property.DtEnd) BwLocation(org.bedework.calfacade.BwLocation) Location(net.fortuna.ical4j.model.property.Location)

Aggregations

Description (net.fortuna.ical4j.model.property.Description)13 Uid (net.fortuna.ical4j.model.property.Uid)9 VEvent (net.fortuna.ical4j.model.component.VEvent)8 Location (net.fortuna.ical4j.model.property.Location)8 PropertyList (net.fortuna.ical4j.model.PropertyList)7 LastModified (net.fortuna.ical4j.model.property.LastModified)7 DateTime (net.fortuna.ical4j.model.DateTime)6 Summary (net.fortuna.ical4j.model.property.Summary)6 XProperty (net.fortuna.ical4j.model.property.XProperty)6 URISyntaxException (java.net.URISyntaxException)5 Date (java.util.Date)5 Property (net.fortuna.ical4j.model.Property)5 Contact (net.fortuna.ical4j.model.property.Contact)5 Created (net.fortuna.ical4j.model.property.Created)5 URI (java.net.URI)4 Calendar (net.fortuna.ical4j.model.Calendar)4 DtStart (net.fortuna.ical4j.model.property.DtStart)4 Duration (net.fortuna.ical4j.model.property.Duration)4 RecurrenceId (net.fortuna.ical4j.model.property.RecurrenceId)4 IOException (java.io.IOException)3