I created a client that is getting calendar data (VEvents) from Yahoo. Now I need to be able to update existing or create new event and 'publish' it, to be visible from Yahoo calendar.
Can this be done with ical4j or I need to find some other way to do it?
Ok, I found a way of doing this. The problem was that for CalDavCollection, you can't actually add event directly, you need to add it as a Calendar. The code that is working:
public void addEvent(VEvent event, VTimeZone timezone){
try {
Calendar calendar = new Calendar();
calendar.getProperties().add(new ProdId(prodId));
calendar.getProperties().add(Version.VERSION_2_0);
calendar.getProperties().add(CalScale.GREGORIAN);
calendar.getComponents().add(event);
collection.add(httpClient, calendar);
} catch (CalDAV4JException e) {
e.printStackTrace();
}
}
The 'prodId' in line
calendar.getProperties().add(new ProdId(prodId));
is the prodId of the Calendar provider (in my case it is PRODID://Yahoo//Calendar//EN)
The collection is the instance of the CalDavCollecion, that is related to specific Calendar, so just adding calendar with new event inside will add it to the server to the correct calendar.