hyrax 3.0.0.pre.rc4 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (271) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +41 -8
  3. data/.dassie/Gemfile +10 -5
  4. data/.dassie/config/cable.yml +1 -1
  5. data/.dassie/config/environments/development.rb +2 -0
  6. data/.dassie/config/environments/production.rb +1 -1
  7. data/.dassie/config/initializers/hyrax.rb +5 -0
  8. data/.dassie/config/initializers/riiif.rb +22 -20
  9. data/.dassie/config/redis.yml +1 -0
  10. data/.dassie/config/role_map.yml +2 -0
  11. data/.dassie/db/seeds.rb +9 -1
  12. data/.dassie/package.json +3 -5
  13. data/.dockerignore +4 -0
  14. data/.env +1 -2
  15. data/.rubocop.yml +4 -0
  16. data/CONTAINERS.md +21 -1
  17. data/Dockerfile +46 -17
  18. data/Gemfile +21 -27
  19. data/app/actors/hyrax/actors/base_actor.rb +1 -1
  20. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +89 -41
  21. data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
  22. data/app/actors/hyrax/actors/file_actor.rb +4 -2
  23. data/app/actors/hyrax/actors/file_set_actor.rb +18 -11
  24. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +20 -8
  25. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
  26. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
  27. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +38 -8
  28. data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +0 -4
  29. data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
  30. data/app/controllers/hyrax/dashboard/collection_members_controller.rb +13 -9
  31. data/app/controllers/hyrax/dashboard/collections_controller.rb +14 -14
  32. data/app/controllers/hyrax/file_sets_controller.rb +49 -13
  33. data/app/controllers/hyrax/permissions_controller.rb +3 -4
  34. data/app/controllers/hyrax/workflow_actions_controller.rb +3 -1
  35. data/app/forms/hyrax/forms/collection_form.rb +12 -6
  36. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +24 -2
  37. data/app/forms/hyrax/forms/file_set_form.rb +46 -0
  38. data/app/forms/hyrax/forms/permission.rb +23 -0
  39. data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
  40. data/app/forms/hyrax/forms/resource_form.rb +31 -13
  41. data/app/forms/hyrax/forms/work_form.rb +5 -2
  42. data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
  43. data/app/helpers/hyrax/collections_helper.rb +88 -2
  44. data/app/helpers/hyrax/dashboard_helper_behavior.rb +16 -5
  45. data/app/helpers/hyrax/embargo_helper.rb +4 -0
  46. data/app/helpers/hyrax/file_set_helper.rb +25 -6
  47. data/app/helpers/hyrax/hyrax_helper_behavior.rb +8 -0
  48. data/app/helpers/hyrax/lease_helper.rb +4 -0
  49. data/app/helpers/hyrax/url_helper.rb +4 -1
  50. data/app/helpers/hyrax/work_form_helper.rb +53 -0
  51. data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
  52. data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +118 -0
  53. data/app/indexers/hyrax/valkyrie_indexer.rb +10 -4
  54. data/app/indexers/hyrax/valkyrie_work_indexer.rb +3 -1
  55. data/app/inputs/controlled_vocabulary_input.rb +2 -5
  56. data/app/jobs/attach_files_to_work_job.rb +19 -10
  57. data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
  58. data/app/jobs/embargo_expiry_job.rb +7 -5
  59. data/app/jobs/file_set_attached_event_job.rb +6 -1
  60. data/app/jobs/ingest_local_file_job.rb +18 -2
  61. data/app/jobs/inherit_permissions_job.rb +9 -5
  62. data/app/jobs/lease_expiry_job.rb +6 -4
  63. data/app/models/admin_set.rb +6 -25
  64. data/app/models/collection_branding_info.rb +25 -9
  65. data/app/models/concerns/hyrax/ability.rb +14 -1
  66. data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
  67. data/app/models/concerns/hyrax/embargoable.rb +24 -0
  68. data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
  69. data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -46
  70. data/app/models/concerns/hyrax/suppressible.rb +5 -0
  71. data/app/models/concerns/hyrax/user.rb +9 -3
  72. data/app/models/concerns/hyrax/work_behavior.rb +1 -1
  73. data/app/models/hyrax/file_set.rb +7 -0
  74. data/app/models/hyrax/pcdm_collection.rb +1 -0
  75. data/app/models/hyrax/permission_template.rb +98 -12
  76. data/app/models/hyrax/virus_scanner.rb +27 -18
  77. data/app/models/hyrax/work.rb +2 -0
  78. data/app/models/job_io_wrapper.rb +1 -1
  79. data/app/models/sipity/agent.rb +1 -0
  80. data/app/models/sipity/entity.rb +30 -8
  81. data/app/models/sipity/workflow.rb +1 -0
  82. data/app/models/sipity.rb +42 -0
  83. data/app/presenters/hyrax/admin_set_options_presenter.rb +12 -8
  84. data/app/presenters/hyrax/admin_set_presenter.rb +5 -1
  85. data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
  86. data/app/presenters/hyrax/collection_presenter.rb +41 -20
  87. data/app/presenters/hyrax/file_set_presenter.rb +6 -1
  88. data/app/presenters/hyrax/file_usage.rb +3 -2
  89. data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +119 -0
  90. data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
  91. data/app/presenters/hyrax/trophy_presenter.rb +33 -4
  92. data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
  93. data/app/presenters/hyrax/version_list_presenter.rb +19 -0
  94. data/app/presenters/hyrax/version_presenter.rb +3 -2
  95. data/app/presenters/hyrax/work_show_presenter.rb +30 -5
  96. data/app/presenters/hyrax/work_usage.rb +5 -3
  97. data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
  98. data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
  99. data/app/search_builders/hyrax/collection_member_search_builder.rb +6 -1
  100. data/app/search_builders/hyrax/my/collections_search_builder.rb +2 -2
  101. data/app/search_builders/hyrax/nested_collections_parent_search_builder.rb +1 -1
  102. data/app/search_builders/hyrax/single_collection_search_builder.rb +1 -1
  103. data/app/services/hyrax/access_control_list.rb +1 -1
  104. data/app/services/hyrax/adapters/nesting_index_adapter.rb +1 -1
  105. data/app/services/hyrax/admin_set_create_service.rb +3 -1
  106. data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
  107. data/app/services/hyrax/collections/collection_member_service.rb +112 -27
  108. data/app/services/hyrax/collections/migration_service.rb +4 -2
  109. data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
  110. data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
  111. data/app/services/hyrax/collections/permissions_create_service.rb +6 -4
  112. data/app/services/hyrax/contextual_path.rb +24 -1
  113. data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
  114. data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
  115. data/app/services/hyrax/edit_permissions_service.rb +74 -41
  116. data/app/services/hyrax/embargo_manager.rb +1 -1
  117. data/app/services/hyrax/find_objects_via_solr_service.rb +31 -0
  118. data/app/services/hyrax/graph_exporter.rb +1 -1
  119. data/app/services/hyrax/listeners/member_cleanup_listener.rb +26 -0
  120. data/app/services/hyrax/listeners/metadata_index_listener.rb +18 -1
  121. data/app/services/hyrax/listeners/object_lifecycle_listener.rb +1 -1
  122. data/app/services/hyrax/listeners/trophy_cleanup_listener.rb +17 -0
  123. data/app/services/hyrax/listeners.rb +2 -0
  124. data/app/services/hyrax/multiple_membership_checker.rb +53 -29
  125. data/app/services/hyrax/persist_derivatives.rb +3 -1
  126. data/app/services/hyrax/resource_status.rb +7 -0
  127. data/app/services/hyrax/search_service.rb +4 -2
  128. data/app/services/hyrax/solr_query_builder_service.rb +45 -8
  129. data/app/services/hyrax/solr_query_service.rb +224 -0
  130. data/app/services/hyrax/solr_service.rb +8 -1
  131. data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
  132. data/app/services/hyrax/thumbnail_path_service.rb +1 -1
  133. data/app/services/hyrax/versioning_service.rb +1 -1
  134. data/app/services/hyrax/visibility_intention.rb +20 -2
  135. data/app/services/hyrax/visibility_propagator.rb +30 -1
  136. data/app/services/hyrax/work_uploads_handler.rb +22 -4
  137. data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
  138. data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
  139. data/app/services/hyrax/workflow/status_list_service.rb +43 -13
  140. data/app/views/hyrax/admin/admin_sets/_show_document_list_row.html.erb +1 -1
  141. data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
  142. data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
  143. data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
  144. data/app/views/hyrax/base/_form_representative.html.erb +1 -1
  145. data/app/views/hyrax/base/_form_share.html.erb +1 -5
  146. data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
  147. data/app/views/hyrax/base/_form_visibility_error.html.erb +2 -0
  148. data/app/views/hyrax/base/_guts4form.html.erb +3 -3
  149. data/app/views/hyrax/base/_representative_media.html.erb +1 -1
  150. data/app/views/hyrax/base/_show_actions.html.erb +2 -2
  151. data/app/views/hyrax/base/_work_button_row.html.erb +1 -1
  152. data/app/views/hyrax/base/_workflow_actions.html.erb +1 -1
  153. data/app/views/hyrax/batch_edits/edit.html.erb +2 -2
  154. data/app/views/hyrax/batch_uploads/_form.html.erb +1 -1
  155. data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
  156. data/app/views/hyrax/collections/_search_form.html.erb +1 -1
  157. data/app/views/hyrax/collections/show.html.erb +1 -1
  158. data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
  159. data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -1
  160. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  161. data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
  162. data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
  163. data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
  164. data/app/views/hyrax/file_sets/_actions.html.erb +10 -0
  165. data/app/views/hyrax/file_sets/edit.html.erb +1 -1
  166. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
  167. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  168. data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
  169. data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
  170. data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
  171. data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
  172. data/app/views/hyrax/file_sets/show.html.erb +1 -1
  173. data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
  174. data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
  175. data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
  176. data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
  177. data/app/views/hyrax/stats/file.html.erb +1 -1
  178. data/app/views/hyrax/stats/work.html.erb +1 -1
  179. data/app/views/hyrax/uploads/_js_templates.html.erb +4 -4
  180. data/app/views/hyrax/uploads/_js_templates_versioning.html.erb +4 -4
  181. data/app/views/hyrax/users/_contributions.html.erb +1 -1
  182. data/app/views/hyrax/users/_profile_tabs.html.erb +2 -2
  183. data/app/views/hyrax/users/_search_form.html.erb +1 -1
  184. data/app/views/hyrax/users/_user.html.erb +1 -1
  185. data/app/views/hyrax/users/_user_info.html.erb +9 -9
  186. data/bin/db-migrate-seed.sh +6 -2
  187. data/bin/hyrax-entrypoint.sh +0 -14
  188. data/bin/solrcloud-assign-configset.sh +35 -0
  189. data/bin/solrcloud-upload-configset.sh +42 -0
  190. data/chart/hyrax/Chart.yaml +12 -8
  191. data/chart/hyrax/README.md +94 -11
  192. data/chart/hyrax/templates/NOTES.txt +1 -1
  193. data/chart/hyrax/templates/_helpers.tpl +98 -0
  194. data/chart/hyrax/templates/branding-pvc.yaml +14 -0
  195. data/chart/hyrax/templates/configmap-env.yaml +21 -11
  196. data/chart/hyrax/templates/cron-embargo.yaml +24 -0
  197. data/chart/hyrax/templates/cron-lease.yaml +24 -0
  198. data/chart/hyrax/templates/deployment-worker.yaml +129 -0
  199. data/chart/hyrax/templates/deployment.yaml +125 -4
  200. data/chart/hyrax/templates/derivatives-pvc.yaml +14 -0
  201. data/chart/hyrax/templates/ingress.yaml +13 -4
  202. data/chart/hyrax/templates/secrets.yaml +12 -2
  203. data/chart/hyrax/templates/uploads-pvc.yaml +14 -0
  204. data/chart/hyrax/values.yaml +186 -2
  205. data/config/brakeman.ignore +2 -2
  206. data/config/features.rb +47 -43
  207. data/config/initializers/listeners.rb +4 -0
  208. data/config/initializers/valkryrie_storage.rb +7 -0
  209. data/config/locales/hyrax.de.yml +1 -1
  210. data/config/locales/hyrax.en.yml +1 -1
  211. data/config/locales/hyrax.es.yml +1 -1
  212. data/config/locales/hyrax.fr.yml +1 -1
  213. data/config/locales/hyrax.it.yml +1 -1
  214. data/config/locales/hyrax.pt-BR.yml +1 -1
  215. data/config/locales/hyrax.zh.yml +1 -1
  216. data/docker-compose.yml +39 -8
  217. data/documentation/developing-your-hyrax-based-app.md +4 -4
  218. data/documentation/legacyREADME.md +3 -3
  219. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
  220. data/lib/generators/hyrax/templates/config/initializers/riiif.rb +22 -20
  221. data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
  222. data/lib/hyrax/configuration.rb +28 -0
  223. data/lib/hyrax/engine.rb +3 -1
  224. data/lib/hyrax/errors.rb +2 -0
  225. data/lib/hyrax/resource_name.rb +1 -0
  226. data/lib/hyrax/specs/capybara.rb +5 -3
  227. data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
  228. data/lib/hyrax/transactions/container.rb +32 -1
  229. data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
  230. data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
  231. data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
  232. data/lib/hyrax/transactions/steps/delete_resource.rb +38 -0
  233. data/lib/hyrax/transactions/steps/destroy_work.rb +1 -0
  234. data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
  235. data/lib/hyrax/transactions/work_create.rb +2 -1
  236. data/lib/hyrax/transactions/work_destroy.rb +20 -0
  237. data/lib/hyrax/valkyrie_can_can_adapter.rb +3 -0
  238. data/lib/hyrax/valkyrie_simple_path_generator.rb +20 -0
  239. data/lib/hyrax/version.rb +1 -1
  240. data/lib/hyrax.rb +9 -0
  241. data/lib/tasks/collection_type_global_id.rake +1 -1
  242. data/lib/tasks/embargo_lease.rake +27 -0
  243. data/lib/tasks/regenerate_derivatives.rake +12 -0
  244. data/lib/wings/active_fedora_converter/default_work.rb +19 -0
  245. data/lib/wings/attribute_transformer.rb +29 -19
  246. data/lib/wings/converter_value_mapper.rb +2 -2
  247. data/lib/wings/model_transformer.rb +21 -20
  248. data/lib/wings/orm_converter.rb +42 -23
  249. data/lib/wings/setup.rb +2 -0
  250. data/lib/wings/valkyrie/persister.rb +8 -5
  251. data/lib/wings/valkyrie/query_service.rb +96 -41
  252. data/lib/wings/valkyrie/storage.rb +56 -1
  253. data/lib/wings.rb +0 -21
  254. data/template.rb +1 -1
  255. metadata +41 -21
  256. data/chart/fcrepo/.gitignore +0 -2
  257. data/chart/fcrepo/.helmignore +0 -23
  258. data/chart/fcrepo/Chart.yaml +0 -11
  259. data/chart/fcrepo/README.md +0 -50
  260. data/chart/fcrepo/templates/NOTES.txt +0 -21
  261. data/chart/fcrepo/templates/_helpers.tpl +0 -68
  262. data/chart/fcrepo/templates/configmap-env.yaml +0 -19
  263. data/chart/fcrepo/templates/deployment.yaml +0 -109
  264. data/chart/fcrepo/templates/ingress.yaml +0 -41
  265. data/chart/fcrepo/templates/pvc.yaml +0 -20
  266. data/chart/fcrepo/templates/secret.yaml +0 -12
  267. data/chart/fcrepo/templates/service.yaml +0 -15
  268. data/chart/fcrepo/templates/serviceaccount.yaml +0 -12
  269. data/chart/fcrepo/templates/tests/test-connection.yaml +0 -15
  270. data/chart/fcrepo/values.yaml +0 -79
  271. data/chart/hyrax/templates/fcrepo-secret.yaml +0 -13
