hyrax 3.0.2 → 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.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +22 -0
  3. data/.dassie/Gemfile +10 -5
  4. data/.dassie/config/initializers/hyrax.rb +5 -0
  5. data/.dockerignore +3 -0
  6. data/.env +0 -1
  7. data/.rubocop.yml +4 -0
  8. data/CONTAINERS.md +1 -1
  9. data/Dockerfile +12 -6
  10. data/Gemfile +21 -27
  11. data/app/actors/hyrax/actors/base_actor.rb +1 -1
  12. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +85 -63
  13. data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
  14. data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +20 -8
  15. data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
  16. data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
  17. data/app/controllers/concerns/hyrax/works_controller_behavior.rb +22 -3
  18. data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
  19. data/app/controllers/hyrax/dashboard/collection_members_controller.rb +13 -9
  20. data/app/controllers/hyrax/dashboard/collections_controller.rb +12 -10
  21. data/app/controllers/hyrax/file_sets_controller.rb +49 -13
  22. data/app/controllers/hyrax/permissions_controller.rb +3 -4
  23. data/app/controllers/hyrax/workflow_actions_controller.rb +3 -1
  24. data/app/forms/hyrax/forms/collection_form.rb +7 -3
  25. data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +24 -2
  26. data/app/forms/hyrax/forms/file_set_form.rb +46 -0
  27. data/app/forms/hyrax/forms/permission.rb +23 -0
  28. data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
  29. data/app/forms/hyrax/forms/resource_form.rb +10 -17
  30. data/app/forms/hyrax/forms/work_form.rb +5 -2
  31. data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
  32. data/app/helpers/hyrax/collections_helper.rb +88 -2
  33. data/app/helpers/hyrax/dashboard_helper_behavior.rb +3 -7
  34. data/app/helpers/hyrax/file_set_helper.rb +25 -6
  35. data/app/helpers/hyrax/work_form_helper.rb +53 -0
  36. data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
  37. data/app/indexers/hyrax/valkyrie_indexer.rb +3 -3
  38. data/app/inputs/controlled_vocabulary_input.rb +2 -5
  39. data/app/jobs/attach_files_to_work_job.rb +19 -10
  40. data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
  41. data/app/jobs/inherit_permissions_job.rb +9 -5
  42. data/app/models/admin_set.rb +6 -25
  43. data/app/models/concerns/hyrax/ability.rb +3 -1
  44. data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
  45. data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
  46. data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -52
  47. data/app/models/concerns/hyrax/suppressible.rb +5 -0
  48. data/app/models/concerns/hyrax/user.rb +9 -3
  49. data/app/models/hyrax/file_set.rb +6 -0
  50. data/app/models/hyrax/pcdm_collection.rb +1 -0
  51. data/app/models/hyrax/permission_template.rb +98 -12
  52. data/app/models/hyrax/virus_scanner.rb +27 -18
  53. data/app/models/sipity/agent.rb +1 -0
  54. data/app/models/sipity/entity.rb +30 -8
  55. data/app/models/sipity/workflow.rb +1 -0
  56. data/app/models/sipity.rb +42 -0
  57. data/app/presenters/hyrax/admin_set_options_presenter.rb +2 -10
  58. data/app/presenters/hyrax/admin_set_presenter.rb +5 -1
  59. data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
  60. data/app/presenters/hyrax/collection_presenter.rb +31 -6
  61. data/app/presenters/hyrax/file_set_presenter.rb +6 -1
  62. data/app/presenters/hyrax/file_usage.rb +3 -2
  63. data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
  64. data/app/presenters/hyrax/trophy_presenter.rb +33 -4
  65. data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
  66. data/app/presenters/hyrax/version_list_presenter.rb +19 -0
  67. data/app/presenters/hyrax/version_presenter.rb +3 -2
  68. data/app/presenters/hyrax/work_show_presenter.rb +25 -4
  69. data/app/presenters/hyrax/work_usage.rb +5 -3
  70. data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
  71. data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
  72. data/app/search_builders/hyrax/my/collections_search_builder.rb +1 -1
  73. data/app/services/hyrax/admin_set_create_service.rb +3 -1
  74. data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
  75. data/app/services/hyrax/collections/collection_member_service.rb +112 -27
  76. data/app/services/hyrax/collections/migration_service.rb +4 -2
  77. data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
  78. data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
  79. data/app/services/hyrax/collections/permissions_create_service.rb +6 -4
  80. data/app/services/hyrax/contextual_path.rb +23 -0
  81. data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
  82. data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
  83. data/app/services/hyrax/edit_permissions_service.rb +27 -20
  84. data/app/services/hyrax/find_objects_via_solr_service.rb +11 -7
  85. data/app/services/hyrax/multiple_membership_checker.rb +51 -31
  86. data/app/services/hyrax/resource_status.rb +7 -0
  87. data/app/services/hyrax/search_service.rb +4 -2
  88. data/app/services/hyrax/solr_query_builder_service.rb +29 -6
  89. data/app/services/hyrax/solr_query_service.rb +224 -0
  90. data/app/services/hyrax/solr_service.rb +8 -1
  91. data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
  92. data/app/services/hyrax/work_uploads_handler.rb +17 -2
  93. data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
  94. data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
  95. data/app/services/hyrax/workflow/status_list_service.rb +43 -13
  96. data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
  97. data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
  98. data/app/views/hyrax/base/_form_representative.html.erb +1 -1
  99. data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
  100. data/app/views/hyrax/base/_guts4form.html.erb +2 -2
  101. data/app/views/hyrax/base/_representative_media.html.erb +1 -1
  102. data/app/views/hyrax/base/_show_actions.html.erb +1 -1
  103. data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
  104. data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
  105. data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
  106. data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
  107. data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
  108. data/app/views/hyrax/file_sets/edit.html.erb +1 -1
  109. data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
  110. data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
  111. data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
  112. data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
  113. data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
  114. data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
  115. data/app/views/hyrax/file_sets/show.html.erb +1 -1
  116. data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
  117. data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
  118. data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
  119. data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
  120. data/bin/solrcloud-assign-configset.sh +8 -5
  121. data/bin/solrcloud-upload-configset.sh +4 -2
  122. data/chart/hyrax/Chart.yaml +3 -3
  123. data/chart/hyrax/README.md +47 -1
  124. data/chart/hyrax/templates/_helpers.tpl +1 -1
  125. data/chart/hyrax/templates/configmap-env.yaml +1 -3
  126. data/chart/hyrax/templates/deployment-worker.yaml +6 -3
  127. data/chart/hyrax/templates/deployment.yaml +8 -3
  128. data/chart/hyrax/values.yaml +12 -0
  129. data/config/brakeman.ignore +2 -2
  130. data/config/locales/hyrax.de.yml +1 -1
  131. data/config/locales/hyrax.en.yml +1 -1
  132. data/config/locales/hyrax.es.yml +1 -1
  133. data/config/locales/hyrax.fr.yml +1 -1
  134. data/config/locales/hyrax.it.yml +1 -1
  135. data/config/locales/hyrax.pt-BR.yml +1 -1
  136. data/config/locales/hyrax.zh.yml +1 -1
  137. data/docker-compose.yml +1 -0
  138. data/documentation/developing-your-hyrax-based-app.md +1 -1
  139. data/documentation/legacyREADME.md +1 -1
  140. data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
  141. data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
  142. data/lib/hyrax/configuration.rb +8 -0
  143. data/lib/hyrax/engine.rb +1 -0
  144. data/lib/hyrax/errors.rb +2 -0
  145. data/lib/hyrax/specs/capybara.rb +3 -1
  146. data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
  147. data/lib/hyrax/transactions/container.rb +21 -0
  148. data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
  149. data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
  150. data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
  151. data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
  152. data/lib/hyrax/transactions/work_create.rb +2 -1
  153. data/lib/hyrax/valkyrie_can_can_adapter.rb +1 -0
  154. data/lib/hyrax/version.rb +1 -1
  155. data/lib/hyrax.rb +9 -0
  156. data/lib/tasks/collection_type_global_id.rake +1 -1
  157. data/lib/tasks/regenerate_derivatives.rake +12 -0
  158. data/lib/wings/orm_converter.rb +18 -2
  159. data/lib/wings/setup.rb +1 -0
  160. data/lib/wings/valkyrie/storage.rb +56 -1
  161. data/template.rb +1 -1
  162. metadata +17 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83e192b584ccacb1817682f20c3f92863142dcd6bb0f5cf3ad94510c9bfd8b6e
