def connectionStatus(self):
     return VidyoOperations.isRoomConnected(
         self,
         VidyoTools.getLinkRoomAttribute(self.getLinkObject(),
                                         attName="h323-ip"),
         VidyoTools.getLinkRoomAttribute(self.getLinkObject(),
                                         attName="vidyopanorama-id"))
Beispiel #2
0
    def call(self):
        try:
            maxDate = VidyoTools.getBookingsOldDate()
            previousTotal = VidyoTools.getEventEndDateIndex().getCount()

            error, attainedDate = DeleteOldRoomsAction._deleteRemoteRooms(
                maxDate)

            newTotal = VidyoTools.getEventEndDateIndex().getCount()

            page = WDeleteOldRoomsActionResult(maxDate, previousTotal,
                                               newTotal, error,
                                               attainedDate).getHTML()

            #we send the mail without ExternalOperationsManager wrapping so that we see the result of an
            #eventual 2nd pass (we do want to have more than 1 email, or at least the last one)
            #TODO: change later when emails are stored in ContextManager and sent after commit
            DeleteOldRoomsAction._sendResultEmail(maxDate, previousTotal,
                                                  newTotal, error,
                                                  attainedDate)

            return page

        except Exception:
            Logger.get("Vidyo").exception(
                "Exception during Vidyo's DeleteOldRoomsAction call")
            raise
Beispiel #3
0
 def setBookingNotPresent(self):
     """ Changes some of the booking's attributes when the room is still in the Indico DB
         but not in the remote system any more.
     """
     self._created = False
     # booking is not present remotely so no need to delete it later
     VidyoTools.getEventEndDateIndex().unindexBooking(self)
Beispiel #4
0
 def isRoomConnected(cls, booking, roomIp="", roomPanoramaUser=""):
     try:
         if roomIp != "":
             answer = RavemApi.isLegacyEndpointConnected(roomIp)
         else:
             answer = RavemApi.isVidyoPanoramaConnected(roomPanoramaUser)
         if not answer.ok or "error" in answer.json():
             Logger.get('Vidyo').exception("""Evt:%s, booking:%s,
                                           Ravem API's isConnected operation not successfull: %s""" %
                                           (booking.getConference().getId(), booking.getId(), answer.text))
             return VidyoError("roomCheckFailed", "roomConnected",
                               _("There was a problem obtaining the room status from Vidyo. {0}").format(VidyoTools.getContactSupportText()))
         result = {"roomName": None, "isConnected": False, "service": None}
         answer = answer.json()
         if "result" in answer:
             for service in answer.get("result").get("services"):
                 if service.get("name", "") == "videoconference":
                     result["roomName"] = VidyoTools.recoverVidyoName(service.get("event_name"))
                     result["isConnected"] = service.get("status") == 1
                     result["service"] = VidyoTools.recoverVidyoDescription(service.get("event_type"))
         return result
     except Exception:
         return VidyoError("roomCheckFailed", "roomConnected",
                           _("There was a problem obtaining the room status from Vidyo. {0}").format(
                                 VidyoTools.getContactSupportText()))
Beispiel #5
0
    def _attach(self):
        """ Creates the Vidyo public room that will be associated to this CSBooking,
            based on the booking params.
            Returns None if success.
            Returns a VidyoError if there is a problem.
        """
        result = ExternalOperationsManager.execute(self, "attachRoom", VidyoOperations.attachRoom, self)
        if isinstance(result, VidyoError):
            return result

        else:
            self._roomId = str(result.roomID)
            self._extension = str(result.extension)
            self._url = str(result.RoomMode.roomURL)
            self.setOwnerAccount(str(result.ownerName), updateAvatar = True)
            recoveredDescription = VidyoTools.recoverVidyoDescription(result.description)
            if recoveredDescription:
                self._bookingParams["roomDescription"] = recoveredDescription
            else:
                self._warning = "invalidDescription"
            if bool(result.RoomMode.hasPIN):
                self.setPin(str(result.RoomMode.roomPIN))
            else:
                self.setPin("")
            if bool(result.RoomMode.hasModeratorPIN):
                self.setModeratorPin(str(result.RoomMode.moderatorPIN))
            else:
                self.setModeratorPin("")
            self._bookingParams["autoMute"] = self._getAutomute()
            self.setBookingOK()
            VidyoTools.getEventEndDateIndex().indexBooking(self)
            VidyoTools.getIndexByVidyoRoom().indexBooking(self)
Beispiel #6
0
    def _delete(self, fromDeleteOld = False, maxDate = None):
        """ Deletes the Vidyo Public room associated to this CSBooking, based on the roomId
            Returns None if success.
            If trying to delete a non existing room, there will be a message in self._warning
            so that it is caught by Main.js's postDelete function.
        """

        if self.isCreated():
            deleteRemote = unindexBooking = False

            if self.hasToBeDeleted(fromDeleteOld, maxDate):
                self.setCreated(False)
                deleteRemote = unindexBooking = True
            elif not fromDeleteOld:
                unindexBooking = True

            if deleteRemote:
                result = ExternalOperationsManager.execute(self, "deleteRoom", VidyoOperations.deleteRoom, self, self._roomId)

                if isinstance(result, VidyoError):
                    if result.getErrorType() == "unknownRoom" and result.getOperation() == "delete":
                        if not fromDeleteOld:
                            self._warning = "cannotDeleteNonExistant"
                    else:
                        return result

            if unindexBooking:
                VidyoTools.getEventEndDateIndex().unindexBooking(self)
                VidyoTools.getIndexByVidyoRoom().unindexBooking(self)
Beispiel #7
0
 def setBookingNotPresent(self):
     """ Changes some of the booking's attributes when the room is still in the Indico DB
         but not in the remote system any more.
     """
     self._created = False
     #booking is not present remotely so no need to delete it later
     VidyoTools.getEventEndDateIndex().unindexBooking(self)
     for booking in VidyoTools.getIndexByVidyoRoom().getBookingList(
             self.getRoomId()):
         VidyoTools.getIndexByVidyoRoom().unindexBooking(booking)
         booking.setCreated(False)
Beispiel #8
0
    def _checkStatus(self):
        """ Queries the data for the Vidyo Public room associated to this CSBooking
            and updates the locally stored data.
            When API problems are solved, uncomment and test the commented code.
            The User API call of VidyoOperations.queryRoom will not be necessary any more.
        """
        result = VidyoOperations.queryRoom(self, self._roomId)

        if isinstance(result, VidyoError):
            if result.getErrorType() == 'unknownRoom':
                self.setBookingNotPresent()
            return result

        else:
            adminApiResult = result[0]
            userApiResult = result[1]

            recoveredVidyoName = VidyoTools.recoverVidyoName(
                userApiResult.displayName)
            if recoveredVidyoName:
                self._bookingParams["roomName"] = recoveredVidyoName
            else:
                self._warning = "invalidName"
            self._extension = str(adminApiResult.extension)

            if bool(adminApiResult.RoomMode.hasPIN):
                self._pin = str(adminApiResult.RoomMode.roomPIN)
            else:
                self._pin = ""

            if bool(adminApiResult.RoomMode.hasModeratorPIN):
                self._moderatorPin = str(adminApiResult.RoomMode.moderatorPIN)
            else:
                self._moderatorPin = ""

            self._url = str(adminApiResult.RoomMode.roomURL)
            self.setOwnerAccount(str(adminApiResult.ownerName),
                                 updateAvatar=True)

            recoveredDescription = VidyoTools.recoverVidyoDescription(
                adminApiResult.description)
            if recoveredDescription:
                self._bookingParams["roomDescription"] = recoveredDescription
            else:
                self._warning = "invalidDescription"

            # what to do if the Vidyo group is not Indico?
            #if str(adminApiResult.groupName) != getVidyoOptionValue("indicoGroup"):
            #    return VidyoError("invalidGroup", "checkStatus")

            self._bookingParams["autoMute"] = self._getAutomute()
            self._updateRelatedBookings()