@@ -1,15 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
  class EmbargoExpiryJob < Hyrax::ApplicationJob
3
3
  def perform
4
- records_with_expired_embargos.each do |id|
5
- work = ActiveFedora::Base.find(id)
6
- Hyrax::Actors::EmbargoActor.new(work).destroy
4
+ records_with_expired_embargos.each do |resource|
5
+ Hyrax::EmbargoManager.release_embargo_for(resource: resource) &&
6
+ Hyrax::AccessControlList(resource).save
7
7
  end
8
8
  end
9
9
 
10
10
  ##
11
- # @return [Enumerator<String>] ids for all the objects that have expired active embargoes
11
+ # @return [Enumerator<Valkyrie::Resource>] ids for all the objects that have expired active embargoes
12
12
  def records_with_expired_embargos
13
- Hyrax::EmbargoService.assets_with_expired_embargoes.map(&:id)
13
+ ids = Hyrax::EmbargoService.assets_with_expired_embargoes.map(&:id)
14
+
15
+ Hyrax.query_service.find_many_by_ids(ids: ids)
14
16
  end
15
17
  end
@@ -30,6 +30,11 @@ class FileSetAttachedEventJob < ContentEventJob
30
30
  end
31
31
 
32
32
  def curation_concern
33
- repo_object.in_works.first
33
+ case repo_object
34
+ when ActiveFedora::Base
35
+ repo_object.in_works.first
36
+ else
37
+ Hyrax.query_service.find_parents(resource: repo_object).first
38
+ end
34
39
  end