4
- data.tar.gz: 0f4e5459438aa41d335cad94e3c4fa9167d5dbc7eb52323cbb56a532e91c76a3
3
+ metadata.gz: ea0970bcb0ea485337ce206cd398d9ca95ce9f5dbd22bda820b6112e089ed624
4
+ data.tar.gz: c58183be603ec7ac6af52523412034f3b28332b2b8d5aa788239e7dabbf4c521
5
5
  SHA512:
6
- metadata.gz: bc71e039869a7b368cdeb864333683d3b9079fb2d4191d70c8bbdb1cd32c8686060814846590d5b418321c9f57b28ab8b35989a86b02282453761a2c90d26467
7
- data.tar.gz: 6540b1bcb3b98e523cf5d1790ca160ccb39a1cc0ecec77e2747205727c699710cb67f063fafd3030f8433b8ce0ce85ecc3b075a8e744ad5a8519a8a61ecd4e34
6
+ metadata.gz: af2b27f2c10d54ede9007a17f4a126bf408d92c163a924081658625212ff52edccb06bbc7edcf49fce1faa56c715bdf0454f687fbc284f93cfd8d30dbb26d46a
7
+ data.tar.gz: 85b38c0dc2628abbbb56dc8aed70461bb5fe6e9ce4444a2d61d6f972968efd1f9157881fc2a5f4443cb1bba85f0495b78e3bc2e7d0d7fe5ea9a8d4cb69d6946b
data/.circleci/config.yml CHANGED
@@ -136,6 +136,21 @@ jobs:
136
136
  command: bundle exec rake app:db:migrate
