Interface CaldavConnectionDAO
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<CaldavConnectionEntity,,Long> org.springframework.data.jpa.repository.JpaRepository<CaldavConnectionEntity,,Long> org.springframework.data.repository.ListCrudRepository<CaldavConnectionEntity,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<CaldavConnectionEntity,,Long> org.springframework.data.repository.PagingAndSortingRepository<CaldavConnectionEntity,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<CaldavConnectionEntity>,org.springframework.data.repository.Repository<CaldavConnectionEntity,Long>
-
Method Summary
Modifier and TypeMethodDescriptionlongcountUsersWithPairsButNoIdentity(long serverId, org.exoplatform.caldav.model.CalendarSyncStatus status) How many users hold a pair in one state on one server without an identity recorded for that server.intdeleteByUserIdentityId(long userIdentityId) Removes the identity recorded for one eXo user.findByServer(long serverId, org.springframework.data.domain.Pageable pageable) The rows recorded on one server, lowest user first (EXO-90253).findByServerAndPrincipal(long serverId, String principal, org.springframework.data.domain.Pageable pageable) The rows recording one principal on one server, lowest user first.findByUserIdentityId(long userIdentityId) The identity recorded for one eXo user, whichever server it names.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
-
findByUserIdentityId
The identity recorded for one eXo user, whichever server it names.Served by the unique index
UQ_CALDAV_CONNECTION_USER: a point lookup, asked once per discovery to decide whether anything changed.- Parameters:
userIdentityId- the eXo user- Returns:
- the row, when the user's identity has been recorded
-
findByServerAndPrincipal
@Query("SELECT c FROM CaldavConnectionEntity c WHERE c.serverId = :serverId AND c.principal = :principal ORDER BY c.userIdentityId ASC") List<CaldavConnectionEntity> findByServerAndPrincipal(@Param("serverId") long serverId, @Param("principal") String principal, org.springframework.data.domain.Pageable pageable) The rows recording one principal on one server, lowest user first.Served by
IDX_CALDAV_CONNECTION_PRINCIPAL (SERVER_ID, PRINCIPAL). The equality is the database's, and on MySQL that equality is the column collation's, which ignores case and accents: this answers the candidates, and the caller keeps only the rows whose principal is exactly the one asked about. Ordered so that a bounded page names the same users on every call.- Parameters:
serverId- the declared server registrationprincipal- the principal, canonicalpageable- how many rows to read at most; required- Returns:
- the candidate rows
-
findByServer
@Query("SELECT c FROM CaldavConnectionEntity c WHERE c.serverId = :serverId ORDER BY c.userIdentityId ASC") List<CaldavConnectionEntity> findByServer(@Param("serverId") long serverId, org.springframework.data.domain.Pageable pageable) The rows recorded on one server, lowest user first (EXO-90253).The population a calendar on that server can be shared with: an eXo user is named to the server only by the principal recorded here. Served by the leading column of
IDX_CALDAV_CONNECTION_PRINCIPAL (SERVER_ID, PRINCIPAL); ordered so that a bounded page names the same users on every call.- Parameters:
serverId- the declared server registrationpageable- how many rows to read at most; required- Returns:
- the rows
-
countUsersWithPairsButNoIdentity
@Query("SELECT COUNT(DISTINCT p.userIdentityId) FROM CaldavCalendarSyncEntity p WHERE p.serverId = :serverId AND p.status = :status AND NOT EXISTS (SELECT c.id FROM CaldavConnectionEntity c WHERE c.userIdentityId = p.userIdentityId AND c.serverId = p.serverId)") long countUsersWithPairsButNoIdentity(@Param("serverId") long serverId, @Param("status") org.exoplatform.caldav.model.CalendarSyncStatus status) How many users hold a pair in one state on one server without an identity recorded for that server.The completeness question behind the owner of a share (EXO-90243): "exactly one user is connected as this principal" can be read off the table only once every user synchronising with the server is in it, because a second user on the same login who has not been recorded yet is invisible to
findByServerAndPrincipal(long, java.lang.String, org.springframework.data.domain.Pageable). Asked with the active state, the state of an account being synchronised, whose next successful discovery records its identity. An identity recorded for another server does not count, since it says nothing about who the user is on this one.Active is not "will be recorded". Some users keep active pairs on a server and are never recorded for it: an account pointed at another server without being disconnected (its old pairs stay active, and every discovery records it under the new server), a principal the column cannot hold (its row is removed on every pass), settings removed without the disconnect that pauses the pairs, a discovery that keeps failing with something other than a refused credential. Each of them keeps this count above zero for as long as it lasts — possibly for good — and so keeps every share on that server named by its principal alone. That is the safe direction; the owner service says so once per server at info.
What it costs: the status index
IDX_CALDAV_CALENDAR_SYNC_STATUSserves the state, the server is compared on the rows it yields, and theNOT EXISTSis a point lookup onUQ_CALDAV_CONNECTION_USERper user. Asked only when a share's owner principal has exactly one recorded user, once per principal per listing.- Parameters:
serverId- the declared server registrationstatus- the state a pair has to be in to count, active in practice- Returns:
- the number of distinct such users, zero when every one is recorded
-
deleteByUserIdentityId
@Modifying @Transactional @Query("DELETE FROM CaldavConnectionEntity c WHERE c.userIdentityId = :userIdentityId") int deleteByUserIdentityId(@Param("userIdentityId") long userIdentityId) Removes the identity recorded for one eXo user.A bulk statement rather than a find-then-delete, so that forgetting a user nobody recorded costs one statement and no read.
- Parameters:
userIdentityId- the eXo user- Returns:
- how many rows were removed, zero or one
-