Example #1
0
def deletePrivateFiles(meetingID):
    # JSON Response BEGIN (error message)
    jsonError = jsonObject()
    jsonError.clearResponse()
    jsonError.add('result','false')
    jsonError.add('method','deletePrivateFiles')
    #JSON Response END
    
    # JSON Response BEGIN (success message)
    jsonSuccess = jsonObject()
    jsonSuccess.clearResponse()
    jsonSuccess.add('result','true')
    jsonSuccess.add('method','deletePrivateFiles')
    #JSON Response END
    
    if meetingID == '':
        return jsonError.jsonResponse()
    
    pathEntries = filehelper.searchPathByKeyword(filemgrArchive, meetingID)
    
    if len(pathEntries) == 0:
        return jsonError.jsonResponse()
    
    if sys.platform.startswith('win'):
        accessPath = filemgrArchive + '\\' + meetingID
    else:
        accessPath = filemgrArchive + '/' + meetingID

    try:
        shutil.rmtree(accessPath)
    except:
        return jsonError.jsonResponse()
            
    return jsonSuccess.jsonResponse()
Example #2
0
    def closeMeeting(self, meetingID):

        # JSON Response BEGIN (error message)
        jsonError = jsonObject()
        jsonError.clearResponse()
        jsonError.add('result','false')
        jsonError.add('method','closeMeeting')
        jsonError.add('meetingID',meetingID)
        jsonError.add('error','7404')
        #JSON Response END

        # Do meetingID-related input verification
        if (meetingID == ''):
            return jsonError.jsonResponse()

        if sys.platform.startswith('win'):
            archiveDirectory = string.rstrip(osconfig.slidedeckArchive(), '\\')
        else:
            archiveDirectory = string.rstrip(osconfig.slidedeckArchive(), '/')

        localMeetingDir = os.path.join(archiveDirectory, meetingID)

        if not os.path.isdir(localMeetingDir):
            return jsonError.jsonResponse()

        docList = os.listdir(localMeetingDir)

        if len(docList) == 0:
            return jsonError.jsonResponse()

        for i in range (0, len(docList)):
            if docList[i] == 'Preloaded': # we don't delete preloaded directories
                continue
            docPath = os.path.join(localMeetingDir, docList[i])
            try:
                shutil.rmtree(docPath)
            except:
                pass

        docList = os.listdir(localMeetingDir)
        if len(docList) == 0:
            try:
                os.rmdir(localMeetingDir)
            except:
                pass

        # JSON Response BEGIN
        jsonSuccess = jsonObject()
        jsonSuccess.clearResponse()
        jsonSuccess.add('result','true')
        jsonSuccess.add('method','closeMeeting')
        jsonSuccess.add('meetingID',meetingID)
        jsonSuccess.add('error', '7200')
        #JSON Response END

        return jsonSuccess.jsonResponse()
Example #3
0
    def copyAllPreloaded(self, sourceMeetingRoom, destinationMeetingRoom, strictJSON = False):
        slidedeckArchive = osconfig.slidedeckArchive()

        sourcePath = os.path.join(os.path.join(slidedeckArchive, sourceMeetingRoom), 'Preloaded')

        if not os.path.isdir(sourcePath):
            if not strictJSON:
                jsonError = jsonObject()
                jsonError.clearResponse()
                jsonError.add('result', 'false')
                jsonError.add('method', 'copyAllPreloaded')
                jsonError.add('error', '7404')
                return jsonError.jsonResponse()
            else:
                jsonError = {'result':'false', 'method':'copyAllPreloaded', 'error':7404}
                response = self.demHelper.encode(jsonError)
                return response.encode()

        for entry in os.listdir(sourcePath):
            sourcePath = os.path.join(os.path.join(os.path.join(slidedeckArchive, sourceMeetingRoom), 'Preloaded'), entry)
            destPath = os.path.join(os.path.join(os.path.join(slidedeckArchive, destinationMeetingRoom), 'Preloaded'), entry)

            try:
                # in case the destination directory doesn't exist
                os.makedirs(destPath)
            except:
                pass
            
            try:
                fileList = dir_util.copy_tree(sourcePath, destPath)
            except:
                if not strictJSON:
                    jsonError = jsonObject()
                    jsonError.clearResponse()
                    jsonError.add('result', 'false')
                    jsonError.add('method', 'copyAllPreloaded')
                    jsonError.add('error', '7500')
                    return jsonError.jsonResponse()
                else:
                    jsonError = {'result':'false', 'method':'copyAllPreloaded', 'error':7500}
                    response = self.demHelper.encode(jsonError)
                    return response.encode()

        if not strictJSON:
            jsonError = jsonObject()
            jsonError.clearResponse()
            jsonError.add('result', 'true')
            jsonError.add('method', 'copyAllPreloaded')
            jsonError.add('error', '7200')
            return jsonError.jsonResponse()
        else:
            jsonError = {'result':'true', 'method':'copyAllPreloaded', 'error':7200}
            response = self.demHelper.encode(jsonError)
            return response.encode()