35
40
  end
@@ -2,13 +2,29 @@
2
2
  class IngestLocalFileJob < Hyrax::ApplicationJob
3
3
  queue_as Hyrax.config.ingest_queue_name
4
4
 
5
- # @param [FileSet] file_set
5
+ # @param [FileSet, Hyrax::FileSet] file_set
6
6
  # @param [String] path
7
7
  # @param [User] user
8
8
  def perform(file_set, path, user)
9
+ case file_set
10
+ when ActiveFedora::Base
11
+ __perform(file_set, path, user, use_valkyrie: false)
12
+ else
13
+ __perform(file_set, path, user, use_valkyrie: true)
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ # @note Based on the present implementation (see SHA a8597884e) of
20
+ # the Hyrax::Actors::FileSetActor, we wouldn't need to pass the
21
+ # `use_valkyrie` parameter. However, I want to include this logic
22
+ # to demonstrate that "Yes, the IngestLocalFileJob has been tested
23
+ # for Valkyrie usage"
24
+ def __perform(file_set, path, user, use_valkyrie:)
9
25
  file_set.label ||= File.basename(path)
10
26
 
11
- actor = Hyrax::Actors::FileSetActor.new(file_set, user)
27
+ actor = Hyrax::Actors::FileSetActor.new(file_set, user, use_valkyrie: use_valkyrie)
12
28
 
