Class AgendaCalendarShareServiceImpl

java.lang.Object
org.exoplatform.agenda.service.AgendaCalendarShareServiceImpl
All Implemented Interfaces:
org.exoplatform.agenda.service.AgendaCalendarShareService

@Service public class AgendaCalendarShareServiceImpl extends Object implements org.exoplatform.agenda.service.AgendaCalendarShareService
Holds every rule of calendar sharing (EXO-90357): who shares what with whom, what a sharee may read, and how a delivery channel is composed with the eXo record.

Sharing is the owner's: a personal calendar — its owner is a user, not a space — that is not a subscription (EXO-90278). A space calendar is read by its members already, and sharing one is a later decision. The sharee is a usable user of this deployment other than the owner.

Delivery: the record is written first and stands whatever the channels answer. Each registered CalendarShareChannelPlugin is asked to carry the share; the first that delivers is recorded on the row, a failure is logged at WARN and leaves the row undelivered — the owner is told nothing and nothing is retried on its own — and a channel that says the share is none of its business leaves the row eXo-only. A grant a channel holds for a colleague that eXo has no record of is recorded silently, as an adopted share, when the owner lists their shares. The plugins are collected from the Spring context at the moment they are asked, so an add-on booting after agenda is found all the same — the idiom of AgendaRemoteCopyService.