Example #4
0
def privateFilesExist(meetingID):
    # JSON Response BEGIN (error message)
    jsonError = jsonObject()
    jsonError.clearResponse()
    jsonError.add('result','false')
    jsonError.add('method','privateFilesExist')
    jsonError.add('meetingID', meetingID)
    #JSON Response END
    
    # JSON Response BEGIN (success message)
    jsonSuccess = jsonObject()
    jsonSuccess.clearResponse()
    jsonSuccess.add('result','true')
    jsonSuccess.add('method','privateFilesExist')
    jsonSuccess.add('meetingID', meetingID)
    #JSON Response END
    
    if meetingID == '':
        return jsonError.jsonResponse()
    
    folderName = os.path.join(filemgrArchive, meetingID);
    
    if not os.path.exists(folderName):
        return jsonError.jsonResponse()
    
    filelist = os.listdir(folderName)
    
    if len(filelist) == 0:
        return jsonError.jsonResponse()
    
    fileListBuffer = '['
    for i in range (0, len(filelist)):
        if os.path.isdir(os.path.join(folderName, filelist[i])):
            continue
        fileJSON = jsonObject()
        fileJSON.clearResponse()
        fileJSON.add('fileName', filelist[i])
        fileListBuffer += fileJSON.jsonResponse()
        if i < (len(filelist) - 1):
            fileListBuffer += ','
            
    fileListBuffer += ']'
    jsonSuccess.add('files', fileListBuffer)
    accessPath = os.path.basename(filemgrArchive) + '/' + meetingID
    jsonSuccess.add('path',accessPath)
    return jsonSuccess.jsonResponse()

    jsonSuccess.add('files', filelist)
    accessPath = os.path.basename(filemgrArchive) + '/' + meetingID
    jsonSuccess.add('path',accessPath)
    return jsonSuccess.jsonResponse()
Example #5
0
    def startDocumentConversion(self, docID, docName, meetingID, roomID, sessionID, docType, uploadType):

        # 'uploadType accepts "global" or "preloaded". If neither is specified, it is assumed as a regular presentation.
        # if the type is global, "global-meeting" is used as a meeting key. Any meeting ID specified is discarded

        errorjson = jsonObject()
        errorjson.clearResponse()
        errorjson.add('result', 'false')
        errorjson.add('method', 'startDocumentConversion')
        errorjson.add('meetingID', meetingID)
        errorjson.add('docID', docID)

        type = string.lower(uploadType)

        fileStoreLocation = os.path.join(mediaDirectory, docID)
        fileStoreLocation += '.' + str(docType)

        if not os.path.isfile(fileStoreLocation):
            errorjson.add('error', '7404')       # file not found. not uploaded properly
            return errorjson.jsonResponse()

        xPorter = None
        try:
            xPorter = exportEngine(meetingID, roomID, sessionID, fileStoreLocation, docID, uploadType, docName, docType, self.officeLock, self.pdfLock, self.collator)
            self.processMap[docID] = xPorter
            xPorter.start()

            # job created. register in collator
            self.collator.register(docID)

        except:
            errorjson.add('error', '7503')      # service not available. unable to convert
            return errorjson.jsonResponse()

        # JSON Response BEGIN
        jsondata = jsonObject()
        jsondata.clearResponse()
        jsondata.add('result','true')
        jsondata.add('method','startDocumentConversion')
        #jsondata.add('docName',docName)
        jsondata.add('docID',docID)
        jsondata.add('docType', docType)
        jsondata.add('meetingID', meetingID)
        #JSON Response END

        doc = xml.dom.minidom.Document()
        textNode = doc.createElement("jb")
        textNode.appendChild(doc.createTextNode(jsondata.jsonResponse()))
        doc.appendChild(textNode)

        return jsondata.jsonResponse()
Example #6
0
    def getDocumentData(self, meetingID, docID, strictJSON=False):
        slidedeckArchive = osconfig.slidedeckArchive()
        [installationID, dimdimID] = osconfig.splitIdentity(meetingID)
        meetingID = installationID + '____' + dimdimID
        jsonSuccess = jsonObject()
        jsonSuccess.clearResponse()
        jsonSuccess.add('result', 'true')
        jsonSuccess.add('method', 'getDocumentData')
        jsonSuccess.add('meetingID', meetingID)
        entries = self.findDocuments(slidedeckArchive, meetingID, docID)
        
        strictSuccess = {'result' : 'true', 'method' : 'getDocumentData', 'meetingID' : meetingID}

        if len(entries) == 0:
            if not strictJSON:
                jsonError = jsonObject()
                jsonError.clearResponse()
                jsonError.add('result', 'false')
                jsonError.add('method', 'getDocumentData')
                jsonError.add('meetingID', meetingID)
                jsonError.add('docID', docID)
                jsonError.add('error', '7404')
                return jsonError.jsonResponse()
            else:
                strictError = {'result':'false', 'method':'getDocumentData', 'meetingID':meetingID, 'docID':docID, 'error':7404}
                response = self.demHelper.encode(strictError)
                return response.encode()

        if not strictJSON:
            for i in range(0, len(entries)):
                fp = serialObject()
                fp.clearBuffer()
                fp.importData(entries[i])
                #jsonSuccess.add('docName', fp.get('docName'))
                jsonSuccess.add('docID', docID)
                jsonSuccess.add('docName', fp.get('docName'))
                jsonSuccess.add('noOfPages', string.atoi(fp.get('noOfPages')))
                jsonSuccess.add('width', fp.get('width'))
                jsonSuccess.add('height', fp.get('height'))
            jsonSuccess.add('error', '7200')
            return jsonSuccess.jsonResponse()
        else:
            for i in range(0, len(entries)):
                fp = serialObject()
                fp.clearBuffer()
                fp.importData(entries[i])
                strictSuccess.update({'docID':docID, 'docName':fp.get('docName'), 'noOfPages' : string.atoi(fp.get('noOfPages')), \
                                      'width': string.atoi(fp.get('width')), 'height': string.atoi(fp.get('height'))})
                
            response = self.demHelper.encode(strictSuccess)
            return response.encode()