13
29
  if actor.create_content(File.open(path))
14
30
  Hyrax.config.callback.run(:after_import_local_file_success, file_set, user, path, warn: false)
@@ -5,12 +5,16 @@ class InheritPermissionsJob < Hyrax::ApplicationJob
5
5
  # Perform the copy from the work to the contained filesets
6
6
  #
7
7
  # @param work containing access level and filesets
8
- # @param use_valkyrie [Boolean] whether to use valkyrie support
9
- def perform(work, use_valkyrie: Hyrax.config.use_valkyrie?)
10
- if use_valkyrie
11
- valkyrie_perform(work)
12
- else
8
+ # @param use_valkyrie [Boolean] whether to use valkyrie support (deprecated)
9
+ def perform(work, use_valkyrie: :DEFAULT)
10
+ Deprecation.warn("use_valkyrie argument is deprecated, behavior depends on deserialized resource") unless
11
+ use_valkyrie == :DEFAULT
12
+
13
+ case work
14
+ when ActiveFedora::Base
13
15
  af_perform(work)
16
+ else
17
+ valkyrie_perform(work)
14
18
  end
15
19
  end
16
20
 
@@ -1,15 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
  class LeaseExpiryJob < Hyrax::ApplicationJob
3
3
  def perform
4
- records_with_expired_leases.each do |id|
5
- work = ActiveFedora::Base.find(id)
6
- Hyrax::Actors::LeaseActor.new(work).destroy
4
+ records_with_expired_leases.each do |resource|
5
+ Hyrax::LeaseManager.release_lease_for(resource: resource) &&
6
+ Hyrax::AccessControlList(resource).save
7
7
  end
