Interface AgendaCalendarSubscriptionService
Who: a subscription is personal; only the user who subscribed reads, edits, refreshes or removes it. What the platform fetches: only the addresses the subscription guard lets through — never a loopback, private, link-local or cloud-metadata address unless the deployment allows internal addresses — with bounded size, time and redirects, no credentials and no cookies. What is imported: title, time, location and a plain-text description of each occurrence in a bounded window; never an organizer, an attendee, an alarm or an attachment; and nothing imported produces an invitation, a notification or a copy to a connected remote account.
Refusals are thrown as IllegalArgumentException carrying a message
code agenda.calendarSubscription.*; a refresh asked too soon, or a
URL read too many times in a short window (tooManyReads -- reached
from checkUrl(java.lang.String, java.lang.String), createSubscription(java.lang.String, java.lang.String, java.lang.String, java.lang.String) and
updateSubscription(long, java.lang.String, java.lang.String, java.lang.String, java.lang.String) alike, since all three read the URL), as an
IllegalStateException with such a code.
-
Method Summary
Modifier and TypeMethodDescriptionChecks that a URL can be subscribed to, by reading it once, without storing anything.createSubscription(String url, String name, String color, String username) Subscribes the user to a URL: reads it, creates the calendar and imports its events.voiddeleteCalendarSubscription(long calendarId) Removes the subscription of a calendar that was deleted by another path, with no permission check, for the platform's own clean-up.voiddeleteSubscription(long subscriptionId, String username) Unsubscribes: removes the subscription, its calendar and every event it imported.getSubscription(long subscriptionId, String username) Reads one of the user's subscriptions.getSubscriptions(String username) Lists the user's subscriptions, oldest first, each with its URL in clear.intrefreshDueSubscriptions(int batchSize) Refreshes the subscriptions whose refresh is due, at most a batch of them, each claimed in the database first so that a single node of a cluster refreshes it.refreshSubscription(long subscriptionId, String username) Refreshes one of the user's subscriptions now.updateSubscription(long subscriptionId, String url, String name, String color, String username) Changes the name, the colour or the URL of one of the user's subscriptions.
-
Method Details
-
getSubscriptions
Lists the user's subscriptions, oldest first, each with its URL in clear.- Parameters:
username- the user- Returns:
- the subscriptions, bounded
- Throws:
IllegalAccessException- when the user has no usable identity
-
getSubscription
CalendarSubscription getSubscription(long subscriptionId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Reads one of the user's subscriptions.- Parameters:
subscriptionId- technical identifier of the subscriptionusername- the user- Returns:
- the subscription, with its URL in clear
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when no such subscription existsIllegalAccessException- when it is not the user's
-
checkUrl
Checks that a URL can be subscribed to, by reading it once, without storing anything.- Parameters:
url- the URL as the user typed it;webcal://is acceptedusername- the user- Returns:
- the calendar's own name (
X-WR-CALNAME), or null when it names none - Throws:
IllegalAccessException- when the user has no usable identityIllegalArgumentException- with a message code when the URL is refused or does not serve a calendarIllegalStateException- withtooManyReadswhen the user has read too many URLs in too short a window
-
createSubscription
CalendarSubscription createSubscription(String url, String name, String color, String username) throws IllegalAccessException Subscribes the user to a URL: reads it, creates the calendar and imports its events.- Parameters:
url- the URL as the user typed itname- the calendar name, or blank for the feed's own namecolor- the calendar colour#RRGGBB, or blank for an automatic oneusername- the user- Returns:
- the subscription
- Throws:
IllegalAccessException- when the user has no usable identityIllegalArgumentException- with a message code when the URL is refused, already subscribed, or does not serve a calendarIllegalStateException- withtooManyReadswhen the user has read too many URLs in too short a window
-
updateSubscription
CalendarSubscription updateSubscription(long subscriptionId, String url, String name, String color, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Changes the name, the colour or the URL of one of the user's subscriptions. A new URL is read before it is stored, and its events replace the old ones.- Parameters:
subscriptionId- technical identifier of the subscriptionurl- the new URL, or blank to keep the current onename- the new name, or blank to keep the current onecolor- the new colour, or blank to keep the current oneusername- the user- Returns:
- the subscription as it now stands
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when no such subscription existsIllegalAccessException- when it is not the user'sIllegalStateException- withtooManyReadswhen a new URL is given and the user has read too many in too short a window
-
refreshSubscription
CalendarSubscription refreshSubscription(long subscriptionId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Refreshes one of the user's subscriptions now. A failure is not thrown: it is recorded on the subscription returned, as a scheduled refresh records it.- Parameters:
subscriptionId- technical identifier of the subscriptionusername- the user- Returns:
- the subscription after the refresh
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when no such subscription existsIllegalAccessException- when it is not the user'sIllegalStateException- with a message code when it was refreshed a moment ago or is being refreshed
-
deleteSubscription
void deleteSubscription(long subscriptionId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Unsubscribes: removes the subscription, its calendar and every event it imported.- Parameters:
subscriptionId- technical identifier of the subscriptionusername- the user- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when no such subscription existsIllegalAccessException- when it is not the user's
-
deleteCalendarSubscription
void deleteCalendarSubscription(long calendarId) Removes the subscription of a calendar that was deleted by another path, with no permission check, for the platform's own clean-up.- Parameters:
calendarId- technical identifier of the deleted calendar
-
refreshDueSubscriptions
int refreshDueSubscriptions(int batchSize) Refreshes the subscriptions whose refresh is due, at most a batch of them, each claimed in the database first so that a single node of a cluster refreshes it.- Parameters:
batchSize- most subscriptions to refresh- Returns:
- how many were refreshed by this call
-