Class AppointmentManager

java.lang.Object
org.apache.openmeetings.service.calendar.caldav.AppointmentManager

@Component public class AppointmentManager extends Object
Class which does syncing and provides respective API's required for performing CalDAV Operations.
Author:
Ankush Mishra (ankushmishra9@gmail.com)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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
    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
    Method which is called when the Context is destroyed.
     
    Method to get user's calendars please see OmCalendarDao.getByUser(Long)
    Method to get user's google calendars please see OmCalendarDao.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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 context
      calendar - 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 calendar
      context - http context
      calendar - - calendar to be created
      Returns:
      true if calendar was created/updated
    • deleteCalendar

      public void deleteCalendar(OmCalendar calendar)
      Deletes the calendar from the local database.
      Parameters:
      calendar - Calendar to delete
    • getCalendars

      public List<OmCalendar> getCalendars()
    • getCalendars

      public List<OmCalendar> getCalendars(Long userid)
      Method to get user's calendars please see OmCalendarDao.getByUser(Long)
      Parameters:
      userid - - id of the user
      Returns:
      the list of the calendars
    • getGoogleCalendars

      public List<OmCalendar> getGoogleCalendars(Long userId)
      Method to get user's google calendars please see OmCalendarDao.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 calendar
      context - http context
      calendar - 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 calendar
      context - http context
      userId - - 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 calendar
      context - http context
      appointment - 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 calendar
      context - http context
      appointment - 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.