8
8
  end
9
9
 
10
10
  ##
11
11
  # @return [Enumerator<String>] ids for all the objects that have expired active leases
12
12
  def records_with_expired_leases
13
- Hyrax::LeaseService.assets_with_expired_leases.map(&:id)
13
+ ids = Hyrax::LeaseService.assets_with_expired_leases.map(&:id)
14
+
15
+ Hyrax.query_service.find_many_by_ids(ids: ids)
14
16
  end
15
17
  end
@@ -75,37 +75,18 @@ class AdminSet < ActiveFedora::Base
75
75
  Sipity::Workflow.find_active_workflow_for(admin_set_id: id)
76
76
  end
77
77
 
78
+ ##
79
+ # @deprecated use PermissionTemplate#reset_access_controls instead
80
+ #
78
81
  # Calculate and update who should have edit access based on who
79
82
  # has "manage" access in the PermissionTemplateAccess
80
83
  def reset_access_controls!
81
- # NOTE: This is different from Collections in that it doesn't update read access based on visibility.
82
- # See also app/models/concerns/hyrax/collection_behavior.rb#reset_access_controls!
83
- update!(edit_users: permission_template_edit_users,
84
- edit_groups: permission_template_edit_groups,
85
- read_users: permission_template_read_users,
86
- read_groups: permission_template_read_groups)
87
- end
88
-
89
- private
90
-
91
- def permission_template_edit_users
92
- permission_template.agent_ids_for(access: 'manage', agent_type: 'user')
93
- end
94
-
95
- def permission_template_edit_groups
96
- permission_template.agent_ids_for(access: 'manage', agent_type: 'group')
97
- end
84
+ Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls instead.")
98
85
 
