Class CalendarLinkStorage
CalendarLink. No cache:
a feed is fetched every few hours per subscriber, and a cached digest would
keep a reset link answering until the cache let it go.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandeleteByCalendarId(long calendarId) Deletes the link of a calendar.org.exoplatform.agenda.model.CalendarLinkgetByCalendarId(long calendarId) Reads the link of a calendar.List<org.exoplatform.agenda.model.CalendarLink> getByCalendarOwnerIds(List<Long> ownerIds, int limit) Reads the links of the calendars some identities own, in one query.org.exoplatform.agenda.model.CalendarLinkgetByTokenHash(String tokenHash) Reads the link a token digest opens.org.exoplatform.agenda.model.CalendarLinkWrites the link of a calendar, creating the row or replacing the one the calendar already has.
-
Constructor Details
-
CalendarLinkStorage
Builds the storage.- Parameters:
calendarLinkDAO- the repository of calendar link rows
-
-
Method Details
-
getByCalendarId
public org.exoplatform.agenda.model.CalendarLink getByCalendarId(long calendarId) Reads the link of a calendar.- Parameters:
calendarId- technical identifier of the calendar- Returns:
- the link, or null when the calendar has none
-
getByTokenHash
Reads the link a token digest opens.- Parameters:
tokenHash- lowercase hexadecimal SHA-256 digest of a token- Returns:
- the link, or null when no link carries that digest
-
getByCalendarOwnerIds
public List<org.exoplatform.agenda.model.CalendarLink> getByCalendarOwnerIds(List<Long> ownerIds, int limit) Reads the links of the calendars some identities own, in one query.- Parameters:
ownerIds- identity identifiers owning the calendarslimit- most links to read- Returns:
- the links, newest first, empty when no owner is given
-
save
public org.exoplatform.agenda.model.CalendarLink save(long calendarId, long creatorId, String tokenHash, String tokenEncrypted, Date createdDate) Writes the link of a calendar, creating the row or replacing the one the calendar already has.Two managers creating a link for the same calendar at the same moment both find no row, and the unique constraint on the calendar refuses the second insert. That refusal is not an error for the second manager: their link simply replaces the first one, as a reset would, so the insert is retried once as an update of the row that won.
The insert is flushed, so that the refusal surfaces here on every engine — with a sequence generator the row would otherwise only reach the database at commit, past this method. It is caught both as Spring's translated exception and as the raw JPA one, because whether a repository call is translated depends on the context it runs in; a refusal that is not about the calendar's row is rethrown, since no row is found on the retry.
- Parameters:
calendarId- technical identifier of the calendarcreatorId- identity identifier of the user creating the linktokenHash- digest of the new tokentokenEncrypted- the new token encrypted by the platform codeccreatedDate- when the link is created- Returns:
- the stored link
-
deleteByCalendarId
public boolean deleteByCalendarId(long calendarId) Deletes the link of a calendar.- Parameters:
calendarId- technical identifier of the calendar- Returns:
- true when a link was deleted
-