Example #7
0
    def deletePreloadedDocuments(self, meetingID, strictJSON = False):

        if sys.platform.startswith('win'):
            archiveDirectory = string.rstrip(osconfig.slidedeckArchive(), '\\')
        else:
            archiveDirectory = osconfig.slidedeckArchive()

        preloadedDocDir = os.path.join(os.path.join(archiveDirectory, meetingID), 'Preloaded')

        try:
            shutil.rmtree(preloadedDocDir)
        except:
            pass

        if not strictJSON:
            # JSON Response BEGIN
            jsondata = jsonObject()
            jsondata.clearResponse()
            jsondata.add('result','true')
            jsondata.add('method','deletePreloadedDocuments')
            jsondata.add('meetingID', meetingID)
            jsondata.add('error', '7200')
            #JSON Response END
    
            return jsondata.jsonResponse()
        else:
            jsondata = {'result' : 'true', 'method' : 'deletePreloadedDocuments', 'meetingID': meetingID, 'error' : 7200}
            response = self.demHelper.encode(jsondata)
            return response.encode()
Example #8
0
    def cancelDocumentConversion(self, docID, meetingID):
        jsondata = jsonObject()
        jsondata.clearResponse()
        [installationID, dimdimID] = osconfig.splitIdentity(meetingID)
        meetingID = installationID + '____' + dimdimID
        if self.processMap.has_key(docID):
            self.collator.setConversionState(docID, 'done')
            try:
                xPorter = self.processMap.get(docID)
                xPorter.cancelConversion(False)
                self.processMap.pop(docID)
                try:
                    del xPorter
                except:
                    pass
                jsondata.add('result','true')
                jsondata.add('method','cancelDocumentConversion')
                jsondata.add('docID',docID)
                jsondata.add('error', '7200')
            except:
                jsondata.add('result','false')
                jsondata.add('method', 'cancelDocumentConversion')
                jsondata.add('docID',docID)
                jsondata.add('error','7500')
        else:
            jsondata.add('result','false')
            jsondata.add('method', 'cancelDocumentConversion')
            jsondata.add('docID',docID)
            jsondata.add('error','7404')

        self.deleteDocument(docID, meetingID)
        return jsondata.jsonResponse()
Example #9
0
    def copyPreloadedDocument(self, sourceMeetingRoom, docID, destinationMeetingRoom, strictJSON=False):
        slidedeckArchive = osconfig.slidedeckArchive()

        sourcePath = os.path.join(os.path.join(os.path.join(slidedeckArchive, sourceMeetingRoom), 'Preloaded'), docID)
        destPath = os.path.join(os.path.join(os.path.join(slidedeckArchive, destinationMeetingRoom), 'Preloaded'), docID)
        if not os.path.isdir(sourcePath):
            if not strictJSON:
                jsonError = jsonObject()
                jsonError.clearResponse()
                jsonError.add('result', 'false')
                jsonError.add('method', 'copyPreloadedDocument')
                jsonError.add('error', '7404')
                return jsonError.jsonResponse()
            else:
                jsonError = {'result':'false', 'method':'copyPreloadedDocument', 'error':7404}
                response = self.demHelper.encode(jsonError)
                return response.encode()

        try:
            fileList = dir_util.copy_tree(sourcePath, destPath)
        except:
            if not strictJSON:
                jsonError = jsonObject()
                jsonError.clearResponse()
                jsonError.add('result', 'false')
                jsonError.add('method', 'copyPreloadedDocument')
                jsonError.add('error', '7500')
                return jsonError.jsonResponse()
            else:
                jsonError = {'result':'false', 'method':'copyPreloadedDocument', 'error':7500}
                response = self.demHelper.encode(jsonError)
                return response.encode()

        if not strictJSON:
            jsonError = jsonObject()
            jsonError.clearResponse()
            jsonError.add('result', 'true')
            jsonError.add('method', 'copyPreloadedDocument')
            jsonError.add('error', '7200')
            return jsonError.jsonResponse()
        else:
            jsonError = {'result':'true', 'method':'copyPreloadedDocument', 'error':7200}
            response = self.demHelper.encode(jsonError)
            return response.encode()
Example #10
0
 def closeMeeting(self, dimdimID):
     self.stateEngine.handleMeetingClose(dimdimID)
     
     jsonSuccess = jsonObject()
     jsonSuccess.clearResponse()
     jsonSuccess.add('result', 'true')
     jsonSuccess.add('method', 'closeMeeting')
     jsonSuccess.add('dimdimID', dimdimID)
     jsonSuccess.add('error', '7200')
     return jsonSuccess.jsonResponse()
Example #11
0
    def uploadPPTXSlide(self, docFile, meetingID, docID, docName, pageNo, noOfPages):
        # 'Type' will be 'regular', becuase PPTX slides are uploaded by the presenter
        # There is no conversion involved in this operation. We just need to commit this file to archive

        iPageNo = string.atoi(pageNo)
        iNoOfPages = string.atoi(noOfPages)

        jsonComplete = jsonObject()
        jsonComplete.clearResponse()
        jsonComplete.add('result', 'true')
        jsonComplete.add('method', 'uploadPPTXSlide')
        jsonComplete.add('docID', docID)

        slidedeckArchive = osconfig.slidedeckArchive()
        specArchive = os.path.join(slidedeckArchive, meetingID)

        if docID == 'GENERATE' or docID == '':
            docID = idgen.gen()

        specArchive = os.path.join(specArchive, docID)

        if not os.path.isdir(specArchive):
            os.makedirs(specArchive)

        storedFileName = os.path.join(specArchive, pageNo)
        storedFileName += ".jpg"

        if sys.platform.startswith('win'):
            storedFile = open(storedFileName, 'wb')
        else:
            storedFile = open(storedFileName, 'w')
        while True:
            data = docFile.file.read(8192)
            if not data:
                break
            storedFile.write(data)

        storedFile.close()

        if (iPageNo == iNoOfPages - 1):
            # store some details for probable future use
            storeObject = filehelper.serialObject()
            storeObject.clearBuffer()
            storeObject.add('docName', docName)
            storeObject.add('docID',docID)
            storeObject.add('noOfPages',noOfPages)
            dataStore = os.path.join(specArchive, 'documentData.txt');
            storeObject.exportData(dataStore)

            jsonComplete.add('complete', 'true')
            return jsonComplete.jsonResponse()

        jsonComplete.add('complete', 'false')
        return jsonComplete.jsonResponse()