Revoking withdraws from the channel first, then deletes the row whatever the channel answered: a grant the channel could not remove shows up under the external shares, with its own removal, rather than keeping a colleague on the eXo record the owner asked to end.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Most shares one "shared with me" listing reads.

    Fields inherited from interface org.exoplatform.agenda.service.AgendaCalendarShareService

    CALENDAR_SHARE_LEVEL_CHANGED_EVENT, CALENDAR_SHARED_EVENT, CALENDAR_UNSHARED_EVENT, INVALID_CALENDAR, LEVEL_MANDATORY, LEVEL_NOT_NARROWED, NO_CHANNEL, SHARE_NOT_FOUND, SHARE_NOT_REMOVED, SHAREE_DISABLED, SHAREE_IS_OWNER, SHAREE_UNKNOWN
  • Constructor Summary

    Constructors
    Constructor
    Description
    AgendaCalendarShareServiceImpl(CalendarShareStorage calendarShareStorage, org.exoplatform.agenda.service.AgendaCalendarService agendaCalendarService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.services.listener.ListenerService listenerService, org.springframework.context.ApplicationContext applicationContext)
    Builds the service.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clearDelivery(long ownerIdentityId, String channelId)
    void
    deleteShares(long calendarId)
    void
    deleteSharesOfUser(long identityId)
    org.exoplatform.agenda.model.ChannelShares
    getChannelShares(long calendarId, String ownerUsername)
    List<org.exoplatform.agenda.model.ExternalShare>
    getExternalShares(long calendarId, String ownerUsername)
    getSharedCalendarIds(long viewerIdentityId)
    List<org.exoplatform.agenda.model.CalendarShare>
    org.exoplatform.agenda.constant.CalendarShareLevel
    getShareLevel(long calendarId, long viewerIdentityId)
    Map<Long,org.exoplatform.agenda.constant.CalendarShareLevel>
    getShareLevels(long viewerIdentityId)
    List<org.exoplatform.agenda.model.CalendarShare>
    getShares(long calendarId, String ownerUsername)
    boolean
    holdsMeetingCopies(long calendarId, String ownerUsername)
    boolean
    isSharedWith(long calendarId, long viewerIdentityId)
    void
    removeExternalShare(long calendarId, String channelId, String externalId, String ownerUsername)
    void
    setHidden(long calendarId, String username, boolean hidden)
    org.exoplatform.agenda.model.CalendarShare
    setLevel(long calendarId, long shareeIdentityId, org.exoplatform.agenda.constant.CalendarShareLevel level, String ownerUsername)
    org.exoplatform.agenda.model.CalendarShare
    share(long calendarId, String shareeUsername, org.exoplatform.agenda.constant.CalendarShareLevel level, String ownerUsername)
    void
    unshare(long calendarId, long shareeIdentityId, String ownerUsername)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_SHARED_WITH_ME

      public static final int MAX_SHARED_WITH_ME
      Most shares one "shared with me" listing reads.
      See Also:
  • Constructor Details

    • AgendaCalendarShareServiceImpl

      @Autowired public AgendaCalendarShareServiceImpl(CalendarShareStorage calendarShareStorage, org.exoplatform.agenda.service.AgendaCalendarService agendaCalendarService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.services.listener.ListenerService listenerService, org.springframework.context.ApplicationContext applicationContext)
      Builds the service.
      Parameters:
      calendarShareStorage - storage of the share records
      agendaCalendarService - reads calendars
      identityManager - resolves users
      listenerService - the platform event bus, told of every share and revoke so that notifications and channels can react
      applicationContext - the Spring context of this WAR, from which the delivery channels are collected when asked
  • Method Details

    • share

      public org.exoplatform.agenda.model.CalendarShare share(long calendarId, String shareeUsername, org.exoplatform.agenda.constant.CalendarShareLevel level, String ownerUsername) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      share in interface org.exoplatform.agenda.service.AgendaCalendarShareService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • setLevel

      public org.exoplatform.agenda.model.CalendarShare setLevel(long calendarId, long shareeIdentityId, org.exoplatform.agenda.constant.CalendarShareLevel level, String ownerUsername) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      setLevel in interface org.exoplatform.agenda.service.AgendaCalendarShareService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • unshare

      public void unshare(long calendarId, long shareeIdentityId, String ownerUsername) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      unshare in interface org.exoplatform.agenda.service.AgendaCalendarShareService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • getShares

      public List<org.exoplatform.agenda.model.CalendarShare> getShares(long calendarId, String ownerUsername) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      getShares in interface org.exoplatform.agenda.service.AgendaCalendarShareService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • getExternalShares

      public List<org.exoplatform.agenda.model.ExternalShare> getExternalShares(long calendarId, String ownerUsername) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      getExternalShares in interface org.exoplatform.agenda.service.AgendaCalendarShareService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • getChannelShares

      public org.exoplatform.agenda.model.ChannelShares getChannelShares(long calendarId, String ownerUsername) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException

      One pass over the channels, one ask each (EXO-90385): a channel answers the grants its server holds and the meeting-copies flag out of the same read, so no channel talks to its server twice for one opening of the drawer.

      A channel that throws out of CalendarShareChannelPlugin.listShares(long, java.lang.String, java.util.List<java.lang.Long>) contributes neither shares nor the warning. The SPI default guards each of its two questions on its own, so only a channel overriding listShares can lose both, and the one that does (caldav) answers the flag on its own when the list cannot be read.

      Specified by:
      getChannelShares in interface org.exoplatform.agenda.service.AgendaCalendarShareService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • holdsMeetingCopies

      public boolean holdsMeetingCopies(long calendarId, String ownerUsername) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException

      A channel that throws is read as copying nothing: the confirmation is a courtesy to the owner, not a gate, and a channel that cannot answer must not stop the share.

      Specified by:
      holdsMeetingCopies in interface org.exoplatform.agenda.service.AgendaCalendarShareService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • removeExternalShare

      public void removeExternalShare(long calendarId, String channelId, String externalId, String ownerUsername) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException

      A channel that answers false — the server refused, or could not be reached — is an IllegalStateException bearing AgendaCalendarShareService.SHARE_NOT_REMOVED: the request was well formed and allowed, the state on the server is what stands in the way.

      Specified by:
      removeExternalShare in interface org.exoplatform.agenda.service.AgendaCalendarShareService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • countShareesByCalendar

      public Map<Long,Long> countShareesByCalendar(String ownerUsername) throws IllegalAccessException
      Specified by:
      countShareesByCalendar in interface org.exoplatform.agenda.service.AgendaCalendarShareService
      Throws:
      IllegalAccessException
    • getSharedWithMe

      public List<org.exoplatform.agenda.model.CalendarShare> getSharedWithMe(String username) throws IllegalAccessException

      A share whose calendar is gone, or whose owner is gone or no longer a user, is left out rather than drawn: the calendar cache answers the check.

      Specified by:
      getSharedWithMe in interface org.exoplatform.agenda.service.AgendaCalendarShareService
      Throws:
      IllegalAccessException
    • setHidden

      public void setHidden(long calendarId, String username, boolean hidden) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException
      Specified by:
      setHidden in interface org.exoplatform.agenda.service.AgendaCalendarShareService
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
      IllegalAccessException
    • isSharedWith

      public boolean isSharedWith(long calendarId, long viewerIdentityId)
      Specified by:
      isSharedWith in interface org.exoplatform.agenda.service.AgendaCalendarShareService
    • getShareLevel

      public org.exoplatform.agenda.constant.CalendarShareLevel getShareLevel(long calendarId, long viewerIdentityId)
      Specified by:
      getShareLevel in interface org.exoplatform.agenda.service.AgendaCalendarShareService
    • getShareLevels

      public Map<Long,org.exoplatform.agenda.constant.CalendarShareLevel> getShareLevels(long viewerIdentityId)
      Specified by:
      getShareLevels in interface org.exoplatform.agenda.service.AgendaCalendarShareService
    • getSharedCalendarIds

      public List<Long> getSharedCalendarIds(long viewerIdentityId)
      Specified by:
      getSharedCalendarIds in interface org.exoplatform.agenda.service.AgendaCalendarShareService
    • deleteShares

      public void deleteShares(long calendarId)
      Specified by:
      deleteShares in interface org.exoplatform.agenda.service.AgendaCalendarShareService
    • deleteSharesOfUser

      public void deleteSharesOfUser(long identityId)
      Specified by:
      deleteSharesOfUser in interface org.exoplatform.agenda.service.AgendaCalendarShareService
    • clearDelivery

      public void clearDelivery(long ownerIdentityId, String channelId)
      Specified by:
      clearDelivery in interface org.exoplatform.agenda.service.AgendaCalendarShareService