Class AgendaCalendarSubscriptionServiceImpl

java.lang.Object
org.exoplatform.agenda.service.AgendaCalendarSubscriptionServiceImpl
All Implemented Interfaces:
org.exoplatform.agenda.service.AgendaCalendarSubscriptionService

@Service public class AgendaCalendarSubscriptionServiceImpl extends Object implements org.exoplatform.agenda.service.AgendaCalendarSubscriptionService
Holds every rule of calendar subscriptions (EXO-90278).

Stored events. A subscription fills a personal calendar of its own, flagged as a subscription, with one agenda event per occurrence of the feed in the window — so imported events appear in every view, the search and the preview like any other. They are written through AgendaEventStorage, never through AgendaEventService: no creation, update or deletion is broadcast, so nothing imported sends an invitation or a notification, computes a reminder, earns points, or reaches a connector's listeners; the search index is kept in step directly. The calendar flag is what makes them read-only (AgendaEventServiceImpl#canUpdateEvent) and what keeps the calendar out of the listings a connector binds remote collections from.

Reading a link. A link of this very eXo — its public domain and the path of a published calendar — is read in the process, through AgendaCalendarLinkService, with the token checks the anonymous feed applies; and refused when the calendar it publishes is one the user already sees. Every other link is read by CalendarFeedFetcher, whose guard decides which addresses the platform may reach.

Refreshing. A refresh is claimed in the database before it runs, by the scheduled job on every node and by the owner's "refresh now" alike, so a single node reads a feed at a time. It sends the validators of the last read, skips a body identical to the last one imported, rewrites only the occurrences that changed and removes those the feed dropped. A failure keeps the last good copy and records its message code.