Beispiel #9
0
    def getVars(self):
        variables = WCSPageTemplateBase.getVars(self)

        variables["MaxDate"] = self._maxDate
        variables["TotalRoomCount"] = VidyoTools.getEventEndDateIndex().getCount()

        oldBookingsPerConfIterator = VidyoTools.getEventEndDateIndex().iterBookingsPerConf(maxDate = self._maxDate)
        newBookingsPerConfIterator = VidyoTools.getEventEndDateIndex().iterBookingsPerConf(minDate = self._maxDate + timedelta(seconds = 1))
        variables["OldBookings"] = WBookingsList(oldBookingsPerConfIterator).getHTML()
        variables["NewBookings"] = WBookingsList(newBookingsPerConfIterator).getHTML()
        variables["ServerTZ"] = info.HelperMaKaCInfo.getMaKaCInfoInstance().getTimezone()

        return variables
Beispiel #10
0
    def cloneEvent(cls, confToClone, params):
        """ we'll clone only the vidyo services created by the user who is cloning the conference"""
        conf = params['conf']
        options = params['options']

        if options.get("vidyo", True):
            for vs in confToClone.getCSBookingManager().getBookingList(filterByType="Vidyo"):
                # Do not cloning the booking when were are NOT cloning the timetable (optionas has sessions and contribs)
                # and the booking is linked to a contrib/session
                if (options.get('sessions', False) and options.get('contributions', False)) or not vs.hasSessionOrContributionLink():
                    newBooking = vs.clone(conf)
                    conf.getCSBookingManager().addBooking(newBooking)
                    VidyoTools.getIndexByVidyoRoom().index_obj(newBooking)
Beispiel #11
0
    def _checkStatus(self):
        """ Queries the data for the Vidyo Public room associated to this CSBooking
            and updates the locally stored data.
        """
        adminApiResult = VidyoOperations.queryRoom(self, self._roomId)

        if isinstance(adminApiResult, VidyoError):
            if adminApiResult.getErrorType() == 'unknownRoom':
                self.setBookingNotPresent()
            return adminApiResult

        else:

            recoveredVidyoName = VidyoTools.recoverVidyoName(adminApiResult.name)
            if recoveredVidyoName:
                self._bookingParams["roomName"] = recoveredVidyoName
            else:
                self._warning = "invalidName"

            self._extension = str(adminApiResult.extension)

            """

            We do not update the PIN because in the new version of Vidyo comes
            encrypted.

            if bool(adminApiResult.RoomMode.hasPIN):
                self._pin = str(adminApiResult.RoomMode.roomPIN)
            else:
                self._pin = ""

            if bool(adminApiResult.RoomMode.hasModeratorPIN):
                self._moderatorPin = str(adminApiResult.RoomMode.moderatorPIN)
            else:
                self._moderatorPin = ""
            """
            self._url = str(adminApiResult.RoomMode.roomURL)
            self.setOwnerAccount(str(adminApiResult.ownerName), updateAvatar = True)

            recoveredDescription = VidyoTools.recoverVidyoDescription(adminApiResult.description)
            if recoveredDescription:
                self._bookingParams["roomDescription"] = recoveredDescription
            else:
                self._warning = "invalidDescription"

            # what to do if the Vidyo group is not Indico?
            #if str(adminApiResult.groupName) != getVidyoOptionValue("indicoGroup"):
            #    return VidyoError("invalidGroup", "checkStatus")

            self._bookingParams["autoMute"] = self._getAutomute()
            self._updateRelatedBookings()
Beispiel #12
0
    def _connect(self, force=False):
        self._checkStatus()

        connectionStatus = self.connectionStatus()
        if isinstance(connectionStatus, VidyoError):
            return connectionStatus

        confRoomIp = VidyoTools.getLinkRoomAttribute(self.getLinkObject(), attName="H323 IP")
        confRoomPanoramaUser = VidyoTools.getLinkRoomAttribute(self.getLinkObject(), attName="VidyoPanorama ID")
        if confRoomIp == "" and confRoomPanoramaUser == "":
            return VidyoError("noValidConferenceRoom", "connect")

        if connectionStatus.get("isConnected") == True:
            if connectionStatus.get("roomName") == self.getBookingParamByName("roomName"):
                return VidyoError("alreadyConnected", "connect",
                                  _("It seems that the room has been already connected to the room, please refresh the page."))
            if not force:
                # if connect is not forced, give up
                return VidyoError("alreadyConnected", "connect",
                                  _("The room is already connected to some other endpoint. Please refresh the page."))
            else:
                # otherwise, replace whatever call is going on
                ExternalOperationsManager.execute(
                    self, "disconnectRoom", VidyoOperations.disconnectRoom,
                    self, connectionStatus, confRoomIp, confRoomPanoramaUser)

                retry = 15
                connected = True

                # wait for the current call to be disconnected
                while retry:
                    connectionStatus = self.connectionStatus()
                    time.sleep(2)
                    retry -= 1
                    if connectionStatus.get("isConnected") == False:
                        connected = False
                        break
                if connected:
                    return VidyoError("couldntStop", "connect",
                                      _("It seems like we haven't managed to stop "
                                        "the current call. Please refresh the page and try again."))
                else:
                    # give it some time before trying to connect
                    time.sleep(5)

        query = (getVidyoOptionValue("prefixConnect") + confRoomIp) if confRoomIp else confRoomPanoramaUser
        result = ExternalOperationsManager.execute(self, "connectRoom", VidyoOperations.connectRoom, self, self._roomId,
                                                   query)
        if isinstance(result, VidyoError):
            return result
        return self
Beispiel #13
0
    def cloneEvent(cls, confToClone, params):
        """ we'll clone only the vidyo services created by the user who is cloning the conference"""
        conf = params['conf']
        options = params['options']

        if options.get("vidyo", True):
            for vs in Catalog.getIdx("cs_bookingmanager_conference").get(confToClone.getId()).getBookingList(filterByType="Vidyo"):
                # Do not cloning the booking when were are NOT cloning the timetable (optionas has sessions and contribs)
                # and the booking is linked to a contrib/session
                if (options.get('sessions', False) and options.get('contributions', False)) or not vs.hasSessionOrContributionLink():
                    newBooking = vs.clone(conf)
                    Catalog.getIdx("cs_bookingmanager_conference").get(conf.getId()).addBooking(newBooking)
                    VidyoTools.getIndexByVidyoRoom().indexBooking(newBooking)
                    VidyoTools.getEventEndDateIndex().indexBooking(newBooking)
