Changeset 00c3a2f in indico


Ignore:
Timestamp:
10/21/10 10:33:56 (3 years ago)
Author:
Jose Benito <jose.benito.gonzalez@…>
Branches:
new-webex
Children:
66081b
Parents:
7fb95e
git-author:
Kevin Flannery <flannery@…> (05/28/10 20:35:51)
git-committer:
Jose Benito <jose.benito.gonzalez@…> (10/21/10 10:33:56)
Message:

Removed unneeded code and fixing access to protected variables where it shouldn't be happening

Location:
indico/MaKaC/plugins/Collaboration/WebEx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/plugins/Collaboration/WebEx/collaboration.py

    r2cffcc r00c3a2f  
    3131from MaKaC.plugins.Collaboration.WebEx.common import WebExControlledException, WebExException,\ 
    3232    getMinStartDate, getMaxEndDate, ChangesFromWebExError,\ 
    33     WebExError, WebExWarning, getWebExOptionValueByName, sendXMLRequest, makeTime, findDuration, \ 
    34     Participant, makeParticipantXML 
     33    WebExError, WebExWarning, getWebExOptionValueByName, makeTime, findDuration, \ 
     34    Participant, makeParticipantXML, sendXMLRequest 
    3535from MaKaC.plugins.Collaboration.WebEx.mail import NewWebExMeetingNotificationAdmin, \ 
    3636    WebExMeetingModifiedNotificationAdmin, WebExMeetingRemovalNotificationAdmin, \ 
    3737    NewWebExMeetingNotificationManager, WebExMeetingModifiedNotificationManager,\ 
    3838    WebExMeetingRemovalNotificationManager, WebExParticipantNotification 
     39from MaKaC.plugins.Collaboration.WebEx.api.operations import WebExOperations 
    3940from MaKaC.common.mail import GenericMailer 
    4041from MaKaC.webinterface.mail import personMail, Mailer 
     
    4849from MaKaC.common.fossilize import fossilizes, fossilize 
    4950from MaKaC.plugins.Collaboration.fossils import ICSBookingBaseConfModifFossil 
     51from MaKaC.common.externalOperationsManager import ExternalOperationsManager 
    5052 
    5153class CSBooking(CSBookingBase): 
     
    160162        return self._bookingParams['webExUser'] 
    161163 
     164    def getDuration(self): 
     165        return self._duration 
     166 
    162167    def getWebExKey(self): 
    163168        try: 
     
    171176    def getChangesFromWebEx(self): 
    172177        return self._changesFromWebEx 
     178 
     179    def setWebExKey( self, webExKey ): 
     180        self._webExKey = webExKey 
     181 
     182    def getWebExKey( self ): 
     183        return self._webExKey 
    173184     
    174185    def getLastCheck(self): 
     
    255266    
    256267    def bookingOK(self): 
     268        """ 
     269        This function is called after the booking parameters are  
     270        checked and the booking appears to have been successful. 
     271        """ 
    257272        self._statusMessage = _("Booking created") 
    258273        self._statusClass = "statusMessageOK" 
     
    288303        """ Creates a booking in the EVO server if all conditions are met. 
    289304        """ 
    290         try: 
    291             params = self.getBookingParams() 
    292             self.setAccessPassword( params['accessPassword'] ) 
    293              
    294             participant_xml = makeParticipantXML(self._participants) 
    295              
    296             t1 = makeTime( self.getAdjustedStartDate('UTC') ) 
    297             self._duration = findDuration( self.getAdjustedStartDate('UTC'), self.getAdjustedEndDate('UTC') ) 
    298             start_date = t1.strftime( "%m/%d/%Y %H:%M" ) 
    299             request_xml = """<?xml version="1.0\" encoding="UTF-8"?> 
    300 <serv:message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:serv=\"http://www.webex.com/schemas/2002/06/service" > 
    301 <header> 
    302   <securityContext> 
    303     <webExID>%(username)s</webExID> 
    304     <password>%(password)s</password> 
    305     <siteID>%(siteID)s</siteID> 
    306     <partnerID>%(partnerID)s</partnerID> 
    307   </securityContext> 
    308 </header> 
    309 <body> 
    310   <bodyContent xsi:type="java:com.webex.service.binding.meeting.CreateMeeting" xmlns:meet="http://www.webex.com/schemas/2002/06/service/meeting" > 
    311     <accessControl> 
    312       <meetingPassword>%(meetingPassword)s</meetingPassword> 
    313     </accessControl> 
    314     <metaData> 
    315       <confName>%(meetingName)s</confName> 
    316       <agenda>%(description)s</agenda> 
    317     </metaData> 
    318     %(participants)s 
    319     <enableOptions> 
    320       <chat>true</chat> 
    321       <poll>true</poll> 
    322       <audioVideo>true</audioVideo> 
    323     </enableOptions> 
    324     <schedule> 
    325       <startDate>%(startDate)s:00</startDate> 
    326       <joinTeleconfBeforeHost>false</joinTeleconfBeforeHost> 
    327       <duration>%(duration)s</duration> 
    328       <timeZoneID>20</timeZoneID><!--Zone 20 is Greenwich GMT/UTC--> 
    329     </schedule> 
    330     <telephony> 
    331       <telephonySupport>CALLIN</telephonySupport> 
    332     </telephony> 
    333   </bodyContent> 
    334 </body> 
    335 </serv:message> 
    336  
    337 """ % ( { "username" : params['webExUser'], "password" : params['webExPass'], "siteID" : getWebExOptionValueByName("WESiteID"), "partnerID" : getWebExOptionValueByName("WEPartnerID"), "meetingPassword": params['accessPassword'], "startDate" : start_date, "duration" : self._duration, "meetingName" : params['meetingTitle'], "description" : params['meetingDescription'], "participants": participant_xml } ) 
    338             Logger.get('WebEx').debug( "WebEx Response:\n\n%s" % ( request_xml ) ) 
    339             response_xml = sendXMLRequest( request_xml ) 
    340             Logger.get('WebEx').debug( "WebEx Response:\n\n%s" % ( response_xml ) ) 
    341             dom = xml.dom.minidom.parseString( response_xml ) 
    342             status = dom.getElementsByTagName( "serv:result" )[0].firstChild.toxml('utf-8') 
    343             if status == "SUCCESS": 
    344                 self._webExKey = dom.getElementsByTagName( "meet:meetingkey" )[0].firstChild.toxml('utf-8') 
    345                 self._iCalURL = dom.getElementsByTagName( "serv:attendee" )[0].firstChild.toxml('utf-8') 
    346                 #Check if they left the trialing slash in the base URL we need 
    347                 if getWebExOptionValueByName("WEhttpServerLocation")[-1] == "/": 
    348                     self._url = getWebExOptionValueByName("WEautoJoinURL") + 'm.php?AT=JM&MK=' + self._webExKey 
    349                 else:  #Add in the slash for them 
    350                     self._url = getWebExOptionValueByName("WEautoJoinURL") + '/m.php?AT=JM&MK=' + self._webExKey 
    351                 #We do this because the call in number is not returned in create response 
    352                 self.bookingOK() 
    353                 self.checkCanStart() 
    354                 self._checkStatus() 
    355                 recipients = [] 
    356                 for k in self._participants.keys(): 
    357                     recipients.append( self._participants[k]._email ) 
    358                 if len(recipients)>0: 
    359                     notification = WebExParticipantNotification( self, recipients, 'new' ) 
    360                     GenericMailer.send( notification ) 
    361             else: 
    362                 self._url = "" 
    363                 errorID = dom.getElementsByTagName( "serv:exceptionID" )[0].firstChild.toxml('utf-8') 
    364                 errorReason = dom.getElementsByTagName( "serv:reason" )[0].firstChild.toxml('utf-8') 
    365                 return WebExError( errorID, userMessage = errorReason ) 
    366  
    367             if MailTools.needToSendEmails('WebEx'): 
    368                 try: 
    369                     notification = NewWebExMeetingNotificationAdmin(self) 
    370                     GenericMailer.sendAndLog(notification, self.getConference(), 
    371                             "MaKaC/plugins/Collaboration/WebEx/collaboration.py", 
    372                             self.getConference().getCreator()) 
    373                 except Exception,e: 
    374                     Logger.get('WebEx').error( 
    375                                """Could not send NewWebExMeetingNotificationAdmin for booking with id %s of event with id %s, exception: %s""" % 
    376                                (self.getId(), self.getConference().getId(), str(e))) 
    377                      
    378             if self._bookingParams["sendMailToManagers"]: 
    379                 try: 
    380                     notification = NewWebExMeetingNotificationManager(self) 
    381                     GenericMailer.sendAndLog(notification, self.getConference(), 
    382                                              "MaKaC/plugins/Collaboration/WebEx/collaboration.py", 
    383                                              self.getConference().getCreator()) 
    384                 except Exception,e: 
    385                     Logger.get('WebEx').error( 
    386                         """Could not send NewEVOMeetingNotificationManager for booking with id %s , exception: %s""" % (self._id, str(e))) 
    387         except WebExControlledException, e: 
    388             Logger.get('WebEx').debug( "caught exception in function _create" ) 
    389             raise WebExException(_("The booking could not be created due to a problem with the WebEx Server\n.It sent the following message: ") + e.message, e) 
     305        params = self.getBookingParams() 
     306        self.setAccessPassword( params['accessPassword'] ) 
     307        t1 = makeTime( self.getAdjustedStartDate('UTC') ) 
     308        self._duration = findDuration( self.getAdjustedStartDate('UTC'), self.getAdjustedEndDate('UTC') ) 
     309 
     310        result = ExternalOperationsManager.execute(self, "createBooking", WebExOperations.createBooking, self) 
     311        if isinstance(result, WebExError): 
     312            return result 
     313        #We do this because the call in number is not returned in create response 
     314        self.bookingOK() 
     315        self.checkCanStart() 
     316        self._checkStatus() 
     317        return None 
    390318 
    391319    def _modify(self, oldBookingParams): 
     
    394322        Logger.get('WebEx').debug( "in _modify" ) 
    395323        if self._created: 
    396             arguments = self.getCreateModifyArguments() 
    397             #we take care of the participants  
    398  
    399             try: 
    400                 params = self.getBookingParams() 
    401                 self.setAccessPassword( params['accessPassword'] ) 
    402                 t1 = datetime( *strptime( str(self.getAdjustedStartDate('UTC'))[:-9], "%Y-%m-%d %H:%M" )[0:7]) 
    403                 t2 = datetime( *strptime( str(self.getAdjustedEndDate('UTC'))[:-9], "%Y-%m-%d %H:%M" )[0:7]) 
    404                 diff = t2 - t1 
    405                 days = diff.days 
    406                 minutes,seconds = divmod(diff.seconds, 60) 
    407                 duration = minutes + diff.days * 1440 
    408                 Logger.get('WebEx').debug( "Found duration %s" % str(duration) ) 
    409 #                self._startDate = getAdjustedDate(WE_time, tz=self._conf.getTimezone()) 
    410 #self.getAdjustedStartDate('UTC') 
    411 #                self._endDate = getAdjustedDate(self._startDate, tz=self._conf.getTimezone()) + timedelta( minutes=int( self._duration ) ) 
    412                 start_date = t1.strftime( "%m/%d/%Y %H:%M" ) 
    413                 request_xml = """<?xml version="1.0\" encoding="UTF-8"?> 
    414 <serv:message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:serv=\"http://www.webex.com/schemas/2002/06/service" > 
    415 <header> 
    416   <securityContext> 
    417     <webExID>%(username)s</webExID> 
    418     <password>%(password)s</password> 
    419     <siteID>%(siteID)s</siteID> 
    420     <partnerID>%(partnerID)s</partnerID> 
    421   </securityContext> 
    422 </header> 
    423 <body> 
    424   <bodyContent xsi:type="java:com.webex.service.binding.meeting.SetMeeting" xmlns:meet="http://www.webex.com/schemas/2002/06/service/meeting" > 
    425     <meetingkey>%(meetingKey)s</meetingkey> 
    426     <accessControl> 
    427       <meetingPassword>%(meetingPassword)s</meetingPassword> 
    428     </accessControl> 
    429     <metaData> 
    430       <confName>%(meetingName)s</confName> 
    431       <agenda>%(description)s</agenda> 
    432     </metaData> 
    433     %(participants)s 
    434     <enableOptions> 
    435       <chat>true</chat> 
    436       <poll>true</poll> 
    437       <audioVideo>true</audioVideo> 
    438     </enableOptions> 
    439      
    440     <schedule> 
    441       <startDate>%(startDate)s:00</startDate> 
    442       <joinTeleconfBeforeHost>false</joinTeleconfBeforeHost> 
    443       <duration>%(duration)s</duration> 
    444       <timeZoneID>20</timeZoneID><!--Zone 20 is Greenwich GMT/UTC--> 
    445     </schedule> 
    446     <telephony> 
    447       <telephonySupport>CALLIN</telephonySupport> 
    448     </telephony> 
    449   </bodyContent> 
    450 </body> 
    451 </serv:message> 
    452  
    453 """ % ( { "username" : params['webExUser'], "password" : params['webExPass'], "siteID" : getWebExOptionValueByName("WESiteID"), "partnerID" : getWebExOptionValueByName("WEPartnerID"), "meetingPassword": params['accessPassword'], "startDate" : start_date, "duration" : int(duration), "meetingName" : params['meetingTitle'], "meetingKey" : self._webExKey, "description": params["meetingDescription"], "participants": makeParticipantXML(self._participants) } ) 
    454                 Logger.get('WebEx').debug( "WebEx Modify Request:\n\n%s" % ( request_xml ) ) 
    455                 response_xml = sendXMLRequest( request_xml ) 
    456                 Logger.get('WebEx').debug( "WebEx Modify Response:\n\n%s" % ( response_xml ) ) 
    457                 dom = xml.dom.minidom.parseString( response_xml ) 
    458                 status = dom.getElementsByTagName( "serv:result" )[0].firstChild.toxml('utf-8') 
    459                 if status != "SUCCESS": 
    460                     errorID = dom.getElementsByTagName( "serv:exceptionID" )[0].firstChild.toxml('utf-8') 
    461                     errorReason = dom.getElementsByTagName( "serv:reason" )[0].firstChild.toxml('utf-8') 
    462                     return WebExError( errorID, userMessage = errorReason ) 
    463  
    464                 self.bookingOK() 
    465                 self.checkCanStart() 
    466                 self._checkStatus() 
    467                 recipients = [] 
    468                 for k in self._participants.keys(): 
    469                     recipients.append( self._participants[k]._email ) 
    470                 if len(recipients)>0: 
    471                     notification = WebExParticipantNotification( self, recipients, 'modify' ) 
    472                     GenericMailer.send( notification ) 
    473  
    474                 if MailTools.needToSendEmails('WebEx'): 
    475                     try: 
    476                         notification = WebExMeetingModifiedNotificationAdmin(self) 
    477                         GenericMailer.sendAndLog(notification, self.getConference(), 
    478                                              "MaKaC/plugins/Collaboration/WebEx/collaboration.py", 
    479                                              self.getConference().getCreator()) 
    480                     except Exception,e: 
    481                         Logger.get('WebEx').error( 
    482                             """Could not send WebExMeetingModifiedNotificationAdmin for booking with id %s of event with id %s, exception: %s""" % 
    483                             (self.getId(), self.getConference().getId(), str(e))) 
    484                 if self._bookingParams["sendMailToManagers"]: 
    485                     try: 
    486                         notification = WebExMeetingModifiedNotificationManager(self) 
    487                         GenericMailer.sendAndLog(notification, self.getConference(), 
    488                                              "MaKaC/plugins/Collaboration/WebEx/collaboration.py", 
    489                                              self.getConference().getCreator()) 
    490                     except Exception,e: 
    491                         Logger.get('WebEx').error( 
    492                             """Could not send WebExMeetingModifiedNotificationManager for booking with id %s , exception: %s""" % (self._id, str(e))) 
    493                  
    494             except WebExControlledException, e: 
    495                 raise WebExException(_("The booking could not be modified due to a problem with the WebEx Server.\n") ) 
     324#            result = ExternalOperationsManager.execute(self, "modifyRoom", VidyoOperations.modifyRoom, self, oldBookingParams) 
     325            result = ExternalOperationsManager.execute(self, "modifyBooking", WebExOperations.modifyBooking, self) 
     326            if isinstance(result, WebExError): 
     327                return result 
    496328        else: 
    497             self._create() 
     329            return WebExError( errorType = None, userMessage = "The booking appears to have not been created according to the Indico system" ) 
     330#            self._create() 
    498331        return None 
    499332 
     
    573406 
    574407    def _delete(self): 
    575         self._warning = WebExWarning( "a test of the warning system" ) 
    576         params = self.getBookingParams() 
    577         request_xml = """<?xml version="1.0" encoding="ISO-8859-1"?> 
    578 <serv:message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    579    <header> 
    580       <securityContext> 
    581          <webExID>%(username)s</webExID> 
    582          <password>%(password)s</password> 
    583          <siteID>%(siteID)s</siteID> 
    584          <partnerID>%(partnerID)s</partnerID> 
    585       </securityContext> 
    586    </header> 
    587    <body> 
    588       <bodyContent xsi:type="java:com.webex.service.binding.meeting.DelMeeting"> 
    589          <meetingKey>%(webex_key)s</meetingKey> 
    590       </bodyContent> 
    591    </body> 
    592 </serv:message> 
    593 """ % { "username" : params['webExUser'], "password" : params['webExPass'], "siteID" : getWebExOptionValueByName("WESiteID"), "partnerID" : getWebExOptionValueByName("WEPartnerID"), "webex_key": self._webExKey } 
    594         Logger.get('WebEx').debug( "delete func. is self._created? %s XML:\n%s " % ( self._created, request_xml ) ) 
    595         response_xml = sendXMLRequest( request_xml ) 
    596         dom = xml.dom.minidom.parseString( response_xml ) 
    597         status = dom.getElementsByTagName( "serv:result" )[0].firstChild.toxml('utf-8') 
    598         if status != "SUCCESS": 
    599             errorID = dom.getElementsByTagName( "serv:exceptionID" )[0].firstChild.toxml('utf-8') 
    600             errorReason = dom.getElementsByTagName( "serv:reason" )[0].firstChild.toxml('utf-8') 
    601             Logger.get('WebEx').info( "In delete function, appears to have failed: %s" % response_xml ) 
    602             return WebExError( errorID, userMessage = errorReason ) 
    603 #            self._warning = WebExWarning( reason ) 
    604         else: 
    605             Logger.get('WebEx').info( "In delete function, appears to have been successful" ) 
    606  
    607         if self._created: 
    608             try: 
    609 #                if MailTools.needToSendEmails('WebEx'): 
    610                 if True: 
    611                     try: 
    612 #                        notification = WebExParticipantNotification(self, [ "flannery@gmail.com", "flannery@fnal.gov", "flannery@imsa.edu" ]) 
    613                         #send(addto, addcc, addfrom, subject, body): 
    614                         Logger.get('WebEx').info("I am in the mailer block") 
    615                         recipients = "" 
    616                         for k in participants.keys(): 
    617                             recipients += participants[k]._email + " , " 
    618                         Logger.get('WebEx').info("Recipients: " + recipients ) 
    619                         personMail.send(recipients, "", "Kevin O'Flannery", "A Subject", "Some body in here" ) 
    620 #notification, self.getConference(), 
    621 #                                             "MaKaC/plugins/Collaboration/WebEx/collaboration.py", 
    622 #                                             self.getConference().getCreator()) 
    623                     except Exception,e: 
    624                         Logger.get('WebEx').error( 
    625                             """Could not send WebExMeetingRemovalNotificationAdmin for booking with id %s of event with id %s, exception: %s""" % 
    626                             (self.getId(), self.getConference().getId(), str(e))) 
    627                 
    628 #                if self._bookingParams["sendMailToManagers"]: 
    629 #                    try: 
    630 #                        notification = EVOMeetingRemovalNotificationManager(self) 
    631 #                        GenericMailer.sendAndLog(notification, self.getConference(), 
    632 #                                             "MaKaC/plugins/Collaboration/WebEx/collaboration.py", 
    633 #                                             self.getConference().getCreator()) 
    634 #                    except Exception,e: 
    635 #                        Logger.get('EVO').error( 
    636 #                            """Could not send EVOMeetingRemovalNotificationManager for booking with id %s , exception: %s""" % (self._id, str(e))) 
    637  
    638             except WebExControlledException, e:                 
    639                 if e.message == "DELETE_MEETING_OVER": 
    640                     return WebExError('cannotDeleteOld', str(requestURL)) 
    641                 if e.message == "DELETE_MEETING_ONGOING": 
    642                     return WebExError('cannotDeleteOngoing', str(requestURL)) 
    643                 if e.message == "DELETE_MEETING_NO_ID": 
    644                     self._warning = EVOWarning('cannotDeleteNonExistant') 
    645                 else: 
    646                     return WebExError( userMessage = "The booking could not be deleted due to a problem with the WebEx Server" ) 
    647 #                    raise WebExException(_("The booking could not be deleted due to a problem with the EVO Server\n.The EVO Server sent the following error message: ") + e.message, e) 
    648                  
    649         self._error = False 
    650         return None 
     408        """ 
     409        This function will delete the specified video booking from the WebEx server 
     410        """ 
     411        result = ExternalOperationsManager.execute(self, "deleteBooking", WebExOperations.deleteBooking, self) 
     412        if isinstance(result, WebExError): 
     413            return result 
    651414         
    652415         
  • indico/MaKaC/plugins/Collaboration/WebEx/common.py

    r2cffcc r00c3a2f  
    3939    IChangesFromWebExErrorFossil, IParticipantFossil 
    4040 
     41def sendXMLRequest(xml):   
     42    conn = httplib.HTTPSConnection( getWebExOptionValueByName("WEhttpServerLocation") ) 
     43    conn.request( "POST", "/WBXService/XMLService", xml ) 
     44    r = conn.getresponse() 
     45    response_xml = r.read() 
     46#    Logger.get('WebEx').debug( "WebEx Response:\n\n\n\n%s" % ( response_xml ) ) 
     47    return response_xml 
     48 
    4149def getWebExOptionValueByName(optionName): 
    4250    return CollaborationTools.getOptionValue('WebEx', optionName) 
     
    8492    """ 
    8593    return datetime( *strptime( str(the_dateTime)[0:16], "%Y-%m-%d %H:%M" )[0:7])  
    86      
    87      
    88 def sendXMLRequest(xml):   
    89     conn = httplib.HTTPSConnection( getWebExOptionValueByName("WEhttpServerLocation") ) 
    90     conn.request( "POST", "/WBXService/XMLService", xml ) 
    91     r = conn.getresponse() 
    92     response_xml = r.read() 
    93 #    Logger.get('WebEx').debug( "WebEx Response:\n\n%s" % ( response_xml ) ) 
    94     return response_xml 
    9594    
    9695def getMinStartDate(conference): 
Note: See TracChangeset for help on using the changeset viewer.