Example #1
0
 def _checkParams(self):
     optionName = self._params.get('optionName', None)
     if optionName:
         options = optionName.split('.')
         ph = PluginsHolder()
         if len(options) == 3:
             pluginType, plugin, option = options
             if ph.hasPluginType(pluginType):
                 if ph.getPluginType(pluginType).hasPlugin(plugin):
                     self._targetOption = ph.getPluginType(
                         pluginType).getPlugin(plugin).getOption(option)
                 else:
                     raise ServiceError(
                         'ERR-PLUG4',
                         'plugin: ' + str(plugin) + ' does not exist')
             else:
                 raise ServiceError(
                     'ERR-PLUG3', 'pluginType: ' + str(pluginType) +
                     ' does not exist, is not visible or not active')
         elif len(options) == 2:
             pluginType, option = options
             if ph.hasPluginType(pluginType):
                 self._targetOption = ph.getPluginType(
                     pluginType).getOption(option)
             else:
                 raise ServiceError(
                     'ERR-PLUG3', 'pluginType: ' + str(pluginType) +
                     ' does not exist, is not visible or not active')
         else:
             raise ServiceError(
                 'ERR-PLUG1',
                 'optionName argument does not have the proper pluginType.plugin.option format'
             )
     else:
         raise ServiceError('ERR-PLUG0', 'optionName argument not present')
Example #2
0
    def _checkParams(self):
        try:
            self._target = self._conf = conference.ConferenceHolder().getById(
                self._params["conference"])
        except:
            try:
                self._target = self._conf = conference.ConferenceHolder(
                ).getById(self._params["confId"])
            except:
                raise ServiceError("ERR-E4", "Invalid conference id.")

        if self._conf == None:
            raise Exception("Conference id not specified.")

        try:
            self._target = self._contribution = self._conf.getContributionById(
                self._params["contribution"])
        except:
            try:
                self._target = self._contribution = self._conf.getContributionById(
                    self._params["contribId"])
            except:
                raise ServiceError("ERR-C0", "Invalid contribution id.")

        if self._target == None:
            raise Exception("Contribution id not specified.")

        # create a parameter manager that checks the consistency of passed parameters
        self._pm = ParameterManager(self._params)
Example #3
0
 def _checkParams(self):
     ConferenceReviewingPRMRefereeBase._checkParams(self)
     self._attribute = self._params.get("attribute", None)
     if self._attribute is None:
         raise ServiceError("ERR-REV5",_("No type/session/track specified"))
     self._selectedAttribute = self._params.get("selectedAttributes", None)
     if self._selectedAttribute is None:
         raise ServiceError("ERR-REV5",_("No attribute specified"))
Example #4
0
 def _checkProtection(self):
     LoggedOnlyService._checkProtection(self)
     if self._aw.getUser():
         if not self._target.canModify(self._aw):
             raise ServiceError(
                 "ERR-U6", _("You are not allowed to perform this request"))
     else:
         raise ServiceError(
             "ERR-U7",
             _("You are currently not authenticated. Please log in again."))
Example #5
0
    def _getAnswer(self):

        ##        raise ServiceError("ERR-FOO","For no apparent reason")

        if (self._obj == None):
            raise ServiceError("ERR-U0", "User does not exist!")
        if (self._target.getPersonalInfo().getBasket().deleteElement(
                self._obj)):
            return
        else:
            raise ServiceError("ERR-U2", "Element not in list!")
Example #6
0
    def _handleSet(self):
        try:
            naiveDate = parseDateTime(self._value)
        except ValueError:
            raise ServiceError("ERR-E2",
                               "Date/time is not in the correct format")

        try:
            self._pTime = setAdjustedDate(naiveDate, self._conf)
            return self._setParam()
        except TimingError, e:
            raise ServiceError("ERR-E2", e.getMessage())
Example #7
0
 def _checkParams(self):
     self._pm = ParameterManager(self._params)
     userId = self._pm.extract("userId", None)
     if userId is not None:
         ah = user.AvatarHolder()
         self._user = self._avatar = self._target = ah.getById(userId)
     else:
         raise ServiceError("ERR-U5", _("User id not specified"))
     self._dataType = self._pm.extract("dataType",
                                       pType=str,
                                       allowEmpty=False)
     if not self._dataType in self._dataTypes:
         raise ServiceError("ERR-U7", _("Data argument is not valid"))