Beispiel #14
0
    def _search(cls, user, query, offset=0, limit=None):

        if not query.strip():
            return [], None

        ask_for_more = True
        allowed_rooms = []

        while ask_for_more:
            result = VidyoOperations.searchRooms(query,
                                                 offset=offset,
                                                 limit=limit)

            if isinstance(result, VidyoError):
                # query held no results? there's nothing left.
                return result, offset

            if not result:
                # set offset to None, meaning that the bottom of the "search stream" has been reached
                offset = None
                break

            for room in result:
                av = VidyoTools.getAvatarByAccountName(room.ownerName)

                # go through all bookings that use this room and check if this user has any privileges
                # over them
                for booking in VidyoTools.getIndexByVidyoRoom().getBookingList(
                        room.roomID):
                    if av == user or booking.getConference() in user.getLinkTo("conference", "manager") \
                            or user == booking.getConference().getCreator() \
                            or RCVideoServicesManager.hasRights(user, booking.getConference(), ["Vidyo"]) \
                            or user.isAdmin():

                        # if that's the case, add the booking to our list
                        bookingParams = booking.getBookingParams().copy()
                        bookingParams["videoLinkType"] = "event"
                        bookingParams["videoLinkSession"] = ""
                        bookingParams["videoLinkContribution"] = ""
                        allowed_rooms.append(bookingParams)
                        break

                offset += 1

                if limit is not None and len(allowed_rooms) >= limit:
                    # reached limit? that's enough!
                    ask_for_more = False
                    break

        return (allowed_rooms, offset)
Beispiel #15
0
    def _checkStatus(self):
        """ Queries the data for the Vidyo Public room associated to this CSBooking
            and updates the locally stored data.
            When API problems are solved, uncomment and test the commented code.
            The User API call of VidyoOperations.queryRoom will not be necessary any more.
        """
        result = VidyoOperations.queryRoom(self, self._roomId)

        if isinstance(result, VidyoError):
            if result.getErrorType() == 'unknownRoom':
                self.setBookingNotPresent()
            return result

        else:
            adminApiResult = result[0]
            userApiResult = result[1]

            recoveredVidyoName = VidyoTools.recoverVidyoName(userApiResult.displayName)
            if recoveredVidyoName:
                self._bookingParams["roomName"] = recoveredVidyoName
            else:
                self._warning = "invalidName"
            self._extension = str(adminApiResult.extension)

            if bool(adminApiResult.RoomMode.hasPIN):
                self._pin = str(adminApiResult.RoomMode.roomPIN)
            else:
                self._pin = ""

            if bool(adminApiResult.RoomMode.hasModeratorPIN):
                self._moderatorPin = str(adminApiResult.RoomMode.moderatorPIN)
            else:
                self._moderatorPin = ""

            self._url = str(adminApiResult.RoomMode.roomURL)
            self.setOwnerAccount(str(adminApiResult.ownerName), updateAvatar = True)

            recoveredDescription = VidyoTools.recoverVidyoDescription(adminApiResult.description)
            if recoveredDescription:
                self._bookingParams["roomDescription"] = recoveredDescription
            else:
                self._warning = "invalidDescription"

            # what to do if the Vidyo group is not Indico?
            #if str(adminApiResult.groupName) != getVidyoOptionValue("indicoGroup"):
            #    return VidyoError("invalidGroup", "checkStatus")

            self._bookingParams["autoMute"] = self._getAutomute()
            self._updateRelatedBookings()
Beispiel #16
0
    def _checkStatus(self):
        """ Queries the data for the Vidyo Public room associated to this CSBooking
            and updates the locally stored data.
            When API problems are solved, uncomment and test the commented code.
            The User API call of VidyoOperations.queryRoom will not be necessary any more.
        """
        result = VidyoOperations.queryRoom(self, self._roomId)
        if isinstance(result, VidyoError):
            self.setBookingNotPresent()
            return result

        else:
            adminApiResult = result[0]
            userApiResult = result[1]

            recoveredVidyoName = VidyoTools.recoverVidyoName(userApiResult.displayName)
            if recoveredVidyoName:
                self._bookingParams["roomName"] = recoveredVidyoName
            else:
                self._warning = "invalidName"
            self._extension = str(adminApiResult.extension)

            if bool(adminApiResult.RoomMode.hasPin):
                self._pin = str(adminApiResult.RoomMode.roomPIN)
            else:
                self._pin = ""

            self._url = str(adminApiResult.RoomMode.roomURL)
            self.setOwnerAccount(str(adminApiResult.ownerName), updateAvatar=True)
Beispiel #17
0
    def getVars(self):
        variables = WJSBase.getVars(self)

        variables["LoggedInUser"] = self._user.fossilize(IAvatarFossil)
        variables["MaxNameLength"] = VidyoTools.maxRoomNameLength(self._conf.getId())

        return variables
Beispiel #18
0
    def getVars(self):
        variables = WCSPageTemplateBase.getVars(self)

        variables["EventTitle"] = VidyoTools.defaultRoomName(self._conf)
        variables["EventDescription"] = unescape_html(strip_ml_tags(self._conf.getDescription())).strip()

        return variables
Beispiel #19
0
    def getVars(self):
        variables = WJSBase.getVars(self)

        variables["LoggedInUser"] = self._user.fossilize(IAvatarFossil)
        variables["MaxNameLength"] = VidyoTools.maxRoomNameLength()

        return variables
Beispiel #20
0
    def _search(cls, user, query, offset=0, limit=None):

        if not query.strip():
            return [], None

        ask_for_more = True
        allowed_rooms = []

        while ask_for_more:
            result = VidyoOperations.searchRooms(query, offset=offset, limit=limit)

            if isinstance(result, VidyoError):
                # query held no results? there's nothing left.
                return result, offset

            if not result:
                # set offset to None, meaning that the bottom of the "search stream" has been reached
                offset = None
                break

            for room in result:
                av = VidyoTools.getAvatarByAccountName(room.ownerName)

                # go through all bookings that use this room and check if this user has any privileges
                # over them
                for booking in VidyoTools.getIndexByVidyoRoom().getBookingList(room.roomID):
                    if av == user or booking.getConference() in user.getLinkTo("conference", "manager") \
                            or user == booking.getConference().getCreator() \
                            or RCVideoServicesManager.hasRights(user, booking.getConference(), ["Vidyo"]) \
                            or user.isAdmin():

                        # if that's the case, add the booking to our list
                        bookingParams = booking.getBookingParams().copy()
                        bookingParams["videoLinkType"] = "event"
                        bookingParams["videoLinkSession"] = ""
                        bookingParams["videoLinkContribution"] = ""
                        allowed_rooms.append(bookingParams)
                        break

                offset += 1

                if limit is not None and len(allowed_rooms) >= limit:
                    # reached limit? that's enough!
                    ask_for_more = False
                    break

        return (allowed_rooms, offset)
