hyrax 3.0.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +46 -13
- data/.dassie/Gemfile +11 -6
- data/.dassie/app/controllers/catalog_controller.rb +6 -0
- data/.dassie/config/initializers/hyrax.rb +5 -0
- data/.dassie/config/initializers/riiif.rb +22 -20
- data/.dassie/config/role_map.yml +2 -0
- data/.dassie/db/seeds.rb +1 -1
- data/.dassie/package.json +3 -5
- data/.dockerignore +3 -0
- data/.env +1 -2
- data/.rubocop.yml +4 -0
- data/CONTAINERS.md +21 -1
- data/Dockerfile +42 -17
- data/Gemfile +21 -27
- data/app/actors/hyrax/actors/base_actor.rb +2 -2
- data/app/actors/hyrax/actors/collections_membership_actor.rb +3 -3
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +85 -63
- data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
- data/app/actors/hyrax/actors/file_set_actor.rb +12 -5
- data/app/assets/stylesheets/hyrax/_styles.scss +5 -0
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +30 -10
- data/app/controllers/concerns/hyrax/controller.rb +13 -2
- 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 +22 -3
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +2 -19
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +5 -6
- data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
- data/app/controllers/hyrax/collections_controller.rb +3 -1
- data/app/controllers/hyrax/dashboard/collection_members_controller.rb +24 -17
- data/app/controllers/hyrax/dashboard/collections_controller.rb +99 -35
- data/app/controllers/hyrax/dashboard/nest_collections_controller.rb +75 -39
- data/app/controllers/hyrax/file_sets_controller.rb +49 -13
- data/app/controllers/hyrax/my_controller.rb +4 -4
- data/app/controllers/hyrax/permissions_controller.rb +3 -4
- data/app/controllers/hyrax/workflow_actions_controller.rb +11 -6
- data/app/forms/hyrax/forms/administrative_set_form.rb +62 -0
- data/app/forms/hyrax/forms/collection_form.rb +14 -8
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +38 -6
- data/app/forms/hyrax/forms/file_set_form.rb +46 -0
- data/app/forms/hyrax/forms/pcdm_collection_form.rb +64 -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 +34 -26
- data/app/forms/hyrax/forms/work_form.rb +5 -2
- data/app/forms/hyrax/forms/workflow_action_form.rb +4 -0
- 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 +9 -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/pcdm_collection_indexer.rb +2 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +2 -0
- data/app/indexers/hyrax/valkyrie_indexer.rb +4 -3
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +1 -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/ingest_local_file_job.rb +18 -2
- data/app/jobs/inherit_permissions_job.rb +9 -5
- data/app/models/admin_set.rb +22 -30
- data/app/models/collection_branding_info.rb +25 -9
- data/app/models/concerns/hyrax/ability/admin_set_ability.rb +31 -7
- data/app/models/concerns/hyrax/ability/collection_ability.rb +35 -20
- data/app/models/concerns/hyrax/ability/collection_type_ability.rb +1 -1
- data/app/models/concerns/hyrax/ability.rb +5 -3
- 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 +11 -54
- 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/administrative_set.rb +7 -1
- data/app/models/hyrax/file_set.rb +6 -0
- data/app/models/hyrax/pcdm_collection.rb +1 -0
- data/app/models/hyrax/permission.rb +1 -1
- data/app/models/hyrax/permission_template.rb +112 -12
- data/app/models/hyrax/virus_scanner.rb +27 -18
- data/app/models/hyrax/work.rb +1 -0
- data/app/models/hyrax/workflow_action_info.rb +16 -0
- data/app/models/sipity/agent.rb +1 -0
- data/app/models/sipity/comment.rb +17 -0
- data/app/models/sipity/entity.rb +30 -8
- data/app/models/sipity/workflow.rb +1 -0
- data/app/models/sipity.rb +53 -2
- data/app/presenters/hyrax/admin_set_options_presenter.rb +12 -8
- data/app/presenters/hyrax/admin_set_presenter.rb +13 -4
- data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
- data/app/presenters/hyrax/collection_presenter.rb +44 -23
- 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 +32 -6
- data/app/presenters/hyrax/work_usage.rb +5 -3
- data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
- data/app/search_builders/hyrax/abstract_type_relation.rb +4 -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/dashboard/collections_search_builder.rb +1 -1
- data/app/search_builders/hyrax/exposed_models_relation.rb +1 -1
- data/app/search_builders/hyrax/filter_by_type.rb +1 -2
- 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/admin_set_create_service.rb +136 -52
- data/app/services/hyrax/collection_types/permissions_service.rb +1 -1
- data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
- data/app/services/hyrax/collections/collection_member_service.rb +122 -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 +82 -78
- data/app/services/hyrax/collections/permissions_service.rb +1 -1
- data/app/services/hyrax/contextual_path.rb +24 -1
- data/app/services/hyrax/curation_concern.rb +24 -2
- 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/default_middleware_stack.rb +11 -0
- data/app/services/hyrax/edit_permissions_service.rb +74 -41
- data/app/services/hyrax/ensure_well_formed_admin_set_service.rb +3 -3
- data/app/services/hyrax/find_objects_via_solr_service.rb +31 -0
- data/app/services/hyrax/listeners/active_fedora_acl_index_listener.rb +1 -0
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +26 -0
- data/app/services/hyrax/listeners/metadata_index_listener.rb +25 -9
- 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/permission_manager.rb +4 -4
- 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 +9 -2
- data/app/services/hyrax/statistics/collections/over_time.rb +2 -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/visibility_intention.rb +20 -2
- data/app/services/hyrax/visibility_propagator.rb +30 -1
- data/app/services/hyrax/work_uploads_handler.rb +17 -2
- data/app/services/hyrax/workflow/abstract_notification.rb +2 -2
- data/app/services/hyrax/workflow/action_taken_service.rb +16 -4
- data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
- data/app/services/hyrax/workflow/activate_object.rb +5 -4
- data/app/services/hyrax/workflow/changes_required_notification.rb +5 -4
- data/app/services/hyrax/workflow/deactivate_object.rb +7 -5
- data/app/services/hyrax/workflow/deposited_notification.rb +8 -4
- data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +7 -3
- data/app/services/hyrax/workflow/grant_read_to_depositor.rb +10 -3
- data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
- data/app/services/hyrax/workflow/revoke_edit_from_depositor.rb +8 -2
- data/app/services/hyrax/workflow/status_list_service.rb +43 -13
- data/app/services/hyrax/workflow/workflow_action_service.rb +4 -1
- data/app/views/hyrax/admin/admin_sets/_form.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_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/batch_uploads/_form.html.erb +1 -1
- data/app/views/hyrax/collections/show.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_collection_title.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form.html.erb +4 -4
- 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/_sort_and_per_page.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/homepage/index.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/my/collections/_modal_collection_types_to_create.html.erb +1 -1
- data/app/views/layouts/hyrax/dashboard.html.erb +1 -0
- data/app/views/layouts/hyrax.html.erb +1 -0
- data/app/views/shared/_read_only.html.erb +5 -0
- data/bin/db-migrate-seed.sh +3 -1
- data/bin/hyrax-entrypoint.sh +0 -14
- data/bin/solrcloud-assign-configset.sh +11 -3
- data/bin/solrcloud-upload-configset.sh +17 -6
- data/chart/hyrax/Chart.yaml +9 -5
- data/chart/hyrax/README.md +52 -5
- data/chart/hyrax/templates/_helpers.tpl +23 -1
- data/chart/hyrax/templates/branding-pvc.yaml +14 -0
- data/chart/hyrax/templates/configmap-env.yaml +14 -3
- data/chart/hyrax/templates/deployment-worker.yaml +129 -0
- data/chart/hyrax/templates/deployment.yaml +95 -0
- data/chart/hyrax/templates/derivatives-pvc.yaml +14 -0
- data/chart/hyrax/templates/ingress.yaml +13 -4
- data/chart/hyrax/templates/secrets.yaml +9 -0
- data/chart/hyrax/templates/uploads-pvc.yaml +14 -0
- data/chart/hyrax/values.yaml +114 -1
- data/config/brakeman.ignore +2 -2
- data/config/features.rb +50 -43
- data/config/initializers/1_healthz.rb +1 -0
- data/config/initializers/listeners.rb +4 -1
- data/config/initializers/valkryrie_storage.rb +7 -0
- data/config/locales/hyrax.de.yml +1 -1
- data/config/locales/hyrax.en.yml +2 -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/db/seeds.rb +1 -1
- data/docker-compose.yml +39 -8
- data/documentation/developing-your-hyrax-based-app.md +3 -3
- data/documentation/legacyREADME.md +3 -3
- data/hyrax.gemspec +1 -1
- data/lib/generators/hyrax/templates/catalog_controller.rb +3 -1
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +15 -0
- data/lib/generators/hyrax/templates/config/initializers/riiif.rb +22 -20
- data/lib/generators/hyrax/work/templates/feature_spec.rb.erb +1 -1
- data/lib/generators/hyrax/work_resource/templates/indexer_spec.rb.erb +1 -0
- data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
- data/lib/hyrax/collection_name.rb +6 -2
- data/lib/hyrax/configuration.rb +56 -0
- data/lib/hyrax/engine.rb +3 -1
- data/lib/hyrax/errors.rb +2 -0
- data/lib/hyrax/form_fields.rb +1 -0
- data/lib/hyrax/publisher.rb +12 -0
- data/lib/hyrax/resource_name.rb +1 -0
- data/lib/hyrax/resource_sync/change_list_writer.rb +2 -2
- data/lib/hyrax/resource_sync/resource_list_writer.rb +2 -2
- data/lib/hyrax/specs/capybara.rb +5 -3
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +2 -0
- data/lib/hyrax/specs/shared_specs/indexers.rb +6 -0
- data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
- data/lib/hyrax/transactions/collection_create.rb +25 -0
- data/lib/hyrax/transactions/collection_update.rb +20 -0
- data/lib/hyrax/transactions/container.rb +47 -0
- 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_collections.rb +13 -1
- data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
- data/lib/hyrax/transactions/steps/apply_collection_type_permissions.rb +29 -0
- data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
- data/lib/hyrax/transactions/steps/save.rb +18 -6
- data/lib/hyrax/transactions/steps/set_collection_type_gid.rb +35 -0
- data/lib/hyrax/transactions/work_create.rb +2 -1
- 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/default_admin_set.rake +12 -11
- data/lib/tasks/regenerate_derivatives.rake +12 -0
- data/lib/wings/active_fedora_converter/default_work.rb +15 -0
- data/lib/wings/converter_value_mapper.rb +2 -2
- data/lib/wings/model_transformer.rb +17 -1
- data/lib/wings/orm_converter.rb +18 -2
- data/lib/wings/setup.rb +2 -0
- data/lib/wings/valkyrie/persister.rb +7 -5
- data/lib/wings/valkyrie/query_service.rb +60 -17
- data/lib/wings/valkyrie/storage.rb +56 -1
- data/lib/wings.rb +0 -21
- data/template.rb +1 -1
- metadata +42 -9
@@ -2,92 +2,96 @@
|
|
2
2
|
module Hyrax
|
3
3
|
module Collections
|
4
4
|
class PermissionsCreateService
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
5
|
+
class << self
|
6
|
+
# @api public
|
7
|
+
#
|
8
|
+
# Set the default permissions for a (newly created) collection
|
9
|
+
#
|
10
|
+
# @param collection [#collection_type_gid || Hyrax::AdministrativeSet] the collection or admin set the new permissions will act on
|
11
|
+
# @param creating_user [User] the user that created the collection
|
12
|
+
# @param grants [Array<Hash>] additional grants to apply to the new collection
|
13
|
+
# @return [Hyrax::PermissionTemplate]
|
14
|
+
def create_default(collection:, creating_user:, grants: [])
|
15
|
+
collection_type = Hyrax::CollectionType.find_by_gid!(collection.collection_type_gid)
|
16
|
+
access_grants = access_grants_attributes(collection_type: collection_type, creating_user: creating_user, grants: grants)
|
17
|
+
template = Hyrax::PermissionTemplate.create!(source_id: collection.id.to_s,
|
18
|
+
access_grants_attributes: access_grants.uniq)
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
# Add access grants to a collection
|
24
|
-
#
|
25
|
-
# @param collection_id [String] id of a collection
|
26
|
-
# @param grants [Array<Hash>] array of grants to add to the collection
|
27
|
-
# @example grants
|
28
|
-
# [ { agent_type: Hyrax::PermissionTemplateAccess::GROUP,
|
29
|
-
# agent_id: 'my_group_name',
|
30
|
-
# access: Hyrax::PermissionTemplateAccess::DEPOSIT } ]
|
31
|
-
# @see Hyrax::PermissionTemplateAccess for valid values for agent_type and access
|
32
|
-
def self.add_access(collection_id:, grants:)
|
33
|
-
collection = ::Collection.find(collection_id)
|
34
|
-
template = Hyrax::PermissionTemplate.find_by!(source_id: collection_id)
|
35
|
-
grants.each do |grant|
|
36
|
-
Hyrax::PermissionTemplateAccess.find_or_create_by(permission_template_id: template.id,
|
37
|
-
agent_type: grant[:agent_type],
|
38
|
-
agent_id: grant[:agent_id],
|
39
|
-
access: grant[:access])
|
20
|
+
template.reset_access_controls_for(collection: collection, interpret_visibility: true)
|
21
|
+
template
|
40
22
|
end
|
41
|
-
collection.reset_access_controls!
|
42
|
-
end
|
43
23
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
24
|
+
# @api public
|
25
|
+
#
|
26
|
+
# Add access grants to a collection
|
27
|
+
#
|
28
|
+
# @param collection_id [String] id of a collection
|
29
|
+
# @param grants [Array<Hash>] array of grants to add to the collection
|
30
|
+
# @example grants
|
31
|
+
# [ { agent_type: Hyrax::PermissionTemplateAccess::GROUP,
|
32
|
+
# agent_id: 'my_group_name',
|
33
|
+
# access: Hyrax::PermissionTemplateAccess::DEPOSIT } ]
|
34
|
+
# @see Hyrax::PermissionTemplateAccess for valid values for agent_type and access
|
35
|
+
def add_access(collection_id:, grants:)
|
36
|
+
collection = Hyrax.query_service.find_by(id: collection_id)
|
37
|
+
template = Hyrax::PermissionTemplate.find_by!(source_id: collection_id.to_s)
|
38
|
+
grants.each do |grant|
|
39
|
+
Hyrax::PermissionTemplateAccess.find_or_create_by(permission_template_id: template.id.to_s,
|
40
|
+
agent_type: grant[:agent_type],
|
41
|
+
agent_id: grant[:agent_id],
|
42
|
+
access: grant[:access])
|
43
|
+
end
|
61
44
|
|
62
|
-
|
63
|
-
#
|
64
|
-
# Retrieve the users or groups with manage permissions for a collection type
|
65
|
-
#
|
66
|
-
# @param collection_type [CollectionType] the collection type of the new collection
|
67
|
-
# @return [Hash] a hash containing permission attributes
|
68
|
-
def self.managers_of_collection_type(collection_type:)
|
69
|
-
attribute_list = []
|
70
|
-
user_managers = Hyrax::CollectionTypes::PermissionsService.user_edit_grants_for_collection_of_type(collection_type: collection_type)
|
71
|
-
user_managers.each do |user|
|
72
|
-
attribute_list << { agent_type: 'user', agent_id: user, access: Hyrax::PermissionTemplateAccess::MANAGE }
|
45
|
+
template.reset_access_controls_for(collection: collection, interpret_visibility: true)
|
73
46
|
end
|
74
|
-
|
75
|
-
|
76
|
-
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# @api private
|
51
|
+
#
|
52
|
+
# Gather the default permissions needed for a new collection
|
53
|
+
#
|
54
|
+
# @param collection_type [CollectionType] the collection type of the new collection
|
55
|
+
# @param creating_user [User] the user that created the collection
|
56
|
+
# @param grants [Array<Hash>] additional grants to apply to the new collection
|
57
|
+
# @return [Array<Hash>] a hash containing permission attributes
|
58
|
+
def access_grants_attributes(collection_type:, creating_user:, grants:)
|
59
|
+
[
|
60
|
+
{ agent_type: 'group', agent_id: admin_group_name, access: Hyrax::PermissionTemplateAccess::MANAGE }
|
61
|
+
].tap do |attribute_list|
|
62
|
+
# Grant manage access to the creating_user if it exists
|
63
|
+
attribute_list << { agent_type: 'user', agent_id: creating_user.user_key, access: Hyrax::PermissionTemplateAccess::MANAGE } if creating_user
|
64
|
+
end + managers_of_collection_type(collection_type: collection_type) + grants
|
65
|
+
end
|
66
|
+
|
67
|
+
# @api private
|
68
|
+
#
|
69
|
+
# Retrieve the users or groups with manage permissions for a collection type
|
70
|
+
#
|
71
|
+
# @param collection_type [CollectionType] the collection type of the new collection
|
72
|
+
# @return [Array<Hash>] a hash containing permission attributes
|
73
|
+
def managers_of_collection_type(collection_type:)
|
74
|
+
attribute_list = []
|
75
|
+
user_managers = Hyrax::CollectionTypes::PermissionsService.user_edit_grants_for_collection_of_type(collection_type: collection_type)
|
76
|
+
user_managers.each do |user|
|
77
|
+
attribute_list << { agent_type: 'user', agent_id: user, access: Hyrax::PermissionTemplateAccess::MANAGE }
|
78
|
+
end
|
79
|
+
group_managers = Hyrax::CollectionTypes::PermissionsService.group_edit_grants_for_collection_of_type(collection_type: collection_type)
|
80
|
+
group_managers.each do |group|
|
81
|
+
attribute_list << { agent_type: 'group', agent_id: group, access: Hyrax::PermissionTemplateAccess::MANAGE }
|
82
|
+
end
|
83
|
+
attribute_list
|
77
84
|
end
|
78
|
-
attribute_list
|
79
|
-
end
|
80
|
-
private_class_method :managers_of_collection_type
|
81
85
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
86
|
+
# @api private
|
87
|
+
#
|
88
|
+
# The value of the admin group name
|
89
|
+
#
|
90
|
+
# @return [String] a string representation of the admin group name
|
91
|
+
def admin_group_name
|
92
|
+
::Ability.admin_group_name
|
93
|
+
end
|
89
94
|
end
|
90
|
-
private_class_method :admin_group_name
|
91
95
|
end
|
92
96
|
end
|
93
97
|
end
|
@@ -243,7 +243,7 @@ module Hyrax
|
|
243
243
|
# @note Several checks get the user's groups from the user's ability. The same values can be retrieved directly from a passed in ability.
|
244
244
|
def self.access_to_collection?(collection_id:, access:, ability:, exclude_groups: [])
|
245
245
|
return false unless collection_id
|
246
|
-
template = Hyrax::PermissionTemplate.find_by!(source_id: collection_id)
|
246
|
+
template = Hyrax::PermissionTemplate.find_by!(source_id: collection_id.to_s)
|
247
247
|
return true if ([ability.current_user.user_key] & template.agent_ids_for(agent_type: 'user', access: access)).present?
|
248
248
|
return true if (ability.user_groups & (template.agent_ids_for(agent_type: 'group', access: access) - exclude_groups)).present?
|
249
249
|
false
|
@@ -1,17 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
|
+
##
|
4
|
+
# @api public
|
5
|
+
#
|
6
|
+
# Provides a polymorphic path for a target object (presenter) nested under the
|
7
|
+
# path of the parent, if given.
|
8
|
+
#
|
9
|
+
# @see WorkShowPresenter#contextual_path
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Hyrax::ContextualPath.new(my_file_set, parent_object).show
|
13
|
+
# # => "/concerns/parent/id4parent/file_sets/id4file_set"
|
14
|
+
#
|
15
|
+
# @example with a nil parent
|
16
|
+
# Hyrax::ContextualPath.new(my_file_set, nil).show
|
17
|
+
# # => "/concerns/file_sets/id4file_set"
|
18
|
+
#
|
3
19
|
class ContextualPath
|
4
20
|
include Rails.application.routes.url_helpers
|
5
21
|
include ActionDispatch::Routing::PolymorphicRoutes
|
6
22
|
attr_reader :presenter, :parent_presenter
|
23
|
+
|
24
|
+
##
|
25
|
+
# @param presenter [#model_name] an ActiveModel-like target object
|
26
|
+
# @param parent_presenter [#id, nil] an ActiveModel-like presenter for the
|
27
|
+
# target's parent
|
7
28
|
def initialize(presenter, parent_presenter)
|
8
29
|
@presenter = presenter
|
9
30
|
@parent_presenter = parent_presenter
|
10
31
|
end
|
11
32
|
|
33
|
+
##
|
34
|
+
# @return [String]
|
12
35
|
def show
|
13
36
|
if parent_presenter
|
14
|
-
polymorphic_path([:hyrax, :parent, presenter.model_name.singular],
|
37
|
+
polymorphic_path([:hyrax, :parent, presenter.model_name.singular.to_sym],
|
15
38
|
parent_id: parent_presenter.id,
|
16
39
|
id: presenter.id)
|
17
40
|
else
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
3
|
class CurationConcern
|
4
|
+
##
|
4
5
|
# The actor middleware stack can be customized like so:
|
5
6
|
# # Adding a new middleware
|
6
7
|
# Hyrax::CurationConcern.actor_factory.use MyCustomActor
|
@@ -16,14 +17,35 @@ module Hyrax
|
|
16
17
|
#
|
17
18
|
# You can customize the actor stack, so long as you do so before the actor
|
18
19
|
# is used. Once it is used, it becomes immutable.
|
20
|
+
#
|
19
21
|
# @return [ActionDispatch::MiddlewareStack]
|
22
|
+
# @see Hyrax::DefaultMiddlewareStack
|
20
23
|
def self.actor_factory
|
21
24
|
@actor_factory ||= Hyrax::DefaultMiddlewareStack.build_stack
|
22
25
|
end
|
23
26
|
|
24
|
-
|
25
|
-
#
|
27
|
+
##
|
28
|
+
# Provides the Hyrax "Actor Stack" used during creation of Works when
|
29
|
+
# +ActiveFedora+ models are used by the application
|
30
|
+
#
|
31
|
+
# The "Actor Stack" consists of a series of objects ("Actors"), which
|
32
|
+
# implement +#create+, +#update+ and +#destroy+. Each actor's methods
|
33
|
+
# promise to call the same methods on the next actor in the series, and may
|
34
|
+
# do some work before (on the way down the stack) and/or after (on the
|
35
|
+
# way up) calling to the next actor.
|
36
|
+
#
|
37
|
+
# The normal convention is to call an actor inheriting
|
38
|
+
# {Hyrax::Actors::BaseActor} at or near the bottom of the stack, to handle
|
39
|
+
# the create, update , or destroy action.
|
40
|
+
#
|
41
|
+
# @note this stack, and the Actor classes it calls, is not used when
|
42
|
+
# +Valkyrie+ models are defined by the application. in that context,
|
43
|
+
# this behavior is replaced by `Hyrax::Transactions::Container`.
|
44
|
+
#
|
26
45
|
# @return [#create, #update] an actor that can create and update the work
|
46
|
+
#
|
47
|
+
# @see Hyrax::DefaultMiddlewareStack
|
48
|
+
# @see https://samvera.github.io/actor_stack.html
|
27
49
|
def self.actor
|
28
50
|
@work_middleware_stack ||= actor_factory.build(Actors::Terminator.new)
|
29
51
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# Provide custom queries for finding Hyrax::FileMetadata
|
3
|
-
# @example
|
4
|
-
# Hyrax.custom_queries.find_file_metadata_by(id: valkyrie_id)
|
5
|
-
# Hyrax.custom_queries.find_file_metadata_by_alternate_identifier(alternate_identifier: alt_id)
|
6
|
-
# Hyrax.custom_queries.find_many_file_metadata_by_ids(ids: [valkyrie_id, valkyrie_id])
|
7
2
|
module Hyrax
|
8
3
|
module CustomQueries
|
4
|
+
##
|
5
|
+
# Provide custom queries for finding Hyrax::FileMetadata
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# Hyrax.custom_queries.find_file_metadata_by(id: valkyrie_id)
|
9
|
+
# Hyrax.custom_queries.find_file_metadata_by_alternate_identifier(alternate_identifier: alt_id)
|
10
|
+
# Hyrax.custom_queries.find_many_file_metadata_by_ids(ids: [valkyrie_id, valkyrie_id])
|
9
11
|
class FindFileMetadata
|
10
12
|
def self.queries
|
11
13
|
[:find_file_metadata_by,
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hyrax
|
4
|
+
module CustomQueries
|
5
|
+
module Navigators
|
6
|
+
##
|
7
|
+
# Navigate from a resource to the parent collections of the resource.
|
8
|
+
#
|
9
|
+
# @see https://github.com/samvera/valkyrie/wiki/Queries#custom-queries
|
10
|
+
# @since 3.0.0
|
11
|
+
class ParentCollectionsNavigator
|
12
|
+
# Define the queries that can be fulfilled by this navigator.
|
13
|
+
def self.queries
|
14
|
+
[:find_parent_collections, :find_parent_collection_ids]
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :query_service
|
18
|
+
|
19
|
+
def initialize(query_service:)
|
20
|
+
@query_service = query_service
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Find parent collections of a given resource, and map to Valkyrie Resources
|
25
|
+
#
|
26
|
+
# @param [Valkyrie::Resource] resource
|
27
|
+
#
|
28
|
+
# @return [Array<Valkyrie::Resource>]
|
29
|
+
def find_parent_collections(resource:)
|
30
|
+
query_service
|
31
|
+
.find_many_by_ids(ids: find_parent_collection_ids(resource: resource))
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Find the ids of parent collections of a given resource, and map to Valkyrie Resources IDs
|
36
|
+
#
|
37
|
+
# @param [Valkyrie::Resource] resource
|
38
|
+
#
|
39
|
+
# @return [Array<Valkyrie::ID>]
|
40
|
+
def find_parent_collection_ids(resource:)
|
41
|
+
resource.member_of_collection_ids
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,5 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
|
+
##
|
4
|
+
# Defines the Hyrax "Actor Stack", used in creation of works when using
|
5
|
+
# +ActiveFedora+.
|
6
|
+
#
|
7
|
+
# @note this stack, and the Actor classes it calls, is not used when
|
8
|
+
# +Valkyrie+ models are defined by the application. in that context,
|
9
|
+
# this behavior is replaced by `Hyrax::Transactions::Container`.
|
10
|
+
#
|
11
|
+
# @see Hyrax::CurationConcern.actor
|
12
|
+
# @see Hyrax::WorksControllerBehavior#create
|
13
|
+
# @see Hyrax::WorksControllerBehavior#update
|
3
14
|
class DefaultMiddlewareStack
|
4
15
|
# rubocop:disable Metrics/MethodLength
|
5
16
|
def self.build_stack
|
@@ -1,11 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
|
+
##
|
4
|
+
# @api public
|
5
|
+
#
|
3
6
|
# Encapsulates the logic to determine which object permissions may be edited by a given user
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
7
|
+
# * user is permitted to update any work permissions coming ONLY from collections they manage
|
8
|
+
# * user is not permitted to update a work permission if it comes from a collection they do not manage, even if also from a managed collection
|
9
|
+
# * user is permitted to update only non-manager permissions from any Collections
|
10
|
+
# * user is permitted to update any non-collection permissions
|
8
11
|
class EditPermissionsService
|
12
|
+
##
|
9
13
|
# @api public
|
10
14
|
# @since v3.0.0
|
11
15
|
#
|
@@ -14,15 +18,15 @@ module Hyrax
|
|
14
18
|
# @return [Hyrax::EditPermissionService]
|
15
19
|
#
|
16
20
|
# @note
|
17
|
-
# form object.class = SimpleForm::FormBuilder
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
21
|
+
# +form object.class = SimpleForm::FormBuilder+
|
22
|
+
# For works (i.e. GenericWork):
|
23
|
+
# * form object.object = Hyrax::GenericWorkForm
|
24
|
+
# * form object.object.model = GenericWork
|
25
|
+
# * use the work itself
|
26
|
+
# For file_sets:
|
27
|
+
# * form object.object.class = FileSet
|
28
|
+
# * use work the file_set is in
|
29
|
+
# No other object types are supported by this view.
|
26
30
|
def self.build_service_object_from(form:, ability:)
|
27
31
|
if form.object.respond_to?(:model) && form.object.model.work?
|
28
32
|
new(object: form.object, ability: ability)
|
@@ -33,7 +37,9 @@ module Hyrax
|
|
33
37
|
|
34
38
|
attr_reader :depositor, :unauthorized_collection_managers
|
35
39
|
|
36
|
-
|
40
|
+
##
|
41
|
+
# @param object [#depositor, #admin_set_id, #member_of_collection_ids]
|
42
|
+
# +GenericWorkForm+ (if called for object) or +GenericWork+ (if called for file set)
|
37
43
|
# @param ability [Ability] user's current_ability
|
38
44
|
def initialize(object:, ability:)
|
39
45
|
@object = object
|
@@ -47,7 +53,7 @@ module Hyrax
|
|
47
53
|
# @api private
|
48
54
|
# @todo refactor this code to use "can_edit?"; Thinking in negations can be challenging.
|
49
55
|
#
|
50
|
-
# @param permission_hash [Hash] one set of permission fields for object
|
56
|
+
# @param permission_hash [Hash] one set of permission fields for object +:name+, :access}
|
51
57
|
# @return [Boolean] true if user cannot edit the given permissions
|
52
58
|
def cannot_edit_permissions?(permission_hash)
|
53
59
|
permission_hash.fetch(:access) == "edit" && @unauthorized_managers.include?(permission_hash.fetch(:name))
|
@@ -55,7 +61,7 @@ module Hyrax
|
|
55
61
|
|
56
62
|
# @api private
|
57
63
|
#
|
58
|
-
# @param permission_hash [Hash] one set of permission fields for object
|
64
|
+
# @param permission_hash [Hash] one set of permission fields for object +:name+, +:access+
|
59
65
|
# @return [Boolean] true if given permissions are one of fixed exclusions
|
60
66
|
def excluded_permission?(permission_hash)
|
61
67
|
exclude_from_display.include? permission_hash.fetch(:name).downcase
|
@@ -68,9 +74,10 @@ module Hyrax
|
|
68
74
|
# * returns false if the given permission_hash is part of the fixed exclusions.
|
69
75
|
# * yields a PermissionPresenter to provide additional logic and text for rendering
|
70
76
|
#
|
71
|
-
# @param permission_hash [Hash
|
72
|
-
#
|
73
|
-
# @
|
77
|
+
# @param permission_hash [Hash{Symbol => Object}]
|
78
|
+
#
|
79
|
+
# @return [Boolean] +false+ if the given +permission_hash+ is a fixed exclusion
|
80
|
+
# @yield [PermissionPresenter]
|
74
81
|
#
|
75
82
|
# @see #excluded_permission?
|
76
83
|
def with_applicable_permission(permission_hash:)
|
@@ -81,7 +88,7 @@ module Hyrax
|
|
81
88
|
# @api private
|
82
89
|
#
|
83
90
|
# A helper class to contain specific presentation logic related to
|
84
|
-
# the EditPermissionsService
|
91
|
+
# the {EditPermissionsService}
|
85
92
|
class PermissionPresenter
|
86
93
|
# @param service [Hyrax::EditPermissionsService]
|
87
94
|
# @param permission_hash [Hash]
|
@@ -158,38 +165,64 @@ module Hyrax
|
|
158
165
|
# find all of the work's collections a user can manage
|
159
166
|
# @return [Array] of collection ids
|
160
167
|
def object_managed_collection_ids
|
161
|
-
@object_managed_collection_ids ||=
|
168
|
+
@object_managed_collection_ids ||= object_member_of_ids & managed_collection_ids
|
162
169
|
end
|
163
170
|
|
164
|
-
# find all of the work's collections a user cannot manage
|
165
|
-
#
|
171
|
+
# find all of the work's collections a user cannot manage note: if
|
172
|
+
# the collection type doesn't include
|
173
|
+
# "sharing_applies_to_new_works", we don't limit access
|
174
|
+
#
|
166
175
|
# @return [Array] of collection ids with limited access
|
167
176
|
def object_unauthorized_collection_ids
|
168
177
|
@object_unauthorized_collection_ids ||= begin
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
unauthorized_collection_ids.each do |id|
|
173
|
-
# TODO: Can we instead use a SOLR query? This seems to be somewhat expensive. However, as this is
|
174
|
-
# used in administration instead of user front-end displays, I'm not as concerned.
|
175
|
-
collection = ActiveFedora::Base.find(id)
|
176
|
-
limited_access << id if (collection.instance_of? AdminSet) || collection.share_applies_to_new_works?
|
177
|
-
end
|
178
|
+
unauthorized_collection_ids = object_member_of_ids - object_managed_collection_ids
|
179
|
+
qualified_resources = Hyrax.query_service.find_many_by_ids(ids: unauthorized_collection_ids).select do |resource|
|
180
|
+
qualifies_as_unauthorized_collection?(resource: resource)
|
178
181
|
end
|
179
|
-
|
182
|
+
qualified_resources.map { |resource| resource.id.to_s }
|
180
183
|
end
|
181
184
|
end
|
182
185
|
|
186
|
+
# Does the given resource qualify as a collection the current user cannot manage.
|
187
|
+
#
|
188
|
+
# @see {#object_unauthorized_collection_ids}
|
189
|
+
#
|
190
|
+
# @param resource [Valkyrie::Resource, AdminSet, Collection, #collection_type_gid, #share_applies_to_new_works?]
|
191
|
+
# the given resource, hopefully a collection-like thing
|
192
|
+
# (e.g. AdminSet, Hyrax::AdminSet, Hyrax::PcdmCollection,
|
193
|
+
# Collection)
|
194
|
+
#
|
195
|
+
# @return [Boolean]
|
196
|
+
#
|
197
|
+
# @todo Refactor inner working of code as there's lots of branching logic with potential hidden assumptions.
|
198
|
+
def qualifies_as_unauthorized_collection?(resource:)
|
199
|
+
case resource
|
200
|
+
when AdminSet, Hyrax::AdministrativeSet
|
201
|
+
# Prior to this refactor, we looked at AdminSet only; However with the advent of the
|
202
|
+
# Hyrax::AdministrativeSet, we need to test both cases.
|
203
|
+
true
|
204
|
+
else
|
205
|
+
if resource.respond_to?(:share_applies_to_new_works?)
|
206
|
+
# The Collection model has traditionally delegated #share_applies_to_new_works? to
|
207
|
+
# the underlying collection_type
|
208
|
+
# (see https://github.com/samvera/hyrax/blob/696da5db/spec/models/collection_spec.rb#L189)
|
209
|
+
resource.share_applies_to_new_works?
|
210
|
+
elsif resource.respond_to?(:collection_type_gid)
|
211
|
+
# This is likely a Hyrax::PcdmCollection object, which means we don't have the delegation
|
212
|
+
# behavior. Instead we'll query the collection type directly.
|
213
|
+
collection_type = CollectionType.find_by_gid(resource.collection_type_gid)
|
214
|
+
collection_type&.share_applies_to_new_works?
|
215
|
+
else
|
216
|
+
# How might we get here?
|
217
|
+
false
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
183
222
|
# find all of the collection ids an object is a member of
|
184
223
|
# @return [Array] array of collection ids
|
185
|
-
def
|
186
|
-
@
|
187
|
-
belongs_to = []
|
188
|
-
# get all of work's collection ids from the form
|
189
|
-
belongs_to += @object.member_of_collection_ids
|
190
|
-
belongs_to << @object.admin_set_id if @object.admin_set_id.present?
|
191
|
-
belongs_to
|
192
|
-
end
|
224
|
+
def object_member_of_ids
|
225
|
+
@object_member_of_ids ||= (@object.member_of_collection_ids + [@object.admin_set_id]).select(&:present?)
|
193
226
|
end
|
194
227
|
|
195
228
|
# The list of all collections this user has manage rights on
|
@@ -14,12 +14,12 @@ module Hyrax
|
|
14
14
|
#
|
15
15
|
# @param admin_set_id [String, nil]
|
16
16
|
#
|
17
|
-
# @return [
|
17
|
+
# @return [#to_s] an admin_set_id; if you provide a "present"
|
18
18
|
# admin_set_id, this service will return that.
|
19
19
|
#
|
20
|
-
# @see
|
20
|
+
# @see Hyrax::AdminSetCreateService.find_or_create_default_admin_set
|
21
21
|
def self.call(admin_set_id: nil)
|
22
|
-
admin_set_id = admin_set_id.presence ||
|
22
|
+
admin_set_id = admin_set_id.presence&.to_s || Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s
|
23
23
|
Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set_id)
|
24
24
|
admin_set_id
|
25
25
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
# @deprecated This class is being replaced by Hyrax::SolrQueryService #get_objects method.
|
4
|
+
#
|
5
|
+
# Methods in this class search solr to get the ids and then use the query service to find the objects.
|
6
|
+
class FindObjectsViaSolrService
|
7
|
+
class_attribute :solr_query_builder, :solr_service, :query_service
|
8
|
+
self.solr_query_builder = Hyrax::SolrQueryService
|
9
|
+
self.solr_service = Hyrax::SolrService
|
10
|
+
self.query_service = Hyrax.query_service
|
11
|
+
|
12
|
+
class << self
|
13
|
+
# Find objects matching search criteria.
|
14
|
+
# @param model [Class] if not using Valkyrie, this is expected to be an ActiveFedora::Base object that supports #where
|
15
|
+
# @param field_pairs [Hash] a list of pairs of property name and values
|
16
|
+
# @param join_with [String] the value we're joining the clauses with (default: ' OR ' for backward compatibility with ActiveFedora where)
|
17
|
+
# @param type [String] The type of query to run. Either 'raw' or 'field' (default: 'field')
|
18
|
+
# @param use_valkyrie [Boolean] if true, return Valkyrie resource(s); otherwise, return ActiveFedora object(s)
|
19
|
+
# @return [Array<ActiveFedora::Base|Valkyrie::Resource>] objects matching the query
|
20
|
+
def find_for_model_by_field_pairs(model:, field_pairs:, join_with: ' OR ', type: 'field', use_valkyrie: Hyrax.config.use_valkyrie?)
|
21
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
22
|
+
"Instead, use 'Hyrax::SolrQueryService.new.with_model(...).with_field_pairs(...).get_objects'.")
|
23
|
+
|
24
|
+
solr_query_builder.new
|
25
|
+
.with_model(model: model)
|
26
|
+
.with_field_pairs(field_pairs: field_pairs, join_with: join_with, type: type)
|
27
|
+
.get_objects(use_valkyrie: use_valkyrie).to_a
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -13,6 +13,7 @@ module Hyrax
|
|
13
13
|
#
|
14
14
|
# @param event [Dry::Event]
|
15
15
|
def on_object_acl_updated(event)
|
16
|
+
return if Hyrax.config.disable_wings
|
16
17
|
return unless event[:result] == :success # do nothing on failure
|
17
18
|
|
18
19
|
if Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hyrax
|
4
|
+
module Listeners
|
5
|
+
##
|
6
|
+
# Listens for object deleted events and cleans up associated members
|
7
|
+
class MemberCleanupListener
|
8
|
+
def on_object_deleted(event)
|
9
|
+
return unless event.payload.key?(:object) # legacy callback
|
10
|
+
return if event[:object].is_a?(ActiveFedora::Base) # handled by legacy code
|
11
|
+
|
12
|
+
Hyrax.custom_queries.find_child_filesets(resource: event[:object]).each do |file_set|
|
13
|
+
begin
|
14
|
+
Hyrax.persister.delete(resource: file_set)
|
15
|
+
Hyrax.publisher
|
16
|
+
.publish('object.deleted', object: file_set, id: file_set.id, user: user)
|
17
|
+
rescue StandardError # we don't uncaught errors looping filesets
|
18
|
+
Hyrax.logger.warn "Failed to delete #{file_set.class}:#{file_set.id} " \
|
19
|
+
"during cleanup for resource: #{event[:object]}. " \
|
20
|
+
'This member may now be orphaned.'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|