Secrets. Feed URLs often embed one; a URL is stored encrypted with the platform codec, compared through a digest, returned to its owner only, and never logged.

  • Field Details

    • PAST_DAYS

      public static final int PAST_DAYS
      Days of past occurrences imported.
      See Also:
    • FUTURE_DAYS

      public static final int FUTURE_DAYS
      Days of future occurrences imported.
      See Also:
    • MAX_EVENTS

      public static final int MAX_EVENTS
      Most occurrences imported per subscription.
      See Also:
    • MAX_SUBSCRIPTIONS

      public static final int MAX_SUBSCRIPTIONS
      Most subscriptions a user holds.
      See Also:
    • DEFAULT_REFRESH

      public static final Duration DEFAULT_REFRESH
      Refresh interval of a feed that advertises none.
    • MIN_REFRESH

      public static final Duration MIN_REFRESH
      Shortest refresh interval honoured.
    • MAX_REFRESH

      public static final Duration MAX_REFRESH
      Longest refresh interval honoured.
    • RETRY_AFTER_FAILURE

      public static final Duration RETRY_AFTER_FAILURE
      Wait before retrying a failed refresh.
    • RETRY_AFTER_DEAD_END

      public static final Duration RETRY_AFTER_DEAD_END
      Wait before retrying a subscription that cannot be refreshed at all.
    • MANUAL_REFRESH_INTERVAL

      public static final Duration MANUAL_REFRESH_INTERVAL
      Shortest time between two refreshes asked by the owner.
    • CLAIM_STALE

      public static final Duration CLAIM_STALE
      Age after which a refresh claim is taken over.
    • MAX_NAME

      public static final int MAX_NAME
      Longest calendar name.
      See Also:
    • ALREADY_SUBSCRIBED

      public static final String ALREADY_SUBSCRIBED
      The user already subscribes to this URL.
      See Also:
    • TOO_MANY_SUBSCRIPTIONS

      public static final String TOO_MANY_SUBSCRIPTIONS
      The user holds the most subscriptions allowed.
      See Also:
    • URL_UNREADABLE

      public static final String URL_UNREADABLE
      The stored URL cannot be decrypted: the platform codec key was replaced.
      See Also:
    • REFRESH_TOO_SOON

      public static final String REFRESH_TOO_SOON
      A refresh was asked a moment ago.
      See Also:
    • REFRESH_IN_PROGRESS

      public static final String REFRESH_IN_PROGRESS
      A refresh is running.
      See Also:
    • REFRESH_FAILED

      public static final String REFRESH_FAILED
      A refresh failed for a reason of the platform's.
      See Also:
    • USER_DISABLED

      public static final String USER_DISABLED
      The owner's account is disabled or deleted.
      See Also:
    • NAME_TOO_LONG

      public static final String NAME_TOO_LONG
      A name longer than allowed.
      See Also:
    • INVALID_COLOR

      public static final String INVALID_COLOR
      A colour that is not #RRGGBB.
      See Also:
    • TOO_MANY_READS

      public static final String TOO_MANY_READS
      The user already has as many links being read as allowed.
      See Also:
    • MAX_READS_PER_USER

      public static final int MAX_READS_PER_USER
      Most links one user may have read at the same time on one node, through checking, subscribing, editing and refreshing: a user looping on slow hosts would otherwise hold the connections the scheduled refresh and every other user share.
      See Also:
  • Constructor Details

    • AgendaCalendarSubscriptionServiceImpl

      @Autowired public AgendaCalendarSubscriptionServiceImpl(CalendarSubscriptionStorage subscriptionStorage, org.exoplatform.agenda.service.AgendaCalendarService agendaCalendarService, AgendaEventStorage agendaEventStorage, AgendaEventAttendeeStorage attendeeStorage, org.exoplatform.agenda.service.AgendaCalendarLinkService calendarLinkService, CalendarFeedFetcher feedFetcher, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, org.exoplatform.web.security.codec.CodecInitializer codecInitializer, org.exoplatform.commons.search.index.IndexingService indexingService)
      Builds the service.
      Parameters:
      subscriptionStorage - the subscription rows
      agendaCalendarService - creates, reads and deletes the calendars
      agendaEventStorage - writes the imported events without broadcasting
      attendeeStorage - writes the owner as the attendee of an imported event
      calendarLinkService - reads the links of this eXo
      feedFetcher - reads every other link
      identityManager - resolves users
      spaceService - resolves space memberships
      codecInitializer - the platform codec URLs are encrypted with
      indexingService - keeps the search index in step with the imported events
  • Method Details

    • getSubscriptions

      public List<org.exoplatform.agenda.model.CalendarSubscription> getSubscriptions(String username) throws IllegalAccessException
      Specified by:
      getSubscriptions in interface org.exoplatform.agenda.service.AgendaCalendarSubscriptionService
      Throws:
      IllegalAccessException
    • getSubscription

      public org.exoplatform.agenda.model.CalendarSubscription getSubscription(long subscriptionId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      getSubscription in interface org.exoplatform.agenda.service.AgendaCalendarSubscriptionService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • checkUrl

      public String checkUrl(String url, String username) throws IllegalAccessException
      Specified by:
      checkUrl in interface org.exoplatform.agenda.service.AgendaCalendarSubscriptionService
      Throws:
      IllegalAccessException
    • createSubscription

      public org.exoplatform.agenda.model.CalendarSubscription createSubscription(String url, String name, String color, String username) throws IllegalAccessException
      Specified by:
      createSubscription in interface org.exoplatform.agenda.service.AgendaCalendarSubscriptionService
      Throws:
      IllegalAccessException
    • updateSubscription

      public org.exoplatform.agenda.model.CalendarSubscription updateSubscription(long subscriptionId, String url, String name, String color, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      updateSubscription in interface org.exoplatform.agenda.service.AgendaCalendarSubscriptionService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • refreshSubscription

      public org.exoplatform.agenda.model.CalendarSubscription refreshSubscription(long subscriptionId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      refreshSubscription in interface org.exoplatform.agenda.service.AgendaCalendarSubscriptionService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • deleteSubscription

      public void deleteSubscription(long subscriptionId, String username) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      deleteSubscription in interface org.exoplatform.agenda.service.AgendaCalendarSubscriptionService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • deleteCalendarSubscription

      public void deleteCalendarSubscription(long calendarId)
      Specified by:
      deleteCalendarSubscription in interface org.exoplatform.agenda.service.AgendaCalendarSubscriptionService
    • refreshDueSubscriptions

      public int refreshDueSubscriptions(int batchSize)
      Specified by:
      refreshDueSubscriptions in interface org.exoplatform.agenda.service.AgendaCalendarSubscriptionService