Package org.exoplatform.caldav.dao
Interface CaldavPendingSubscriptionDAO
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<CaldavPendingSubscriptionEntity,,Long> org.springframework.data.jpa.repository.JpaRepository<CaldavPendingSubscriptionEntity,,Long> org.springframework.data.repository.ListCrudRepository<CaldavPendingSubscriptionEntity,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<CaldavPendingSubscriptionEntity,,Long> org.springframework.data.repository.PagingAndSortingRepository<CaldavPendingSubscriptionEntity,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<CaldavPendingSubscriptionEntity>,org.springframework.data.repository.Repository<CaldavPendingSubscriptionEntity,Long>
public interface CaldavPendingSubscriptionDAO
extends org.springframework.data.jpa.repository.JpaRepository<CaldavPendingSubscriptionEntity,Long>
The subscription changes eXo owes colleagues' BlueMind accounts
(EXO-90277).
Every query string is spelled out and every parameter named, for the
reason CaldavPendingPushDAO records: a mock answers happily to a
query the engine would refuse, and CaldavSyncDAOQueryTest runs
these through a real repository proxy over HSQLDB.
-
Method Summary
Modifier and TypeMethodDescriptionintdeleteAsking(long userIdentityId, long serverId, String containerUid, org.exoplatform.caldav.model.PendingSubscriptionKind kind) Deletes the row of a colleague, a server and a container only while it still asks for the given change, in one statement: a read followed by a delete by id would let a revoke recorded in between be deleted with it.findAttemptable(int maxAttempts, org.springframework.data.domain.Pageable pageable) The changes still worth attempting, whoever they are owed to.findAttemptableOf(long userIdentityId, int maxAttempts, org.springframework.data.domain.Pageable pageable) The changes one colleague is owed and that are still worth attempting.findByUserIdentityIdAndServerIdAndContainerUid(long userIdentityId, long serverId, String containerUid) The one row a colleague, a server and a container may have.intrecordAttempt(long id, org.exoplatform.caldav.model.PendingSubscriptionKind kind) Counts one more refused attempt, in one statement, so two nodes draining the same row do not lose an increment to a read-modify-save — and only while the row still asks for the change that was refused: a row renewed with the other kind since it was read is a new instruction, and the old one's verdict is not written against it.intspendBudget(long id, org.exoplatform.caldav.model.PendingSubscriptionKind kind, int attempts) Spends the whole budget at once: the change is given up on without counting toward the bound, because the answer will not change by asking again — a refusal, a container that is gone, a colleague no longer connected, a session that is not theirs.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByUserIdentityIdAndServerIdAndContainerUid
Optional<CaldavPendingSubscriptionEntity> findByUserIdentityIdAndServerIdAndContainerUid(long userIdentityId, long serverId, String containerUid) The one row a colleague, a server and a container may have.- Parameters:
userIdentityId- the shareeserverId- the server keycontainerUid- the container uid- Returns:
- the row, if any
-
findAttemptable
@Query("SELECT q FROM CaldavPendingSubscriptionEntity q WHERE q.attempts < :maxAttempts") List<CaldavPendingSubscriptionEntity> findAttemptable(@Param("maxAttempts") int maxAttempts, org.springframework.data.domain.Pageable pageable) The changes still worth attempting, whoever they are owed to.Table-wide on purpose: the colleague owed a subscription holds no active pair and is never selected by the sweep's per-account paging, so the drain reads the table rather than visiting accounts. The caller pages oldest first and groups by sharee.
- Parameters:
maxAttempts- the configured boundpageable- the page, sorted by the caller- Returns:
- the rows
-
findAttemptableOf
@Query("SELECT q FROM CaldavPendingSubscriptionEntity q WHERE q.userIdentityId = :userIdentityId AND q.attempts < :maxAttempts") List<CaldavPendingSubscriptionEntity> findAttemptableOf(@Param("userIdentityId") long userIdentityId, @Param("maxAttempts") int maxAttempts, org.springframework.data.domain.Pageable pageable) The changes one colleague is owed and that are still worth attempting.- Parameters:
userIdentityId- the shareemaxAttempts- the configured boundpageable- the page, sorted by the caller- Returns:
- the rows
-
recordAttempt
@Modifying(flushAutomatically=true) @Transactional @Query("UPDATE CaldavPendingSubscriptionEntity q SET q.attempts = q.attempts + 1 WHERE q.id = :id AND q.kind = :kind") int recordAttempt(@Param("id") long id, @Param("kind") org.exoplatform.caldav.model.PendingSubscriptionKind kind) Counts one more refused attempt, in one statement, so two nodes draining the same row do not lose an increment to a read-modify-save — and only while the row still asks for the change that was refused: a row renewed with the other kind since it was read is a new instruction, and the old one's verdict is not written against it.- Parameters:
id- the rowkind- the change that was refused- Returns:
- rows updated, one or zero
-
spendBudget
@Modifying(flushAutomatically=true) @Transactional @Query("UPDATE CaldavPendingSubscriptionEntity q SET q.attempts = :attempts WHERE q.id = :id AND q.kind = :kind") int spendBudget(@Param("id") long id, @Param("kind") org.exoplatform.caldav.model.PendingSubscriptionKind kind, @Param("attempts") int attempts) Spends the whole budget at once: the change is given up on without counting toward the bound, because the answer will not change by asking again — a refusal, a container that is gone, a colleague no longer connected, a session that is not theirs.Only while the row still asks for the change given up on, for the reason
recordAttempt(long, PendingSubscriptionKind)gives.- Parameters:
id- the rowkind- the change given up onattempts- the configured bound, written whole- Returns:
- rows updated, one or zero
-
deleteAsking
@Modifying(flushAutomatically=true) @Transactional @Query("DELETE FROM CaldavPendingSubscriptionEntity q WHERE q.userIdentityId = :userIdentityId AND q.serverId = :serverId AND q.containerUid = :containerUid AND q.kind = :kind") int deleteAsking(@Param("userIdentityId") long userIdentityId, @Param("serverId") long serverId, @Param("containerUid") String containerUid, @Param("kind") org.exoplatform.caldav.model.PendingSubscriptionKind kind) Deletes the row of a colleague, a server and a container only while it still asks for the given change, in one statement: a read followed by a delete by id would let a revoke recorded in between be deleted with it.- Parameters:
userIdentityId- the shareeserverId- the server keycontainerUid- the container uidkind- the change that landed- Returns:
- rows deleted, one or zero
-