Beispiel #21
0
    def _connect(self, force=False):
        self._checkStatus()

        connectionStatus = self.connectionStatus()
        if isinstance(connectionStatus, VidyoError):
            return connectionStatus

        confRoomIp = VidyoTools.getLinkRoomIp(self.getLinkObject())
        if confRoomIp == "":
            return VidyoError("noValidConferenceRoom", "connect")

        if connectionStatus.get("isConnected") == True:
            if connectionStatus.get("roomName") == self.getBookingParamByName(
                    "roomName"):
                return VidyoError(
                    "alreadyConnected", "connect",
                    _("It seems that the room has been already connected to the room, please refresh the page."
                      ))
            if not force:
                # if connect is not forced, give up
                return VidyoError(
                    "alreadyConnected", "connect",
                    _("The room is already connected to some other endpoint. Please refresh the page."
                      ))
            else:
                # otherwise, replace whatever call is going on
                ExternalOperationsManager.execute(
                    self, "disconnectRoom", VidyoOperations.disconnectRoom,
                    self, confRoomIp, connectionStatus.get("service"))

                retry = 15
                connected = True

                # wait for the current call to be disconnected
                while retry:
                    connectionStatus = self.connectionStatus()
                    time.sleep(2)
                    retry -= 1
                    if connectionStatus.get("isConnected") == False:
                        connected = False
                        break
                if connected:
                    return VidyoError(
                        "couldntStop", "connect",
                        _("It seems like we haven't managed to stop "
                          "the current call. Please refresh the page and try again."
                          ))
                else:
                    # give it some time before trying to connect
                    time.sleep(5)

        prefixConnect = getVidyoOptionValue("prefixConnect")
        result = ExternalOperationsManager.execute(self, "connectRoom",
                                                   VidyoOperations.connectRoom,
                                                   self, self._roomId,
                                                   prefixConnect + confRoomIp)
        if isinstance(result, VidyoError):
            return result
        return self
Beispiel #22
0
    def getVars(self):
        variables = WCSPageTemplateBase.getVars(self)

        variables["EventTitle"] = VidyoTools.defaultRoomName(self._conf)
        variables["EventDescription"] = unescape_html(
            strip_ml_tags(self._conf.getDescription())).strip()

        return variables
Beispiel #23
0
 def _disconnect(self):
     self._checkStatus()
     confRoomIp = VidyoTools.getLinkRoomAttribute(self.getLinkObject(), attName="H323 IP")
     confRoomPanoramaUser = VidyoTools.getLinkRoomAttribute(self.getLinkObject(), attName="VidyoPanorama ID")
     if confRoomIp == "" and confRoomPanoramaUser == "":
         return VidyoError("noValidConferenceRoom", "disconnect")
     connectionStatus = self.connectionStatus()
     if isinstance(connectionStatus, VidyoError):
         return connectionStatus
     if not connectionStatus.get("isConnected"):
         return VidyoError("alreadyDisconnected", "disconnect",
                           _("It seems that the room has been already disconnected, please refresh the page"))
     result = ExternalOperationsManager.execute(self, "disconnectRoom", VidyoOperations.disconnectRoom, self,
                                                connectionStatus, confRoomIp, confRoomPanoramaUser)
     if isinstance(result, VidyoError):
         return result
     return self
Beispiel #24
0
 def disconnectRoom(cls, booking, roomIp, serviceType):
     try:
         answer = RavemApi.disconnectRoom(roomIp, serviceType)
         if not answer.ok or answer.json.has_key("error"):
             Logger.get('Vidyo').exception(
                 """Evt:%s, booking:%s, Ravem API's disconnectRoom operation not successfull: %s"""
                 % (booking.getConference().getId(), booking.getId(),
                    answer.text))
             return VidyoError(
                 "disconnectFailed", "disconnect",
                 _("There was a problem with the videoconference disconnection. "
                   ) + VidyoTools.getContactSupportText())
     except Exception:
         return VidyoError(
             "disconnectFailed", "disconnect",
             _("There was a problem with the videoconference disconnection. "
               ) + VidyoTools.getContactSupportText())
Beispiel #25
0
    def call(self):
        try:
            maxDate = VidyoTools.getBookingsOldDate()
            previousTotal = VidyoTools.getEventEndDateIndex().getCount()

            error, attainedDate = DeleteOldRoomsAction._deleteRemoteRooms(maxDate)

            if error:
                VidyoTools.getEventEndDateIndex().deleteKeys(maxDate = attainedDate - timedelta(seconds = 1))
            else:
                VidyoTools.getEventEndDateIndex().deleteKeys(maxDate = maxDate)

            newTotal = VidyoTools.getEventEndDateIndex().getCount()

            page = WDeleteOldRoomsActionResult(maxDate, previousTotal, newTotal, error, attainedDate).getHTML()

            #we send the mail without ExternalOperationsManager wrapping so that we see the result of an
            #eventual 2nd pass (we do want to have more than 1 email, or at least the last one)
            #TODO: change later when emails are stored in ContextManager and sent after commit
            DeleteOldRoomsAction._sendResultEmail(maxDate, previousTotal, newTotal, error, attainedDate)

            return page

        except Exception:
            Logger.get("Vidyo").exception("Exception during Vidyo's DeleteOldRoomsAction call")
            raise
Beispiel #26
0
 def _checkProtection(self):
     if self.getAW().getUser(
     ) and request.remote_addr == VidyoTools.getLinkRoomAttribute(
             self._booking.getLinkObject(), attName='ip'):
         return
     elif not hasattr(
             self._booking, "getOwnerObject"
     ) or self._booking.getOwnerObject() != self.getAW().getUser():
         CollaborationBookingModifBase._checkProtection(self)
Beispiel #27
0
 def _checkProtection(self):
     if self.getAW().getUser() and self.getHostIP(
     ) == VidyoTools.getLinkRoomIp(self._booking.getLinkObject(),
                                   ipAttName='IP'):
         return
     elif not hasattr(
             self._booking, "getOwnerObject"
     ) or self._booking.getOwnerObject() != self.getAW().getUser():
         CollaborationBookingModifBase._checkProtection(self)
Beispiel #28
0
    def _create(self):
        """ Creates the Vidyo public room that will be associated to this CSBooking,
            based on the booking params.
            After creation, it also retrieves some more information from the newly created room.
            Returns None if success.
            Returns a VidyoError if there is a problem, such as the name being duplicated.
        """
        result = ExternalOperationsManager.execute(self, "createRoom", VidyoOperations.createRoom, self)
        if isinstance(result, VidyoError):
            return result

        else:
            # Link to a Session or Contribution if requested
            self._roomId = str(result.roomID)  # we need to convert values read to str or there will be a ZODB exception
            self._extension = str(result.extension)
            self._url = str(result.RoomMode.roomURL)
            self.setOwnerAccount(str(result.ownerName))
            self.setBookingOK()
            VidyoTools.getEventEndDateIndex().indexBooking(self)
Beispiel #29
0
    def isRoomConnected(cls, booking, roomIp):
        try:
            answer =  RavemApi.isRoomConnected(roomIp)

            if not answer.ok or answer.json.has_key("error"):
                Logger.get('Vidyo').exception("""Evt:%s, booking:%s, Ravem API's isRoomConnected operation not successfull: %s""" %
                        (booking.getConference().getId(), booking.getId(), answer.text))
                return VidyoError("roomCheckFailed", "roomConnected", _("There was a problem obtaining the room status. ") + VidyoTools.getContactSupportText())
            result = {"roomName": None, "isConnected": False, "service": None}
            answer =  answer.json
            if answer.has_key("result"):
                for service in answer.get("result").get("services"):
                    if service.get("name","") == "videoconference":
                        result["roomName"] = VidyoTools.recoverVidyoName(service.get("eventName"))
                        result["isConnected"] = service.get("status") == 1
                        result["service"] = VidyoTools.recoverVidyoDescription(service.get("eventType"))
            return result
        except Exception:
            return VidyoError("roomCheckFailed", "roomConnected", _("There was a problem obtaining the room status. ") + VidyoTools.getContactSupportText())
