Class 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 Detail

      • AppointmentManager

        public AppointmentManager()
    • Method Detail

      • 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
      • 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.