99
- def permission_template_read_users
100
- (permission_template.agent_ids_for(access: 'view', agent_type: 'user') +
101
- permission_template.agent_ids_for(access: 'deposit', agent_type: 'user')).uniq
86
+ permission_template.reset_access_controls_for(collection: self)
102
87
  end
103
88
 
104
- def permission_template_read_groups
105
- (permission_template.agent_ids_for(access: 'view', agent_type: 'group') +
106
- permission_template.agent_ids_for(access: 'deposit', agent_type: 'group')).uniq -
107
- [::Ability.registered_group_name, ::Ability.public_group_name]
108
- end
89
+ private
109
90
 
110
91
  def destroy_permission_template
111
92
  permission_template.destroy
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  class CollectionBrandingInfo < ApplicationRecord
3
- # i = ColectionImageInfo.new()
4
-
5
3
  def initialize(collection_id:,
6
4
  filename:,
7
5
  role:,
@@ -13,20 +11,32 @@ class CollectionBrandingInfo < ApplicationRecord
13
11
  self.role = role
14
12
  self.alt_text = alt_txt
15
13
  self.target_url = target_url
16
-
17
- self.local_path = find_local_filename(collection_id, role, filename)
14
+ self.local_path = File.join(role, filename)
18
15
  end
19
16
 
20
17
  def save(file_location, copy_file = true)
21
- local_dir = find_local_dir_name(collection_id, role)
22
- FileUtils.mkdir_p local_dir
23
- FileUtils.cp file_location, local_path unless file_location == local_path || !copy_file
18
+ filename = File.split(local_path).last
19
+ role_and_filename = File.join(role, filename)
20
+
21
+ storage.upload(resource: Hyrax::PcdmCollection.new(id: collection_id),
22
+ file: File.open(file_location),
23
+ original_filename: role_and_filename)
24
+ self.local_path = find_local_filename(collection_id, role, filename)
25
+
24
26
  FileUtils.remove_file(file_location) if File.exist?(file_location) && copy_file
25
27
  super()
26
28
  end
27
29
 
28
- def delete(location_path)
29
- FileUtils.remove_file(location_path) if File.exist?(location_path)
30
+ def delete(location_path = nil)
31
+ id = if location_path
32
+ Deprecation.warn('Passing an explict location path is ' \
33
+ 'deprecated. Call without arguments instead.')
34
+ location_path
35
+ else
36
+ local_path
37
+ end
38
+
39
+ storage.delete(id: id)
30
40
  end
31
41
 
32
42
  def find_local_filename(collection_id, role, filename)
@@ -37,4 +47,10 @@ class CollectionBrandingInfo < ApplicationRecord
37
47
  def find_local_dir_name(collection_id, role)
38
48
  File.join(Hyrax.config.branding_path, collection_id.to_s, role.to_s)
39
49
  end
50
+
51
+ private
52
+
53
+ def storage
54
+ Hyrax.config.branding_storage_adapter
55
+ end
40
56
  end
@@ -37,6 +37,7 @@ module Hyrax
37
37
  self.registered_group_name = Hyrax.config.registered_user_group_name
38
38
  self.public_group_name = Hyrax.config.public_user_group_name
39
39
  self.ability_logic += [:admin_permissions,
40
+ :edit_resources,
40
41
  :curation_concerns_permissions,
41
42
  :operation_abilities,
42
43
  :add_to_collection,
@@ -108,6 +109,16 @@ module Hyrax
108
109
  end
109
110
  end
110
111
 
112
+ ##
113
+ # @api public
114
+ #
115
+ # Allows
116
+ def edit_resources
117
+ can [:edit, :update, :destroy], Hyrax::Resource do |resource|
118
+ test_edit(resource.id)
119
+ end
120
+ end
121
+
111
122
  ##
112
123
  # @api public
113
124
  #
@@ -406,8 +417,10 @@ module Hyrax
406
417
 
407
418
  def extract_subjects(subject)
408
419
  case subject
420
+ when Hyrax::WorkShowPresenter, FileSetPresenter, Hyrax::CollectionPresenter
421
+ extract_subjects(subject.solr_document)
409
422
  when Draper::Decorator
410
- super(subject.model)
423
+ extract_subjects(subject.model)
411
424
  else
412
425
  super
413
426
  end
@@ -51,27 +51,22 @@ module Hyrax
51
51
  end
52
52
 
53
53
  # Add members using the members association.
54
- # TODO: Confirm if this is ever used. I believe all relationships are done through
55
- # add_member_objects using the member_of_collections relationship. Deprecate?
56
54
  def add_members(new_member_ids)
57
- return if new_member_ids.blank?
58
- members << Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: new_member_ids, use_valkyrie: false)
55
+ Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
56
+ "Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.")
57
+ Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id,
58
+ new_member_ids: new_member_ids,
59
+ user: nil)
59
60
  end
