Class AppointmentManager
java.lang.Object
org.apache.openmeetings.service.calendar.caldav.AppointmentManager
Class which does syncing and provides respective API's required for performing CalDAV Operations.
- Author:
- Ankush Mishra (ankushmishra9@gmail.com)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Cleans up unused idle connections.boolean
createCalendar
(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, OmCalendar calendar) Create or Update calendar on the database.org.apache.http.client.HttpClient
Returns a new HttpClient with the inbuilt connection manager in this.void
deleteCalendar
(OmCalendar calendar) Deletes the calendar from the local database.boolean
deleteItem
(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, Appointment appointment) Delete Appointment on the CalDAV server.void
destroy()
Method which is called when the Context is destroyed.getCalendars
(Long userid) Method to get user's calendars please seeOmCalendarDao.getByUser(Long)
getGoogleCalendars
(Long userId) Method to get user's google calendars please seeOmCalendarDao.getGoogleCalendars(Long)
static String
getTokenFromProperty
(org.apache.jackrabbit.webdav.property.DavProperty<?> property) Returns the String value of the property, else null.void
provideCredentials
(org.apache.http.client.protocol.HttpClientContext context, OmCalendar calendar, org.apache.http.auth.Credentials credentials) Adds the Credentials provided to the given client on the Calendar's URL.void
syncItem
(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, OmCalendar calendar) Function which when called performs syncing based on the type of Syncing detected.void
syncItems
(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, Long userId) Syncs all the calendars currrently present on the DB.boolean
testConnection
(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, OmCalendar calendar) Tests if the Calendar's URL can be accessed, or not.boolean
updateItem
(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, Appointment appointment) Function for create/updating multiple appointment on the server.
-
Constructor Details
-
AppointmentManager
public AppointmentManager()
-
-
Method Details
-
createHttpClient
public org.apache.http.client.HttpClient createHttpClient()Returns a new HttpClient with the inbuilt connection manager in this.- Returns:
- HttpClient object that was created.
-
provideCredentials
public void provideCredentials(org.apache.http.client.protocol.HttpClientContext context, OmCalendar calendar, org.apache.http.auth.Credentials credentials) Adds the Credentials provided to the given client on the Calendar's URL.- Parameters:
context
- Context of the Client which makes the connection.calendar
- Calendar whose Host the Credentials are for.credentials
- Credentials to add
-
testConnection
public boolean testConnection(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, OmCalendar calendar) Tests if the Calendar's URL can be accessed, or not.- Parameters:
client
- Client which makes the connection.context
- http contextcalendar
- Calendar whose URL is to be accessed.- Returns:
- Returns true for HTTP Status 200, or 204, else false.
-
createCalendar
public boolean createCalendar(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, OmCalendar calendar) Create or Update calendar on the database.- Parameters:
client
- -HttpClient
to discover calendarcontext
- http contextcalendar
- - calendar to be created- Returns:
true
if calendar was created/updated
-
deleteCalendar
Deletes the calendar from the local database.- Parameters:
calendar
- Calendar to delete
-
getCalendars
-
getCalendars
Method to get user's calendars please seeOmCalendarDao.getByUser(Long)
- Parameters:
userid
- - id of the user- Returns:
- the list of the calendars
-
getGoogleCalendars
Method to get user's google calendars please seeOmCalendarDao.getGoogleCalendars(Long)
- Parameters:
userId
- - id of the user- Returns:
- the list of the calendars
-
syncItem
public void syncItem(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, OmCalendar calendar) Function which when called performs syncing based on the type of Syncing detected.- Parameters:
client
- -HttpClient
to discover calendarcontext
- http contextcalendar
- Calendar who's sync has to take place
-
syncItems
public void syncItems(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, Long userId) Syncs all the calendars currrently present on the DB.- Parameters:
client
- -HttpClient
to discover calendarcontext
- http contextuserId
- - id of the user
-
updateItem
public boolean updateItem(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, Appointment appointment) Function for create/updating multiple appointment on the server. Performs modification alongside of creation new events on the server.- Parameters:
client
- -HttpClient
to discover calendarcontext
- http contextappointment
- Appointment to create/update.- Returns:
true
in case item was updated
-
deleteItem
public boolean deleteItem(org.apache.http.client.HttpClient client, org.apache.http.client.protocol.HttpClientContext context, Appointment appointment) Delete Appointment on the CalDAV server. Delete's on the Server only if the ETag of the Appointment is the one on the server, i.e. only if the Event hasn't changed on the Server.- Parameters:
client
- -HttpClient
to discover calendarcontext
- http contextappointment
- Appointment to Delete- Returns:
true
in case item was deleted
-
getTokenFromProperty
public static String getTokenFromProperty(org.apache.jackrabbit.webdav.property.DavProperty<?> property) Returns the String value of the property, else null.- Parameters:
property
- Property who's string value is to be returned.- Returns:
- String representation of the Property Value.
-
cleanupIdleConnections
public void cleanupIdleConnections()Cleans up unused idle connections. -
destroy
@PreDestroy public void destroy()Method which is called when the Context is destroyed.
-