Beispiel #1
0
def handleStorageResponse(message, event):
    headers = message.header_frame.headers or {}
    (context, session_data) = parse_headers(headers)
    if not context:
        # we will attach default context of an amqp message:
        # amqp folder.
        print "... no context at headers so try AMQP Folder as default context"
        pcatalog = api.portal.get_tool('portal_catalog') 
        context = pcatalog(portal_type="edeposit.content.amqpfolder")[0].getObject()
        session_data={}

    if "exception" in headers:
        amqpError = AMQPError(payload=message.body, 
                              exception_name = headers.get('exception_name'),
                              exception = headers.get('exception'),
                              headers = headers)
        getMultiAdapter((context,amqpError),IAMQPHandler).handle()
        message.ack()
    else:
        if not message.body:
            print "... old style message - without body. Ignoring message"
        else:
            result = _deserializeNT(message.body,globals())
            getMultiAdapter((context,result),IAMQPHandler).handle()
    
        message.ack()
Beispiel #2
0
def handleAntivirusResponse(message, event):
    print "handle antivirus response"
    wft = api.portal.get_tool('portal_workflow')
    headers = message.header_frame.headers
    (context, session_data) = parse_headers(headers)
    if not context:
        print "no context at headers"
        print message.body
        message.ack()
        return

    if "exception" in headers:
        amqpError = AMQPError(payload=message.body, 
                              exception_name = headers.get('exception_name'),
                              exception = headers.get('exception'),
                              headers = headers)
        getMultiAdapter((context,amqpError),IAMQPHandler).handle()
        message.ack()
    else:
        # Messages from Antivir has its own deserialization logic. 
        # So we will use it.
        result = _deserializeNT(message.body,globals())
        getMultiAdapter((context,result),IAMQPHandler).handle()
        message.ack()
    pass
Beispiel #3
0
def handleAlephResponse(message, event):
    print "handle aleph response"
    wft = api.portal.get_tool('portal_workflow')
    headers = message.header_frame.headers
    (context, session_data) = parse_headers(headers)
    if not context:
        print "... no context at headers, try use AMQPFolder context"
        print "... headers:", headers
        print message.body
        pcatalog = api.portal.get_tool('portal_catalog') 
        context = pcatalog(portal_type="edeposit.content.amqpfolder")[0].getObject()
 
    if "exception" in headers:
        amqpError = AMQPError(payload=message.body, 
                              exception_name = headers.get('exception_name'),
                              exception = headers.get('exception'),
                              headers = headers)
        getMultiAdapter((context,amqpError),IAMQPHandler).handle()
        message.ack()
    else:
        if not message.body:
            result = EmptyMessage()
            pass
        else:
            result = _deserializeNT(message.body,globals())
            #dataKeys = session_data.keys()

        # ResultFactory = None
        # if 'renew-records-for-sysnumber' in dataKeys:
        #     ResultFactory = AlephSearchDocumentResult
        # elif 'load-summary-record-for-sysnumber' in dataKeys:
        #     ResultFactory = AlephSearchSummaryRecordResult

        # if ResultFactory:
        #     records = result.records
        #     if records:
        #         newResult = ResultFactory(record = result.records[0])
        #         getMultiAdapter((context,newResult),IAMQPHandler).handle()
        #     else:
        #         print "... there are no records at the result"
        # else:
        getMultiAdapter((context,result),IAMQPHandler).handle()
        message.ack()
Beispiel #4
0
def handlePDFGenResponse(message, event):
    print "handle pdfgen response"
    wft = api.portal.get_tool('portal_workflow')
    headers = message.header_frame.headers
    (context, session_data) = parse_headers(headers)
    if not context:
        print "no context at headers"
        message.ack()
        return

    if "exception" in headers:
        amqpError = AMQPError(payload=message.body, 
                              exception_name = headers.get('exception_name'),
                              exception = headers.get('exception'),
                              headers = headers)
        getMultiAdapter((context,amqpError),IAMQPHandler).handle()
        message.ack()
    else:
        result = _deserializeNT(message.body,globals())
        getMultiAdapter((context,result),IAMQPHandler).handle()
        message.ack()