lib/sidekiq_workers.rb
# Converts a document file to a new format. The converted file will be stored in
# the document version directory. If the callback_url is specified, the [CallbackWorker]
# will be called to POST the conversion results back to the client application.
# @param doc_key_str [String] the serialised [DocKey]
# @param version [String] the file version
# @param filename [String] the file to convert
# @param action [String] the conversion to perform
# @param callback_url [String] optional callback URL
Converts a document file to a new format. The converted file will be stored in
the document version directory. If the callback_url is specified, the [CallbackWorker]
will be called to POST the conversion results back to the client application.
Converts a document file to a new format . The converted file will be stored in the document version directory . If the callback_url is specified the [ CallbackWorker ] will be called to POST the conversion results back to the client application .
def perform doc_key_str, version, filename, action, callback_url=nil
        doc_key = DocKey.parse doc_key_str
        new_filename = Converter.new.convert doc_key, version, filename, action
        status = 200
        message = "Document converted"
      rescue Heathen::TaskNotFound => e
        logger.warn "#{e.message}, will not attempt to re-process this request"
        log_error e, doc_key_str, filename, action
        status = 400
        message = e.message
      rescue StandardError => e
        logger.warn "#{e.message}, will not attempt to re-process this request"
        log_error e, doc_key_str, filename, action
        status = 500
        message = e.message
      ensure
        CallbackWorker.perform_async doc_key_str, version, action, new_filename, callback_url, status, message if callback_url
      end
def perform doc_key_str , version , filename , action , callback_url = nil doc_key = DocKey . parse doc_key_str new_filename = Converter . new . convert doc_key , version , filename , action status = 200 message = "Document converted" rescue Heathen :: TaskNotFound => e logger . warn "#{e.message}, will not attempt to re-process this request" log_error e , doc_key_str , filename , action status = 400 message = e . message rescue StandardError => e logger . warn "#{e.message}, will not attempt to re-process this request" log_error e , doc_key_str , filename , action status = 500 message = e . message ensure CallbackWorker . perform_async doc_key_str , version , action , new_filename , callback_url , status , message if callback_url end
Converts a document file to a new format.
Converts a document file to a new format .
doc_key_str
the serialised [DocKey]
the serialised [ DocKey ]
version
the file version
the file version
filename
the file to convert
the file to convert
action
the conversion to perform
the conversion to perform
callback_url
optional callback URL
optional callback URL