Class CaldavServerOwnerStorage

java.lang.Object
org.exoplatform.caldav.storage.CaldavServerOwnerStorage

@Component public class CaldavServerOwnerStorage extends Object
The owner of every calendar an account sees, as BlueMind's subscription listing reports it, kept across passes (EXO-90347).

Why a cache, and why here. The listing costs a REST login, a GET and a logout of the user's own BlueMind session. Read only when a pass meets an eXo-shaped collection nobody here recognises, that is still every sweep — every five minutes, on every node — for every account that holds one such calendar, again each time the user opens their agenda, and once more when the hidden-calendars drawer describes a bound eXo-shaped calendar (CaldavReadService#describeCollections), where the listing is what tells a calendar adopted before EXO-90347 — a colleague's, and kept — from the user's own. Owners almost never change, so the answer is kept for meeds.cache.caldav.server.owners.ttl seconds (one hour by default, caldav.properties) and at most meeds.cache.caldav.server.owners.max accounts, through the platform's Spring cache adapter over the Kernel's ExoCache — the storage-like layer caching belongs to, tunable per deployment, and a single-flight load under Cacheable.sync(): concurrent misses on one account open one session, not two.

The key is the account and nothing less. A listing says which calendars one person's mailbox can see; served to another person it is a leak. So the key carries the two discriminators the answer depends on — the declared server and the eXo user whose stored credentials opened the session — as explicit, equals-compared fields (CaldavServerOwnerStorage.Key), never a folded hash: two users on one server, and one user on two servers, hold separate entries by construction. The principal uid the pass discovered is not part of the key, because it is derived from the same credentials; the listing carries the uid the session was authenticated as, and a reader that finds it differing from the pass's principal — credentials re-pointed at another mailbox — asks for a refresh rather than believing the entry.

What is not cached. A fetch that throws caches nothing: Spring writes no entry for a loader that failed, so an unreachable or refusing server costs one attempt per pass, as it did before the cache, and the next pass tries again. A listing that does not name a collection is cached as it came; the reader's one forced refresh(CaldavServerOwnerStorage.Key, CalDavEndpoint) per pass is what keeps a share made after the entry was written from waiting out the TTL.

In a cluster. Each node holds the entries it loaded and expires them on its own clock: a load never travels. An owner change made outside eXo — a share granted in BlueMind's webmail — is seen by a node within the TTL at the latest, and sooner on the node whose pass meets the new collection, since that is a miss it refreshes on. An eviction, by a change eXo itself makes (evict(CaldavServerOwnerStorage.Key)) or by a refresh(CaldavServerOwnerStorage.Key, CalDavEndpoint), reaches every node, asynchronously: the cache is invalidated.

  • Field Details

    • CACHE_NAME

      public static final String CACHE_NAME
      The cache, and the meeds.cache.<name>.* tuning prefix.
      See Also:
  • Constructor Details

    • CaldavServerOwnerStorage

      public CaldavServerOwnerStorage()
  • Method Details

    • listing

      @Cacheable(cacheNames="caldav.server.owners", key="#p0", sync=true) public CalendarOwners listing(CaldavServerOwnerStorage.Key key, CalDavEndpoint endpoint)
      The account's listing, from the cache when it holds one, else read from the server and kept.
      Parameters:
      key - the account
      endpoint - the account's DAV endpoint, minted from the registry for the user's eXo login — the session is opened with its credentials; not part of the key, which the two identifiers already determine
      Returns:
      the listing
      Throws:
      UnsupportedOperationException - when the account's configured credentials are not a login and password; nothing is cached
      CalDavException - when the server refuses, cannot be reached, or answers the wrong shape; nothing is cached
    • refresh

      @CacheEvict(cacheNames="caldav.server.owners", key="#p0") public CalendarOwners refresh(CaldavServerOwnerStorage.Key key, CalDavEndpoint endpoint)
      The account's listing read from the server now, dropping whatever the cache held: a pass that meets a collection the cached listing does not name asks this once, so a share made after the entry was written is classified in the pass that first sees it rather than after the TTL. The entry is dropped rather than replaced: a listing put in the cache stays on the node that read it, while a drop reaches every node of a cluster, each of which reads the listing again on its next read.
      Parameters:
      key - the account
      endpoint - the account's DAV endpoint
      Returns:
      the fresh listing, which the cache does not hold
      Throws:
      UnsupportedOperationException - as listing(CaldavServerOwnerStorage.Key, CalDavEndpoint); the stale entry is left as it was
      CalDavException - as listing(CaldavServerOwnerStorage.Key, CalDavEndpoint); the stale entry is left as it was
    • evict

      @CacheEvict(cacheNames="caldav.server.owners", key="#p0") public void evict(CaldavServerOwnerStorage.Key key)
      Drops the account's entry: eXo itself changed what the account can see — a share it granted or revoked, a subscription it followed — or the account itself changed hands, on connect, disconnect or new credentials. A no-op when there is no entry.
      Parameters:
      key - the account