60
61
 
61
62
  # Add member objects by adding this collection to the objects' member_of_collection association.
62
63
  # @param [Enumerable<String>] the ids of the new child collections and works collection ids
63
64
  def add_member_objects(new_member_ids)
64
- Array(new_member_ids).collect do |member_id|
65
- member = Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: member_id, use_valkyrie: false)
66
- message = Hyrax::MultipleMembershipChecker.new(item: member).check(collection_ids: id, include_current_members: true)
67
- if message
68
- member.errors.add(:collections, message)
69
- else
70
- member.member_of_collections << self
71
- member.save!
72
- end
73
- member
74
- end
65
+ Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
66
+ "Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.")
67
+ Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id,
68
+ new_member_ids: new_member_ids,
69
+ user: nil)
75
70
  end
76
71
 
77
72
  # @return [Enumerable<ActiveFedora::Base>] an enumerable over the children of this collection
@@ -125,41 +120,19 @@ module Hyrax
125
120
  Hyrax::PermissionTemplate.find_by!(source_id: id)
126
121
  end
127
122
 
123
+ ##
124
+ # @deprecated use PermissionTemplate#reset_access_controls instead
125
+ #
128
126
  # Calculate and update who should have read/edit access to the collections based on who
129
127
  # has access in PermissionTemplateAccess
130
128
  def reset_access_controls!
131
- update!(edit_users: permission_template_edit_users,
132
- edit_groups: permission_template_edit_groups,
133
- read_users: permission_template_read_users,
134
- read_groups: (permission_template_read_groups + visibility_group).uniq)
135
- end
136
-
137
- private
138
-
139
- def permission_template_edit_users
140
- permission_template.agent_ids_for(access: 'manage', agent_type: 'user')
141
- end
129
+ Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls instead.")
142
130
 
143
- def permission_template_edit_groups
144
- permission_template.agent_ids_for(access: 'manage', agent_type: 'group')
131
+ permission_template
132
+ .reset_access_controls_for(collection: self, interpret_visibility: true)
145
133
  end
146
134
 
147
- def permission_template_read_users
148
- (permission_template.agent_ids_for(access: 'view', agent_type: 'user') +
149
- permission_template.agent_ids_for(access: 'deposit', agent_type: 'user')).uniq
150
- end
151
-
152
- def permission_template_read_groups
153
- (permission_template.agent_ids_for(access: 'view', agent_type: 'group') +
154
- permission_template.agent_ids_for(access: 'deposit', agent_type: 'group')).uniq -
155
- [::Ability.registered_group_name, ::Ability.public_group_name]
156
- end
157
-
158
- def visibility_group
159
- return [Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC] if visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
160
- return [Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED] if visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
161
- []
162
- end
135
+ private
163
136
 
164
137
  # Solr field name works use to index member ids
165
138
  def member_ids_field
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ module Hyrax
3
+ module Embargoable
4
+ extend ActiveSupport::Concern
5
+ include Hydra::AccessControls::Embargoable
6
+
7
+ included do
8
+ validates :lease_expiration_date, 'hydra/future_date': true, on: :create
9
+ validates :embargo_release_date, 'hydra/future_date': true, on: :create
10
+ end
11
+
12
+ ##
13
+ # Override aggressive Hydra::AccessControls validation
14
+ def enforce_future_date_for_embargo?
15
+ false
16
+ end
17
+
18
+ ##
19
+ # Override aggressive Hydra::AccessControls validation
20
+ def enforce_future_date_for_lease?
21
+ false
22
+ end
23
+ end
24
+ end
@@ -1,18 +1,24 @@
1
1
  # frozen_string_literal: true