Example #12
0
def deleteImageFiles(meetingID):
    # JSON Response BEGIN (error message)
    jsonError = jsonObject()
    jsonError.clearResponse()
    jsonError.add('result','false')
    jsonError.add('method','deleteImageFiles')
    #JSON Response END
    
    # JSON Response BEGIN (success message)
    jsonSuccess = jsonObject()
    jsonSuccess.clearResponse()
    jsonSuccess.add('result','true')
    jsonSuccess.add('method','deleteImageFiles')
    #JSON Response END
    
    if meetingID == '':
        return jsonError.jsonResponse()
    
    pathEntries = filehelper.searchPathByKeyword(filemgrArchive, meetingID)
    
    if len(pathEntries) == 0:
        return jsonError.jsonResponse()
    
    if sys.platform.startswith('win'):
        accessPath = filemgrArchive + '\\' + meetingID
    else:
        accessPath = filemgrArchive + '/' + meetingID

    try:
        for root, dirs, files in os.walk(accessPath):
            for name in files:
                if string.find(name, 'dimdim_logo.') >= 0:
                    if sys.platform.startswith('win'):
                        os.remove(accessPath + '\\' + name)
                    else:
                        os.remove(accessPath + '/' + name)
    except:
        return jsonError.jsonResponse()
           
    return jsonSuccess.jsonResponse()
Example #13
0
    def uploadDocument(self, docFile, meetingID, roomID, sessionID, docID, docType, uploadType):

        # 'uploadType' accepts "global" or "preloaded". If neither is specified, it is assumed as a regular presentation.
        # if the type is global, "global-meeting" is used as a meeting key. Any meeting ID specified is discarded
        oosetupsemaphore = threading.BoundedSemaphore(1)
        if not docType == 'pdf':
            #print 'in upload document function'
            self.isOOHealthy = self.checkOO()
            #print self.isOOHealthy+' ooHealthy'
            if self.isOOHealthy=="False":
                oosetupsemaphore.acquire()
                self.startOO()
                oosetupsemaphore.release()
        uploadType = string.lower(uploadType)

        if docID == 'GENERATE' or docID == '':
            docID = idgen.gen()

        fileStoreLocation = os.path.join(mediaDirectory, docID)
        fileStoreLocation += '.' + docType
        storedFile = None
        if sys.platform.startswith('win'):
            storedFile = open(fileStoreLocation, 'wb')
        else:
            storedFile = open(fileStoreLocation, 'w')
        while True:
            data = docFile.file.read(8192)
            if not data:
                break
            storedFile.write(data)

        storedFile.close()
        xPorter = exportEngine(meetingID, roomID, sessionID, fileStoreLocation, docID, uploadType, os.path.basename(docFile.filename), docType, self.officeLock, self.pdfLock, self.collator)

        self.processMap[docID] = xPorter
        xPorter.start()

        # JSON Response BEGIN
        jsondata = jsonObject()
        jsondata.clearResponse()
        jsondata.add('result','true')
        jsondata.add('method','uploadDocument')
        jsondata.add('docName',os.path.basename(docFile.filename))
        jsondata.add('docType',docType)
        jsondata.add('docID',docID)
        #JSON Response END

        return jsondata.jsonResponse()
Example #14
0
    def uploadPreloadedDocument(self, docFile, fileName, meetingID, docID, docType, strictJSON = False):

         # fileName can be empty. If that is the case, we take the name from the file object

        if docID == 'GENERATE' or docID == '':
            docID = idgen.gen()

        fileStoreLocation = os.path.join(mediaDirectory, docID)
        fileStoreLocation += '.' + docType
        storedFile = None
        if sys.platform.startswith('win'):
            storedFile = open(fileStoreLocation, 'wb')
        else:
            storedFile = open(fileStoreLocation, 'w')
        while True:
            data = docFile.file.read(8192)
            if not data:
                break
            storedFile.write(data)

        storedFile.close()

        if len(fileName) == 0:
            fileName = os.path.basename(docFile.filename)

        xPorter = exportEngine(meetingID, '', '', fileStoreLocation, docID, 'preloaded', fileName, docType, self.officeLock, self.pdfLock, self.collator)

        self.processMap[docID] = xPorter
        xPorter.start()

        if not strictJSON:
            # JSON Response BEGIN
            jsondata = jsonObject()
            jsondata.clearResponse()
            jsondata.add('result','true')
            jsondata.add('method','uploadPreloadedDocument')
            jsondata.add('docName',fileName)
            jsondata.add('docType',docType)
            jsondata.add('docID',docID)
            #JSON Response END
    
            return jsondata.jsonResponse()
        else:
            strictData = {'result' : 'true', 'method' : 'uploadPreloadedDocument', 'docName' : fileName, 'docType' : docType, 'docID': docID}
            response = self.demHelper.encode(strictData)
            return response.encode()