137
137
  - samvera/parallel_rspec
138
138
 
139
+ # Trigger a workflow on the nurax repository that will deploy the most recent hyrax gem code to https://nurax-dev.curationexperts.com/
140
+ deploy:
141
+ docker:
142
+ - image: ubuntu
143
+ steps:
144
+ - run:
145
+ name: Install curl
146
+ command: apt-get update && apt-get install -y curl
147
+ - run:
148
+ name: "Trigger Nurax deploy"
149
+ command: |
150
+ curl -X POST https://circleci.com/api/v2/project/gh/curationexperts/nurax/pipeline \
151
+ --header "Circle-Token: $NURAX_CIRCLECI_TOKEN" \
152
+ --header 'Accept: text/plain' \
153
+ --header 'Content-Type: application/json'
139
154
  workflows:
140
155
  version: 2
141
156
  ruby2-5-8:
@@ -192,3 +207,10 @@ workflows:
192
207
  bundler_version: "2.1.4"
193
208
  requires:
194
209
  - build
210
+ nurax-dev_deploy:
211
+ jobs:
212
+ - deploy:
213
+ filters:
214
+ branches:
215
+ only:
216
+ - main
data/.dassie/Gemfile CHANGED
@@ -1,4 +1,11 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+ # Attempts to determine if a global gem source has ready been added by another Gemfile
3
+ if @sources.global_rubygems_source == Bundler::SourceList.new.global_rubygems_source
4
+ Bundler.ui.info '[Dassie] Adding global rubygems source.'
5
+ source 'https://rubygems.org'
6
+ else
7
+ Bundler.ui.info "[Dassie] Global rubygems source already set: #{@sources.global_rubygems_source.inspect}"
8
+ end
2
9
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
10
 