Beispiel #30
0
    def getVars(self):
        variables = WCSPageTemplateBase.getVars(self)

        variables["MaxDate"] = self._maxDate
        variables["TotalRoomCount"] = VidyoTools.getEventEndDateIndex(
        ).getCount()
        oldBookingsPerConfIterator = VidyoTools.getEventEndDateIndex(
        ).iterbookings(maxDate=self._maxDate)
        newBookingsPerConfIterator = VidyoTools.getEventEndDateIndex(
        ).iterbookings(minDate=self._maxDate + timedelta(seconds=1))
        oldBookingsPerConf, newBookingsPerConf = self._postProcessingClones(
            oldBookingsPerConfIterator, newBookingsPerConfIterator)

        variables["OldBookings"] = WBookingsList(oldBookingsPerConf).getHTML()
        variables["NewBookings"] = WBookingsList(newBookingsPerConf).getHTML()
        variables["ServerTZ"] = info.HelperMaKaCInfo.getMaKaCInfoInstance(
        ).getTimezone()

        return variables
Beispiel #31
0
 def setOwnerAccount(self, ownerAccount, updateAvatar=False):
     """ Sets the Vidyo account used.
         Also will try to update the _owner Avatar attribute depending on how it is called.
     """
     self._ownerVidyoAccount = ownerAccount
     if updateAvatar:
         avatar = VidyoTools.getAvatarByAccountName(ownerAccount)
         if avatar:
             self._owner = avatar
         else:
             self._owner = FakeAvatarOwner(ownerAccount)
Beispiel #32
0
 def _updateRelatedBookings(self):
     for booking in VidyoTools.getIndexByVidyoRoom().getBookingList(self.getRoomId()):
         booking.setExtension(self.getExtension())
         booking.setPin(self.getPin())
         booking.setModeratorPin(self.getModeratorPin())
         booking.setURL(self.getURL())
         booking.setOwnerAccount(self.getOwnerAccount(), True)
         booking.setBookingOK()
         booking._bookingParams["roomName"] = self._bookingParams["roomName"]
         booking._bookingParams["roomDescription"] = self._bookingParams["roomDescription"]
         booking._bookingParams["autoMute"] = self._bookingParams["autoMute"]
Beispiel #33
0
 def _connect(self):
     self._checkStatus()
     if self.canBeConnected():
         confRoomIp = VidyoTools.getLinkRoomIp(self.getLinkObject())
         if confRoomIp == "":
             return VidyoError("noValidConferenceRoom", "connect")
         prefixConnect = getVidyoOptionValue("prefixConnect")
         result = ExternalOperationsManager.execute(self, "connectRoom", VidyoOperations.connectRoom, self, self._roomId, prefixConnect + confRoomIp)
         if isinstance(result, VidyoError):
             return result
         return self
Beispiel #34
0
 def setOwnerAccount(self, ownerAccount, updateAvatar = False):
     """ Sets the Vidyo account used.
         Also will try to update the _owner Avatar attribute depending on how it is called.
     """
     self._ownerVidyoAccount = ownerAccount
     if updateAvatar:
         avatar = VidyoTools.getAvatarByAccountName(ownerAccount)
         if avatar:
             self._owner = avatar
         else:
             self._owner = FakeAvatarOwner(ownerAccount)
Beispiel #35
0
    def searchRooms(cls, query):
        try:
            searchFilter = SOAPObjectFactory.createFilter('admin', "%%%s%%" % VidyoTools.replaceSpacesInName(query))
            rooms = AdminApi.getRooms(searchFilter)
            if rooms.total:
                return rooms.room
            return []

        except WebFault, e:
            Logger.get('Vidyo').exception("""Admin API's searchRooms operation got WebFault: %s"""
                                          % e.fault.faultstring)
            raise
Beispiel #36
0
    def _checkBookingParams(self):
        if len(self._bookingParams["roomName"].strip()) == 0:
            raise VidyoException("roomName parameter (" + str(self._bookingParams["roomName"]) + " ) is empty for Vidyo booking with id: " + str(self._id))
        elif unicodeLength(self._bookingParams["roomName"]) > VidyoTools.maxRoomNameLength():
            return VidyoError("nameTooLong")
        else:
            if not VidyoTools.verifyRoomName(self._bookingParams["roomName"]):
                return VidyoError("invalidName")
            else:
                self._bookingParams["roomName"] = VidyoTools.replaceSpacesInName(self._bookingParams["roomName"])

        if len(self._bookingParams["roomDescription"].strip()) == 0:
            raise VidyoException("roomDescription parameter (" + str(self._bookingParams["roomDescription"]) + " ) is empty for Vidyo booking with id: " + str(self._id))

        if self._pin and not self._pin.isdigit():
            raise VidyoException("pin parameter ({0}) is not an integer for Vidyo booking with id: {1}".format(self._pin, self._id))

        if self._moderatorPin and not self._moderatorPin.isdigit():
            raise VidyoException("moderator pin parameter ({0}) is not an integer for Vidyo booking with id: {1}".format(self._moderatorPin, self._id))

        return False
Beispiel #37
0
 def _disconnect(self):
     self._checkStatus()
     confRoomIp = VidyoTools.getLinkRoomAttribute(self.getLinkObject(),
                                                  attName="h323-ip")
     confRoomPanoramaUser = VidyoTools.getLinkRoomAttribute(
         self.getLinkObject(), attName="vidyopanorama-id")
     if confRoomIp == "" and confRoomPanoramaUser == "":
         return VidyoError("noValidConferenceRoom", "disconnect")
     connectionStatus = self.connectionStatus()
     if isinstance(connectionStatus, VidyoError):
         return connectionStatus
     if not connectionStatus.get("isConnected"):
         return VidyoError(
             "alreadyDisconnected", "disconnect",
             _("It seems that the room has been already disconnected, please refresh the page"
               ))
     result = ExternalOperationsManager.execute(
         self, "disconnectRoom", VidyoOperations.disconnectRoom, self,
         connectionStatus, confRoomIp, confRoomPanoramaUser)
     if isinstance(result, VidyoError):
         return result
     return self
Beispiel #38
0
    def _checkBookingParams(self):

        if len(self._bookingParams["roomName"].strip()) == 0:
            raise VidyoException("roomName parameter (" + str(self._bookingParams["roomName"]) + " ) is empty for Vidyo booking with id: " + str(self._id))
        elif unicodeLength(self._bookingParams["roomName"]) > VidyoTools.maxRoomNameLength(self._conf):
            return VidyoError("nameTooLong")
        else:
            if not VidyoTools.verifyRoomName(self._bookingParams["roomName"]):
                return VidyoError("invalidName")
            else:
                self._bookingParams["roomName"] = VidyoTools.replaceSpacesInName(self._bookingParams["roomName"])

        if len(self._bookingParams["roomDescription"].strip()) == 0:
            raise VidyoException("roomDescription parameter (" + str(self._bookingParams["roomDescription"]) + " ) is empty for Vidyo booking with id: " + str(self._id))

        if self._pin:
            try:
                int(self._pin)
            except ValueError:
                raise VidyoException("pin parameter (" + str(self._pin) + ") is not an integer for Vidyo booking with id: " + str(self._id))

        return False