Example #15
0
 def syncToResource(self, dimdimID, roomID, sessionID, resourceID, returnType):
     
     # navigate to the given resource first
     self.stateEngine.navigateToResource(dimdimID, resourceID)
     self.stateEngine.resetCurrentResource(dimdimID)
     self.stateEngine.trimResourceToCurrentPage(dimdimID)
     
     # prepare attendee and presenter cache with current state
     resource = self.stateEngine.getCurrentResource(dimdimID)
     resourceType = self.stateEngine.getCurrentResourceType(dimdimID)
     
     currentPageNum = resource.get('currentPage')
     
     # prepare cache
     presenterLocation = resourceType + '/' + resourceID + '/' + str(currentPageNum) + '/presenter/content.html'
     presenterCache = string.replace(self.presenterCacheBuffer, 'DIMDIMSL_COB_CONTENT_SRC', presenterLocation)
     
     attendeeLocation = resourceType + '/' + resourceID + '/' + str(currentPageNum) + '/attendee/content.html'
     attendeeCache = string.replace(self.attendeeCacheBuffer, 'DIMDIMSL_COB_CONTENT_SRC', attendeeLocation)
     
     pCacheLocation = os.path.join(os.path.join(osconfig.cobArchive(), dimdimID), 'p_cache.html')
     pCacheHandle = open(pCacheLocation, 'wb')
     pCacheHandle.write(presenterCache)
     pCacheHandle.close()
     
     aCacheLocation = os.path.join(os.path.join(osconfig.cobArchive(), dimdimID), 'a_cache.html')
     aCacheHandle = open(aCacheLocation, 'wb')
     aCacheHandle.write(attendeeCache)
     aCacheHandle.close()
     
     if returnType == 'method':
         return 'cobCallback(\''+str(dimdimID) + '\')'
     
     jsonSuccess = jsonObject()
     jsonSuccess.clearResponse()
     jsonSuccess.add('result', 'true')
     jsonSuccess.add('method', 'syncToURLResource')
     jsonSuccess.add('error', '7200')
     jsonSuccess.add('location', '/content/' + str(dimdimID))
     
     logManager.log('Meeting ' + dimdimID + ' synced to resource ' + resourceID, logging.INFO)
     
     return jsonSuccess.jsonResponse()
Example #16
0
    def uploadPreloadedDocumentWithPath(self, filePath, fileName, meetingID, docID, docType, strictJSON = False):

        if docID == 'GENERATE' or docID == '':
            docID = idgen.gen()

        docPath = os.path.join(osconfig.preloadedDocumentRoot(),filePath)
        if not os.path.isfile(docPath):
            return 'invalid file location'

        fileStoreLocation = os.path.join(mediaDirectory, docID)
        fileStoreLocation += '.' + docType

        # copy the file from location to media directory

        if sys.platform.startswith('win'):
            os.system('copy ' + docPath + ' ' + fileStoreLocation)
        else:
            os.system('cp ' + docPath + ' ' + fileStoreLocation)

        if len(fileName) == 0:
            fileName = os.path.basename(docPath)
        xPorter = exportEngine(meetingID, '', '', fileStoreLocation, docID, 'preloaded', fileName, docType, self.officeLock, self.pdfLock, self.collator)

        self.processMap[docID] = xPorter
        xPorter.start()
        
        if not strictJSON:
            # JSON Response BEGIN
            jsondata = jsonObject()
            jsondata.clearResponse()
            jsondata.add('result','true')
            jsondata.add('method','uploadPreloadedDocumentWithPath')
            jsondata.add('docName',fileName)
            jsondata.add('docType',docType)
            jsondata.add('docID',docID)
            #JSON Response END
    
            return jsondata.jsonResponse()
        else:
            jsondata = {'result': 'true', 'method' : 'uploadPreloadedDocumentWithPath', 'docName': fileName, 'docType' : docType, 'docID' : docID}
            response = self.demHelper.encode(jsondata)
            return response.encode()
Example #17
0
    def uploadPreloadedDocumentWithURL(self, fileURL, fileName, meetingID, docID, docType, strictJSON = False):

         # fileName can be empty. If that is the case, we take the name from the url using os.path.basename

        fileStoreLocation = os.path.join(mediaDirectory, docID)
        fileStoreLocation += '.' + docType

        # download the file to media directory

        retval = self.curlHandle.downloadToFileFromHTTPURL(fileURL, fileStoreLocation)
        if retval == 0:
            return 'unable to download file'
        if retval == -1:
            return 'internal exception in downloading file'
        if retval == -2:
            return 'unable to create local copy due to access privileges'

        if len(fileName) == 0:
            fileName = os.path.basename(fileURL)
        xPorter = exportEngine(meetingID, '', '', fileStoreLocation, docID, 'preloaded', fileName, docType, self.officeLock, self.pdfLock, self.collator)

        self.processMap[docID] = xPorter
        xPorter.start()
        
        if not strictJSON:
            # JSON Response BEGIN
            jsondata = jsonObject()
            jsondata.clearResponse()
            jsondata.add('result','true')
            jsondata.add('method','uploadPreloadedDocumentWithURL')
            jsondata.add('docName',fileName)
            jsondata.add('docType',docType)
            jsondata.add('docID',docID)
            #JSON Response END
            
            return jsondata.jsonResponse()
        
        else:
            strictData = {'result' : 'true', 'method' : 'uploadPreloadedDocumentWithURL', 'docName' : fileName, 'docType' : docType, 'docID': docID}
            response = self.demHelper.encode(strictData)
            return response.encode()