4
11
  ruby '2.7.2'
@@ -8,7 +15,7 @@ gem 'rails', '~> 5.2.4', '>= 5.2.4.4'
8
15
  # Use postgresql as the database for Active Record
9
16
  gem 'pg', '>= 0.18', '< 2.0'
10
17
  # Use Puma as the app server
11
- gem 'puma', '~> 3.11'
18
+ gem 'puma', '~> 4.3.8'
12
19
  # Use SCSS for stylesheets
13
20
  gem 'sass-rails', '~> 5.0'
14
21
  # Use Uglifier as compressor for JavaScript assets
@@ -43,9 +50,7 @@ end
43
50
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
44
51
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
45
52
 
46
- begin # this is a hack to allow `eval_gemfile` to work correctly
47
- gem 'hyrax', path: ENV.fetch('HYRAX_ENGINE_PATH', '..')
48
- rescue; end
53
+ gemspec name: 'hyrax', path: ENV.fetch('HYRAX_ENGINE_PATH', '..')
49
54
 
50
55
  gem 'rsolr', '>= 1.0', '< 3'
51
56
  gem 'bootstrap-sass', '~> 3.0'
@@ -39,6 +39,11 @@ Hyrax.config do |config|
39
39
  ##
40
40
  # Set the system-wide virus scanner
41
41
  config.virus_scanner = Hyrax::VirusScanner
42
+
43
+ ##
44
+ # To index to the Valkyrie core, uncomment the following two lines.
45
+ # config.query_index_from_valkyrie = true
46
+ # config.index_adapter = :solr_index
42
47
  end
43
48
 
44
49
  Date::DATE_FORMATS[:standard] = "%m/%d/%Y"
