Skip to content

Commit a1dd098

Browse files
authored
Merge pull request #600 from IU-Libraries-Joint-Development/essi-1932_consolidate_fileset_job_calls
[ESSI-1932] consolidate FileSet Inherit, Copy job calls into work actor
2 parents a4a2c57 + 3a961e6 commit a1dd098

File tree

5 files changed

+62
-2
lines changed

5 files changed

+62
-2
lines changed

app/actors/essi/actors/create_with_remote_files_ordered_members_structure_actor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def create(env)
99

1010
def update(env)
1111
structure = env.attributes.delete(:structure)&.deep_symbolize_keys
12-
super(env) && save_structure(env,structure)
12+
super(env) && save_structure(env,structure) && copy_visibility(env) && inherit_permissions(env)
1313
end
1414

1515
private

lib/extensions/bulkrax/object_factory/create_with_dynamic_schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def create
77
attrs = create_attributes
88
init_attrs = { dynamic_schema_id: attrs[:dynamic_schema_id] } if attrs[:dynamic_schema_id].present? && klass.new.respond_to?(:dynamic_schema_id)
99
@object = klass.new(init_attrs)
10-
object.reindex_extent = ::Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
10+
object.reindex_extent = ::Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX if defined?(::Hyrax::Adapters::NestingIndexAdapter) && object.respond_to?(:reindex_extent=)
1111
run_callbacks :save do
1212
run_callbacks :create do
1313
klass == ::Collection ? create_collection(attrs) : work_actor.create(environment(attrs))

lib/extensions/extensions.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ def attribute_will_change!(attr)
9292
Hyrax::CurationConcern.actor_factory.swap Hyrax::Actors::CreateWithRemoteFilesActor, ESSI::Actors::CreateWithRemoteFilesOrderedMembersStructureActor
9393
Hyrax::CurationConcern.actor_factory.swap Hyrax::Actors::CreateWithFilesActor, Hyrax::Actors::CreateWithFilesOrderedMembersActor
9494
Hyrax::Actors::BaseActor.prepend Extensions::Hyrax::Actors::BaseActor::UndoAttributeArrayWrap
95+
Hyrax::Actors::FileSetActor.prepend Extensions::Hyrax::Actors::FileSetActor::CreateContent
96+
9597

9698
# .jp2 conversion settings
9799
Hydra::Derivatives.kdu_compress_path = ESSI.config.dig(:essi, :kdu_compress_path)
@@ -172,6 +174,9 @@ def attribute_will_change!(attr)
172174
IiifPrint::BlacklightIiifSearch::AnnotationDecorator.include Extensions::IiifPrint::BlacklightIiifSearch::AnnotationDecorator::AnnotationDecoratorCompatibility
173175
IiifPrint::IiifSearchDecorator.include Extensions::IiifPrint::IiifSearchDecorator::SearchDecoratorCompatibility
174176

177+
# Patch iiif_print FileSet job calls
178+
IiifPrint::Data.include Extensions::IiifPrint::Data::InheritPermissionsJobCalls
179+
175180
# support for nested works generating file_set sequences in manifests
176181
IIIFManifest::ManifestBuilder::DeepFileSetEnumerator.prepend Extensions::IIIFManifest::ManifestBuilder::DeepFileSetEnumerator::NestedEach
177182

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# modified to apply helper jobs to individual FileSet
2+
module Extensions
3+
module Hyrax
4+
module Actors
5+
module FileSetActor
6+
module CreateContent
7+
# Spawns asynchronous IngestJob unless ingesting from URL
8+
# Called from FileSetsController, AttachFilesToWorkJob, IngestLocalFileJob, ImportUrlJob
9+
# @param [Hyrax::UploadedFile, File] file the file uploaded by the user
10+
# @param [Symbol, #to_s] relation
11+
# @return [IngestJob, FalseClass] false on failure, otherwise the queued job
12+
def create_content(file, relation = :original_file, from_url: false)
13+
# If the file set doesn't have a title or label assigned, set a default.
14+
file_set.label ||= label_for(file)
15+
file_set.title = [file_set.label] if file_set.title.blank?
16+
return false unless file_set.save # Need to save to get an id
17+
if from_url
18+
# If ingesting from URL, don't spawn an IngestJob; instead
19+
# reach into the FileActor and run the ingest with the file instance in
20+
# hand. Do this because we don't have the underlying UploadedFile instance
21+
file_actor = build_file_actor(relation)
22+
file_actor.ingest_file(wrapper!(file: file, relation: relation))
23+
else
24+
IngestJob.perform_later(wrapper!(file: file, relation: relation))
25+
end
26+
end
27+
end
28+
end
29+
end
30+
end
31+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# modified from iiif_print
2+
# removes FileSet job calls handled elsewhere
3+
module Extensions
4+
module IiifPrint
5+
module Data
6+
module InheritPermissionsJobCalls
7+
def self.included(base)
8+
base.class_eval do
9+
# Handler for after_create_fileset, to be called by block subscribing to
10+
# and overriding default Hyrax `:after_create_fileset` handler, via
11+
# app integrating iiif_print.
12+
def self.handle_after_create_fileset(file_set, user)
13+
handle_queued_derivative_attachments(file_set)
14+
# Hyrax queues this job by default, and since iiif_print
15+
# overrides the single subscriber Hyrax uses to do so, we
16+
# must call this here:
17+
::FileSetAttachedEventJob.perform_later(file_set, user)
18+
end
19+
end
20+
end
21+
end
22+
end
23+
end
24+
end

0 commit comments

Comments
 (0)