Class: DeliveryJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
app/jobs/delivery_job.rb

Overview

Delivers derivatives to external services, like GeoServer

Instance Method Summary collapse

Instance Method Details

#content_url(file_set) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'app/jobs/delivery_job.rb', line 21

def content_url(file_set)
  case file_set.geo_mime_type
  when *GeoConcerns::RasterFormatService.select_options.map(&:last)
    return file_set.send(:derivative_url, 'display_raster')
  when *GeoConcerns::VectorFormatService.select_options.map(&:last)
    return file_set.send(:derivative_url, 'display_vector')
  else
    return ''
  end
end

#perform(message) ⇒ Object

Precondition is that all derivatives are created and saved.

Parameters:

  • file_set (FileSet)
  • content_url (String)

    contains the display copy to deliver

Raises:

  • (NotImplementedError)


13
14
15
16
17
18
19
# File 'app/jobs/delivery_job.rb', line 13

def perform(message)
  file_set = ActiveFedora::Base.find(message['id'])
  uri = URI.parse(content_url(file_set))
  return if uri.path == ''
  raise NotImplementedError, 'Only supports file URLs' unless uri.scheme == 'file'
  GeoConcerns::DeliveryService.new(file_set, uri.path).publish
end