Class: ImportUrlJob

Inherits:
Hyrax::ApplicationJob show all
Defined in:
app/jobs/import_url_job.rb

Overview

Note:

this is commonly called during deposit by AttachFilesToWorkJob (when files are uploaded directly as Hyrax::UploadedFile) and Hyrax::Actors::CreateWithRemoteFilesActor when files are located in some other service.

Given a FileSet that has an #import_url property, download that file and deposit into Fedora.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#file_setObject (readonly)

Returns the value of attribute file_set.



16
17
18
# File 'app/jobs/import_url_job.rb', line 16

def file_set
  @file_set
end

#headersObject (readonly)

Returns the value of attribute headers.



16
17
18
# File 'app/jobs/import_url_job.rb', line 16

def headers
  @headers
end

#operationObject (readonly)

Returns the value of attribute operation.



16
17
18
# File 'app/jobs/import_url_job.rb', line 16

def operation
  @operation
end

#uriObject (readonly)

Returns the value of attribute uri.



16
17
18
# File 'app/jobs/import_url_job.rb', line 16

def uri
  @uri
end

#userObject (readonly)

Returns the value of attribute user.



16
17
18
# File 'app/jobs/import_url_job.rb', line 16

def user
  @user
end

Instance Method Details

#perform(file_set, operation, headers = {}, use_valkyrie: false) ⇒ Object

TODO:

At present, this job works for ActiveFedora objects. The use_valkyrie is not complete.

Parameters:

  • file_set (FileSet)
  • operation (Hyrax::BatchCreateOperation)
  • headers (Hash) (defaults to: {})
    • header data to use in interaction with remote url

  • use_valkyrie (Boolean) (defaults to: false)
    • a switch on whether or not to use Valkyrie processing



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/jobs/import_url_job.rb', line 30

def perform(file_set, operation, headers = {}, use_valkyrie: false)
  @file_set = file_set
  @operation = operation
  @headers = headers
  operation.performing!
  @user = User.find_by_user_key(file_set.depositor)
  @uri = URI(file_set.import_url)

  return false unless can_retrieve_remote?

  if use_valkyrie
    # TODO
  else
    perform_af
  end
end