Example #8
0
    def _getAnswer(self):
        if self._confPaperReview.getChoice() == ConferencePaperReview.NO_REVIEWING or self._confPaperReview.getChoice() == ConferencePaperReview.LAYOUT_REVIEWING:
            raise ServiceError("ERR-REV6aa",_("can't assign referee"))
        if not self._targetUser:
            raise ServiceError("ERR-REV6a",_("user id not set"))

        for contribution in self._contributions:
            rm = contribution.getReviewManager()
            if not rm.isReferee(self._targetUser):
                if rm.hasReferee():
                    rm.removeReferee()
                rm.setReferee(self._targetUser)
        return True
Example #9
0
    def _getAnswer(self):

        ##### Why not?
        #if (self._target in self._userList):
        #    raise ServiceError("ERR-U3","Trying to add user to his own favorites!")

        if (self._userList == []):
            raise ServiceError("ERR-U0", "No users specified!")

        for user in self._userList:
            if (not self._target.getPersonalInfo().getBasket().addElement(user)
                ):
                raise ServiceError("ERR-U1", "Element already exists in list!")
Example #10
0
    def _getAnswer(self):
        if not self._targetUser:
            raise ServiceError("ERR-REV6c", _("user id not set"))

        for contribution in self._contributions:
            rm = contribution.getReviewManager()
            if rm.hasReferee():
                if not rm.isReviewer(self._targetUser):
                    rm.addReviewer(self._targetUser)
            else:
                raise ServiceError("ERR-REV9b",
                                   _("This contribution has no Referee yet"))
        return True
Example #11
0
    def _getAnswer(self):
        if self._confPaperReview.getChoice() == ConferencePaperReview.NO_REVIEWING or self._confPaperReview.getChoice() == ConferencePaperReview.LAYOUT_REVIEWING:
            raise ServiceError("ERR-REV6cc",_("can't assign content reviewer"))
        if not self._targetUser:
            raise ServiceError("ERR-REV6c",_("user id not set"))

        for contribution in self._contributions:
            rm = contribution.getReviewManager()
            if rm.hasReferee():
                if not rm.isReviewer(self._targetUser):
                    rm.addReviewer(self._targetUser)
            else:
                raise ServiceError("ERR-REV9b",_("This contribution has no Referee yet"))
        return True
Example #12
0
    def _getAnswer(self):

        ContextManager.set('dateChangeNotificationProblems', {})

        if (self._startDate > self._endDate):
            raise ServiceError(
                "ERR-E3", "Date/time of start cannot " +
                "be greater than date/time of end")

        try:
            self._target.setDates(self._startDate,
                                  self._endDate,
                                  moveEntries=1)
        except TimingError, e:
            raise ServiceError("ERR-E2", e.getMsg())
Example #13
0
    def _getAnswer(self):
        li = LoginInfo(self._username, self._password)
        auth = AuthenticatorMgr()
        av = auth.getAvatar(li)
        if not av:
            from MaKaC.services.interface.rpc.common import ServiceError
            raise ServiceError("Wrong login or password")

        elif not av.isActivated():
            from MaKaC.services.interface.rpc.common import ServiceError
            raise ServiceError(
                "Your account is not active. Please activate it and retry.")
        else:
            self._getSession().setUser(av)
        return '%s OK %s' % (self._username, datetime.datetime.now())
Example #14
0
    def _handleGet(self):
        attributes = []
        for c in self._event.contributions:
            if self._attribute == 'type':
                if c.type is not None and c.type not in attributes:
                    attributes.append(c.type)
            elif self._attribute == 'track':
                if c.track is not None and c.track not in attributes:
                    attributes.append(c.track)
            elif self._attribute == 'session':
                if c.session is not None and c.session not in attributes:
                    attributes.append(c.session)
            else:
                raise ServiceError("ERR-REV5", _("No attribute specified"))

        if self._attribute == 'type':
            return [{
                "id": attribute.id,
                "title": attribute.name
            } for attribute in attributes]
        else:
            return [{
                "id": attribute.id,
                "title": attribute.title
            } for attribute in attributes]
