Example #1
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 #2
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 #3
0
    def __init__(self, meetingID, roomID, sessionID, location, docID,
                 uploadType, docName, docType, officeLock, pdfLock, collator):

        dThread.__init__(self)
        [installationID, dimdimID] = osconfig.splitIdentity(meetingID)
        self.meetingID = installationID + '____' + dimdimID

        self.docID = docID

        self.width = -1
        self.height = -1

        self.docType = docType
        self.docName = docName
        self.location = location
        #self.meetingID          = meetingID
        self.sessionID = sessionID

        self.roomID = roomID
        self.errCode = 7200
        self.uploadType = uploadType

        self.totalPageCount = 0
        self.pagesConverted = 0

        self.conversionComplete = False

        self.pdfLock = pdfLock
        self.stateLock = BoundedSemaphore(1)
        self.officeLock = officeLock

        self.collator = collator

        self.pdfLocked = False
        self.officeLocked = False

        self.destructTimer = None

        self.conversionState = 'CREATED'

        return
Example #4
0
    def __init__(self, meetingID, roomID, sessionID, location, docID, uploadType, docName, docType, officeLock, pdfLock, collator):

        dThread.__init__(self)
        [installationID, dimdimID] = osconfig.splitIdentity(meetingID)
        self.meetingID = installationID + '____' + dimdimID

        self.docID              = docID

        self.width              = -1
        self.height             = -1

        self.docType            = docType
        self.docName            = docName
        self.location           = location
        #self.meetingID          = meetingID
        self.sessionID          = sessionID

        self.roomID             = roomID
        self.errCode            = 7200
        self.uploadType         = uploadType

        self.totalPageCount     = 0
        self.pagesConverted     = 0

        self.conversionComplete = False

        self.pdfLock            = pdfLock
        self.stateLock          = BoundedSemaphore(1)
        self.officeLock         = officeLock

        self.collator           = collator

        self.pdfLocked          = False
        self.officeLocked       = False

        self.destructTimer      = None

        self.conversionState    = 'CREATED'

        return
Example #5
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))
Example #6
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()