2
- # This module points the FileSet to the location of the technical metadata.
3
- # By default, the file holding the metadata is :original_file and the terms
4
- # are listed under ::characterization_terms.
5
- # Implementations may define their own terms or use a different source file, but
6
- # any terms must be set on the ::characterization_proxy by the Hydra::Works::CharacterizationService
7
- #
8
- # class MyFileSet
9
- # include Hyrax::FileSetBehavior
10
- # end
11
- #
12
- # MyFileSet.characterization_proxy = :master_file
13
- # MyFileSet.characterization_terms = [:term1, :term2, :term3]
2
+
14
3
  module Hyrax
15
4
  class FileSet
5
+ ##
6
+ # This module points the FileSet to the location of the technical metadata.
7
+ # By default, the file holding the metadata is +:original_file+ and the terms
8
+ # are listed under +.characterization_terms+.
9
+ #
10
+ # Implementations may define their own terms or use a different source file, but
11
+ # any terms must be set on the +.characterization_proxy+ by the
12
+ # +Hydra::Works::CharacterizationService+.
13
+ #
14
+ # @example
15
+ # class MyFileSet
16
+ # include Hyrax::FileSetBehavior
17
+ # end
18
+ #
19
+ # MyFileSet.characterization_proxy = :master_file
20
+ # MyFileSet.characterization_terms = [:term1, :term2, :term3]
21
+ #
16
22
  module Characterization
17
23
  extend ActiveSupport::Concern
18
24
 
@@ -13,6 +13,8 @@ module Hyrax
13
13
  #
14
14
  # @see https://github.com/projectblacklight/blacklight/wiki/Understanding-Rails-and-Blacklight#models
15
15
  module SolrDocumentBehavior
16
+ ModelWrapper = ActiveFedoraDummyModel # alias for backward compatibility
17
+
16
18
  extend ActiveSupport::Concern
17
19
  include Hydra::Works::MimeTypes
18
20
  include Hyrax::Permissions::Readable
@@ -39,58 +41,13 @@ module Hyrax
39
41
  title_or_label.to_s
40
42
  end
41
43
 
42
- ##
43
- # Given a model class and an +id+, provides +ActiveModel+ style model methods.
44
- #
45
- # @note access this via {SolrDocumentBehavior#to_model}.
46
- class ModelWrapper
47
- ##
48
- # @api private
49
- #
50
- # @param [Class] model
51
- # @param [String, nil] id
52
- def initialize(model, id)
53
- @model = model
54
- @id = id
55
- end
56
-
57
- ##
58
- # @api public
59
- def persisted?
60
- true
61
- end
62
-
63
- ##
64
- # @api public
65
- def to_param
66
- @id
67
- end
68
-
69
- ##
70
- # @api public
71
- def model_name
72
- @model.model_name
73
- end
74
-
75
- ##
76
- # @api public
77
- def to_partial_path
78
- @model._to_partial_path
79
- end
80
-
81
- ##
82
- # @api public
83
- def to_global_id
84
- URI::GID.build app: GlobalID.app, model_name: model_name.name, model_id: @id
85
- end
86
- end
87
44
  ##
88
45
  # Offer the source model to Rails for some of the Rails methods (e.g. link_to).
89
46
  #
90
47
  # @example
91
48
  # link_to '...', SolrDocument(:id => 'bXXXXXX5').new => <a href="/dams_object/bXXXXXX5">...</a>
92
49
  def to_model
93
- @model ||= ModelWrapper.new(hydra_model, id)
50
+ @model ||= ActiveFedoraDummyModel.new(hydra_model, id)
94
51
  end
95
52
 
96
53
  ##
@@ -111,6 +68,12 @@ module Hyrax
111
68
  hydra_model == ::AdminSet
112
69
  end
113
70
 
71
+ ##
72
+ # @return [Boolean]
73
+ def work?
74
+ Hyrax.config.curation_concerns.include? hydra_model
75
+ end
76
+
114
77
  # Method to return the model
115
78
  def hydra_model(classifier: ActiveFedora.model_mapper)
116
79
  "::#{first('has_model_ssim')}".safe_constantize ||