data/.dockerignore CHANGED
@@ -10,3 +10,6 @@ Dockerfile
10
10
  artifacts/*
11
11
  coverage/*
12
12
  chart/*
13
+
14
+ Gemfile.lock
15
+ .dassie/Gemfile.lock
data/.env CHANGED
@@ -1,4 +1,3 @@
1
- CAPYBARA_SERVER=http://app:3010
2
1
  CHROME_HEADLESS_MODE=false
3
2
  DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true
4
3
  DATABASE_TEST_URL=postgresql://hyrax_user:hyrax_password@postgres/hyrax_test?pool=5
data/.rubocop.yml CHANGED
@@ -41,6 +41,10 @@ Metrics/BlockLength:
41
41
  Style/AsciiComments:
42
42
  Enabled: false
43
43
 
44
+ # rubocop suggests !thing.nil? instead, but that is NOT equivalent
45
+ Style/DoubleNegation:
46
+ Enabled: false
47
+
44
48
  Style/CollectionMethods:
45
49
  PreferredMethods:
46
50
  collect: 'map'
data/CONTAINERS.md CHANGED
@@ -8,7 +8,7 @@ providing better guidance around deployment.
8
8
  Where are we at? It's complicated. What we have below is experimental support, but one that we want to push
9
9
  towards. We need your help to keep pushing in this direction. So dig in and prepare to get your hands dirty.
10
10
 
11
- The [Hyrax Engine Development](#hyrax-engine-development) is further along than the [Docker Image for Hyrax-based Applications](docker-image-for-hyrax-based-applications) which is further along than [Deploying to Production](#deploying-to-production).
11
+ The [Hyrax Engine Development](#hyrax-engine-development) is further along than the [Docker Image for Hyrax-based Applications](#docker-image-for-hyrax-based-applications) which is further along than [Deploying to Production](#deploying-to-production).
12
12
 
13
13
  <!-- NOTE: This title is referenced in the top-level README.md. Keep that in mind if you change it. -->
14
14
  ## Hyrax Engine Development
data/Dockerfile CHANGED
@@ -44,7 +44,7 @@ ONBUILD RUN bundle install --jobs "$(nproc)"
44
44
  ONBUILD RUN RAILS_ENV=production SECRET_KEY_BASE=`bin/rake secret` DB_ADAPTER=nulldb DATABASE_URL='postgresql://fake' bundle exec rake assets:precompile
45
45
 
46
46
 
47
- FROM hyrax-base as hyrax-worker
47
+ FROM hyrax-base as hyrax-worker-base
48
48
 
49
49
  ENV MALLOC_ARENA_MAX=2
50
50
 
@@ -64,13 +64,17 @@ RUN mkdir -p /app/fits && \
64
64
  chmod a+x /app/fits/fits.sh
65
65
  ENV PATH="${PATH}:/app/fits"
66
66
 
67
+ CMD bundle exec sidekiq
68
+
69
+
70
+ FROM hyrax-worker-base as hyrax-worker
71
+
67
72
  ARG APP_PATH=.
68
73
  ARG BUNDLE_WITHOUT="development test"
69
74
 
70
75
  ONBUILD COPY --chown=1001:101 $APP_PATH /app/samvera/hyrax-webapp
71
76
  ONBUILD RUN bundle install --jobs "$(nproc)"
72
-
73
- CMD bundle exec sidekiq
77
+ ONBUILD RUN RAILS_ENV=production SECRET_KEY_BASE=`bin/rake secret` DB_ADAPTER=nulldb DATABASE_URL='postgresql://fake' bundle exec rake assets:precompile
74
78
 
75
79
 
76
80
  FROM hyrax-base as hyrax-engine-dev
@@ -83,11 +87,13 @@ ENV HYRAX_ENGINE_PATH /app/samvera/hyrax-engine
83
87
  COPY --chown=1001:101 $APP_PATH /app/samvera/hyrax-webapp
84
88
  COPY --chown=1001:101 . /app/samvera/hyrax-engine
85
89
 
86
- RUN cd /app/samvera/hyrax-engine && bundle install --jobs "$(nproc)"
90
+ RUN gem update bundler && gem cleanup bundler && bundle -v && \
91
+ bundle install --jobs "$(nproc)" && \
92
+ cd $HYRAX_ENGINE_PATH && bundle install --jobs "$(nproc)"
87
93
  RUN RAILS_ENV=production SECRET_KEY_BASE='fakesecret1234' DB_ADAPTER=nulldb DATABASE_URL='postgresql://fake' bundle exec rake assets:precompile
88
94
 
89
95
 
90
- FROM hyrax-worker as hyrax-engine-dev-worker
96
+ FROM hyrax-worker-base as hyrax-engine-dev-worker
91
97
 
92
98
  ARG APP_PATH=.dassie
93
99
  ARG BUNDLE_WITHOUT=
@@ -97,4 +103,4 @@ ENV HYRAX_ENGINE_PATH /app/samvera/hyrax-engine
97
103
  COPY --chown=1001:101 $APP_PATH /app/samvera/hyrax-webapp
98
104
  COPY --chown=1001:101 . /app/samvera/hyrax-engine
99
105
 
100
- RUN cd /app/samvera/hyrax-engine && bundle install --jobs "$(nproc)"
106
+ RUN bundle install --jobs "$(nproc)"
data/Gemfile CHANGED
@@ -1,44 +1,38 @@
1
1
  # frozen_string_literal: true
2
- source 'https://rubygems.org' do
3
- # Please see hyrax.gemspec for dependency information.
4
- gemspec
2
+ source 'https://rubygems.org'
3
+ # Please see hyrax.gemspec for dependency information.
4
+ gemspec
5
5
 
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
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 "[Hyrax] Unable to find test application dependencies in #{test_app_gemfile}, using placeholder dependencies"
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,90 +26,112 @@ module Hyrax
26
26
 
27
27
  private
28
28
 
29
- def registered_ingest_dirs
30
- Hyrax.config.registered_ingest_dirs
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
- # @param uri [URI] the uri fo the resource to import
34
- def validate_remote_url(uri)
35
- if uri.scheme == 'file'
36
- path = File.absolute_path(CGI.unescape(uri.path))
37
- registered_ingest_dirs.any? do |dir|
38
- path.start_with?(dir) && path.length > dir.length
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
- else
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
- # @param [HashWithIndifferentAccess] remote_files
47
- # @return [TrueClass]
48
- def attach_files(env, remote_files)
49
- return true unless remote_files
50
- remote_files.each do |file_info|
51
- next if file_info.blank? || file_info[:url].blank?
52
- # Escape any space characters, so that this is a legal URI
53
- uri = URI.parse(Addressable::URI.escape(file_info[:url]))
54
- unless validate_remote_url(uri)
55
- Rails.logger.error "User #{env.user.user_key} attempted to ingest file from url #{file_info[:url]}, which doesn't pass validation"
56
- return false
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
- def create_file_from_url(env, uri, file_name, auth_header)
65
- case env.curation_concern
66
- when Valkyrie::Resource
67
- create_file_from_url_through_valkyrie(env, uri, file_name, auth_header)
68
- else
69
- create_file_from_url_through_active_fedora(env, uri, file_name, auth_header)
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)
70
105
  end
71
- end
72
106
 
73
- # Generic utility for creating FileSet from a URL
74
- # Used in to import files using URLs from a file picker like browse_everything
75
- def create_file_from_url_through_active_fedora(env, uri, file_name, auth_header)
76
- import_url = URI.decode_www_form_component(uri.to_s)
77
- ::FileSet.new(import_url: import_url, label: file_name) do |fs|
78
- actor = Hyrax::Actors::FileSetActor.new(fs, env.user)
79
- actor.create_metadata(visibility: env.curation_concern.visibility)
80
- actor.attach_to_work(env.curation_concern)
81
- fs.save!
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
82
114
  if uri.scheme == 'file'
83
115
  # Turn any %20 into spaces.
84
116
  file_path = CGI.unescape(uri.path)
85
- IngestLocalFileJob.perform_later(fs, file_path, env.user)
117
+ IngestLocalFileJob.perform_later(file_set, file_path, user)
86
118
  else
87
- ImportUrlJob.perform_later(fs, operation_for(user: actor.user), auth_header)
119
+ ImportUrlJob.perform_later(file_set, operation_for(user: user), auth_header)
88
120
  end
89
121
  end
90
- end
91
122
 
92
- # Generic utility for creating Hyrax::FileSet from a URL
93
- # Used in to import files using URLs from a file picker like browse_everything
94
- def create_file_from_url_through_valkyrie(env, uri, file_name, auth_header)
95
- import_url = URI.decode_www_form_component(uri.to_s)
96
- fs = Hyrax.persister.save(resource: Hyrax::FileSet.new(import_url: import_url, label: file_name))
97
- actor = Hyrax::Actors::FileSetActor.new(fs, env.user, use_valkyrie: true)
98
- actor.create_metadata(visibility: env.curation_concern.visibility)
99
- actor.attach_to_work(env.curation_concern)
100
- if uri.scheme == 'file'
101
- # Turn any %20 into spaces.
102
- file_path = CGI.unescape(uri.path)
103
- IngestLocalFileJob.perform_later(fs, file_path, env.user)
104
- else
105
- ImportUrlJob.perform_later(fs, operation_for(user: actor.user), auth_header)
123
+ def operation_for(user:)
124
+ Hyrax::Operation.create!(user: user,
125
+ operation_type: "Attach Remote File")
106
126
  end
107
- end
108
127
 
109
- def operation_for(user:)
110
- Hyrax::Operation.create!(user: user,
111
- operation_type: "Attach Remote File")
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
112
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
113
135
  end
114
136
  end
115
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
- remote_files.each do |file_info|
49
- next if file_info.blank? || file_info[:url].blank?
50
- # Escape any space characters, so that this is a legal URI
51
- uri = URI.parse(Addressable::URI.escape(file_info[:url]))
52
- unless validate_remote_url(uri)
53
- Rails.logger.error "User #{env.user.user_key} attempted to ingest file from url #{file_info[:url]}, which doesn't pass validation"
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