コード例 #1
0
ファイル: operations.py プロジェクト: pferreir/indico-backup
    def roomWithSameOwner(cls, owner, roomName):
        # we retrieve the just created room; we need to do this because Vidyo will have
        # added extra data like the room id, the url
        searchFilter = SOAPObjectFactory.createFilter('admin', roomName)
        answer = AdminApi.getRooms(searchFilter)
        createdRooms = answer.room

        for room in createdRooms:
            if str(room.name) == roomName and str(room.ownerName) == owner:
                return room
        return None
コード例 #2
0
    def roomWithSameOwner(cls, owner, roomName):
        # we retrieve the just created room; we need to do this because Vidyo will have
        # added extra data like the room id, the url
        searchFilter = SOAPObjectFactory.createFilter('admin', roomName)
        answer = AdminApi.getRooms(searchFilter)
        createdRooms = answer.room

        for room in createdRooms:
            if str(room.name) == roomName and str(room.ownerName) == owner:
                return room
        return None
コード例 #3
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
コード例 #4
0
ファイル: operations.py プロジェクト: ferhatelmas/indico
    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")
コード例 #5
0
ファイル: operations.py プロジェクト: pferreir/indico-backup
    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")
コード例 #6
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
コード例 #7
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")
コード例 #8
0
class VidyoOperations(object):
    """ This class has several class methods,
        each of which represents a high-level operation,
        which sometimes involve several actual SOAP service calls.

        The objective is to not clutter the CSBooking methods with API logic.
        None of these methods should change the Indico DB, so they should not set any value on any object.
    """
    @classmethod
    def roomWithSameOwner(cls, owner, roomName):
        # we retrieve the just created room; we need to do this because Vidyo will have
        # added extra data like the room id, the url
        searchFilter = SOAPObjectFactory.createFilter('admin', roomName)
        answer = AdminApi.getRooms(searchFilter)
        createdRooms = answer.room

        for room in createdRooms:
            if str(room.name) == roomName and str(room.ownerName) == owner:
                return room
        return None

    @classmethod
    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

        #if we could not create the room, the owner did not have any Vidyo accounts
        if not roomCreated and loginToUse == len(possibleLogins):
            return VidyoError("badOwner", "create")

        # we retrieve the just created room; we need to do this because Vidyo will have
        # added extra data like the room id, the url
        searchFilter = SOAPObjectFactory.createFilter('admin', extension)
        answer = AdminApi.getRooms(searchFilter)
        createdRooms = answer.room

        for room in createdRooms:
            if str(room.extension) == extension:
                return room
        return None