Example #1
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 #2
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 #3
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 #4
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 #5
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()