Interface CalendarObjectWriter

All Known Implementing Classes:
BlueMindImportWriter, CalDavObjectWriter

public interface CalendarObjectWriter
The door through which one calendar object is written to, or removed from, a server — the four write shapes the engine uses, and nothing else.

Why an interface between the engine and CalDavClient (EXO-90307). On BlueMind a CalDAV PUT makes the server schedule the meeting itself, and the only door that does not is BlueMind's own REST import API; the engine, though, must not know which server it is talking to — a service that branched on "is this BlueMind" at every write would carry that knowledge into a dozen call sites. So each write goes through the writer CalendarObjectWriters resolves for the server, and the engine's own rules — conditional in both directions, a 412 is an answer and not a fault, a 404 on delete is a fact — are stated once here and honoured by every implementation.

The contracts are those of the CalDavClient methods of the same names, restated so an implementation that has no If-Match header to send knows what it must emulate:

Every result's etag is the version the server now holds for the object, in the shape the server's own listings answer for it, or null when the implementation could not learn it.
  • Method Details

    • putObject

      PutResult putObject(CalDavEndpoint endpoint, String href, String icsData)
      Creates one object; an object already at the href is answered 412.
      Parameters:
      endpoint - the declared server
      href - the object's server-absolute path to create at
      icsData - the iCalendar text to store
      Returns:
      the status and, when known, the stored version
      Throws:
      CalDavAuthenticationException - when the credentials are refused
      CalDavException - when the write could not be carried out
    • overwriteObject

      PutResult overwriteObject(CalDavEndpoint endpoint, String href, String icsData)
      Writes one object over whatever is there, with no precondition at all.
      Parameters:
      endpoint - the declared server
      href - the object's server-absolute path
      icsData - the iCalendar text to store
      Returns:
      the status and, when known, the stored version; never a 412
      Throws:
      CalDavAuthenticationException - when the credentials are refused
      CalDavException - when the write could not be carried out
    • updateObject

      PutResult updateObject(CalDavEndpoint endpoint, String href, String icsData, String ifMatch)
      Replaces one existing object, only when its version is still the one the caller last read.
      Parameters:
      endpoint - the declared server
      href - the object's server-absolute path
      icsData - the iCalendar text to store
      ifMatch - the version the caller's own read answered, verbatim
      Returns:
      the status and, when known, the stored version; 412 when the object moved on or is gone
      Throws:
      IllegalArgumentException - when the precondition is blank
      CalDavAuthenticationException - when the credentials are refused
      CalDavException - when the write could not be carried out
    • deleteObject

      int deleteObject(CalDavEndpoint endpoint, String href, String ifMatch)
      Deletes one object, conditionally when a version is given.
      Parameters:
      endpoint - the declared server
      href - the object's server-absolute path
      ifMatch - the version to condition the removal on, or null to remove unconditionally
      Returns:
      200 or 204 removed, 404 or 410 already gone, 412 refused
      Throws:
      CalDavAuthenticationException - when the credentials are refused
      CalDavException - when the removal could not be carried out