Class CaldavPendingPushStorage

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

@Component public class CaldavPendingPushStorage extends Object
Maps the writes eXo owes a calendar copy between their JPA entity and the service-layer DTO.

No business logic: which copies are owed a write, how hard to try and when to stop belong to the service. What lives here is the mechanical part — that an obligation is one per copy, so recording the same one twice replaces it rather than queueing it, and that renewing it resets the attempt count because a new edit deserves its own patience.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    abandoned(long id, int maxAttempts)
    Records that an obligation is given up on, without counting toward the bound first.
    List<org.exoplatform.caldav.model.PendingPush>
    attemptable(long userIdentityId, int maxAttempts, int limit)
    What one account is owed and is still worth attempting, oldest first.
    org.exoplatform.caldav.model.PendingPush
    owe(long objectSyncId, long userIdentityId, org.exoplatform.caldav.model.PendingPushKind kind, Long localEventId, String icsUid)
    Records that one copy is behind, replacing whatever was owed to it before.
    long
    owed(long userIdentityId)
    How many copies of one account are behind, abandoned ones included.
    long
    owedAndStillTrying(long userIdentityId, int maxAttempts)
    How many copies of one account are behind and still being argued for.
    void
    refused(long id)
    Records that one more attempt was refused.
    void
    settled(long objectSyncId)
    Forgets what was owed to one copy, because it has been written.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CaldavPendingPushStorage

      public CaldavPendingPushStorage()
  • Method Details

    • owe

      @Transactional public org.exoplatform.caldav.model.PendingPush owe(long objectSyncId, long userIdentityId, org.exoplatform.caldav.model.PendingPushKind kind, Long localEventId, String icsUid)
      Records that one copy is behind, replacing whatever was owed to it before.

      Replacing, not queueing, and the attempt count goes back to zero with it. Both follow from what an obligation says: not "this write failed" but "this copy does not yet show what eXo holds". Five edits in a minute leave one write owed, and the latest instruction is the one that describes the copy — a rewrite recorded after a removal would otherwise put back a meeting somebody destroyed.

      The lookup before the write is a check-then-act, and the database is what settles it. Two listener threads carrying two edits of the same meeting can both read "nothing owed" before either has written, and the unique constraint on the mapping row is what makes the outcome one row rather than two — the loser's insert is refused and its caller says so. Nothing is lost by that: the winner's row already records the same instruction about the same copy. The only case where the two differ is an edit and a deletion of one meeting in the same instant, and there the refusal is visible in the log rather than silent.

      Parameters:
      objectSyncId - the mapping row whose copy is behind
      userIdentityId - whose calendar the copy sits in
      kind - whether the copy has to be written again or removed
      localEventId - the eXo event to render, null for a removal
      icsUid - the iCalendar identity a removal addresses the object by
      Returns:
      the obligation as it now stands
    • settled

      @Transactional public void settled(long objectSyncId)
      Forgets what was owed to one copy, because it has been written.

      By the mapping row rather than by the obligation's own identifier: the caller settling a copy knows which copy it settled, and looking the obligation up again is what makes settling one that was renewed in the meantime remove the renewal too — which is correct, since the write that just landed carries whatever the renewal was about.

      Parameters:
      objectSyncId - the mapping row whose copy was written
    • refused

      @Transactional public void refused(long id)
      Records that one more attempt was refused.
      Parameters:
      id - the obligation
    • abandoned

      @Transactional public void abandoned(long id, int maxAttempts)
      Records that an obligation is given up on, without counting toward the bound first.
      Parameters:
      id - the obligation
      maxAttempts - the configured bound, written whole
    • attemptable

      public List<org.exoplatform.caldav.model.PendingPush> attemptable(long userIdentityId, int maxAttempts, int limit)
      What one account is owed and is still worth attempting, oldest first.

      Oldest first because a backlog is drained rather than shuffled: a copy that has been wrong the longest is the one somebody is most likely to be acting on.

      Parameters:
      userIdentityId - whose calendar the copies sit in
      maxAttempts - how many refusals are argued with before stopping
      limit - how many to take in one pass
      Returns:
      the obligations to attempt now, possibly none
    • owed

      public long owed(long userIdentityId)
      How many copies of one account are behind, abandoned ones included.
      Parameters:
      userIdentityId - whose calendar the copies sit in
      Returns:
      the count, zero on an account whose copies all landed
    • owedAndStillTrying

      public long owedAndStillTrying(long userIdentityId, int maxAttempts)
      How many copies of one account are behind and still being argued for.

      Deliberately not owed(long): that one counts every row, the abandoned ones included, which is the right number for a report about the store and the wrong one for a sentence telling somebody to wait.

      Parameters:
      userIdentityId - whose calendar the copies sit in
      maxAttempts - how many refusals are argued with before stopping
      Returns:
      the count, zero on an account whose copies all landed