Example #18
0
    def listDocuments(self, meetingID, strictJSON = False):
        slidedeckArchive = osconfig.slidedeckArchive()
        [installationID, dimdimID] = osconfig.splitIdentity(meetingID)
        meetingID = installationID + '____' + dimdimID
        jsondata = jsonObject()
        jsondata.clearResponse()
        entries = self.findMeetingDocuments(slidedeckArchive, meetingID)

        if len(entries) == 0:
            if not strictJSON:
                jsondata.add('result', 'false')
                jsondata.add('method', 'listDocuments')
                jsondata.add('error', '7404')
                jsondata.add('meetingID', meetingID)
                return jsondata.jsonResponse()
            else:
                jsondata = {'result':'false', 'method':'listDocuments', 'error':7404, 'meetingID':meetingID}
                response = self.demHelper.encode(jsondata)
                return response.encode()
            
        if not strictJSON:
            jsondata.add('result', 'true')
            jsondata.add('method', 'listDocuments')
            jsondata.add('meetingID', meetingID)
            jsondata.add('error', '7200')
    
            entryJSONValue = '['
            for i in range(0, len(entries)):
                entryJSON = jsonObject()
                entryJSON.clearResponse()
                fp = serialObject()
                fp.clearBuffer()
                fp.importData(entries[i])
                entryJSON.add('docName',fp.get('docName'))
                entryJSON.add('docID',fp.get('docID'))
                entryJSON.add('width', fp.get('width'))
                entryJSON.add('height', fp.get('height'))
                entryJSON.add('noOfPages',string.atoi(fp.get('noOfPages')))
                if entries[i].find('global-meeting') >= 0:
                    entryJSON.add('Type', "global")
                else:
                    entryJSON.add('Type', "preloaded")
                entryJSONValue += entryJSON.jsonResponse()
                if i < len(entries) -1:
                    entryJSONValue += ','
    
            entryJSONValue += ']'
            jsondata.add('docs',entryJSONValue)
            return jsondata.jsonResponse()
        else:
            jsondata = {'result':'true', 'method':'listDocuments', 'meetingID':meetingID, 'error':7200}
            entryList = []
            for i in range(0, len(entries)):
                fp = serialObject()
                fp.clearBuffer()
                fp.importData(entries[i])
                entryMap = {'docName' : fp.get('docName'), 'docID' : fp.get('docID'), 'width' : string.atoi(fp.get('width')), \
                                        'height': string.atoi(fp.get('height')), 'noOfPages' : string.atoi(fp.get('noOfPages')) }
                if entries[i].find('global-meeting') >= 0:
                    entryMap.update({'Type':'global'})
                else:
                    entryMap.update({'Type' : 'preloaded'})
                entryList.append(entryMap)
            jsondata.update({'docs':entryList})
            response = self.demHelper.encode(jsondata)
            return response.encode()
Example #19
0
    def getDocumentStatus(self, docID, strictJSON = False):
        
        strictData = {}
        jsondata = jsonObject()
        jsondata.clearResponse()
        if self.processMap.has_key(docID):
            try:
                xPorter = self.processMap.get(docID)
                bPop = False
                if xPorter.errCode != 7200:

                    try:
                        if xPorter.docType == 'ppt':
                            self.collator.registerPPTFailure(docID, xPorter.meetingID)
                        elif xPorter.docType == 'pdf':
                            self.collator.registerPDFFailure(docID, xPorter.meetingID)
                    except:
                        pass
                    
                    if not strictJSON:
                        jsondata.add('result', 'false')
                        jsondata.add('method', 'getDocumentStatus')
                        jsondata.add('docID', docID)
                        jsondata.add('error', xPorter.errCode)
                    else:
                        strictData.update({'result' : 'false', 'method' : 'getDocumentStatus', 'docID' : docID, 'error' : xPorter.errCode})
                        
                    bPop = True
                    meetingID = xPorter.meetingID
                    self.collator.setConversionState(docID, 'done')
                    try:
                        xPorter.cancelConversion()
                    except:
                        pass

                    try:
                         self.deleteDocument(docID, meetingID, strictJSON)
                    except:
                        pass

                    try:
                        del xPorter
                    except:
                        pass

                    if not strictJSON:
                        return jsondata.jsonResponse()
                    else:
                        response = self.demHelper.encode(strictData)
                        return response.encode()
                    
                    
                if not strictJSON:
                    jsondata.add('result','true')
                    jsondata.add('method','getDocumentStatus')
                    jsondata.add('docID',docID)
                    jsondata.add('width',xPorter.width)
                    jsondata.add('height',xPorter.height)
                    jsondata.add('pagesConverted',xPorter.pagesConverted)
                    jsondata.add('totalPages',xPorter.totalPageCount)
                    jsondata.add('conversionComplete',xPorter.conversionComplete)
                    jsondata.add('error', '7200')
                else:
                    strictData.update({'result':'true', 'method':'getDocumentStatus', 'docID':docID, 'width':xPorter.width, 'height':xPorter.height, \
                                       'pagesConverted' : xPorter.pagesConverted, 'totalPages': xPorter.totalPageCount, \
                                       'conversionComplete':xPorter.conversionComplete, 'error':7200})


                if xPorter.conversionComplete == True:
                    bPop = True
                    try:
                        if xPorter.docType == 'pdf':
                            self.collator.resetPDFFailures()
                        else:
                            self.collator.resetUploadFailures()
                    except:
                        pass

                    try:
                        del xPorter
                    except:
                        pass

                if bPop:
                    self.processMap.pop(docID)

            except:
                jsondata.add('result', 'false')
                jsondata.add('method', 'getDocumentStatus')
                jsondata.add('docID', docID)
                jsondata.add('error', '7500')
                strictData.update({'result':'false', 'method':'getDocumentStatus', 'docID':docID, 'error':7500})
        else:
            if not strictJSON:
                jsondata.add('result','false')
                jsondata.add('method','getDocumentStatus')
                jsondata.add('docID',docID)
                jsondata.add('error','7404')
            else:
                strictData.update({'result':'false', 'method':'getDocumentStatus', 'docID':docID, 'error':7404})

        if not strictJSON:
            return jsondata.jsonResponse()
        else:
            response = self.demHelper.encode(strictData)
            return response.encode()
