Java Code Examples for net.fortuna.ical4j.model.ComponentList#isEmpty()

The following examples show how to use net.fortuna.ical4j.model.ComponentList#isEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DavEvent.java    From cosmo with Apache License 2.0 5 votes vote down vote up
protected void setCalendar(Calendar calendar) throws CosmoDavException {

        ComponentList<VEvent> vevents = calendar.getComponents(Component.VEVENT);
        if (vevents.isEmpty()) {
            throw new UnprocessableEntityException("VCALENDAR does not contain any VEVENTs");
        }

        getEventStamp().setEventCalendar(calendar);
    }
 
Example 2
Source File: DavJournal.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * @param cal Imports a calendar object containing a VJOURNAL. Sets the
 * following properties:
 * </p>
 * <ul>
 * <li>display name: the VJOURNAL's SUMMARY (or the item's name, if the
 * SUMMARY is blank)</li>
 * <li>icalUid: the VJOURNAL's UID</li>
 * <li>body: the VJOURNAL's DESCRIPTION</li>
 * </ul>
 */
public void setCalendar(Calendar cal)
    throws CosmoDavException {
    NoteItem note = (NoteItem) getItem();
  
    ComponentList<VJournal> vjournals = cal.getComponents(Component.VJOURNAL);
    if (vjournals.isEmpty()) {
        throw new UnprocessableEntityException("VCALENDAR does not contain any VJOURNALS");
    }

    EntityConverter converter = new EntityConverter(getEntityFactory());
    converter.convertJournalCalendar(note, cal);
}
 
Example 3
Source File: DavTask.java    From cosmo with Apache License 2.0 3 votes vote down vote up
/**
 * <p>
 * Imports a calendar object containing a VTODO. Sets the
 * following properties:
 * </p>
 * <ul>
 * <li>display name: the VTODO's SUMMARY (or the item's name, if the
 * SUMMARY is blank)</li>
 * <li>icalUid: the VTODO's UID</li>
 * <li>body: the VTODO's DESCRIPTION</li>
 * <li>reminderTime: if the VTODO has a DISPLAY VALARM
 *     the reminderTime will be set to the trigger time</li>
 * </ul>
 * @param cal The calendar imported.
 * @throws CosmoDavException - if something is wrong this exception is thrown.
 */
public void setCalendar(Calendar cal)
    throws CosmoDavException {
    NoteItem note = (NoteItem) getItem();
    
    ComponentList<VToDo> vtodos = cal.getComponents(Component.VTODO);
    if (vtodos.isEmpty()) {
        throw new UnprocessableEntityException("VCALENDAR does not contain any VTODOS");
    }

    EntityConverter converter = new EntityConverter(getEntityFactory());
    converter.convertTaskCalendar(note, cal);
}