Example #15
0
    def _checkParams(self):
        """
        Checks the materialId, and retrieves the material using it
        """

        self._material = None
        self._conf = None

        l = locators.WebLocator()

        try:

            l.setResource(self._params, 0)
            self._target = l.getObject()

            if isinstance(self._target, conference.Resource):
                self._resource = self._target
                self._material = self._target.getOwner()

            if isinstance(self._target, conference.Material):
                self._material = self._target

            if isinstance(self._target, conference.Category):
                self._categ = self._target
            else:
                self._conf = self._target.getConference()

            if self._conf == None:
                self._categ = self._target.getCategory()

        except Exception, e:
            raise ServiceError("ERR-M0", str(e))
Example #16
0
    def _getAnswer(self):
        """
        Updates the material with the new properties
        """

        if self._material.isBuiltin(
        ) and self._material.getTitle() != self._title:
            raise ServiceError(
                "", "You can't change the name of a built-in material.")

        self.changeUserList(self._material, self._newUserList)

        self._material.setTitle(self._title)
        self._material.setDescription(self._description)
        self._material.setProtection(self._protection)
        self._material.setHidden(self._hidden)
        self._material.setAccessKey(self._accessKey)

        event = self._material.getOwner()
        materialRegistry = event.getMaterialRegistry()

        return {
            'material': self._material.fossilize(IMaterialFossil),
            'newMaterialTypes': materialRegistry.getMaterialList(event)
        }
Example #17
0
 def _checkParams(self):
     ConferenceReviewingPRMBase._checkParams(self)
     userId = self._params.get("user", None)
     if userId:
         self._user = user.AvatarHolder().getById(userId)
     else:
         raise ServiceError("ERR-REV4", _("No user id specified"))
Example #18
0
 def _handleSet(self):
     newDays = self._value
     try:
         newDays = int(self._value)
     except ValueError, e:
         raise ServiceError('ERR-NEWS0',
                            'Recent days value has to be an interger', e)
Example #19
0
def QueryConference(conference, bookingId):
    booking = conference.getBookingById(bookingId)
    if booking == None:
        raise ServiceError("Invalid hermes id.")

    #mcuConference = McuApi.first(McuApi.SelectConferences(conferenceName = booking.getHermesName()))
    #if mcuConference == None:
    #raise ServiceError("Conference no longer exists in MCU.", conferenceName)

    roomName = None
    roomAddress = None
    conferenceRoom = conference.getRoom()
    if conferenceRoom:
        roomName = conferenceRoom.getName()
        try:
            DALManagerCERN.connect()
            room = RoomBase.getRooms(roomName=roomName)
            if room:
                roomAddress = room.customAtts["H323 IP"]
        finally:
            DALManagerCERN.disconnect()

    properties = {
        "mcu": McuApi.mcuAddress,
        "roomName": roomName,
        "roomAddress": roomAddress
    }
    return booking, properties
Example #20
0
 def _checkParams( self, params = None, fieldName = "userList" ):
     if params:
         self._params = params
     if fieldName in self._params:
         self._avatars, self._newUsers, self._editedAvatars = UserListModificationBase.retrieveUsers(self._params, fieldName)
     else:
         raise ServiceError("ERR-E5", '"userList" parameter missing')
Example #21
0
    def _getAnswer(self):
        for user in self._userList:
            if user["_type"] == "Avatar":  # new speaker
                ah = AvatarHolder()
                av = ah.getById(user["id"])
                if av is None:
                    raise NoReportError(
                        _("The user with email %s that you are adding does not exist anymore in the database"
                          ) % user["email"])
                part = self._newParticipant(av)
            elif user[
                    "_type"] == "ContributionParticipation":  # adding existing author to speaker
                part = self._contribution.getAuthorById(user["id"])
                self._contribution.addSpeaker(part)
            if self._submissionRights and part:
                self._contribution.grantSubmission(part)

        if self._kindOfList == "prAuthor":
            return self._getParticipantsList(
                self._contribution.getPrimaryAuthorList())
        elif self._kindOfList == "coAuthor":
            return self._getParticipantsList(
                self._contribution.getCoAuthorList())
        elif self._kindOfList == "speaker":
            return self._getParticipantsList(
                self._contribution.getSpeakerList())
        else:
            raise ServiceError("ERR-UK0", _("Invalid kind of list of users."))
