Sha256: 8f62e67a647a8251597c1dbf4050df919eb566fb78d2e1d5d2dcb3c9eceafc36

Contents?: true

Size: 871 Bytes

Versions: 36

Compression:

Stored size: 871 Bytes

Contents

require 'open3'

class ImportExportJob < ApplicationJob
  include Open3

  # @param resource [String] uri of the resource
  # @param mode [String] "import" or "export" mode
  # @param dir [String] location of export
  # TODO: Support BagIt profile
  def perform(resource:, mode: 'export', dir: Hyrax.config.bagit_dir)
    command = "java -jar #{Hyrax.config.import_export_jar_file_path} --mode #{mode} --resource #{resource} --dir #{dir}"
    internal_call(command)
  end

  private

    def internal_call(command)
      stdin, stdout, stderr, wait_thr = popen3(command)
      begin
        out = stdout.read
        err = stderr.read
        exit_status = wait_thr.value
        raise "Fedora command failed: \"#{command}\"\n#{err}" unless exit_status.success?
        out
      ensure
        stdin.close
        stdout.close
        stderr.close
      end
    end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/jobs/import_export_job.rb
hyrax-2.9.5 app/jobs/import_export_job.rb
hyrax-2.9.4 app/jobs/import_export_job.rb
hyrax-2.9.3 app/jobs/import_export_job.rb
hyrax-2.9.2 app/jobs/import_export_job.rb
hyrax-2.9.1 app/jobs/import_export_job.rb
hyrax-2.9.0 app/jobs/import_export_job.rb
hyrax-2.8.0 app/jobs/import_export_job.rb
hyrax-2.7.2 app/jobs/import_export_job.rb
hyrax-2.7.1 app/jobs/import_export_job.rb
hyrax-2.7.0 app/jobs/import_export_job.rb
hyrax-2.6.0 app/jobs/import_export_job.rb
hyrax-3.0.0.pre.rc1 app/jobs/import_export_job.rb
hyrax-3.0.0.pre.beta3 app/jobs/import_export_job.rb
hyrax-2.5.1 app/jobs/import_export_job.rb
hyrax-2.5.0 app/jobs/import_export_job.rb
hyrax-3.0.0.pre.beta2 app/jobs/import_export_job.rb
hyrax-2.4.1 app/jobs/import_export_job.rb
hyrax-3.0.0.pre.beta1 app/jobs/import_export_job.rb
hyrax-2.4.0 app/jobs/import_export_job.rb