Beispiel #39
0
    def _search(cls, user, query, offset=0, limit=None):
        if query == "":
            return[]
        result = VidyoOperations.searchRooms(query)
        if isinstance(result, VidyoError):
            return result

        allowedRooms = []
        for room in result:
            av = VidyoTools.getAvatarByAccountName(room.ownerName)
            for booking in VidyoTools.getIndexByVidyoRoom().getBookingList(room.roomID):
                if av == user or booking.getConference() in user.getLinkTo("conference", "manager") \
                        or user == booking.getConference().getCreator() \
                        or RCVideoServicesManager.hasRights(user, booking.getConference(), ["Vidyo"]):
                    bookingParams = booking.getBookingParams().copy()
                    bookingParams["videoLinkType"] = "event"
                    bookingParams["videoLinkSession"] = ""
                    bookingParams["videoLinkContribution"] = ""
                    allowedRooms.append(bookingParams)
                    break
        limit = limit if limit else (len(allowedRooms) - 1)
        return allowedRooms[offset:offset+limit]
Beispiel #40
0
    def _delete(self, fromDeleteOld=False):
        """ Deletes the Vidyo Public room associated to this CSBooking, based on the roomId
            Returns None if success.
            If trying to delete a non existing room, there will be a message in self._warning
            so that it is caught by Main.js's postDelete function.
        """
        result = None
        if len(VidyoTools.getIndexByVidyoRoom().getBookingList(
                self._roomId)) == 1:
            result = ExternalOperationsManager.execute(
                self, "deleteRoom", VidyoOperations.deleteRoom, self,
                self._roomId)

        if isinstance(result, VidyoError):
            if result.getErrorType() == "unknownRoom" and result.getOperation(
            ) == "delete":
                if not fromDeleteOld:
                    self._warning = "cannotDeleteNonExistant"
            else:
                return result

        if not fromDeleteOld:
            VidyoTools.getEventEndDateIndex().unindexBooking(self)
            VidyoTools.getIndexByVidyoRoom().unindexBooking(self)
Beispiel #41
0
 def _updateRelatedBookings(self):
     for booking in VidyoTools.getIndexByVidyoRoom().getBookingList(
             self.getRoomId()):
         booking.setExtension(self.getExtension())
         booking.setPin(self.getPin())
         booking.setModeratorPin(self.getModeratorPin())
         booking.setURL(self.getURL())
         booking.setOwnerAccount(self.getOwnerAccount(), True)
         booking.setBookingOK()
         booking._bookingParams["roomName"] = self._bookingParams[
             "roomName"]
         booking._bookingParams["roomDescription"] = self._bookingParams[
             "roomDescription"]
         booking._bookingParams["autoMute"] = self._bookingParams[
             "autoMute"]
Beispiel #42
0
    def attachRoom(cls, booking):
        owner = booking.getOwnerObject()
        possibleLogins = VidyoTools.getAvatarLoginList(owner)
        if not possibleLogins:
            return VidyoError("userHasNoAccounts", "attach")
        roomName = booking.getBookingParamByName("roomName")
        searchFilter = SOAPObjectFactory.createFilter('admin', roomName)
        answer = AdminApi.getRooms(searchFilter, booking.getConference().getId(), booking.getId())
        createdRooms = answer.room

        for room in createdRooms:
            for login in possibleLogins:
                if str(room.name) == roomName and str(room.ownerName) == login:
                    return room
        else:
            return  VidyoError("notValidRoom", "attach")
Beispiel #43
0
def changeVidyoRoomNames(dbi, withRBDB, prevVersion):
    """
    Changing Vidyo Room Names
    """
    ph = PluginsHolder()
    collaboration_pt = ph.getPluginType("Collaboration")
    if not collaboration_pt.isActive() or not collaboration_pt.getPlugin("Vidyo").isActive():
        return
    i = 0
    for booking in VidyoTools.getIndexByVidyoRoom().itervalues():
        if hasattr(booking, '_originalConferenceId'):
            roomName = booking.getBookingParamByName("roomName") + '_indico_' + booking._originalConferenceId
            booking._bookingParams["roomName"] = roomName.decode("utf-8")
            del booking._originalConferenceId
        i += 1
        if i % 10000 == 0:
            dbi.commit()
    dbi.commit()
Beispiel #44
0
def changeVidyoRoomNames(dbi, withRBDB, prevVersion):
    """
    Changing Vidyo Room Names
    """
    ph = PluginsHolder()
    collaboration_pt = ph.getPluginType("Collaboration")
    if not collaboration_pt.isActive() or not collaboration_pt.getPlugin("Vidyo").isActive():
        return
    i = 0
    for booking in VidyoTools.getIndexByVidyoRoom().itervalues():
        if hasattr(booking, '_originalConferenceId'):
            roomName = booking.getBookingParamByName("roomName") + '_indico_' + booking._originalConferenceId
            booking._bookingParams["roomName"] = roomName.decode("utf-8")
            del booking._originalConferenceId
        i += 1
        if i % 10000 == 0:
            dbi.commit()
    dbi.commit()
Beispiel #45
0
 def _deleteRemoteRooms(cls, maxDate):
     """ Deletes the remote rooms from Vidyo
         Ignores if a room does not exist (because booking._delete does not return VidyoError in that case).
         Stops in any other error / exception and returns the error cause and attainedDate-
         booking._delete will execute the remote deletion for 1 room wrapped with ExternalOperationsManager
     """
     error = False
     attainedDate = None
     try:
         for booking in list(VidyoTools.getEventEndDateIndex().iterbookings(maxDate = maxDate)):
             result = booking._delete(fromDeleteOld = True, maxDate = maxDate)
             if isinstance(result, VidyoError):
                 error = result
                 attainedDate = booking.getConference().getAdjustedEndDate(tz = 'UTC')
                 break
     except Exception, e:
         error = e
         attainedDate = booking.getConference().getAdjustedEndDate(tz = 'UTC')
Beispiel #46
0
    def __init__(self, booking):
        VidyoAdminNotificationBase.__init__(self, booking)

        currentCount = VidyoTools.getEventEndDateIndex().getCount()

        self.setSubject("""[Vidyo] Too many public rooms (%s)"""
                        % str(currentCount))

        self.setBody("""Dear Vidyo Manager,<br />
<br />
There are currently %s Vidyo public rooms created by Indico in <a href="%s">%s</a>.<br />
The system was setup to send you a notification if this number was more than %s.<br />
Please go to the <a href="%s">Vidyo Plugin configuration</a> in the Server Admin interface
and press the "Clean old rooms" button.<br />
""" % (str(currentCount),
       MailTools.getServerName(),
       MailTools.getServerName(),
       getVidyoOptionValue("cleanWarningAmount"),
       str(urlHandlers.UHAdminPlugins.getURL(CollaborationTools.getCollaborationPluginType()))))
Beispiel #47
0
    def __init__(self, booking):
        VidyoAdminNotificationBase.__init__(self, booking)

        currentCount = VidyoTools.getEventEndDateIndex().getCount()

        self.setSubject("""[Vidyo] Too many public rooms (%s)""" %
                        str(currentCount))

        self.setBody("""Dear Vidyo Manager,<br />
<br />
There are currently %s Vidyo public rooms created by Indico in <a href="%s">%s</a>.<br />
The system was setup to send you a notification if this number was more than %s.<br />
Please go to the <a href="%s">Vidyo Plugin configuration</a> in the Server Admin interface
and press the "Clean old rooms" button.<br />
""" % (str(currentCount), MailTools.getServerName(), MailTools.getServerName(),
        getVidyoOptionValue("cleanWarningAmount"),
        str(
           urlHandlers.UHAdminPlugins.getURL(
               CollaborationTools.getCollaborationPluginType()))))