Example #22
0
 def _getAnswer(self):
     for obj in self._userData:
         if not self._target.getPersonalInfo().getBasket().deleteUser(
                 obj['id']):
             raise ServiceError(
                 "ERR-U0",
                 "Element '%s' not found in favorites!" % obj['id'])
Example #23
0
 def _checkParams(self):
     SessionSlotBase._checkParams(self)
     if self._params.has_key("scheduleEntry"):
         self._schEntry = self._slot.getSchedule().getEntryById(
             self._params["scheduleEntry"])
         if self._schEntry == None:
             raise ServiceError("ERR-E4", "Invalid scheduleEntry id.")
Example #24
0
    def _checkParams(self):

        try:
            self._location = self._params["location"]
        except:
            from MaKaC.services.interface.rpc.common import ServiceError
            raise ServiceError("ERR-RB0", "Invalid location.")
Example #25
0
 def _param(self, parameter_name):
     try:
         return self._params[parameter_name]
     except:
         raise ServiceError(
             'ERR-RB0',
             'Invalid parameter name: {0}.'.format(parameter_name))
Example #26
0
    def _handleGet(self):
        attributes = []
        for c in self._conf.getContributionList():
            if self._attribute == 'type':
                if c.getType() is not None and c.getType() not in attributes:
                    attributes.append(c.getType())
            elif self._attribute == 'track':
                if c.getTrack() is not None and c.getTrack() not in attributes:
                    attributes.append(c.getTrack())
            elif self._attribute == 'session':
                if c.getSession() is not None and c.getSession(
                ) not in attributes:
                    attributes.append(c.getSession())
            else:
                raise ServiceError("ERR-REV5", _("No attribute specified"))

        if self._attribute == 'type':
            return [{
                "id": attribute.getId(),
                "title": attribute.getName()
            } for attribute in attributes]
        else:
            return [{
                "id": attribute.getId(),
                "title": attribute.getTitle()
            } for attribute in attributes]
Example #27
0
 def _checkProtection(self):
     if self._target.getConference().hasEnabledSection("paperReviewing"):
         ConferenceModifBase._checkProtection(self)
     else:
         raise ServiceError(
             "ERR-REV1a",
             _("Paper Reviewing is not active for this conference"))
Example #28
0
    def _checkParams(self):
        try:
            l = locators.WebLocator()

            self._material = None
            self._conf = None

            l.setMaterial(self._params, 0)
            self._target = l.getObject()

            #if isinstance(self._target, conference.Material):
            self._material = self._target
            self._conf = self._target.getConference()
            if self._conf == None:
                self._categ = self._target
            else:
                self._categ = self._conf.getOwner()

            ## TODO: remove this, since material/resource creation
            ## doesn't come through this method

            ## if isinstance(self._target, conference.Category):
            ##     self._categ = self._target
            ## else:
            ##     self._conf = self._target.getConference()

            ## if self._conf == None:
            ##     self._categ=self._target.getCategory()

        except Exception, e:
            raise ServiceError("ERR-M0", str(e))
Example #29
0
 def _checkParams(self):
     AdminService._checkParams(self)
     pm = ParameterManager(self._params)
     self._userId = pm.extract("userId", pType=str, allowEmpty=False)
     self._av = AvatarHolder().getById(self._userId)
     if self._av == None:
         raise ServiceError("ER-U0", _("Cannot find user with id %s") % self._userId)
Example #30
0
    def _checkParams(self):

        try:
            SessionBase._checkParams(self)

            l = locators.WebLocator()
            l.setSlot(self._params)
            self._slot = self._target = l.getObject()
            self._session = self._slot.getSession()
            self._conf = self._session.getConference()


#        self._session = self._target
#
#        try:
#            self._slot = self._target = self._session.getSlotById(self._params["slot"])
#            if self._target == None:
#                raise ServiceError("ERR-S3", "Invalid slot id.")
#        except ServiceError, e:
#            raise
#        except Exception, e:
#           raise ServiceError("ERR-S3", "Invalid slot id.",inner=str(e))
        except Exception, e:
            raise ServiceError("ERR-S3",
                               "Invalid slot id.%s" % self._params,
                               inner=str(e))