Skip to content

Commit

Permalink
add probe service to image annotations of not public (DLC-1171)
Browse files Browse the repository at this point in the history
  • Loading branch information
barmintor committed Nov 20, 2024
1 parent f2e5f38 commit a98f471
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/models/iiif/painting_annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def to_h

def annotation_body(routing_opts)
body = { 'type' => canvas.canvas_type }
catalog_id = canvas.solr_document.id
if body['type'] == Iiif::Type::V3::IMAGE
dimensions = canvas.dimensions.select {|k,h| k == :height or k == :width}.to_h.stringify_keys
body.merge!(IIIF_TEMPLATES['image_annotation_body'].deep_dup)
Expand All @@ -29,22 +30,22 @@ def annotation_body(routing_opts)
body['format'] = 'image/jpeg'
iiif_id = Dcv::Utils::CdnUtils.info_url(id: canvas.fedora_pid).sub(/\/info.json$/,'')
body['service'].first['@id'] = iiif_id
unless ability_helper.can_access_asset?(canvas.solr_document, Ability.new) # check if public
body['service'].first['service'] = [Iiif::Authz::V2::ProbeService.new(canvas, route_helper: route_helper, ability_helper: ability_helper)]
end
elsif body['type'] == Iiif::Type::V3::TEXT
body.merge!(IIIF_TEMPLATES['text_annotation_body'].deep_dup)
catalog_id = canvas.solr_document.id
bytestream_id = Dcv::Utils::UrlUtils.preferred_content_bytestream(canvas.solr_document)
body['id'] = route_helper.bytestream_content_url({catalog_id: catalog_id, filename: 'content.pdf', bytestream_id: bytestream_id, download: false})
body['service'] = [Iiif::Authz::V2::ProbeService.new(canvas, route_helper: route_helper, ability_helper: ability_helper)]
elsif body['type'] == Iiif::Type::V3::VIDEO || body['type'] == Iiif::Type::V3::SOUND
# use the video player for all AMI
body['type'] = Iiif::Type::V3::VIDEO
# media streaming with auth service
catalog_id = canvas.solr_document.id
bytestream_id = Dcv::Utils::UrlUtils.preferred_content_bytestream(canvas.solr_document)
body['id'] = route_helper.bytestream_resource_url(catalog_id: catalog_id, bytestream_id: bytestream_id)
body['service'] = [Iiif::Authz::V2::ProbeService.new(canvas, route_helper: route_helper, ability_helper: ability_helper)]
else
catalog_id = canvas.solr_document.id
filename = canvas.solr_document['label_ssi']
body['id'] = route_helper.bytestream_content_url({catalog_id: catalog_id, filename: filename, bytestream_id: 'content', download: true})
end
Expand Down

0 comments on commit a98f471

Please sign in to comment.