Example #20
0
    def listURLResources(self, dimdimID, bookmarkAction):
        jsonError = jsonObject()
        jsonError.clearResponse()
        jsonError.add('result', 'false')
        jsonError.add('method', 'listURLResources')
        jsonError.add('dimdimID', dimdimID)
        jsonError.add('error', '7404')
        
        meeting = self.stateEngine.getMeeting(dimdimID)
        if not meeting:
            # register the meeting first
            self.stateEngine.registerMeeting(dimdimID, bookmarkAction)
            return jsonError.jsonResponse()
        
        # update the bookmark action
        meeting.update({'bmAction' : bookmarkAction})
        
        jsonSuccess = jsonObject()
        jsonSuccess.clearResponse()
        jsonSuccess.add('result', 'true')
        jsonSuccess.add('method', 'listURLResources')
        entryJSONValue = '['
        count = 0

        resourceList = meeting.get('resources')
        regularList = resourceList.get('regular')
        preloadedList = resourceList.get('preloaded')
        noOfResources = len(regularList) + len(preloadedList)
        for (resourceID, resource) in regularList.iteritems():
            page = self.stateEngine.getCurrentPage(dimdimID)
            
            entryJSON = jsonObject()
            entryJSON.clearResponse()
            entryJSON.add('resourceID', resourceID)
            entryJSON.add('resourceType', 'regular')
            entryJSON.add('resourceURL', page.get('url'))
            entryJSONValue += entryJSON.jsonResponse()
            del entryJSON
            entryJSON = None
            
            if count < noOfResources - 1:
                entryJSONValue += ','
            count = count + 1
            
        for (resourceID, resource) in preloadedList.iteritems():
            page = self.stateEngine.getCurrentPage(dimdimID)
            
            entryJSON = jsonObject()
            entryJSON.clearResponse()
            entryJSON.add('resourceID', resourceID)
            entryJSON.add('resourceType', 'preloaded')
            entryJSON.add('resourceURL', page.get('url'))
            entryJSONValue += entryJSON.jsonResponse()
            del entryJSON
            entryJSON = None
            
            if count < noOfResources - 1:
                entryJSONValue += ','
            count = count + 1
            
        entryJSONValue += ']'

        jsonSuccess.add('resources',entryJSONValue)
        jsonSuccess.add('dimdimID', dimdimID)
        jsonSuccess.add('error', '7200')
        

        return jsonSuccess.jsonResponse()
Example #21
0
 def createURLResource(self, dimdimID, roomID, sessionID, encodedURL, resourceID = '_default', resourceType = 'regular'):
     
     # createURLResource is only called for a fresh resource
     
     jsonError = jsonObject()
     jsonError.clearResponse()
     jsonError.add('result', 'false')
     jsonError.add('method', 'cacheURL')
     jsonError.add('error', '7500')
     
     meeting = self.stateEngine.getMeeting(dimdimID)
     if not meeting:
         # register the meeting first
         # ideally, this call should never come..
         # meeting should be registered in listURLResources
         logManager.log('Detected that meeting ' + dimdimID + ' was never registered. This could mean that listURLResources was not called', logging.WARN)
         self.stateEngine.registerMeeting(dimdimID, '')
         self.stateEngine.registerMeeting(dimdimID, 'http://webmeeting.dimdim.com:80/dimdim/BookmarkCobResource.action')
         #return jsonError.jsonResponse()
     
     if resourceType != 'regular':
         resourceType = 'preloaded'
         
     if resourceID == '_default':
         resourceType = 'regular'    # can't have preloaded resources with _default
         
     originalURL = urllib.unquote(encodedURL)
     baseURL = self.baseURL(originalURL)
     
     pageNum = '0'       # duh! this is a new resource
     
     resourcePath = os.path.join(os.path.join(os.path.join(osconfig.cobArchive(), dimdimID), resourceType), resourceID)
     presenterPagePath = os.path.join(os.path.join(resourcePath, pageNum), 'presenter')
     attendeePagePath = os.path.join(os.path.join(resourcePath, pageNum), 'attendee')
     
     if not os.path.isdir(presenterPagePath):
         os.makedirs(presenterPagePath)
     if not os.path.isdir(attendeePagePath):
         os.makedirs(attendeePagePath)
     
     tempStore = os.path.join(resourcePath, 'temp.html')
     try:
         os.remove(tempStore)
     except:
         pass
     
     retval = self.curlHandle.downloadToFileFromHTTPURL(encodedURL, tempStore)
     
     if len(retval) < 3:
         try:
             shutil.rmtree(presenterPagePath)
             shutil.rmtree(attendeePagePath)
             os.remove(tempStore)
         except:
             pass
         return jsonError.jsonResponse()
     
     if originalURL != retval:
         # must be a 302. this is our new URL
         originalURL = retval
         baseURL = self.baseURL(originalURL)
         encodedURL = urllib.quote(originalURL)
         
     htmlHandle = open(tempStore, 'r')
     htmlContent = htmlHandle.read()
     htmlHandle.close()
     
     # inject baseURL
     htmlContent = contentMgr.sanitizeHTML(htmlContent, baseURL)
     self.prepareHtml(originalURL, htmlContent, presenterPagePath, attendeePagePath)
     
     # prepare cache
     presenterLocation = resourceType + '/' + resourceID + '/' + pageNum + '/presenter/content.html'
     presenterCache = string.replace(self.presenterCacheBuffer, 'DIMDIMSL_COB_CONTENT_SRC', presenterLocation)
     
     attendeeLocation = resourceType + '/' + resourceID + '/' + pageNum + '/attendee/content.html'
     attendeeCache = string.replace(self.attendeeCacheBuffer, 'DIMDIMSL_COB_CONTENT_SRC', attendeeLocation)
     
     pCacheLocation = os.path.join(os.path.join(osconfig.cobArchive(), dimdimID), 'p_cache.html')
     pCacheHandle = open(pCacheLocation, 'wb')
     pCacheHandle.write(presenterCache)
     pCacheHandle.close()
     
     aCacheLocation = os.path.join(os.path.join(osconfig.cobArchive(), dimdimID), 'a_cache.html')
     aCacheHandle = open(aCacheLocation, 'wb')
     aCacheHandle.write(attendeeCache)
     aCacheHandle.close()
     
     # clean up
     
     try:
         os.remove(tempStore)
     except:
         pass
     
     # register everything
     
     
     self.stateEngine.registerResource(dimdimID, resourceID, resourceType)
     self.stateEngine.registerPage(dimdimID, originalURL)
     
     jsonSuccess = jsonObject()
     jsonSuccess.clearResponse()
     jsonSuccess.add('result', 'true')
     jsonSuccess.add('method', 'cacheURL')
     jsonSuccess.add('error', '7200')
     jsonSuccess.add('location', '/content/' + str(dimdimID))
     
     return jsonSuccess.jsonResponse()