Beispiel #48
0
 def _deleteRemoteRooms(cls, maxDate):
     """ Deletes the remote rooms from Vidyo
         Ignores if a room does not exist (because booking._delete does not return VidyoError in that case).
         Stops in any other error / exception and returns the error cause and attainedDate-
         booking._delete will execute the remote deletion for 1 room wrapped with ExternalOperationsManager
     """
     error = False
     attainedDate = None
     try:
         for booking in VidyoTools.getEventEndDateIndex().iterbookings(
                 maxDate=maxDate):
             result = booking._delete(fromDeleteOld=True)
             if isinstance(result, VidyoError):
                 error = result
                 attainedDate = booking.getConference().getAdjustedEndDate(
                     tz='UTC')
                 break
     except Exception, e:
         error = e
         attainedDate = booking.getConference().getAdjustedEndDate(tz='UTC')
Beispiel #49
0
    def attachRoom(cls, booking):
        owner = booking.getOwnerObject()
        possibleLogins = VidyoTools.getAvatarLoginList(owner)
        if not possibleLogins:
            return VidyoError("userHasNoAccounts", "attach")
        roomName = booking.getBookingParamByName("roomName")
        searchFilter = SOAPObjectFactory.createFilter('admin', roomName)

        # TODO: Do several calls if needed
        # Vidyo should have an exact match feature too
        searchFilter.limit = 100

        answer = AdminApi.getRooms(searchFilter)
        createdRooms = answer.room

        for room in createdRooms:
            for login in possibleLogins:
                if str(room.name) == roomName and str(room.ownerName) == login:
                    return room
        else:
            return VidyoError("notValidRoom", "attach")
Beispiel #50
0
 def connectRoom(cls, booking, roomId, extension):
     confId = booking.getConference().getId()
     bookingId = booking.getId()
     try:
         searchFilter = SOAPObjectFactory.createFilter('user', extension)
         userApiAnswer = UserApi.search(searchFilter, confId, bookingId)
         if userApiAnswer.total == 0:
             return VidyoError("noExistsRoom", "connect", _("The conference room is not registered in the vidyo service. ") + VidyoTools.getContactSupportText())
         legacyMember = userApiAnswer.Entity[0].entityID
         AdminApi.connectRoom(roomId, confId, bookingId, legacyMember)
     except WebFault, e:
         faultString = e.fault.faultstring
         if faultString.startswith('ConferenceID is invalid'):
             return VidyoError("unknownRoom", "connect")
         if faultString.startswith('Failed to Invite to Conference'):
             message = _("The connection has failed. ") + VidyoTools.getContactSupportText()
             return VidyoError("connectFailed", "connect", message)
         else:
             Logger.get('Vidyo').exception("""Evt:%s, booking:%s, Admin API's connectRoom operation got WebFault: %s""" %
                     (confId, bookingId, e.fault.faultstring))
             raise
Beispiel #51
0
    def searchRooms(cls, query, offset=None, limit=None):
        try:
            search_filter = SOAPObjectFactory.createFilter(
                'admin', "%%%s%%" % VidyoTools.replaceSpacesInName(query))

            if offset is not None:
                search_filter.start = offset
            if limit is not None:
                search_filter.limit = limit

            rooms = AdminApi.getRooms(search_filter)

            if rooms.total:
                return rooms.room
            return []

        except WebFault, e:
            Logger.get('Vidyo').exception(
                """Admin API's searchRooms operation got WebFault: %s""" %
                e.fault.faultstring)
            raise
Beispiel #52
0
    def attachRoom(cls, booking):
        owner = booking.getOwnerObject()
        possibleLogins = VidyoTools.getAvatarLoginList(owner)
        if not possibleLogins:
            return VidyoError("userHasNoAccounts", "attach")
        roomName = booking.getBookingParamByName("roomName")
        searchFilter = SOAPObjectFactory.createFilter('admin', roomName)

        # TODO: Do several calls if needed
        # Vidyo should have an exact match feature too
        searchFilter.limit = 100

        answer = AdminApi.getRooms(searchFilter)
        createdRooms = answer.room

        for room in createdRooms:
            for login in possibleLogins:
                if str(room.name) == roomName and str(room.ownerName) == login:
                    return room
        else:
            return VidyoError("notValidRoom", "attach")
Beispiel #53
0
 def call(self):
     VidyoTools.getEventEndDateIndex().clear()
Beispiel #54
0
    def createRoom(cls, booking):
        """ Attempts to create a public room in Vidyo.
            Returns None on success. Will also set booking.setAccountName() if success, with the Indico & Vidyo login used successfully.
            Returns a VidyoError instance if there are problems.

            :param booking: the CSBooking object inside which we try to create the room
            :type booking: MaKaC.plugins.Collaboration.Vidyo.collaboration.CSBooking
        """
        # we extract the different parameters
        # We set the original conference id because the bookings can belong to more than one conference and being cloned
        # and it is used for the long name, we need to keep always the same confId
        confId = booking.getConference().getId()

        bookingId = booking.getId()
        roomName = booking.getBookingParamByName("roomName")
        description = booking.getBookingParamByName("roomDescription")
        owner = booking.getOwnerObject()
        pin = booking.getPin()
        moderatorPin = booking.getModeratorPin()

        #we obtain the unicode object with the proper format for the room name
        roomNameForVidyo = VidyoTools.roomNameForVidyo(roomName)
        if isinstance(roomNameForVidyo, VidyoError):
            return roomNameForVidyo

        #we turn the description into a unicode object
        description = VidyoTools.descriptionForVidyo(description)
        if isinstance(description, VidyoError):
            return description

        #we obtain the most probable extension
        #TODO: there's a length limit for extensions, check this
        baseExtension = getVidyoOptionValue("prefix") + confId
        extension = baseExtension
        extensionSuffix = 1

        #we produce the list of possible account names. We will loop through them to attempt to create the room
        possibleLogins = VidyoTools.getAvatarLoginList(owner)
        if not possibleLogins:
            return VidyoError("userHasNoAccounts", "create")

        # We check the moderator PIN is a 3-10 digit number
        if moderatorPin and (not moderatorPin.isdigit() or
                             len(moderatorPin) < 3 or len(moderatorPin) > 10):
            return VidyoError("PINLength", "create")

        roomCreated = False
        loginToUse = 0

        while not roomCreated and loginToUse < len(possibleLogins):
            #we loop changing the ownerName and the extension until room is created

            newRoom = SOAPObjectFactory.createRoom(roomNameForVidyo,
                                                   description,
                                                   possibleLogins[loginToUse],
                                                   extension, pin,
                                                   moderatorPin)
            try:
                AdminApi.addRoom(newRoom)
                roomCreated = True

            except WebFault, e:
                faultString = e.fault.faultstring

                if faultString.startswith('Room exist for name'):
                    if VidyoOperations.roomWithSameOwner(
                            possibleLogins[loginToUse], roomNameForVidyo):
                        return VidyoError("duplicatedWithOwner", "create")
                    else:
                        return VidyoError("duplicated", "create")

                elif faultString.startswith('Member not found for ownerName'):
                    loginToUse = loginToUse + 1

                elif faultString.startswith(
                        'PIN should be a 3-10 digit number'):
                    return VidyoError("PINLength", "create")

                elif faultString.startswith('Room exist for extension'):
                    extension = baseExtension + str(extensionSuffix)
                    extensionSuffix = extensionSuffix + 1
                else:
                    Logger.get('Vidyo').exception(
                        """Evt:%s, booking:%s, Admin API's addRoom operation got WebFault: %s"""
                        % (confId, bookingId, e.fault.faultstring))
                    raise
