Class WebConferencingService

java.lang.Object
org.exoplatform.webconferencing.WebConferencingService
All Implemented Interfaces:
org.picocontainer.Startable

public class WebConferencingService extends Object implements org.picocontainer.Startable
Created by The eXo Platform SAS.
Version:
$Id: SkypeService.java 00000 Feb 22, 2017 pnedonosko $
Author:
Peter Nedonosko
  • Field Details

    • ID_MAX_LENGTH

      public static final int ID_MAX_LENGTH
      The Constant ID_MAX_LENGTH.
      See Also:
    • TEXT_MAX_LENGTH

      public static final int TEXT_MAX_LENGTH
      The Constant TEXT_MAX_LENGTH.
      See Also:
    • ARG_MAX_LENGTH

      public static final int ARG_MAX_LENGTH
      The Constant ARG_MAX_LENGTH.
      See Also:
    • DATA_MAX_LENGTH

      public static final int DATA_MAX_LENGTH
      The Constant DATA_MAX_LENGTH.
      See Also:
    • MAX_RESULT_SIZE

      public static final int MAX_RESULT_SIZE
      The Constant MAX_RESULT_SIZE.
      See Also:
    • OPERATION_CALL_ADDED

      public static final String OPERATION_CALL_ADDED
      The operation call added.
      See Also:
    • OPERATION_CALL_STARTED

      public static final String OPERATION_CALL_STARTED
      The operation call started.
      See Also:
    • OPERATION_CALL_JOINED

      public static final String OPERATION_CALL_JOINED
      The operation call joined.
      See Also:
    • OPERATION_CALL_LEAVED

      public static final String OPERATION_CALL_LEAVED
      The operation call leaved.
      See Also:
    • OPERATION_CALL_DECLINED

      public static final String OPERATION_CALL_DECLINED
      The operation call declined.
      See Also:
    • OPERATION_CALL_MISSED

      public static final String OPERATION_CALL_MISSED
      The operation call missed.
      See Also:
    • OPERATION_CALL_STOPPED

      public static final String OPERATION_CALL_STOPPED
      The operation call stopped.
      See Also:
    • OPERATION_CALL_DELETED

      public static final String OPERATION_CALL_DELETED
      The operation call deleted.
      See Also:
    • OPERATION_CALL_RECORDED

      public static final String OPERATION_CALL_RECORDED
      The operation call recorded.
      See Also:
    • STATUS_OK

      public static final String STATUS_OK
      The status ok.
      See Also:
    • STATUS_NOT_OK

      public static final String STATUS_NOT_OK
      The status not ok.
      See Also:
    • EVENT_CALL_CREATED

      public static final String EVENT_CALL_CREATED
      See Also:
    • EVENT_CALL_STARTED

      public static final String EVENT_CALL_STARTED
      See Also:
    • EVENT_CALL_JOINDED

      public static final String EVENT_CALL_JOINDED
      See Also:
    • EVENT_CALL_LEFT

      public static final String EVENT_CALL_LEFT
      See Also:
    • EVENT_CALL_STOPPED

      public static final String EVENT_CALL_STOPPED
      See Also:
    • EVENT_CALL_RECORDED

      public static final String EVENT_CALL_RECORDED
      See Also:
    • EVENT_CALL_MISSED

      public static final String EVENT_CALL_MISSED
      Broadcast once per participant who did not answer a call before its incoming call alert timed out, or before the call stopped. The source is the call, the data holds the participant in EVENT_DATA_USER_ID, the user who started the call in EVENT_DATA_CALLER_ID and, for a group call that had already ended, EVENT_DATA_CALL_ENDED.
      See Also:
    • EVENT_CALL_DECLINED

      public static final String EVENT_CALL_DECLINED
      Broadcast once per participant who declines a call that alerted its participants. The source is the call, the data holds the user who started the call in EVENT_DATA_USER_ID, the one the decline is reported to, and the participant who declined in EVENT_DATA_DECLINER_ID.
      See Also:
    • EVENT_CALL_DECLINES_CLOSED

      public static final String EVENT_CALL_DECLINES_CLOSED
      Broadcast once per call start whose incoming call alert closed with at least one decline: when the alert timed out, or when the call stopped before. The source is the call, the data holds the user who started the call in EVENT_DATA_USER_ID and the participants who declined it in EVENT_DATA_DECLINER_IDS.
      See Also:
    • EVENT_DATA_USER_ID

      public static final String EVENT_DATA_USER_ID
      The key of the user concerned by a call event, in the event data.
      See Also:
    • EVENT_DATA_CALLER_ID

      public static final String EVENT_DATA_CALLER_ID
      The key of the user who started the call, in the data of EVENT_CALL_MISSED.
      See Also:
    • EVENT_DATA_CALL_ENDED

      public static final String EVENT_DATA_CALL_ENDED
      The key telling, in the data of EVENT_CALL_MISSED, that a group call had already ended when the participant missed it: "true", absent otherwise.
      See Also:
    • EVENT_DATA_DECLINER_ID

      public static final String EVENT_DATA_DECLINER_ID
      The key of the participant who declined the call, in the data of EVENT_CALL_DECLINED.
      See Also:
    • EVENT_DATA_DECLINER_IDS

      public static final String EVENT_DATA_DECLINER_IDS
      The key of the participants who declined the call, comma separated, in the data of EVENT_CALL_DECLINES_CLOSED.
      See Also:
    • ROOM_DEFAULT_AVATAR_URL

      public static final String ROOM_DEFAULT_AVATAR_URL
      See Also:
    • CALL_OWNER_SCOPE_NAME

      protected static final String CALL_OWNER_SCOPE_NAME
      The Constant CALL_OWNER_SCOPE_NAME.
    • CALL_ID_SCOPE_NAME

      protected static final String CALL_ID_SCOPE_NAME
      The Constant CALL_ID_SCOPE_NAME.
    • USER_CALLS_SCOPE_NAME

      protected static final String USER_CALLS_SCOPE_NAME
      The Constant USER_CALLS_SCOPE_NAME.
    • PROVIDER_SCOPE_NAME

      protected static final String PROVIDER_SCOPE_NAME
      The Constant PROVIDER_SCOPE_NAME.
    • JWT_CONFIGURATION_PROPERTIES

      protected static final String JWT_CONFIGURATION_PROPERTIES
      The Constant JWT_CONFIGURATION_PROPERTIES.
      See Also:
    • SECRET_KEY

      protected static final String SECRET_KEY
      The Constant SECRET_KEY.
      See Also:
    • INCOMING_CALL_TIMEOUT

      protected static final String INCOMING_CALL_TIMEOUT
      The init param holding how long, in seconds, a started call alerts its participants.
      See Also:
    • DEFAULT_INCOMING_CALL_TIMEOUT

      protected static final long DEFAULT_INCOMING_CALL_TIMEOUT
      The default duration, in seconds, of an incoming call alert.
      See Also:
    • LEAVE_GRACE_TIME

      protected static final String LEAVE_GRACE_TIME
      The init param holding how long, in seconds, the leave of a call window whose connection ended waits, once Cometd detected that end: a window reloaded joins again meanwhile and stays in the call.
      See Also:
    • DEFAULT_LEAVE_GRACE_TIME

      protected static final long DEFAULT_LEAVE_GRACE_TIME
      The default leave grace time, in seconds.
      See Also:
    • MISSED_CALL_CHECK_MARGIN

      protected static final long MISSED_CALL_CHECK_MARGIN
      How long after the incoming call alert times out the missed call is checked, in seconds: a client starts its alert once the call state reached it and the call was read, so it may still be answered a little after the timeout counted from the call start.
      See Also:
    • MISSED_CALL_THREADS

      protected static final int MISSED_CALL_THREADS
      The threads marking and notifying the participants who missed a call: a large space call does not hold up the other calls' notifications, and the conditional marks notify each participant once whatever runs concurrently.
      See Also:
    • MAX_INCOMING_CALL_TIMEOUT

      protected static final long MAX_INCOMING_CALL_TIMEOUT
      The longest incoming call alert, in seconds: the longest delay a browser timer accepts.
      See Also:
    • LAST_DATE_PRECISION

      public static final long LAST_DATE_PRECISION
      How much later than in memory the start date of a call may read from the storage, in milliseconds: a storage keeping whole seconds rounds the fraction up or down.
      See Also:
    • VIDEO_CONFERENCE_IS_ENABLED

      protected static final String VIDEO_CONFERENCE_IS_ENABLED
      See Also:
    • ALL_USERS

      public static final String ALL_USERS
      The Constant ALL_USERS.
      See Also:
    • GROUP

      public static final String GROUP
      The Constant GROUP.
      See Also:
    • USER

      public static final String USER
      The Constant USER.
      See Also:
    • OWNER_TYPE_USER

      public static final String OWNER_TYPE_USER
      The Constant OWNER_TYPE_USER.
      See Also:
    • OWNER_TYPE_SPACE

      public static final String OWNER_TYPE_SPACE
      The Constant OWNER_TYPE_SPACE.
      See Also:
    • OWNER_TYPE_SPACEEVENT

      public static final String OWNER_TYPE_SPACEEVENT
      The Constant OWNER_TYPE_SPACEEVENT.
      See Also:
    • OWNER_TYPE_CHATROOM

      public static final String OWNER_TYPE_CHATROOM
      The Constant OWNER_TYPE_CHATROOM.
      See Also:
    • CMS_GROUPS_PATH

      public static final String CMS_GROUPS_PATH
      The Constant CMS_GROUPS_PATH.
      See Also:
    • EXO_TITLE_PROP

      public static final String EXO_TITLE_PROP
      The Constant EXO_TITLE_PROP.
      See Also:
    • NT_FILE

      public static final String NT_FILE
      The Constant NT_FILE.
      See Also:
    • JCR_CONTENT

      public static final String JCR_CONTENT
      The Constant JCR_CONTENT.
      See Also:
    • JCR_DATA

      public static final String JCR_DATA
      The Constant JCR_DATA.
      See Also:
    • JCR_MIME_TYPE

      public static final String JCR_MIME_TYPE
      The Constant JCR_MIME_TYPE.
      See Also:
    • JCR_LAST_MODIFIED_PROP

      public static final String JCR_LAST_MODIFIED_PROP
      The Constant JCR_LAST_MODIFIED_PROP.
      See Also:
    • EXO_RSS_ENABLE_PROP

      public static final String EXO_RSS_ENABLE_PROP
      The Constant EXO_RSS_ENABLE_PROP.
      See Also:
    • NT_RESOURCE

      public static final String NT_RESOURCE
      The Constant NT_RESOURCE.
      See Also:
    • MIX_PRIVILEGEABLE

      public static final String MIX_PRIVILEGEABLE
      The Constant MIX_PRIVILEGEABLE.
      See Also:
    • LOG

      protected static final org.exoplatform.services.log.Log LOG
      The Constant LOG.
    • secretKey

      protected final String secretKey
      The secret key.
    • incomingCallTimeout

      protected final long incomingCallTimeout
      How long, in seconds, a started call alerts its participants before they missed it.
    • leaveGraceTime

      protected final long leaveGraceTime
      How long, in seconds, the leave of a call window whose connection ended waits.
    • missedCallTimer

      protected final ScheduledExecutorService missedCallTimer
      Runs the missed call check of each started call once its incoming call alert timed out.
    • organization

      protected final org.exoplatform.services.organization.OrganizationService organization
      The organization.
    • socialIdentityManager

      protected final org.exoplatform.social.core.manager.IdentityManager socialIdentityManager
      The social identity manager.
    • listenerService

      protected final org.exoplatform.services.listener.ListenerService listenerService
      The listener service.
    • settingService

      protected final org.exoplatform.commons.api.settings.SettingService settingService
      The settings service.
    • callStorage

      protected final CallDAO callStorage
      The calls storage.
    • participantsStorage

      protected final ParticipantDAO participantsStorage
      The participants storage.
    • originsStorage

      protected final OriginDAO originsStorage
      The call origins storage.
    • inviteStorage

      protected final InviteDAO inviteStorage
      The invite storage.
    • providers

      protected final Map<String, CallProvider> providers
      The providers.
    • spaceService

      protected org.exoplatform.social.core.space.spi.SpaceService spaceService
      The space service.
    • shareService

      protected org.exoplatform.wcm.ext.component.document.service.ShareDocumentService shareService
      The share service.
    • userListeners

      protected final Map<String, Set<UserCallListener>> userListeners
      The user listeners.
    • uploadService

      protected final org.exoplatform.upload.UploadService uploadService
      The upload service.
    • repositoryService

      protected final org.exoplatform.services.jcr.RepositoryService repositoryService
      The repository service.
    • sessionProviders

      protected final org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders
      The session providers.
    • nodeCreator

      protected final org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator nodeCreator
      The node creator.
    • identityRegistry

      protected final org.exoplatform.services.security.IdentityRegistry identityRegistry
      The identity registry.
    • authenticator

      protected final org.exoplatform.services.security.Authenticator authenticator
      The authenticator.
    • linkManager

      protected final org.exoplatform.services.cms.link.LinkManager linkManager
      The Link manager.
  • Constructor Details

    • WebConferencingService

      public WebConferencingService(org.exoplatform.services.organization.OrganizationService organization, org.exoplatform.social.core.manager.IdentityManager socialIdentityManager, org.exoplatform.services.listener.ListenerService listenerService, org.exoplatform.commons.api.settings.SettingService settingService, CallDAO callStorage, ParticipantDAO participantsStorage, OriginDAO originsStorage, InviteDAO inviteStorage, org.exoplatform.upload.UploadService uploadService, org.exoplatform.services.jcr.RepositoryService repositoryService, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator nodeCreator, org.exoplatform.services.security.IdentityRegistry identityRegistry, org.exoplatform.services.security.Authenticator authenticator, org.exoplatform.wcm.ext.component.document.service.ShareDocumentService shareService, org.exoplatform.container.xml.InitParams initParams, org.exoplatform.services.cms.link.LinkManager linkManager, org.exoplatform.web.security.codec.CodecInitializer codecInitializer)
      Instantiates a new web conferencing service.
      Parameters:
      organization - the organization
      socialIdentityManager - the social identity manager
      listenerService - the listener service
      settingService - the setting service
      callStorage - the call storage
      participantsStorage - the participants storage
      originsStorage - the origins storage
      inviteStorage - the invite storage
      uploadService - the upload service
      repositoryService - the repository service
      sessionProviders - the session providers
      nodeCreator - the node creator
      identityRegistry - the identity registry
      authenticator - the authenticator
      shareService - the share service
      initParams - the initParams
      linkManager - the link manager
  • Method Details

    • isValidId

      public static boolean isValidId(String id)
      Checks is ID valid (not null, not empty and not longer of 255 chars).
      Parameters:
      id - the id
      Returns:
      true, if is valid id
    • isValidText

      public static boolean isValidText(String text)
      Checks if is valid text (null, not empty and not longer of 255 chars).
      Parameters:
      text - the text
      Returns:
      true, if is valid text
    • isValidArg

      public static boolean isValidArg(String arg)
      Checks if argument valid (null or not empty and not longer of 32 chars).
      Parameters:
      arg - the arg
      Returns:
      true, if is valid arg
    • isNotNullArg

      public static boolean isNotNullArg(String arg)
      Checks if argument not null (also not empty and not longer of 32 chars).
      Parameters:
      arg - the arg
      Returns:
      true, if is not null arg
    • isValidData

      public static boolean isValidData(String data) throws UnsupportedEncodingException
      Checks if data valid (null or not empty and not longer of 2000 bytes in UTF8 encoding).
      Parameters:
      data - the data
      Returns:
      true, if is valid data
      Throws:
      UnsupportedEncodingException - if UTF8 encoding not found in runtime
    • userInfo

      protected UserInfo userInfo(String id) throws IdentityStateException
      Throws:
      IdentityStateException
    • getUserInfo

      public UserInfo getUserInfo(String id) throws IdentityStateException
      Gets the user info.
      Parameters:
      id - the id
      Returns:
      the user info
      Throws:
      IdentityStateException - if error happened during searching the user in Organization Service
    • getSpaceInfo

      public WebConferencingService.SpaceInfo getSpaceInfo(String spacePrettyName) throws IdentityStateException, StorageException
      Gets the space info, it will return actual space members at the moment of invocation.
      Parameters:
      spacePrettyName - the space pretty name
      Returns:
      the space info
      Throws:
      IdentityStateException - if error reading space member in Organization Service
      StorageException - if error reading saved group call ID associated with a space
    • getSpaceEventInfo

      public WebConferencingService.SpaceEventInfo getSpaceEventInfo(String spaceIdentityId, String[] partIds, String[] spacesPrettyName) throws IdentityStateException, StorageException
      Gets the space event info, it will return actual event participants at the moment of invocation. Even participants will be resolved from the owner and given spaces' members plus given participants IDs.
      Parameters:
      spaceIdentityId - the space identity id
      partIds - the participants IDs (attendees) added to the event directly
      spacesPrettyName - the Social spaces' pretty names for add its members as participants (attendees) to the event
      Returns:
      the space event info
      Throws:
      IdentityStateException - the identity state exception
      StorageException - the storage exception
    • getSecretKey

      public String getSecretKey()
      Gets the JWT secret key.
      Returns:
      the secret key
    • spaceInfo

      protected WebConferencingService.SpaceInfo spaceInfo(String spacePrettyName, String callId) throws IdentityStateException
      Space info.
      Parameters:
      spacePrettyName - the space pretty name
      callId - the call id
      Returns:
      the space info
      Throws:
      IdentityStateException - if error reading space member in Organization Service
    • spaceEventInfo

      protected WebConferencingService.SpaceEventInfo spaceEventInfo(String spaceIdentityId, String callId, String[] participants, String[] spaces) throws IdentityStateException
      Space event info.
      Parameters:
      spaceIdentityId - the space identity id
      callId - the call id
      participants - the participants user names
      spaces - an array of space pretty names
      Returns:
      the space info
      Throws:
      IdentityStateException - the identity state exception
    • getRoomInfo

      public WebConferencingService.RoomInfo getRoomInfo(String id, String title, String[] members) throws IdentityStateException, StorageException
      Gets the room info.
      Parameters:
      id - the id
      title - the title
      members - the room members
      Returns:
      the room info
      Throws:
      IdentityStateException - if error reading room member in Organization Service
      StorageException - if error reading saved group call ID associated with a room
    • roomInfo

      protected WebConferencingService.RoomInfo roomInfo(String id, String title, String[] members, String callId) throws IdentityStateException
      Room info.
      Parameters:
      id - the id
      title - the title
      members - the members
      callId - the call id
      Returns:
      the room info
      Throws:
      IdentityStateException - if user cannot be read
    • addCall

      Adds the call to list of active and fires STARTED event.
      Parameters:
      id - the id of the call
      ownerId - the owner id of the call
      ownerType - the owner type
      title - the title of the call
      providerType - the provider type
      partIds - the participants IDs
      Returns:
      the call info object of type CallInfo
      Throws:
      CallArgumentException - if call argument has wrong value (failed validation)
      StorageException - if error reading, adding or updating call information in persistent storage
      IdentityStateException - if error reading room member in Organization Service
      CallConflictException - if such call already exists and has active state (started and/or running)
      CallSettingsException - if call entry has wrong settings (it's for Chat room call, the title - too long or has bad value)
    • createCall

      public CallInfo createCall(String id, String ownerId, String ownerType, String title, String providerType, Collection<String> partIds, Collection<String> spaces, boolean start, Date startDate, Date endDate) throws CallArgumentException, StorageException, IdentityStateException, CallConflictException, CallSettingsException
      Create the call and add it to list of the existing in storage, optionally start the call and notify its participants.
      Parameters:
      id - the id of the call
      ownerId - the owner id of the call
      ownerType - the owner type
      title - the title of the call
      providerType - the provider type
      partIds - the original participants collection
      spaces - the original spaces (pretty names collection) with members allowed for participating the call
      start - the start flag, if true then the call will be started (listeners will be notified)
      Returns:
      the call info object of type CallInfo
      Throws:
      CallArgumentException - if call argument has wrong value (failed validation)
      StorageException - if error reading, adding or updating call information in persistent storage
      IdentityStateException - if error reading room member in Organization Service
      CallConflictException - if such call already exists and has active state (started and/or running)
      CallSettingsException - if call entry has wrong settings (it's for Chat room call, the title - too long or has bad value)
    • updateCall

      public CallInfo updateCall(String callId, String ownerId, String newOwnerType, String newTitle, String newProviderType, List<String> partIds, List<String> spaces, Date startDate, Date endDate) throws InvalidCallException, CallArgumentException, CallSettingsException, StorageException, CallNotFoundException, IdentityStateException, ParticipantNotFoundException
      Updates the existing call information and original settings (initial participants and spaces). Note: this method will not update the call actual participants states (who is running the call right now or leaved it), see updateParticipants(String, List) method for such work.
      Parameters:
      callId - the call id
      ownerId - the owner id
      newOwnerType - the owner type
      newTitle - the title
      newProviderType - the provider type
      partIds - the participants
      spaces - the spaces
      startDate - the start date
      endDate - the end date
      Returns:
      the call info
      Throws:
      InvalidCallException - the invalid call exception
      CallArgumentException - the call argument exception
      CallSettingsException - the call settings exception
      StorageException - the storage exception
      CallNotFoundException - the call not found exception
      IdentityStateException - the identity state exception
      ParticipantNotFoundException
      See Also:
    • createParticipants

      protected Set<UserInfo> createParticipants(String providerType, Collection<String> partIds) throws IdentityStateException, CallArgumentException
      Make call's direct participants from its IDs.
      Parameters:
      providerType - the provider type
      partIds - the participants IDs
      Returns:
      the participants
      Throws:
      IdentityStateException - the identity state exception
      CallArgumentException - the call argument exception
    • createOrigins

      protected Set<OriginInfo> createOrigins(String providerType, Collection<String> partIds, Collection<String> spacePrettyNames) throws IdentityStateException, CallArgumentException
      Creates the origins.
      Parameters:
      providerType - the provider type
      partIds - the part ids
      spacePrettyNames - the spaces names
      Returns:
      the sets of origins built from participants and spaces
      Throws:
      IdentityStateException - the identity state exception
      CallArgumentException - the call argument exception
    • createOwner

      protected IdentityInfo createOwner(String ownerId, String ownerType, String title, boolean isUser, boolean isSpace, boolean isSpaceEvent, boolean isRoom) throws CallArgumentException, IdentityStateException
      Creates call owner.
      Parameters:
      ownerId - the owner id
      ownerType - the owner type
      title - the title
      isUser - the is user
      isSpace - the is space
      isSpaceEvent - the is space event
      isRoom - the is room
      Returns:
      the call owner
      Throws:
      CallArgumentException - the call argument exception
      IdentityStateException - the identity state exception
    • getCall

      public CallInfo getCall(String id) throws InvalidCallException
      Gets an active call info.
      Parameters:
      id - the id
      Returns:
      the call info or null if call not found
      Throws:
      InvalidCallException - if call in erroneous state, see cause exception for details
    • initializeStartedCallsState

      public void initializeStartedCallsState()
      initialize all saved started calls state.
    • stopCall

      public CallInfo stopCall(String callId, boolean remove) throws CallNotFoundException, InvalidCallException
      Removes the call info from active and fires STOPPED event. The stop is attributed to the current user, or to the caller of the call when it runs with no user (see stoppingUserId(CallInfo)).
      Parameters:
      callId - the call id
      remove - the remove
      Returns:
      the call info object of type CallInfo
      Throws:
      CallNotFoundException - if call not found
      InvalidCallException - if call in erroneous state and cannot be used, details are in caused exception
    • stoppingUserId

      protected String stoppingUserId(CallInfo call)
      Returns the user a stop is attributed to, in the call stopped event and its metrics: the current user, or, when the stop runs with no user or as the anonymous one, as when a provider's server reports that its meeting ended, the caller of the call.
      Parameters:
      call - the call to stop
      Returns:
      the user id, null or IdentityConstants.ANONIM when there is neither a current user nor a caller
    • stopCall

      protected void stopCall(CallInfo call, String userId, boolean remove) throws StorageException
      Stop call.
      Parameters:
      call - the call
      userId - the user id
      remove - the remove
      Throws:
      StorageException - if persistence exception happen
    • startCall

      public CallInfo startCall(String callId, String clientId) throws CallNotFoundException, InvalidCallException
      Starts existing call and fires STARTED event. It's actual for group calls.
      Parameters:
      callId - the call id
      clientId - the client id
      Returns:
      the call info object of type CallInfo
      Throws:
      CallNotFoundException - if call not found
      InvalidCallException - if call in erroneous state and cannot be used, details are in caused exception
    • startCall

      protected void startCall(CallInfo call, String partId, String clientId, boolean notifyStarted) throws ParticipantNotFoundException, CallSettingsException, StorageException, CallNotFoundException
      Start existing call.
      Parameters:
      call - the call
      partId - the participant id who started the call
      clientId - the client id
      notifyStarted - if true then all participants will be notified about the started call
      Throws:
      ParticipantNotFoundException - if call or its participants not found in storage
      CallSettingsException - if call entry has wrong settings (room title, owner type etc)
      StorageException - if storage exception happen
      CallNotFoundException - if call not found in storage
    • updateParticipants

      public CallInfo updateParticipants(String callId, List<String> partIds) throws CallNotFoundException, InvalidCallException, StorageException
      Update participants of the call. Used to update current participants of call with provided user IDs. Use this method to sycn a group call associated with external apps like eXo Chat.
      Parameters:
      callId - the call id
      partIds - the participants ids
      Returns:
      the call info
      Throws:
      CallNotFoundException - the call not found exception
      InvalidCallException - the invalid call exception
      StorageException - the storage exception
    • addParticipant

      Adds the participant to existing call.
      Parameters:
      callId - the call id
      partId - the part id
      Throws:
      StorageException - the storage exception
      CallNotFoundException - the call not found exception
      InvalidCallException - the invalid call exception
      IdentityStateException - the identity state exception
      CallArgumentException - if participant cannot be found
    • addGuest

      Adds the guest to call. Adds guest as a participant to the call.
      Parameters:
      callIId - the call id
      guestId - the guest id
      Returns:
      the call info
      Throws:
      StorageException - the storage exception
      CallNotFoundException - the call not found exception
      InvalidCallException - the invalid call exception
      IdentityStateException - the identity state exception
    • updateInvites

      public CallInfo updateInvites(String callId, List<InvitedIdentity> identities) throws CallNotFoundException, InvalidCallException, StorageException
      Update invites. Updates list of invited users/groups for the call that can join by invite link.
      Parameters:
      callId - the call id
      identities - the invites
      Returns:
      the call info
      Throws:
      CallNotFoundException - the call not found exception
      InvalidCallException - the invalid call exception
      StorageException - the storage exception
    • joinCall

      Join a call if it is started or start already stopped one.
      Parameters:
      callId - the call id
      partId - the participant id
      clientId - the client id
      Returns:
      the call info object of type CallInfo
      Throws:
      InvalidCallException - if call in erroneous state and cannot be used, details are in caused exception
      CallNotFoundException - if call not found
      IdentityStateException - the identity state exception
      CallArgumentException - if participant cannot be found
    • leaveCall

      public CallInfo leaveCall(String callId, String partId, String clientId) throws InvalidCallException
      If call started, then notify all its parties that given participant leaved. If call not found then null will be returned. A participant in the call from several clients (devices or browser tabs) leaves it only with the last of them: the leave of another client only removes that client, and a leave from a client the participant is not in the call from changes nothing. A leave with no client id makes the participant leave from all their clients.
      Parameters:
      callId - the call id
      partId - the participant id
      clientId - the client id
      Returns:
      the call info or null if call not found
      Throws:
      InvalidCallException - if call in erroneous state and cannot be used, details are in caused exception
    • leaveCallFromClient

      public CallInfo leaveCallFromClient(String callId, String partId, String clientId) throws InvalidCallException
      Leaves a call from a client whose connection to it ended, only when the participant is in the call from that client: a leave applied late, once the leave grace time passed (see getLeaveGraceTime()), changes nothing on a call started again since, which the participant is not in from that client.
      Parameters:
      callId - the call id
      partId - the participant id
      clientId - the client whose connection ended
      Returns:
      the call info or null if call not found
      Throws:
      InvalidCallException - if call in erroneous state and cannot be used, details are in caused exception
    • declineCall

      public CallInfo declineCall(String callId, String partId, String clientId) throws CallNotFoundException, ParticipantNotFoundException, InvalidCallException
      Marks a user participant of a started call as having declined it. The call goes on for its other participants, a P2P one included: its state is unchanged and it is never stopped here. Only the user listeners of the decliner are notified, as having left the call, so that the incoming call alert closes on every client of that user. A participant read as joined is left untouched: the decline comes from an alert still shown after a join from another client. On a call that alerted nobody, the read and the write take no lock, as in joinCall(String, String, String) and leaveCall(String, String, String): a join of the same user committed between them is overwritten. The decliner can still join the call later. On a call that alerted its participants (see CallInfo.getCallerId()), a participant declines while still invited and the call still started, both checked by the storage when the participant is marked, and the decline is broadcast as EVENT_CALL_DECLINED once committed: a decline racing the missed call check, a join or the stop of the call is broadcast only when it is marked first. The decline of a participant who already declined, missed the call or left it, from an alert still shown on another client, changes nothing but that alert. On another call, a participant who did not decline yet is marked declined.
      Parameters:
      callId - the call id
      partId - the participant id, the user declining the call
      clientId - the client id
      Returns:
      the call info
      Throws:
      CallNotFoundException - if call not found
      ParticipantNotFoundException - if the user is not a participant of the call
      InvalidCallException - if call in erroneous state and cannot be used, details are in caused exception
    • isDeclined

      protected boolean isDeclined(UserInfo part)
      Tells if a call participant declined the call, whether the caller was already sent the email grouping the declines or not.
      Parameters:
      part - the participant
      Returns:
      true if the participant declined the call
    • isInCallFromAnotherClient

      protected boolean isInCallFromAnotherClient(CallInfo call, String partId, String clientId) throws ParticipantNotFoundException, StorageException
      Removes a client the participant leaves the call from, and tells if the participant is still in the call from another client. A client the participant is not in the call from is not removed, and still tells so while the participant has other clients. The remaining clients are saved when the leaving one was removed. The client the participant started the call from does not count as one they are in the call from. The clients are read, changed and saved with no lock, as the state in leaveCall(String, String, String): two clients of one user leaving at once can each save the other's client, which keeps the user in the call.
      Parameters:
      call - the call
      partId - the participant id
      clientId - the client the participant leaves from, null to leave from all their clients
      Returns:
      true if the participant is still in the call from another client
      Throws:
      ParticipantNotFoundException - if the participant cannot be found in storage
      StorageException - if storage exception happen
    • hasLeftAlready

      protected boolean hasLeftAlready(CallInfo call, String partId, String clientId)
      Tells if a leave from a client repeats one already applied: the user left the call and has no client in it, as when a call window leaves the call and then its subscription to the call ends.
      Parameters:
      call - the call
      partId - the participant id
      clientId - the client the participant leaves from, null to leave from all their clients
      Returns:
      true if the user already left the call from all their clients
    • isGone

      protected boolean isGone(UserInfo part)
      Tells if a call participant is not in the call: never joined, left or declined it.
      Parameters:
      part - the participant
      Returns:
      true if the participant is not in the call
    • isAlertedCall

      protected boolean isAlertedCall(CallInfo call)
      Tells if starting a call alerts its participants of an incoming call: any call but the one of a planned event.
      Parameters:
      call - the call
      Returns:
      true if the participants are alerted when the call starts
    • scheduleMissedCall

      protected void scheduleMissedCall(String callId, String callerId, Date startedAt)
      Schedules the missed call check of a call that just started, for when its incoming call alert timed out on every client (see getMissedCallCheckDelay()). The check runs on this server only: a restart stops every started call anyway (see initializeStartedCallsState()). A participant who answered the alert but whose join reaches the server after the check still gets the missed call notification.
      Parameters:
      callId - the call id
      callerId - the user who started the call
      startedAt - the start date of the call
    • markRemovedCallMissed

      protected List<String> markRemovedCallMissed(CallInfo call, List<String> invitedIds)
      Marks as missed, before the call is removed with its participants, the participants still invited to it: among the missed call check of the same start, a join or a decline, a participant is marked once. It runs one conditional update per invited participant, each telling whether this call marked that participant: a single update of all of them would not tell which ones another writer marked meanwhile. Its cost is bounded by the participants the call holds when it is removed, whatever added them (its start, a participants update, a guest): for a space call, up to the members of the space.
      Parameters:
      call - the call to remove
      invitedIds - the participants invited to the call
      Returns:
      the participants marked missed by this call, to notify once the call is removed, or when its removal fails: the missed call check of the same start no longer finds them invited
    • scheduleStoppedMissedCall

      protected void scheduleStoppedMissedCall(CallInfo call, List<String> invitedIds, boolean removed)
      Notifies, out of the request that stopped the call, the participants a call stopped before they answered its incoming call alert, whatever stopped it: the caller hanging up, every other participant leaving, a client stopping or deleting the call, or its call channel ending. A call stopped when the server starts (see initializeStartedCallsState()) or deleted as outdated does not get here.
      Parameters:
      call - the stopped call, as it was when it stopped
      invitedIds - the participants still invited when the call stopped
      removed - true when the call was removed with its participants
    • checkStoppedMissedCall

      protected void checkStoppedMissedCall(CallInfo call, List<String> invitedIds, boolean removed)
      Runs notifyStoppedMissedCall(CallInfo, List, boolean) from the missed call timer, within a request of the portal container.
      Parameters:
      call - the stopped call, as it was when it stopped
      invitedIds - the participants still invited when the call stopped
      removed - true when the call was removed with its participants
    • notifyStoppedMissedCall

      protected void notifyStoppedMissedCall(CallInfo call, List<String> invitedIds, boolean removed)
      Marks as missed the participants still invited to a call when it stopped, and broadcasts EVENT_CALL_MISSED for each of them, as the user who started the call (see CallInfo.getCallerId()), with EVENT_DATA_CALL_ENDED for a group call. A participant of a group call is marked only while still invited and the call still stopped, from a start not later than the stopped one by more than LAST_DATE_PRECISION, checked by the storage when the participant is marked: with the missed call check of the same start, a join or a later start, the event is broadcast at most once per participant. The participants of a removed call were marked before it was removed (see markRemovedCallMissed(CallInfo, List)): they are notified without a mark. The event of a participant is broadcast after the mark is committed: a call started again in between does not withhold it. A participant who cannot be marked is logged and not notified.
      Parameters:
      call - the stopped call, as it was when it stopped
      invitedIds - the participants still invited when the call stopped
      removed - true when the call was removed with its participants
    • getMissedCallCheckDelay

      protected long getMissedCallCheckDelay()
      Gets how long after a call starts its missed call check runs: the incoming call timeout, plus MISSED_CALL_CHECK_MARGIN for the clients that started their alert later.
      Returns:
      the delay in milliseconds
    • checkMissedCall

      protected void checkMissedCall(String callId, String callerId, Date startedAt)
      Runs notifyMissedCall(String, String, Date) from the missed call timer, within a request of the portal container.
      Parameters:
      callId - the call id
      callerId - the user who started the call
      startedAt - the start date of the call
    • notifyDeclinesClosed

      protected void notifyDeclinesClosed(String callId, String callerId, Date startedAt) throws InvalidCallException
      Reports to the caller, once the incoming call alert of a call start timed out, the participants who declined it: they are marked as notified, and EVENT_CALL_DECLINES_CLOSED is broadcast with them, when there is at least one. Nothing is done for a call no longer started, or started again after the given start date, the declines of that later start being its own: a call stopped meanwhile marked its declines once it stopped (see stopCall(CallInfo, String, boolean)), so that the caller gets one email; a removed call marked those read before its removal, a decline marked meanwhile is in none. Each participant is marked only while still declined and the call still from that start, checked by the storage: with the report of a stop running at the same time, a participant is reported once.
      Parameters:
      callId - the call id
      callerId - the user who started the call
      startedAt - the start date of the call the check was scheduled for
      Throws:
      InvalidCallException - if the call cannot be read
    • scheduleStoppedDeclinesClosed

      protected void scheduleStoppedDeclinesClosed(CallInfo call, List<String> declinerIds)
      Reports to the caller, out of the request that stopped the call, the participants who declined it before it stopped and were marked by the stop (see notifyDeclinesClosed(String, String, Date)).
      Parameters:
      call - the stopped call, as it was when it stopped
      declinerIds - the participants marked as notified of their decline when the call stopped
    • markDeclinesClosedOnStop

      protected List<String> markDeclinesClosedOnStop(CallInfo call)
      Marks as notified the participants who declined a call that alerted its participants, when it is stopped or removed: read from the database, each marked only while still declined and the call still from that start. A stopped call is marked once it stopped, in the request that stopped it, when no decline can be marked any more (see declineCall(String, String, String)), but for a decline marked against the call still started and committed after this read, its transaction overlapping the stop: the storage does not order the two, the stop writing the call alone. A removed call loses its participants and is marked before its removal: a decline marked after this read, before the removal, is in no report.
      Parameters:
      call - the call stopped or to remove
      Returns:
      the participants marked, to report to the caller
    • findStoppedCallDeclinerIds

      protected List<String> findStoppedCallDeclinerIds(CallInfo call)
      Reads from the database the participants who declined a call being stopped or removed: the participants this request loaded before may be outdated. A read that fails is logged and reports no decline, so that the stop or the removal goes on.
      Parameters:
      call - the call being stopped or removed
      Returns:
      the ids of the participants who declined the call and whose caller was not notified yet
    • markDeclinesClosed

      protected List<String> markDeclinesClosed(CallInfo call, List<String> declinerIds, Date latestStart)
      Marks as notified of their decline the given participants of a call, each only while still declined and the call still from a start not later than the given date. It runs one conditional update per participant, each telling whether this call marked that participant, so that a decline is reported to the caller once whatever the concurrent writers. Its cost is bounded by the participants who declined the call.
      Parameters:
      call - the call
      declinerIds - the participants who declined the call
      latestStart - the latest start date of the call the participants may be marked for
      Returns:
      the participants marked by this call, to report to the caller
    • notifyMissedCall

      protected void notifyMissedCall(String callId, String callerId, Date startedAt) throws InvalidCallException
      Marks as missed the participants still invited to a call whose incoming call alert timed out, and broadcasts EVENT_CALL_MISSED for each of them. Nothing is done when the call is over, or was started again after the given start date, that later start having its own check. Each participant is marked only while still invited and the call still started from that start, both checked by the storage when the participant is marked: among concurrent checks, with a join or a decline committed meanwhile, or the call stopped or started again meanwhile, the event is broadcast at most once per participant, and never for a start later than the checked one by more than LAST_DATE_PRECISION, the precision of a start date stored in whole seconds: a call started again within that second has its invitees marked by this check, up to a second before its own alert times out. The event of a participant is broadcast after the mark is committed: a join, a decline or a stop committed in between does not withhold it. A participant who cannot be marked is logged and not notified, and the check goes on with the other participants.
      Parameters:
      callId - the call id
      callerId - the user who started the call
      startedAt - the start date of the call the check was scheduled for
      Throws:
      InvalidCallException - if the call cannot be read
    • getUserCalls

      public CallState[] getUserCalls(String userId) throws StorageException
      Gets the user calls.
      Parameters:
      userId - the user id
      Returns:
      the user call states
      Throws:
      StorageException - if persistence error happen
    • addUserCallListener

      public void addUserCallListener(UserCallListener listener)
      Adds the user listener.
      Parameters:
      listener - the listener
    • removeUserCallListener

      public void removeUserCallListener(UserCallListener listener)
      Removes the user listener.
      Parameters:
      listener - the listener
    • fireUserCallStateChanged

      protected void fireUserCallStateChanged(String userId, String callId, String providerType, String callState, String ownerId, String ownerType)
      Fire user call state.
      Parameters:
      userId - the user id
      callId - the call id
      providerType - the provider type
      callState - the call state
      ownerId - the caller id
      ownerType - the caller type
    • fireUserCallJoined

      protected void fireUserCallJoined(String callId, String providerType, String ownerId, String ownerType, String partId, String userId)
      Fire user call joined a new part.
      Parameters:
      callId - the call id
      providerType - the provider type
      ownerId - the owner id
      ownerType - the owner type
      partId - the part id
      userId - the user id
    • fireUserCallLeaved

      protected void fireUserCallLeaved(String callId, String providerType, String ownerId, String ownerType, String partId, String userId)
      Fire user call part leaved.
      Parameters:
      callId - the call id
      providerType - the provider type
      ownerId - the owner id
      ownerType - the owner type
      partId - the part id
      userId - the user id
    • addPlugin

      public void addPlugin(org.exoplatform.container.component.ComponentPlugin plugin)
      Adds a provider plugin. This method is safe in runtime: if configured provider is not an instance of CallProvider then it will log a warning and let server continue the start.
      Parameters:
      plugin - the plugin
    • addProvider

      public void addProvider(CallProvider provider)
      Adds the provider.
      Parameters:
      provider - the provider
    • checkInvite

      public boolean checkInvite(String callId, String inviteId, String identity) throws Exception
      Check invite.
      Parameters:
      callId - the call id
      inviteId - the invite id
      identity - the identity
      Returns:
      true, if successful
      Throws:
      Exception - the exception
    • getProvider

      public CallProvider getProvider(String type)
      Gets the provider.
      Parameters:
      type - the type
      Returns:
      the provider
    • getProviderConfigurations

      public Set<CallProviderConfiguration> getProviderConfigurations(Locale locale, String remoteId, boolean ignoreEnabled)
      Gets the provider configurations.
      Parameters:
      locale - the locale to apply to provider description, if null a default one will be used
      Returns:
      the provider configurations
    • getProviderConfigurations

      public Set<CallProviderConfiguration> getProviderConfigurations()
      Gets the provider configurations.
      Returns:
      the provider configurations
    • getProviderConfiguration

      public CallProviderConfiguration getProviderConfiguration(String providerType, Locale locale)
      Gets the provider configuration.
      Parameters:
      providerType - the provider type
      locale - the locale to apply to provider description, if null a default one will be used
      Returns:
      the provider configuration or null if provider not found
    • saveProviderConfiguration

      public void saveProviderConfiguration(CallProviderConfiguration conf, String spaceId) throws UnsupportedEncodingException, org.json.JSONException
      Save provider configuration.
      Parameters:
      conf - the configuration to save
      Throws:
      UnsupportedEncodingException - if UTF8 not supported
      org.json.JSONException - if cannot serialize to JSON
    • findGroupsAndUsers

      public List<IdentityData> findGroupsAndUsers(String name) throws Exception
      Find groups and users.
      Parameters:
      name - the name
      Returns:
      the list
      Throws:
      Exception - the exception
    • findUsers

      protected List<IdentityData> findUsers(String name, int count) throws Exception
      Find users.
      Parameters:
      name - the name
      count - the count
      Returns:
      the list
      Throws:
      Exception - the exception
    • findGroups

      protected List<IdentityData> findGroups(String name, int count) throws Exception
      Find groups.
      Parameters:
      name - the name
      count - the count
      Returns:
      the list
      Throws:
      Exception - the exception
    • uploadFile

      public void uploadFile(UploadFileInfo uploadInfo, jakarta.servlet.http.HttpServletRequest request) throws UploadFileException, javax.jcr.RepositoryException
      Upload recording of the call.
      Parameters:
      uploadInfo - the upload info
      request - the request
      Throws:
      UploadFileException - the upload recording exception
      javax.jcr.RepositoryException - the repository exception
    • userIdentity

      protected org.exoplatform.services.security.Identity userIdentity(String userId)
      Find or create user identity.
      Parameters:
      userId - the user id
      Returns:
      the identity can be null if not found and cannot be created via current authenticator
    • start

      public void start()
      Specified by:
      start in interface org.picocontainer.Startable
    • stop

      public void stop()
      Specified by:
      stop in interface org.picocontainer.Startable
    • getIncomingCallTimeout

      public long getIncomingCallTimeout()
      Gets how long, in seconds, a started call alerts its participants. Past it, a participant who neither joined nor declined the call missed it.
      Returns:
      the incoming call timeout in seconds
    • getLeaveGraceTime

      public long getLeaveGraceTime()
      Gets how long, in seconds, the leave of a call window whose connection to its call ended waits before it applies, counted from when Cometd detected that end (its session expiry for a window that unloaded without a word, about 10 seconds over WebSocket): a window reloaded that joins the call again meanwhile from a new client, or a window reconnected that subscribed to the call again with the same client, keeps its user in the call. 0 applies the leave once that end is detected.
      Returns:
      the leave grace time in seconds
    • isSpaceMember

      protected boolean isSpaceMember(String userName, String spacePrettyName)
      Checks if is space member.
      Parameters:
      userName - the user name
      spacePrettyName - the space pretty name
      Returns:
      true, if is space member
    • getSpaceMembers

      protected Set<String> getSpaceMembers(String spacePrettyName)
      Gets the space members.
      Parameters:
      spacePrettyName - the space pretty name
      Returns:
      the space members
    • jsonToProviderConfig

      protected CallProviderConfiguration jsonToProviderConfig(org.json.JSONObject json) throws org.json.JSONException
      Json to provider config.
      Parameters:
      json - the json
      Returns:
      the call provider configuration
      Throws:
      org.json.JSONException - the JSON exception
    • providerConfigToJson

      protected org.json.JSONObject providerConfigToJson(CallProviderConfiguration conf) throws org.json.JSONException
      Provider config to json.
      Parameters:
      conf - the conf
      Returns:
      the JSON object
      Throws:
      org.json.JSONException - the JSON exception
    • readProviderConfig

      protected CallProviderConfiguration readProviderConfig(String type)
      Read saved call provider configuration.
      Parameters:
      type - the type
      Returns:
      the configuration
    • currentUserId

      protected String currentUserId()
      Current user id.
      Returns:
      the string
    • notifyUserCallStateChanged

      protected void notifyUserCallStateChanged(CallInfo call, String initiatorId, String state)
      Notify user call state changed.
      Parameters:
      call - the call
      initiatorId - the initiator id
      state - the state
    • readCallEntity

      protected CallInfo readCallEntity(CallEntity savedCall, boolean withParticipants) throws CallSettingsException, IdentityStateException, CallOwnerException
      Read call entity.
      Parameters:
      savedCall - the saved call
      withParticipants - the with participants
      Returns:
      the call info
      Throws:
      CallSettingsException - if call entry has wrong settings (Chat room call title too long or has bad value)
      IdentityStateException - if error reading call owner or participant
      CallOwnerException - if call owner is of wrong type or cannot be found (as an identity)
    • getInviteId

      protected String getInviteId(String callId) throws StorageException
      Gets the invite id.
      Parameters:
      callId - the call id
      Returns:
      the invite id
      Throws:
      StorageException - the storage exception
    • createCallEntity

      protected CallEntity createCallEntity(CallInfo call) throws CallSettingsException
      Creates the call entity.
      Parameters:
      call - the call
      Returns:
      the call entity
      Throws:
      CallSettingsException - if call entry has wrong settings (chat room title)
    • syncCallEntity

      protected void syncCallEntity(CallInfo call, CallEntity entity) throws CallSettingsException
      Update call entity from given CallInfo instance.
      Parameters:
      call - the call
      entity - the entity
      Throws:
      CallSettingsException - if call entry has wrong settings (room title)
    • createParticipantEntity

      protected ParticipantEntity createParticipantEntity(String callId, UserInfo user)
      Creates the participant entity.
      Parameters:
      callId - the call id
      user - the user
      Returns:
      the participant entity
    • createOriginEntity

      protected OriginEntity createOriginEntity(String callId, OriginInfo origin)
      Creates the origin entity.
      Parameters:
      callId - the call id
      origin - the origin
      Returns:
      the origin entity
    • exceptionCause

      protected <C extends SQLException> C exceptionCause(jakarta.persistence.PersistenceException pe, Class<C> causeClass)
      Find cause exception of given type.
      Type Parameters:
      C - the generic type
      Parameters:
      pe - the pe
      causeClass - the cause class
      Returns:
      the c
    • txCreateCall

      protected void txCreateCall(CallInfo call) throws IllegalArgumentException, IllegalStateException, jakarta.persistence.PersistenceException, CallSettingsException
      Creates the call in a single transaction.
      Parameters:
      call - the call
      Throws:
      IllegalArgumentException - the illegal argument exception
      IllegalStateException - the illegal state exception
      jakarta.persistence.PersistenceException - if persistence exception happen
      CallSettingsException - if call entry has wrong settings (chat room title)
      See Also:
      • ExoTransactional
    • txAddParticipant

      protected void txAddParticipant(String callId, UserInfo participant) throws IllegalArgumentException, IllegalStateException, jakarta.persistence.PersistenceException
      Tx add participant.
      Parameters:
      callId - the call id
      participant - the participant
      Throws:
      IllegalArgumentException - the illegal argument exception
      IllegalStateException - the illegal state exception
      jakarta.persistence.PersistenceException - the persistence exception
    • txStopCall

      protected void txStopCall(CallInfo call, boolean remove) throws IllegalArgumentException, IllegalStateException, jakarta.persistence.PersistenceException
      Tx stop call.
      Parameters:
      call - the call
      remove - the remove
      Throws:
      IllegalArgumentException - the illegal argument exception
      IllegalStateException - the illegal state exception
      jakarta.persistence.PersistenceException - the persistence exception
    • txUpdateCall

      protected void txUpdateCall(CallInfo call) throws CallNotFoundException, IllegalArgumentException, IllegalStateException, jakarta.persistence.PersistenceException, CallSettingsException
      Update existing call (mark it started, stopped etc) in a single transaction.
      Parameters:
      call - the call
      Throws:
      CallNotFoundException - if call not found in storage
      IllegalArgumentException - the illegal argument exception
      IllegalStateException - the illegal state exception
      jakarta.persistence.PersistenceException - the persistence exception
      CallSettingsException - if call entry has wrong settings (room call title)
    • txUpdateInvites

      protected void txUpdateInvites(String callId, List<InvitedIdentity> identities) throws IllegalArgumentException, IllegalStateException, jakarta.persistence.PersistenceException
      Tx update invites.
      Parameters:
      callId - the id
      identities - the identities
      Throws:
      IllegalArgumentException - the illegal argument exception
      IllegalStateException - the illegal state exception
      jakarta.persistence.PersistenceException - the persistence exception
    • txUpdateParticipant

      protected void txUpdateParticipant(String callId, UserInfo participant) throws IllegalArgumentException, IllegalStateException, jakarta.persistence.PersistenceException, ParticipantNotFoundException
      Update call participant (for joined or leaved state) in a single transaction.
      Parameters:
      callId - the call id
      participant - the participant
      Throws:
      IllegalArgumentException - the illegal argument exception
      IllegalStateException - the illegal state exception
      jakarta.persistence.PersistenceException - the persistence exception
      ParticipantNotFoundException - if call participant not found in storage
    • txSyncMembersAndParticipants

      protected void txSyncMembersAndParticipants(CallInfo call)
      Sync group members and participants.
      Parameters:
      call - the call
    • txRemoveParticipant

      protected void txRemoveParticipant(String callId, String partId) throws ParticipantNotFoundException
      Remove call participant.
      Parameters:
      callId - the call id
      partId - the participant id
      Throws:
      ParticipantNotFoundException - if participant not found
    • txUpdateCallAndParticipants

      protected void txUpdateCallAndParticipants(CallInfo call) throws IllegalArgumentException, IllegalStateException, jakarta.persistence.PersistenceException, CallNotFoundException, CallSettingsException, ParticipantNotFoundException
      Update call and all its participants in a single transaction.
      Parameters:
      call - the call
      Throws:
      IllegalArgumentException - the illegal argument exception
      IllegalStateException - the illegal state exception
      jakarta.persistence.PersistenceException - the persistence exception
      CallNotFoundException - if call or its participants not found in storage
      CallSettingsException - if call entry has wrong settings (room call title)
      ParticipantNotFoundException - if call participant not found in storage
    • txUpdateCallAndOrigins

      protected void txUpdateCallAndOrigins(CallInfo call) throws IllegalArgumentException, IllegalStateException, jakarta.persistence.PersistenceException, CallNotFoundException, CallSettingsException, ParticipantNotFoundException
      Tx update call and its origins.
      Parameters:
      call - the call
      Throws:
      IllegalArgumentException - the illegal argument exception
      IllegalStateException - the illegal state exception
      jakarta.persistence.PersistenceException - the persistence exception
      CallNotFoundException - the call not found exception
      CallSettingsException - the call settings exception
      ParticipantNotFoundException - the participant not found exception
    • txDeleteCall

      protected void txDeleteCall(String id) throws IllegalArgumentException, IllegalStateException, jakarta.persistence.PersistenceException
      Delete call within a transaction.
      Parameters:
      id - the call id
      Throws:
      IllegalArgumentException - the illegal argument exception
      IllegalStateException - the illegal state exception
      jakarta.persistence.PersistenceException - the persistence exception
    • txUpdateParticipants

      protected void txUpdateParticipants(CallInfo call, List<UserInfo> participants) throws IllegalArgumentException, IllegalStateException, jakarta.persistence.PersistenceException
      Tx update participants.
      Parameters:
      call - the call
      participants - the participants
      Throws:
      IllegalArgumentException - the illegal argument exception
      IllegalStateException - the illegal state exception
      jakarta.persistence.PersistenceException - the persistence exception
    • txDeleteAllUserCalls

      protected int txDeleteAllUserCalls() throws IllegalArgumentException, IllegalStateException, jakarta.persistence.PersistenceException
      Delete all user calls (not group ones) within a single transaction.
      Returns:
      number of deleted calls
      Throws:
      IllegalArgumentException - the illegal argument exception
      IllegalStateException - the illegal state exception
      jakarta.persistence.PersistenceException - the persistence exception
    • clearStorage

      @Deprecated protected void clearStorage()
      Deprecated.
      Clear JPA storage from stale/cached objects.
    • deleteCall

      protected void deleteCall(String id) throws StorageException
      Delete call.
      Parameters:
      id - the id
      Throws:
      StorageException - if storage error happens
    • deleteAllUserCalls

      protected int deleteAllUserCalls() throws StorageException
      Delete all user calls. This will not touch any group call. For use on server start to cleanup the storage.
      Returns:
      number of deleted calls
      Throws:
      StorageException - if storage error happens
    • updateCallAndParticipants

      protected void updateCallAndParticipants(CallInfo call) throws StorageException, ParticipantNotFoundException, CallSettingsException, CallNotFoundException
      Update call and all its participants.
      Parameters:
      call - the call
      Throws:
      StorageException - if storage exception happen
      ParticipantNotFoundException - if call or its participants not found in storage
      CallSettingsException - if call entry has wrong settings (room call title)
      CallNotFoundException - if call not found in storage
    • updateCallAndOrigins

      Update call and its origins.
      Parameters:
      call - the call
      Throws:
      StorageException - the storage exception
      ParticipantNotFoundException - the participant not found exception
      CallSettingsException - the call settings exception
      CallNotFoundException - the call not found exception
    • syncMembersAndParticipants

      protected void syncMembersAndParticipants(CallInfo call) throws StorageException
      Sync group members and participants.
      Parameters:
      call - the call
      Throws:
      StorageException - the storage exception
    • updateParticipant

      protected void updateParticipant(String callId, UserInfo participant) throws ParticipantNotFoundException, StorageException
      Update call participant (for joined or leaved state) in a single transaction.
      Parameters:
      callId - the call id
      participant - the participant
      Throws:
      ParticipantNotFoundException - if call participant not found in storage
      StorageException - if storage exception happen
    • removeParticipant

      protected void removeParticipant(String callId, UserInfo participant) throws ParticipantNotFoundException, StorageException
      Remove call participant (for leaved state) in a single transaction.
      Parameters:
      callId - the call id
      participant - the participant
      Throws:
      ParticipantNotFoundException - if call participant not found in storage
      StorageException - if storage exception happen
    • updateCall

      protected void updateCall(CallInfo call) throws CallNotFoundException, CallSettingsException, StorageException
      Update existing call (mark it started, stopped etc).
      Parameters:
      call - the call
      Throws:
      CallNotFoundException - if call not found in storage
      CallSettingsException - if call entry has wrong settings (room call title)
      StorageException - if storage exception happen
    • findCallById

      protected CallInfo findCallById(String id, boolean withParticipants) throws IdentityStateException, StorageException, CallSettingsException, CallOwnerException
      Find call in storage by its ID.
      Parameters:
      id - the id
      withParticipants - also read participants from the DB
      Returns:
      the call info
      Throws:
      IdentityStateException - if error reading call owner or participant
      StorageException - if persistent error happens
      CallSettingsException - if call entry has wrong settings (Chat room call title too long or has bad value)
      CallOwnerException - if call owner type of unknown type
    • findGroupCallId

      protected String findGroupCallId(String ownerId) throws StorageException
      Find a call, owned by group with given ID, in calls storage.
      Parameters:
      ownerId - the owner id
      Returns:
      the string or null if no call found
      Throws:
      StorageException - the storage exception
    • findSpaceCallId

      protected String findSpaceCallId(String spaceId) throws StorageException
      Find a call, owned by a space with given ID, in calls storage.
      Parameters:
      spaceId - the owner id
      Returns:
      the string or null if no call found
      Throws:
      StorageException - the storage exception
    • findChatRoomCallId

      protected String findChatRoomCallId(String roomId) throws StorageException
      Find a call, owned by a space with given ID, in calls storage.
      Parameters:
      roomId - the room id
      Returns:
      the string or null if no call found
      Throws:
      StorageException - the storage exception
    • findLastSpaceEventCallId

      protected String findLastSpaceEventCallId(String ownerId) throws StorageException
      Find last space event call id.
      Parameters:
      ownerId - the owner id
      Returns:
      the string
      Throws:
      StorageException - the storage exception
    • findUserGroupCalls

      protected Collection<CallInfo> findUserGroupCalls(String userId) throws StorageException
      Find user group calls in calls storage.
      Parameters:
      userId - the user id
      Returns:
      the collection
      Throws:
      StorageException - if persistence error happen
    • createCall

      protected void createCall(CallInfo call) throws StorageException, CallConflictException, CallSettingsException
      Create the call in storage with all its participants. If such call (by ID) already exists a CallConflictException will be raised.
      Parameters:
      call - the call info
      Throws:
      StorageException - if storage exception happen
      CallConflictException - the call conflicts with another (same ID) call
      CallSettingsException - the call settings wrong (chat room title)
    • invalidateCall

      protected void invalidateCall(String id, boolean isGroup) throws CallConflictException, StorageException
      Invalidate a call by an ID. If such call (by ID) already found and, it's P2P call but not active - it will be removed, otherwise CallConflictException will be thrown. This method designed to be called just before createCall(CallInfo).
      Parameters:
      id - the id
      isGroup - the is group
      Throws:
      CallConflictException - if call conflict found and existing call cannot be removed
      StorageException - if storage exception happen
    • metricMessage

      protected String metricMessage(String userId, CallInfo call, String operation, String status, Long duration, String error, Double fileSize)
      Metric message for reporting to the stats logger.
      Parameters:
      userId - the user id of the operation
      call - the call in the operation
      operation - the operation name
      status - the status of operation
      duration - the operation duration in millseconds (can be null), it's not a call duration
      error - the error if present (can be null)
      Returns:
      the string combining all given parameters in specified format according https://community.exoplatform.com/portal/g/:spaces:exo_itop/exo_itop/wiki/SPEC_-_logging_for_monitoring
    • getRecordingUrl

      public String getRecordingUrl(String identity, String fileName, String type) throws Exception
      Throws:
      Exception
    • getActiveProvidersForSpace

      public List<ActiveCallProvider> getActiveProvidersForSpace(String spaceId)
    • saveActiveCallProvider

      public void saveActiveCallProvider(ActiveCallProvider activeCallProvider, String identityId)
    • updateCallProviderUrl

      public ActiveCallProvider updateCallProviderUrl(String identityId, ActiveCallProvider activeCallProvider)
    • updateVideoConferenceEnabled

      public void updateVideoConferenceEnabled(String spaceId, boolean enabled, String provider)
    • isVideoConferenceEnabled

      public boolean isVideoConferenceEnabled(String spaceId)