Example #22
0
    def deleteDocument(self, docID, meetingID, strictJSON = False):

        # JSON Response BEGIN (error message)
        
        strictdata = {'result' : 'false', 'method' : 'deleteDocument', 'docID' : docID, 'meetingID' : meetingID, 'error' : 7404}
        
        jsondata = jsonObject()
        jsondata.clearResponse()
        jsondata.add('result','false')
        jsondata.add('method','deleteDocument')
        jsondata.add('docID', docID)
        jsondata.add('meetingID', meetingID)
        jsondata.add('error', '7404')
        #JSON Response END

        if (docID == ''):
            if not strictJSON:
                return jsondata.jsonResponse()
            else:
                response = self.demHelper.encode(strictdata)
                return response.encode()
            

        if sys.platform.startswith('win'):
            archiveDirectory = string.rstrip(osconfig.slidedeckArchive(), '\\')
        else:
            archiveDirectory = osconfig.slidedeckArchive()

        # check if the directory exists, in global, preloaded and local

        localDocDir = os.path.join(os.path.join(archiveDirectory, meetingID), docID)
        preloadedDocDir = os.path.join(os.path.join(os.path.join(archiveDirectory, meetingID), 'Preloaded'), docID)
        globalDocDir = os.path.join(os.path.join(archiveDirectory, 'global-meeting'), docID)

        docPath = None
        if os.path.isdir(localDocDir):
            docPath = localDocDir
        if os.path.isdir(preloadedDocDir):
            docPath = preloadedDocDir
        if os.path.isdir(globalDocDir):
            if meetingID != 'global-meeting':   # we have already taken care of this
                docPath = globalDocDir

        if not docPath:
            return jsondata.jsonResponse()

        try:
            shutil.rmtree(docPath)
        except:
            pass

        if not strictJSON:
            # JSON Response BEGIN
            jsondata = jsonObject()
            jsondata.clearResponse()
            jsondata.add('result','true')
            jsondata.add('method','deleteDocument')
            jsondata.add('docID', docID)
            jsondata.add('meetingID', meetingID)
            jsondata.add('error', '7200')
            #JSON Response END
    
            return jsondata.jsonResponse()
        else:
            
            strictdata = {'result' : 'true', 'method' : 'deleteDocument', 'docID' : docID, 'meetingID' : meetingID, 'error' : 7200}
            response = self.demHelper.encode(strictdata)
            return response.encode()
Example #23
0
    def retrieveDocument(self, docID, meetingID, pageNo):
        [installationID, dimdimID] = osconfig.splitIdentity(meetingID)
        meetingID = installationID + '____' + dimdimID
        # JSON Response BEGIN (error message)
        jsondata = jsonObject()
        jsondata.clearResponse()
        jsondata.add('result','false')
        jsondata.add('method','retrieveDocument')
        jsondata.add('docID',docID)
        jsondata.add('meetingID',meetingID)
        jsondata.add('error', '7404')
        #JSON Response END

        if (docID == ''):
            return jsondata.jsonResponse()

        if sys.platform.startswith('win'):
            archiveDirectory = string.rstrip(osconfig.slidedeckArchive(), '\\')
        else:
            archiveDirectory = osconfig.slidedeckArchive()

        localDocDir = os.path.join(os.path.join(archiveDirectory, meetingID), docID)
        preloadedDocDir = os.path.join(os.path.join(os.path.join(archiveDirectory, meetingID), 'Preloaded'), docID)
        globalDocDir = os.path.join(os.path.join(archiveDirectory, 'global-meeting'), docID)

        docPath = None
        if os.path.exists(localDocDir):
            docPath = localDocDir
        if os.path.exists(preloadedDocDir):
            docPath = preloadedDocDir
        if os.path.exists(globalDocDir):
            docPath = globalDocDir

        if not docPath:
            self.collator.registerRetrieveFailure()
            return jsondata.jsonResponse()

        fileList = os.listdir(docPath)
        if len(fileList) <= 1:  # we need *atleast* 2 files. i.e. atleast 1 swf and 1 meta data file
            self.collator.registerRetrieveFailure()
            return jsondata.jsonResponse()

        swfpath = docPath
        jpgpath = docPath

        if sys.platform.startswith('win'):
           jpgpath += '\\' + pageNo + '.jpg'
           swfpath += '\\' + pageNo + '.swf'
        else:
           jpgpath += '/' + pageNo + '.jpg'
           swfpath += '/' + pageNo + '.swf'

        path = ''

        if os.path.isfile(swfpath):
            path = swfpath
        elif os.path.isfile(jpgpath):
            path = jpgpath
        else:
            self.collator.registerRetrieveFailure()
            return jsondata.jsonResponse()
        self.collator.resetRetrieveFailures()
        return static.serve_file(path,"application/octet-stream","inline",os.path.basename(path))