hyrax 3.0.0.pre.rc4 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +41 -8
- data/.dassie/Gemfile +10 -5
- data/.dassie/config/cable.yml +1 -1
- data/.dassie/config/environments/development.rb +2 -0
- data/.dassie/config/environments/production.rb +1 -1
- data/.dassie/config/initializers/hyrax.rb +5 -0
- data/.dassie/config/initializers/riiif.rb +22 -20
- data/.dassie/config/redis.yml +1 -0
- data/.dassie/config/role_map.yml +2 -0
- data/.dassie/db/seeds.rb +9 -1
- data/.dassie/package.json +3 -5
- data/.dockerignore +4 -0
- data/.env +1 -2
- data/.rubocop.yml +4 -0
- data/CONTAINERS.md +21 -1
- data/Dockerfile +46 -17
- data/Gemfile +21 -27
- data/app/actors/hyrax/actors/base_actor.rb +1 -1
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +89 -41
- data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
- data/app/actors/hyrax/actors/file_actor.rb +4 -2
- data/app/actors/hyrax/actors/file_set_actor.rb +18 -11
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +20 -8
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
- data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +38 -8
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +0 -4
- data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
- data/app/controllers/hyrax/dashboard/collection_members_controller.rb +13 -9
- data/app/controllers/hyrax/dashboard/collections_controller.rb +14 -14
- data/app/controllers/hyrax/file_sets_controller.rb +49 -13
- data/app/controllers/hyrax/permissions_controller.rb +3 -4
- data/app/controllers/hyrax/workflow_actions_controller.rb +3 -1
- data/app/forms/hyrax/forms/collection_form.rb +12 -6
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +24 -2
- data/app/forms/hyrax/forms/file_set_form.rb +46 -0
- data/app/forms/hyrax/forms/permission.rb +23 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
- data/app/forms/hyrax/forms/resource_form.rb +31 -13
- data/app/forms/hyrax/forms/work_form.rb +5 -2
- data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
- data/app/helpers/hyrax/collections_helper.rb +88 -2
- data/app/helpers/hyrax/dashboard_helper_behavior.rb +16 -5
- data/app/helpers/hyrax/embargo_helper.rb +4 -0
- data/app/helpers/hyrax/file_set_helper.rb +25 -6
- data/app/helpers/hyrax/hyrax_helper_behavior.rb +8 -0
- data/app/helpers/hyrax/lease_helper.rb +4 -0
- data/app/helpers/hyrax/url_helper.rb +4 -1
- data/app/helpers/hyrax/work_form_helper.rb +53 -0
- data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +118 -0
- data/app/indexers/hyrax/valkyrie_indexer.rb +10 -4
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +3 -1
- data/app/inputs/controlled_vocabulary_input.rb +2 -5
- data/app/jobs/attach_files_to_work_job.rb +19 -10
- data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
- data/app/jobs/embargo_expiry_job.rb +7 -5
- data/app/jobs/file_set_attached_event_job.rb +6 -1
- data/app/jobs/ingest_local_file_job.rb +18 -2
- data/app/jobs/inherit_permissions_job.rb +9 -5
- data/app/jobs/lease_expiry_job.rb +6 -4
- data/app/models/admin_set.rb +6 -25
- data/app/models/collection_branding_info.rb +25 -9
- data/app/models/concerns/hyrax/ability.rb +14 -1
- data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
- data/app/models/concerns/hyrax/embargoable.rb +24 -0
- data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
- data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -46
- data/app/models/concerns/hyrax/suppressible.rb +5 -0
- data/app/models/concerns/hyrax/user.rb +9 -3
- data/app/models/concerns/hyrax/work_behavior.rb +1 -1
- data/app/models/hyrax/file_set.rb +7 -0
- data/app/models/hyrax/pcdm_collection.rb +1 -0
- data/app/models/hyrax/permission_template.rb +98 -12
- data/app/models/hyrax/virus_scanner.rb +27 -18
- data/app/models/hyrax/work.rb +2 -0
- data/app/models/job_io_wrapper.rb +1 -1
- data/app/models/sipity/agent.rb +1 -0
- data/app/models/sipity/entity.rb +30 -8
- data/app/models/sipity/workflow.rb +1 -0
- data/app/models/sipity.rb +42 -0
- data/app/presenters/hyrax/admin_set_options_presenter.rb +12 -8
- data/app/presenters/hyrax/admin_set_presenter.rb +5 -1
- data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
- data/app/presenters/hyrax/collection_presenter.rb +41 -20
- data/app/presenters/hyrax/file_set_presenter.rb +6 -1
- data/app/presenters/hyrax/file_usage.rb +3 -2
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +119 -0
- data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
- data/app/presenters/hyrax/trophy_presenter.rb +33 -4
- data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
- data/app/presenters/hyrax/version_list_presenter.rb +19 -0
- data/app/presenters/hyrax/version_presenter.rb +3 -2
- data/app/presenters/hyrax/work_show_presenter.rb +30 -5
- data/app/presenters/hyrax/work_usage.rb +5 -3
- data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
- data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
- data/app/search_builders/hyrax/collection_member_search_builder.rb +6 -1
- data/app/search_builders/hyrax/my/collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/nested_collections_parent_search_builder.rb +1 -1
- data/app/search_builders/hyrax/single_collection_search_builder.rb +1 -1
- data/app/services/hyrax/access_control_list.rb +1 -1
- data/app/services/hyrax/adapters/nesting_index_adapter.rb +1 -1
- data/app/services/hyrax/admin_set_create_service.rb +3 -1
- data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
- data/app/services/hyrax/collections/collection_member_service.rb +112 -27
- data/app/services/hyrax/collections/migration_service.rb +4 -2
- data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
- data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
- data/app/services/hyrax/collections/permissions_create_service.rb +6 -4
- data/app/services/hyrax/contextual_path.rb +24 -1
- data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
- data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
- data/app/services/hyrax/edit_permissions_service.rb +74 -41
- data/app/services/hyrax/embargo_manager.rb +1 -1
- data/app/services/hyrax/find_objects_via_solr_service.rb +31 -0
- data/app/services/hyrax/graph_exporter.rb +1 -1
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +26 -0
- data/app/services/hyrax/listeners/metadata_index_listener.rb +18 -1
- data/app/services/hyrax/listeners/object_lifecycle_listener.rb +1 -1
- data/app/services/hyrax/listeners/trophy_cleanup_listener.rb +17 -0
- data/app/services/hyrax/listeners.rb +2 -0
- data/app/services/hyrax/multiple_membership_checker.rb +53 -29
- data/app/services/hyrax/persist_derivatives.rb +3 -1
- data/app/services/hyrax/resource_status.rb +7 -0
- data/app/services/hyrax/search_service.rb +4 -2
- data/app/services/hyrax/solr_query_builder_service.rb +45 -8
- data/app/services/hyrax/solr_query_service.rb +224 -0
- data/app/services/hyrax/solr_service.rb +8 -1
- data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
- data/app/services/hyrax/thumbnail_path_service.rb +1 -1
- data/app/services/hyrax/versioning_service.rb +1 -1
- data/app/services/hyrax/visibility_intention.rb +20 -2
- data/app/services/hyrax/visibility_propagator.rb +30 -1
- data/app/services/hyrax/work_uploads_handler.rb +22 -4
- data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
- data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
- data/app/services/hyrax/workflow/status_list_service.rb +43 -13
- data/app/views/hyrax/admin/admin_sets/_show_document_list_row.html.erb +1 -1
- data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
- data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
- data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
- data/app/views/hyrax/base/_form_representative.html.erb +1 -1
- data/app/views/hyrax/base/_form_share.html.erb +1 -5
- data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
- data/app/views/hyrax/base/_form_visibility_error.html.erb +2 -0
- data/app/views/hyrax/base/_guts4form.html.erb +3 -3
- data/app/views/hyrax/base/_representative_media.html.erb +1 -1
- data/app/views/hyrax/base/_show_actions.html.erb +2 -2
- data/app/views/hyrax/base/_work_button_row.html.erb +1 -1
- data/app/views/hyrax/base/_workflow_actions.html.erb +1 -1
- data/app/views/hyrax/batch_edits/edit.html.erb +2 -2
- data/app/views/hyrax/batch_uploads/_form.html.erb +1 -1
- data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/collections/_search_form.html.erb +1 -1
- data/app/views/hyrax/collections/show.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
- data/app/views/hyrax/file_sets/_actions.html.erb +10 -0
- data/app/views/hyrax/file_sets/edit.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
- data/app/views/hyrax/file_sets/show.html.erb +1 -1
- data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
- data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
- data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
- data/app/views/hyrax/stats/file.html.erb +1 -1
- data/app/views/hyrax/stats/work.html.erb +1 -1
- data/app/views/hyrax/uploads/_js_templates.html.erb +4 -4
- data/app/views/hyrax/uploads/_js_templates_versioning.html.erb +4 -4
- data/app/views/hyrax/users/_contributions.html.erb +1 -1
- data/app/views/hyrax/users/_profile_tabs.html.erb +2 -2
- data/app/views/hyrax/users/_search_form.html.erb +1 -1
- data/app/views/hyrax/users/_user.html.erb +1 -1
- data/app/views/hyrax/users/_user_info.html.erb +9 -9
- data/bin/db-migrate-seed.sh +6 -2
- data/bin/hyrax-entrypoint.sh +0 -14
- data/bin/solrcloud-assign-configset.sh +35 -0
- data/bin/solrcloud-upload-configset.sh +42 -0
- data/chart/hyrax/Chart.yaml +12 -8
- data/chart/hyrax/README.md +94 -11
- data/chart/hyrax/templates/NOTES.txt +1 -1
- data/chart/hyrax/templates/_helpers.tpl +98 -0
- data/chart/hyrax/templates/branding-pvc.yaml +14 -0
- data/chart/hyrax/templates/configmap-env.yaml +21 -11
- data/chart/hyrax/templates/cron-embargo.yaml +24 -0
- data/chart/hyrax/templates/cron-lease.yaml +24 -0
- data/chart/hyrax/templates/deployment-worker.yaml +129 -0
- data/chart/hyrax/templates/deployment.yaml +125 -4
- data/chart/hyrax/templates/derivatives-pvc.yaml +14 -0
- data/chart/hyrax/templates/ingress.yaml +13 -4
- data/chart/hyrax/templates/secrets.yaml +12 -2
- data/chart/hyrax/templates/uploads-pvc.yaml +14 -0
- data/chart/hyrax/values.yaml +186 -2
- data/config/brakeman.ignore +2 -2
- data/config/features.rb +47 -43
- data/config/initializers/listeners.rb +4 -0
- data/config/initializers/valkryrie_storage.rb +7 -0
- data/config/locales/hyrax.de.yml +1 -1
- data/config/locales/hyrax.en.yml +1 -1
- data/config/locales/hyrax.es.yml +1 -1
- data/config/locales/hyrax.fr.yml +1 -1
- data/config/locales/hyrax.it.yml +1 -1
- data/config/locales/hyrax.pt-BR.yml +1 -1
- data/config/locales/hyrax.zh.yml +1 -1
- data/docker-compose.yml +39 -8
- data/documentation/developing-your-hyrax-based-app.md +4 -4
- data/documentation/legacyREADME.md +3 -3
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
- data/lib/generators/hyrax/templates/config/initializers/riiif.rb +22 -20
- data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
- data/lib/hyrax/configuration.rb +28 -0
- data/lib/hyrax/engine.rb +3 -1
- data/lib/hyrax/errors.rb +2 -0
- data/lib/hyrax/resource_name.rb +1 -0
- data/lib/hyrax/specs/capybara.rb +5 -3
- data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
- data/lib/hyrax/transactions/container.rb +32 -1
- data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
- data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
- data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
- data/lib/hyrax/transactions/steps/delete_resource.rb +38 -0
- data/lib/hyrax/transactions/steps/destroy_work.rb +1 -0
- data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
- data/lib/hyrax/transactions/work_create.rb +2 -1
- data/lib/hyrax/transactions/work_destroy.rb +20 -0
- data/lib/hyrax/valkyrie_can_can_adapter.rb +3 -0
- data/lib/hyrax/valkyrie_simple_path_generator.rb +20 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/hyrax.rb +9 -0
- data/lib/tasks/collection_type_global_id.rake +1 -1
- data/lib/tasks/embargo_lease.rake +27 -0
- data/lib/tasks/regenerate_derivatives.rake +12 -0
- data/lib/wings/active_fedora_converter/default_work.rb +19 -0
- data/lib/wings/attribute_transformer.rb +29 -19
- data/lib/wings/converter_value_mapper.rb +2 -2
- data/lib/wings/model_transformer.rb +21 -20
- data/lib/wings/orm_converter.rb +42 -23
- data/lib/wings/setup.rb +2 -0
- data/lib/wings/valkyrie/persister.rb +8 -5
- data/lib/wings/valkyrie/query_service.rb +96 -41
- data/lib/wings/valkyrie/storage.rb +56 -1
- data/lib/wings.rb +0 -21
- data/template.rb +1 -1
- metadata +41 -21
- data/chart/fcrepo/.gitignore +0 -2
- data/chart/fcrepo/.helmignore +0 -23
- data/chart/fcrepo/Chart.yaml +0 -11
- data/chart/fcrepo/README.md +0 -50
- data/chart/fcrepo/templates/NOTES.txt +0 -21
- data/chart/fcrepo/templates/_helpers.tpl +0 -68
- data/chart/fcrepo/templates/configmap-env.yaml +0 -19
- data/chart/fcrepo/templates/deployment.yaml +0 -109
- data/chart/fcrepo/templates/ingress.yaml +0 -41
- data/chart/fcrepo/templates/pvc.yaml +0 -20
- data/chart/fcrepo/templates/secret.yaml +0 -12
- data/chart/fcrepo/templates/service.yaml +0 -15
- data/chart/fcrepo/templates/serviceaccount.yaml +0 -12
- data/chart/fcrepo/templates/tests/test-connection.yaml +0 -15
- data/chart/fcrepo/values.yaml +0 -79
- data/chart/hyrax/templates/fcrepo-secret.yaml +0 -13
data/Gemfile
CHANGED
|
@@ -1,44 +1,38 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
source 'https://rubygems.org'
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
source 'https://rubygems.org'
|
|
3
|
+
# Please see hyrax.gemspec for dependency information.
|
|
4
|
+
gemspec
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
end
|
|
6
|
+
group :development, :test do
|
|
7
|
+
gem 'benchmark-ips'
|
|
8
|
+
gem 'easy_translate'
|
|
9
|
+
gem 'i18n-tasks'
|
|
10
|
+
gem 'okcomputer'
|
|
11
|
+
gem 'pry' unless ENV['CI']
|
|
12
|
+
gem 'pry-byebug' unless ENV['CI']
|
|
13
|
+
gem 'ruby-prof', require: false
|
|
14
|
+
gem "simplecov", require: false
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
test_app_path = ENV['RAILS_ROOT'] ||
|
|
19
18
|
ENV.fetch('ENGINE_CART_DESTINATION', File.expand_path('.internal_test_app', File.dirname(__FILE__)))
|
|
20
19
|
test_app_gemfile = File.expand_path('Gemfile', test_app_path)
|
|
21
20
|
|
|
21
|
+
# rubocop:disable Bundler/DuplicatedGem
|
|
22
22
|
if File.exist?(test_app_gemfile)
|
|
23
23
|
begin
|
|
24
|
+
Bundler.ui.info "[Hyrax] Including test application dependencies from #{test_app_gemfile}"
|
|
24
25
|
eval_gemfile test_app_gemfile
|
|
25
26
|
rescue Bundler::GemfileError => e
|
|
26
27
|
Bundler.ui.warn '[Hyrax] Skipping Rails application dependencies:'
|
|
27
28
|
Bundler.ui.warn e.message
|
|
28
29
|
end
|
|
30
|
+
elsif ENV['RAILS_VERSION'] == 'edge'
|
|
31
|
+
gem 'rails', github: 'rails/rails', source: 'https://rubygems.org'
|
|
32
|
+
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks'
|
|
33
|
+
elsif ENV['RAILS_VERSION']
|
|
34
|
+
gem 'rails', ENV['RAILS_VERSION'], source: 'https://rubygems.org'
|
|
29
35
|
else
|
|
30
|
-
Bundler.ui.warn
|
|
31
|
-
|
|
32
|
-
# rubocop:disable Bundler/DuplicatedGem
|
|
33
|
-
if ENV['RAILS_VERSION']
|
|
34
|
-
if ENV['RAILS_VERSION'] == 'edge'
|
|
35
|
-
gem 'rails', github: 'rails/rails', source: 'https://rubygems.org'
|
|
36
|
-
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks'
|
|
37
|
-
else
|
|
38
|
-
gem 'rails', ENV['RAILS_VERSION'], source: 'https://rubygems.org'
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
# rubocop:enable Bundler/DuplicatedGem
|
|
42
|
-
|
|
43
|
-
eval_gemfile File.expand_path('spec/test_app_templates/Gemfile.extra', File.dirname(__FILE__))
|
|
36
|
+
Bundler.ui.warn '[Hyrax] Skipping all Rails dependency injection'
|
|
44
37
|
end
|
|
38
|
+
# rubocop:enable Bundler/DuplicatedGem
|
|
@@ -95,7 +95,7 @@ module Hyrax
|
|
|
95
95
|
def clean_attributes(attributes)
|
|
96
96
|
attributes[:license] = Array(attributes[:license]) if attributes.key? :license
|
|
97
97
|
attributes[:rights_statement] = Array(attributes[:rights_statement]) if attributes.key? :rights_statement
|
|
98
|
-
remove_blank_attributes!(attributes)
|
|
98
|
+
remove_blank_attributes!(attributes).except('file_set')
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
# If any attributes are blank remove them
|
|
@@ -26,64 +26,112 @@ module Hyrax
|
|
|
26
26
|
|
|
27
27
|
private
|
|
28
28
|
|
|
29
|
-
def
|
|
30
|
-
|
|
29
|
+
def attach_files(env, remote_files)
|
|
30
|
+
ingest_remote_files_service_class.new(user: env.user,
|
|
31
|
+
curation_concern: env.curation_concern,
|
|
32
|
+
remote_files: remote_files,
|
|
33
|
+
file_set_actor_class: file_set_actor_class).attach!
|
|
31
34
|
end
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
class IngestRemoteFilesService
|
|
37
|
+
##
|
|
38
|
+
# @parm user [User]
|
|
39
|
+
# @parm curation_concern [Hyrax::Work]
|
|
40
|
+
# @param remote_files [HashWithIndifferentAccess]
|
|
41
|
+
# @param file_set_actor_class
|
|
42
|
+
# @param ordered_members [Array]
|
|
43
|
+
# @param ordered [Boolean]
|
|
44
|
+
# rubocop:disable Metrics/ParameterLists
|
|
45
|
+
def initialize(user:, curation_concern:, remote_files:, file_set_actor_class:, ordered_members: [], ordered: false)
|
|
46
|
+
@remote_files = remote_files
|
|
47
|
+
@user = user
|
|
48
|
+
@curation_concern = curation_concern
|
|
49
|
+
@file_set_actor_class = file_set_actor_class
|
|
50
|
+
@ordered_members = ordered_members
|
|
51
|
+
@ordered = ordered
|
|
52
|
+
end
|
|
53
|
+
# rubocop:enable Metrics/ParameterLists
|
|
54
|
+
attr_reader :remote_files, :user, :curation_concern, :ordered_members, :ordered, :file_set_actor_class
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# @return true
|
|
58
|
+
def attach!
|
|
59
|
+
return true unless remote_files
|
|
60
|
+
remote_files.each do |file_info|
|
|
61
|
+
next if file_info.blank? || file_info[:url].blank?
|
|
62
|
+
# Escape any space characters, so that this is a legal URI
|
|
63
|
+
uri = URI.parse(Addressable::URI.escape(file_info[:url]))
|
|
64
|
+
unless self.class.validate_remote_url(uri)
|
|
65
|
+
Rails.logger.error "User #{user.user_key} attempted to ingest file from url #{file_info[:url]}, which doesn't pass validation"
|
|
66
|
+
return false
|
|
67
|
+
end
|
|
68
|
+
auth_header = file_info.fetch(:auth_header, {})
|
|
69
|
+
create_file_from_url(uri, file_info[:file_name], auth_header)
|
|
39
70
|
end
|
|
40
|
-
|
|
41
|
-
Rails.logger.debug "Assuming #{uri.scheme} uri is valid without a serious attempt to validate: #{uri}"
|
|
71
|
+
add_ordered_members! if ordered
|
|
42
72
|
true
|
|
43
73
|
end
|
|
44
|
-
end
|
|
45
74
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
def self.registered_ingest_dirs
|
|
76
|
+
Hyrax.config.registered_ingest_dirs
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# @param uri [URI] the uri fo the resource to import
|
|
80
|
+
def self.validate_remote_url(uri)
|
|
81
|
+
if uri.scheme == 'file'
|
|
82
|
+
path = File.absolute_path(CGI.unescape(uri.path))
|
|
83
|
+
registered_ingest_dirs.any? do |dir|
|
|
84
|
+
path.start_with?(dir) && path.length > dir.length
|
|
85
|
+
end
|
|
86
|
+
else
|
|
87
|
+
Rails.logger.debug "Assuming #{uri.scheme} uri is valid without a serious attempt to validate: #{uri}"
|
|
88
|
+
true
|
|
57
89
|
end
|
|
58
|
-
auth_header = file_info.fetch(:auth_header, {})
|
|
59
|
-
create_file_from_url(env, uri, file_info[:file_name], auth_header)
|
|
60
90
|
end
|
|
61
|
-
true
|
|
62
|
-
end
|
|
63
91
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
def create_file_from_url(uri, file_name, auth_header)
|
|
95
|
+
import_url = URI.decode_www_form_component(uri.to_s)
|
|
96
|
+
use_valkyrie = false
|
|
97
|
+
case curation_concern
|
|
98
|
+
when Valkyrie::Resource
|
|
99
|
+
file_set = Hyrax.persister.save(resource: Hyrax::FileSet.new(import_url: import_url, label: file_name))
|
|
100
|
+
use_valkyrie = true
|
|
101
|
+
else
|
|
102
|
+
file_set = ::FileSet.new(import_url: import_url, label: file_name)
|
|
103
|
+
end
|
|
104
|
+
__create_file_from_url(file_set: file_set, uri: uri, auth_header: auth_header, use_valkyrie: use_valkyrie)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def __create_file_from_url(file_set:, uri:, auth_header:, use_valkyrie: Hyrax.config.use_valkyrie?)
|
|
108
|
+
actor = file_set_actor_class.new(file_set, user, use_valkyrie: use_valkyrie)
|
|
109
|
+
actor.create_metadata(visibility: curation_concern.visibility)
|
|
110
|
+
actor.attach_to_work(curation_concern)
|
|
111
|
+
file_set.save! if file_set.respond_to?(:save!)
|
|
112
|
+
# We'll remember the order, but if it's not `@ordered` we won't do anything.
|
|
113
|
+
ordered_members << file_set
|
|
73
114
|
if uri.scheme == 'file'
|
|
74
115
|
# Turn any %20 into spaces.
|
|
75
116
|
file_path = CGI.unescape(uri.path)
|
|
76
|
-
IngestLocalFileJob.perform_later(
|
|
117
|
+
IngestLocalFileJob.perform_later(file_set, file_path, user)
|
|
77
118
|
else
|
|
78
|
-
ImportUrlJob.perform_later(
|
|
119
|
+
ImportUrlJob.perform_later(file_set, operation_for(user: user), auth_header)
|
|
79
120
|
end
|
|
80
121
|
end
|
|
81
|
-
end
|
|
82
122
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
123
|
+
def operation_for(user:)
|
|
124
|
+
Hyrax::Operation.create!(user: user,
|
|
125
|
+
operation_type: "Attach Remote File")
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def add_ordered_members!
|
|
129
|
+
actor = Hyrax::Actors::OrderedMembersActor.new(ordered_members, user)
|
|
130
|
+
actor.attach_ordered_members_to_work(curation_concern)
|
|
131
|
+
end
|
|
86
132
|
end
|
|
133
|
+
class_attribute :file_set_actor_class, default: ::Hyrax::Actors::FileSetActor
|
|
134
|
+
class_attribute :ingest_remote_files_service_class, default: ::Hyrax::Actors::CreateWithRemoteFilesActor::IngestRemoteFilesService
|
|
87
135
|
end
|
|
88
136
|
end
|
|
89
137
|
end
|
|
@@ -39,54 +39,19 @@ module Hyrax
|
|
|
39
39
|
# url property, it may have spaces, and not be a valid URI.
|
|
40
40
|
class CreateWithRemoteFilesOrderedMembersActor < CreateWithRemoteFilesActor
|
|
41
41
|
attr_reader :ordered_members
|
|
42
|
+
self.file_set_actor_class = Hyrax::Actors::FileSetOrderedMembersActor
|
|
42
43
|
|
|
43
44
|
# @param [HashWithIndifferentAccess] remote_files
|
|
44
45
|
# @return [TrueClass]
|
|
45
46
|
def attach_files(env, remote_files)
|
|
46
|
-
return true unless remote_files
|
|
47
47
|
@ordered_members = env.curation_concern.ordered_members.to_a
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return false
|
|
55
|
-
end
|
|
56
|
-
auth_header = file_info.fetch(:auth_header, {})
|
|
57
|
-
create_file_from_url(env, uri, file_info[:file_name], auth_header)
|
|
58
|
-
end
|
|
59
|
-
add_ordered_members(env.user, env.curation_concern)
|
|
60
|
-
true
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Generic utility for creating FileSet from a URL
|
|
64
|
-
# Used in to import files using URLs from a file picker like browse_everything
|
|
65
|
-
def create_file_from_url(env, uri, file_name, auth_header = {})
|
|
66
|
-
::FileSet.new(import_url: uri.to_s, label: file_name) do |fs|
|
|
67
|
-
actor = file_set_actor_class.new(fs, env.user)
|
|
68
|
-
actor.create_metadata(visibility: env.curation_concern.visibility)
|
|
69
|
-
actor.attach_to_work(env.curation_concern)
|
|
70
|
-
fs.save!
|
|
71
|
-
ordered_members << fs
|
|
72
|
-
if uri.scheme == 'file'
|
|
73
|
-
# Turn any %20 into spaces.
|
|
74
|
-
file_path = CGI.unescape(uri.path)
|
|
75
|
-
IngestLocalFileJob.perform_later(fs, file_path, env.user)
|
|
76
|
-
else
|
|
77
|
-
ImportUrlJob.perform_later(fs, operation_for(user: actor.user), auth_header)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
48
|
+
ingest_remote_files_service_class.new(user: env.user,
|
|
49
|
+
curation_concern: env.curation_concern,
|
|
50
|
+
remote_files: remote_files,
|
|
51
|
+
ordered_members: @ordered_members,
|
|
52
|
+
ordered: true,
|
|
53
|
+
file_set_actor_class: file_set_actor_class).attach!
|
|
80
54
|
end
|
|
81
|
-
|
|
82
|
-
# Add all file_sets as ordered_members in a single action
|
|
83
|
-
def add_ordered_members(user, work)
|
|
84
|
-
actor = Hyrax::Actors::OrderedMembersActor.new(ordered_members, user)
|
|
85
|
-
actor.attach_ordered_members_to_work(work)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
class_attribute :file_set_actor_class
|
|
89
|
-
self.file_set_actor_class = Hyrax::Actors::FileSetOrderedMembersActor
|
|
90
55
|
end
|
|
91
56
|
end
|
|
92
57
|
end
|
|
@@ -11,7 +11,7 @@ module Hyrax
|
|
|
11
11
|
# @param [FileSet] file_set the parent FileSet
|
|
12
12
|
# @param [Symbol, #to_sym] relation the type/use for the file
|
|
13
13
|
# @param [User] user the user to record as the Agent acting upon the file
|
|
14
|
-
def initialize(file_set, relation, user, use_valkyrie:
|
|
14
|
+
def initialize(file_set, relation, user, use_valkyrie: Hyrax.config.query_index_from_valkyrie)
|
|
15
15
|
@use_valkyrie = use_valkyrie
|
|
16
16
|
@file_set = file_set
|
|
17
17
|
@relation = normalize_relation(relation)
|
|
@@ -75,7 +75,7 @@ module Hyrax
|
|
|
75
75
|
CharacterizeJob.perform_later(file_set, repository_file.id, pathhint(io))
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
def perform_ingest_file_through_valkyrie(io)
|
|
78
|
+
def perform_ingest_file_through_valkyrie(io) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
79
79
|
file =
|
|
80
80
|
begin
|
|
81
81
|
Hyrax.storage_adapter.upload(resource: file_set, file: io, original_filename: io.original_name, use: relation)
|
|
@@ -87,7 +87,9 @@ module Hyrax
|
|
|
87
87
|
create_version(file_metadata, user)
|
|
88
88
|
id = file_metadata.file_identifier
|
|
89
89
|
file_set.file_ids << id
|
|
90
|
+
file_set.original_file_id = id
|
|
90
91
|
Hyrax.persister.save(resource: file_set)
|
|
92
|
+
Hyrax.publisher.publish('object.metadata.updated', object: file_set, user: user)
|
|
91
93
|
CharacterizeJob.perform_later(file_set, id.to_s, pathhint(io))
|
|
92
94
|
file_metadata
|
|
93
95
|
end
|
|
@@ -6,7 +6,7 @@ module Hyrax
|
|
|
6
6
|
include Lockable
|
|
7
7
|
attr_reader :file_set, :user, :attributes, :use_valkyrie
|
|
8
8
|
|
|
9
|
-
def initialize(file_set, user, use_valkyrie:
|
|
9
|
+
def initialize(file_set, user, use_valkyrie: Hyrax.config.query_index_from_valkyrie)
|
|
10
10
|
@use_valkyrie = use_valkyrie
|
|
11
11
|
@file_set = file_set
|
|
12
12
|
@user = user
|
|
@@ -31,10 +31,9 @@ module Hyrax
|
|
|
31
31
|
# hand. Do this because we don't have the underlying UploadedFile instance
|
|
32
32
|
file_actor = build_file_actor(relation)
|
|
33
33
|
file_actor.ingest_file(wrapper!(file: file, relation: relation))
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
InheritPermissionsJob.perform_later(file_set.parent)
|
|
34
|
+
parent = parent_for(file_set: file_set)
|
|
35
|
+
VisibilityCopyJob.perform_later(parent)
|
|
36
|
+
InheritPermissionsJob.perform_later(parent)
|
|
38
37
|
else
|
|
39
38
|
IngestJob.perform_later(wrapper!(file: file, relation: relation))
|
|
40
39
|
end
|
|
@@ -68,7 +67,6 @@ module Hyrax
|
|
|
68
67
|
yield(file_set) if block_given?
|
|
69
68
|
end
|
|
70
69
|
|
|
71
|
-
# Adds a FileSet to the work using ore:Aggregations.
|
|
72
70
|
# Locks to ensure that only one process is operating on the list at a time.
|
|
73
71
|
def attach_to_work(work, file_set_params = {})
|
|
74
72
|
acquire_lock_for(work.id) do
|
|
@@ -87,15 +85,18 @@ module Hyrax
|
|
|
87
85
|
def attach_to_valkyrie_work(work, file_set_params)
|
|
88
86
|
work = Hyrax.query_service.find_by(id: work.id) unless work.new_record
|
|
89
87
|
file_set.visibility = work.visibility unless assign_visibility?(file_set_params)
|
|
90
|
-
Hyrax.persister.save(resource: file_set)
|
|
91
|
-
|
|
92
|
-
work.
|
|
93
|
-
work.
|
|
88
|
+
fs = Hyrax.persister.save(resource: file_set)
|
|
89
|
+
Hyrax.publisher.publish('object.metadata.updated', object: fs, user: user)
|
|
90
|
+
work.member_ids << fs.id
|
|
91
|
+
work.representative_id = fs.id if work.representative_id.blank?
|
|
92
|
+
work.thumbnail_id = fs.id if work.thumbnail_id.blank?
|
|
94
93
|
# Save the work so the association between the work and the file_set is persisted (head_id)
|
|
95
94
|
# NOTE: the work may not be valid, in which case this save doesn't do anything.
|
|
96
95
|
Hyrax.persister.save(resource: work)
|
|
96
|
+
Hyrax.publisher.publish('object.metadata.updated', object: work, user: user)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
+
# Adds a FileSet to the work using ore:Aggregations.
|
|
99
100
|
def attach_to_af_work(work, file_set_params)
|
|
100
101
|
work.reload unless work.new_record?
|
|
101
102
|
file_set.visibility = work.visibility unless assign_visibility?(file_set_params)
|
|
@@ -136,6 +137,12 @@ module Hyrax
|
|
|
136
137
|
@ability ||= ::Ability.new(user)
|
|
137
138
|
end
|
|
138
139
|
|
|
140
|
+
# @param file_set [FileSet]
|
|
141
|
+
# @return [ActiveFedora::Base]
|
|
142
|
+
def parent_for(file_set:)
|
|
143
|
+
file_set.parent
|
|
144
|
+
end
|
|
145
|
+
|
|
139
146
|
def build_file_actor(relation)
|
|
140
147
|
fs = use_valkyrie ? file_set.valkyrie_resource : file_set
|
|
141
148
|
file_actor_class.new(fs, relation, user, use_valkyrie: use_valkyrie)
|
|
@@ -177,7 +184,7 @@ module Hyrax
|
|
|
177
184
|
# Although ActiveFedora clears the children nodes it leaves those fields in Solr populated.
|
|
178
185
|
# rubocop:disable Metrics/CyclomaticComplexity
|
|
179
186
|
def unlink_from_work
|
|
180
|
-
work = file_set
|
|
187
|
+
work = parent_for(file_set: file_set)
|
|
181
188
|
return unless work && (work.thumbnail_id == file_set.id || work.representative_id == file_set.id || work.rendering_ids.include?(file_set.id))
|
|
182
189
|
work.thumbnail = nil if work.thumbnail_id == file_set.id
|
|
183
190
|
work.representative = nil if work.representative_id == file_set.id
|
|
@@ -15,14 +15,17 @@ module Hyrax
|
|
|
15
15
|
class_attribute :presenter_class,
|
|
16
16
|
:form_class,
|
|
17
17
|
:single_item_search_builder_class,
|
|
18
|
-
:membership_service_class
|
|
18
|
+
:membership_service_class,
|
|
19
|
+
:parent_collection_query_service
|
|
19
20
|
|
|
20
21
|
self.presenter_class = Hyrax::CollectionPresenter
|
|
21
22
|
|
|
22
23
|
# The search builder to find the collection
|
|
23
24
|
self.single_item_search_builder_class = SingleCollectionSearchBuilder
|
|
24
25
|
# The search builder to find the collections' members
|
|
25
|
-
self.membership_service_class = Collections::
|
|
26
|
+
self.membership_service_class = Collections::CollectionMemberSearchService
|
|
27
|
+
# A search service to use in finding parent collections
|
|
28
|
+
self.parent_collection_query_service = Collections::NestedCollectionQueryService
|
|
26
29
|
end
|
|
27
30
|
|
|
28
31
|
def show
|
|
@@ -74,9 +77,9 @@ module Hyrax
|
|
|
74
77
|
end
|
|
75
78
|
|
|
76
79
|
def query_collection_members
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
load_member_works
|
|
81
|
+
load_member_subcollections if collection.collection_type.nestable?
|
|
82
|
+
load_parent_collections if collection.collection_type.nestable? && action_name == 'show'
|
|
80
83
|
end
|
|
81
84
|
|
|
82
85
|
# Instantiate the membership query service
|
|
@@ -89,12 +92,20 @@ module Hyrax
|
|
|
89
92
|
@member_docs = @response.documents
|
|
90
93
|
@members_count = @response.total
|
|
91
94
|
end
|
|
95
|
+
alias load_member_works member_works
|
|
92
96
|
|
|
93
|
-
|
|
97
|
+
##
|
|
98
|
+
# Handles paged loading for parent collections.
|
|
99
|
+
#
|
|
100
|
+
# @param the query service to use when searching for the parent collections.
|
|
101
|
+
# uses the class attribute +parent_collection_query_service+ by default.
|
|
102
|
+
def parent_collections(query_service: self.class.parent_collection_query_service)
|
|
94
103
|
page = params[:parent_collection_page].to_i
|
|
95
|
-
|
|
96
|
-
|
|
104
|
+
collection.parent_collections = query_service.parent_collections(
|
|
105
|
+
child: collection_object, scope: self, page: page
|
|
106
|
+
)
|
|
97
107
|
end
|
|
108
|
+
alias load_parent_collections parent_collections
|
|
98
109
|
|
|
99
110
|
def collection_object
|
|
100
111
|
action_name == 'show' ? Collection.find(collection.id) : collection
|
|
@@ -106,6 +117,7 @@ module Hyrax
|
|
|
106
117
|
@subcollection_docs = results.documents
|
|
107
118
|
@subcollection_count = @presenter.subcollection_count = results.total
|
|
108
119
|
end
|
|
120
|
+
alias load_member_subcollections member_subcollections
|
|
109
121
|
|
|
110
122
|
# You can override this method if you need to provide additional inputs to the search
|
|
111
123
|
# builder. For example:
|