Beispiel #55
0
 def isRoomInMultipleBookings(self):
     """ If different CSBookings contains the same Vidyo Room.
     """
     return len(VidyoTools.getIndexByVidyoRoom().getBookingList(
         self._roomId)) > 1
Beispiel #56
0
 def notifyEventDateChanges(self, oldStartDate, newStartDate, oldEndDate,
                            newEndDate):
     """ Moves the booking in the old bookings index
     """
     VidyoTools.getEventEndDateIndex().moveBooking(self, oldEndDate)
Beispiel #57
0
    def modifyRoom(cls, booking, oldBookingParams):

        # we extract the different parameters
        # We set the original conference id because the bookings can belong to more than one conference and being cloned
        # and it is used for the long name, we need to keep always the same confId
        confId = booking.getConference().getId()
        bookingId = booking.getId()
        roomId = booking.getRoomId()
        roomName = booking.getBookingParamByName("roomName")
        description = booking.getBookingParamByName("roomDescription")
        newOwner = booking.getOwnerObject()  #an avatar object
        ownerAccountName = booking.getOwnerAccount()  #a str
        oldOwner = oldBookingParams["owner"]  #an IAvatarFossil fossil
        pin = booking.getPin()
        moderatorPin = booking.getModeratorPin()

        #we obtain the unicode object with the proper format for the room name
        roomNameForVidyo = VidyoTools.roomNameForVidyo(roomName)
        if isinstance(roomNameForVidyo, VidyoError):
            return roomNameForVidyo

        #we turn the description into a unicode object
        description = VidyoTools.descriptionForVidyo(description)
        if isinstance(description, VidyoError):
            return description

        #(the extension will not change)

        #we check if the owner has changed. If not, we reuse the same accountName
        useOldAccountName = True
        possibleLogins = []
        if newOwner.getId() != oldOwner["id"]:
            useOldAccountName = False
            #we produce the list of possible account names. We will loop through them to attempt to create the room
            possibleLogins = VidyoTools.getAvatarLoginList(newOwner)
            if not possibleLogins:
                raise CollaborationException(
                    _("The moderator has no login information"))

        # We check the moderator PIN is a 3-10 digit number
        if moderatorPin and (not moderatorPin.isdigit() or
                             len(moderatorPin) < 3 or len(moderatorPin) > 10):
            return VidyoError("PINLength", "modify")

        roomModified = False
        loginToUse = 0
        while not roomModified and (useOldAccountName
                                    or loginToUse < len(possibleLogins)):

            if not useOldAccountName:
                ownerAccountName = possibleLogins[loginToUse]

            newRoom = SOAPObjectFactory.createRoom(roomNameForVidyo,
                                                   description,
                                                   ownerAccountName,
                                                   booking.getExtension(), pin,
                                                   moderatorPin)
            try:
                AdminApi.updateRoom(roomId, newRoom)
                roomModified = True

            except WebFault, e:
                faultString = e.fault.faultstring

                if faultString.startswith('Room not exist for roomID'):
                    return VidyoError("unknownRoom", "modify")

                elif faultString.startswith('Room exist for name'):
                    return VidyoError("duplicated", "modify")

                elif faultString.startswith('Member not found for ownerName'):
                    if useOldAccountName:
                        #maybe the user was deleted between the time the room was created and now
                        return VidyoError("badOwner", "modify")
                    else:
                        loginToUse = loginToUse + 1

                elif faultString.startswith(
                        'PIN should be a 3-10 digit number'):
                    return VidyoError("PINLength", "modify")

                else:
                    Logger.get('Vidyo').exception(
                        """Evt:%s, booking:%s, Admin API's updateRoom operation got WebFault: %s"""
                        % (confId, bookingId, e.fault.faultstring))
                    raise
Beispiel #58
0
 def isLinkedToEquippedRoom(self):
     return self._created and VidyoTools.getLinkRoomIp(
         self.getLinkObject()) != ""
Beispiel #59
0
def conferenceMigration1_0(dbi, withRBDB, prevVersion):
    """
    Tasks: 1. Moving support info fields from conference to a dedicated class
           2. Update non inherited children list
           3. Update Vidyo indexes
    """

    def _updateMaterial(obj):
        for material in obj.getAllMaterialList(sort=False):
            material.getAccessController().setNonInheritingChildren(set())
            if material.getAccessController().getAccessProtectionLevel() != 0:
                material.notify_protection_to_owner(material)
            for resource in material.getResourceList(sort=False):
                if resource.getAccessController().getAccessProtectionLevel() != 0:
                    resource.notify_protection_to_owner()

    def updateSupport(conf):
        #################################################################
        #Moving support info fields from conference to a dedicated class:
        #################################################################

        dMgr = displayMgr.ConfDisplayMgrRegistery().getDisplayMgr(conf)
        caption = email = telephone = ""

        if hasattr(dMgr, "_supportEmailCaption"):
            caption = dMgr._supportEmailCaption
            del dMgr._supportEmailCaption
        if hasattr(conf, "_supportEmail"):
            email = conf._supportEmail
            del conf._supportEmail

        supportInfo = SupportInfo(conf, caption, email, telephone)
        conf.setSupportInfo(supportInfo)

    def updateNonInheritedChildren (conf):
        ####################################
        #Update non inherited children list:
        ####################################

        conf.getAccessController().setNonInheritingChildren(set())
        _updateMaterial(conf)

        for session in conf.getSessionList():
            session.getAccessController().setNonInheritingChildren(set())
            if session.getAccessController().getAccessProtectionLevel() != 0:
                session.notify_protection_to_owner(session)
            _updateMaterial(session)
        for contrib in conf.getContributionList():
            contrib.getAccessController().setNonInheritingChildren(set())
            if contrib.getAccessController().getAccessProtectionLevel() != 0:
                contrib.notify_protection_to_owner(contrib)
            _updateMaterial(contrib)
            for subContrib in contrib.getSubContributionList():
                _updateMaterial(subContrib)

    def updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex, pluginActive):
        ######################
        #Update Vidyo indexes:
        ######################
        if not pluginActive:
            return
        csbm = conf.getCSBookingManager()
        for booking in csbm.getBookingList():
            if booking.getType() == "Vidyo" and booking.isCreated():
                endDateIndex.indexBooking(booking)
                vidyoRoomIndex.indexBooking(booking)

    endDateIndex = VidyoTools.getEventEndDateIndex()
    vidyoRoomIndex = VidyoTools.getIndexByVidyoRoom()
    endDateIndex.clear()
    vidyoRoomIndex.clear()
    ph = PluginsHolder()
    collaboration_pt = ph.getPluginType("Collaboration")
    pluginActive = collaboration_pt.isActive() and collaboration_pt.getPlugin("Vidyo").isActive()

    ch = ConferenceHolder()
    i = 0

    for (__, conf) in console.conferenceHolderIterator(ch, deepness='event'):

        updateSupport(conf)
        updateNonInheritedChildren(conf)
        updateVidyoIndex(conf, endDateIndex, vidyoRoomIndex, pluginActive)

        if i % 10000 == 9999:
            dbi.commit()
        i += 1
    dbi.commit()
Beispiel #60
0
 def call(self):
     maxDate = VidyoTools.getBookingsOldDate()
     return WShowOldRoomIndexActionResult(maxDate).getHTML()