Class: ResourceDuplicateRunner
- Defined in:
- backend/app/lib/job_runners/resource_duplicate_runner.rb
Instance Method Summary collapse
Methods inherited from JobRunner
#add_success_hook, #cancelation_signaler, #canceled?, for, #initialize, #parse_job_params_string, register_for_job_type, registered_job_types, registered_runner_for, #success!, #symbol_keys
Constructor Details
This class inherits a constructor from JobRunner
Instance Method Details
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'backend/app/lib/job_runners/resource_duplicate_runner.rb', line 8 def run begin RequestContext.open( :repo_id => @job.repo_id) do parsed = JSONModel.parse_reference(@json.job["source"]) resource_id = parsed[:id] @job.write_output(I18n.t("resource_duplicate_job.going_to_duplicate_job", resource_id: resource_id)) resource_duplicate = ::Lib::Resource::Duplicate.new(resource_id) resource_duplicate.duplicate if resource_duplicate.errors.length == 0 @job.write_output(I18n.t("resource_duplicate_job.success_message", resource_source_id: resource_id, resource_duplicated_id: resource_duplicate.resource.id)) @job.write_output(I18n.t('resource_duplicate_job.success_reload_message')) @job.record_created_uris([resource_duplicate.resource.uri]) return end resource_duplicate.errors.each do |error| @job.write_output(error[:error]) end end rescue Exception => e @job.write_output(e.) @job.write_output(e.backtrace) raise e end @job.write_output(I18n.t('resource_duplicate_job.job_failed')) raise 'Job Failed' end |