Tickets are a way to transfer read and write privileges to other users. Any user that knows a ticket's ID can use it. They can be limited in time valid, number of uses, and may also specify which privileges the ticket grants. NOTE: Cosmo does not support number of uses, it is always defaulted to infinity. See CosmoTickets
for more information.
Tickets can be used in 2 ways:
- The first is appending it to the URI as a parameter:
- The second is in the request header:
GET /MyCalendar.ics HTTP/1.1
High Level API
This wiki page covers the High Level API for tickets. To see a lower level overview please see TicketsInCalDav4JTutorial
Note: See CalDAV4jTutorial
for information on how to further use CalDAV4j.
CalDAVCalendarCollection is the class that contains all the high level methods. To use it you first must create a valid instance. You must have created a HostConfiguration and CalDAV4JMethodFactory. See CalDAV4jTutorial
CalDAVCalendarCollection calendarCollection = new CalDAVCalendarCollection(
"/", hostConfiguration, methodFactory,
Tickets are made using createTicket. The user must specify the resource's URI to make the ticket on and which privileges to set. The user may also specify the time and the number of visits the ticket is valid for. If you do not wish to specify the time or visits pass a null to createTicket.
To make a ticket on http://www.mysweeturl.com/MyCalendar.ics
, with Read and Write Privileges, 5 uses and a 3600 second timeout:
For purpose of this demonstration we will not go into HttpClient?
. Again please see the CalDAV4jTutorial
HttpClient httpClient = createHttpClient();
// Create the Ticket
String ticketID = calendarCollection.createTicket(httpClient,
"MyCalendar.ics", 5, 3600,
The string returned will be the ID of the created ticket.
Once you have the tickets ID you can begin using the ticket. This is an example of getting your calendar:
Calendar calendar = calendarCollection.getCalendarByPath(httpClient,
Note: The default way to use the ticket is in the request header and not in the URI. In order to change this, before the getCalendarByPath method is called:
// Default is HttpClient.TICKET_LOCATION.HEADERS
Now that you have used the ticket, you can Delete it:
calendarCollection.deleteTicket(httpClient, "MyCalendar.ics", ticketID);
If you want to query all the valid tickets on a resource you can use getTickets. Note: any tickets the user does not have access to will not be returned.
List<String> ticketIDs = calendarCollection.getTickets(httpClient,
- 29 Jun 2006