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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +22 -0
- data/.dassie/Gemfile +10 -5
- data/.dassie/config/initializers/hyrax.rb +5 -0
- data/.dockerignore +3 -0
- data/.env +0 -1
- data/.rubocop.yml +4 -0
- data/CONTAINERS.md +1 -1
- data/Dockerfile +12 -6
- data/Gemfile +21 -27
- data/app/actors/hyrax/actors/base_actor.rb +1 -1
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +85 -63
- data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +20 -8
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
- data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +22 -3
- data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
- data/app/controllers/hyrax/dashboard/collection_members_controller.rb +13 -9
- data/app/controllers/hyrax/dashboard/collections_controller.rb +12 -10
- data/app/controllers/hyrax/file_sets_controller.rb +49 -13
- data/app/controllers/hyrax/permissions_controller.rb +3 -4
- data/app/controllers/hyrax/workflow_actions_controller.rb +3 -1
- data/app/forms/hyrax/forms/collection_form.rb +7 -3
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +24 -2
- data/app/forms/hyrax/forms/file_set_form.rb +46 -0
- data/app/forms/hyrax/forms/permission.rb +23 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
- data/app/forms/hyrax/forms/resource_form.rb +10 -17
- data/app/forms/hyrax/forms/work_form.rb +5 -2
- data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
- data/app/helpers/hyrax/collections_helper.rb +88 -2
- data/app/helpers/hyrax/dashboard_helper_behavior.rb +3 -7
- data/app/helpers/hyrax/file_set_helper.rb +25 -6
- data/app/helpers/hyrax/work_form_helper.rb +53 -0
- data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
- data/app/indexers/hyrax/valkyrie_indexer.rb +3 -3
- 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/inherit_permissions_job.rb +9 -5
- data/app/models/admin_set.rb +6 -25
- data/app/models/concerns/hyrax/ability.rb +3 -1
- data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
- data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
- data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -52
- data/app/models/concerns/hyrax/suppressible.rb +5 -0
- data/app/models/concerns/hyrax/user.rb +9 -3
- data/app/models/hyrax/file_set.rb +6 -0
- data/app/models/hyrax/pcdm_collection.rb +1 -0
- data/app/models/hyrax/permission_template.rb +98 -12
- data/app/models/hyrax/virus_scanner.rb +27 -18
- data/app/models/sipity/agent.rb +1 -0
- data/app/models/sipity/entity.rb +30 -8
- data/app/models/sipity/workflow.rb +1 -0
- data/app/models/sipity.rb +42 -0
- data/app/presenters/hyrax/admin_set_options_presenter.rb +2 -10
- data/app/presenters/hyrax/admin_set_presenter.rb +5 -1
- data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
- data/app/presenters/hyrax/collection_presenter.rb +31 -6
- data/app/presenters/hyrax/file_set_presenter.rb +6 -1
- data/app/presenters/hyrax/file_usage.rb +3 -2
- 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 +25 -4
- data/app/presenters/hyrax/work_usage.rb +5 -3
- data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
- data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
- data/app/search_builders/hyrax/my/collections_search_builder.rb +1 -1
- data/app/services/hyrax/admin_set_create_service.rb +3 -1
- data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
- data/app/services/hyrax/collections/collection_member_service.rb +112 -27
- data/app/services/hyrax/collections/migration_service.rb +4 -2
- data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
- data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
- data/app/services/hyrax/collections/permissions_create_service.rb +6 -4
- data/app/services/hyrax/contextual_path.rb +23 -0
- data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
- data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
- data/app/services/hyrax/edit_permissions_service.rb +27 -20
- data/app/services/hyrax/find_objects_via_solr_service.rb +11 -7
- data/app/services/hyrax/multiple_membership_checker.rb +51 -31
- 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 +29 -6
- data/app/services/hyrax/solr_query_service.rb +224 -0
- data/app/services/hyrax/solr_service.rb +8 -1
- data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
- data/app/services/hyrax/work_uploads_handler.rb +17 -2
- data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
- data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
- data/app/services/hyrax/workflow/status_list_service.rb +43 -13
- data/app/views/hyrax/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/_guts4form.html.erb +2 -2
- data/app/views/hyrax/base/_representative_media.html.erb +1 -1
- data/app/views/hyrax/base/_show_actions.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
- data/app/views/hyrax/file_sets/edit.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
- data/app/views/hyrax/file_sets/show.html.erb +1 -1
- data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
- data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
- data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
- data/bin/solrcloud-assign-configset.sh +8 -5
- data/bin/solrcloud-upload-configset.sh +4 -2
- data/chart/hyrax/Chart.yaml +3 -3
- data/chart/hyrax/README.md +47 -1
- data/chart/hyrax/templates/_helpers.tpl +1 -1
- data/chart/hyrax/templates/configmap-env.yaml +1 -3
- data/chart/hyrax/templates/deployment-worker.yaml +6 -3
- data/chart/hyrax/templates/deployment.yaml +8 -3
- data/chart/hyrax/values.yaml +12 -0
- data/config/brakeman.ignore +2 -2
- data/config/locales/hyrax.de.yml +1 -1
- data/config/locales/hyrax.en.yml +1 -1
- data/config/locales/hyrax.es.yml +1 -1
- data/config/locales/hyrax.fr.yml +1 -1
- data/config/locales/hyrax.it.yml +1 -1
- data/config/locales/hyrax.pt-BR.yml +1 -1
- data/config/locales/hyrax.zh.yml +1 -1
- data/docker-compose.yml +1 -0
- data/documentation/developing-your-hyrax-based-app.md +1 -1
- data/documentation/legacyREADME.md +1 -1
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
- data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
- data/lib/hyrax/configuration.rb +8 -0
- data/lib/hyrax/engine.rb +1 -0
- data/lib/hyrax/errors.rb +2 -0
- data/lib/hyrax/specs/capybara.rb +3 -1
- data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
- data/lib/hyrax/transactions/container.rb +21 -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_parent.rb +36 -0
- data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
- data/lib/hyrax/transactions/work_create.rb +2 -1
- data/lib/hyrax/valkyrie_can_can_adapter.rb +1 -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/regenerate_derivatives.rake +12 -0
- data/lib/wings/orm_converter.rb +18 -2
- data/lib/wings/setup.rb +1 -0
- data/lib/wings/valkyrie/storage.rb +56 -1
- data/template.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ea0970bcb0ea485337ce206cd398d9ca95ce9f5dbd22bda820b6112e089ed624
|
|
4
|
+
data.tar.gz: c58183be603ec7ac6af52523412034f3b28332b2b8d5aa788239e7dabbf4c521
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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
data/.env
CHANGED
data/.rubocop.yml
CHANGED
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
|
|
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
|
|
106
|
+
RUN bundle install --jobs "$(nproc)"
|
data/Gemfile
CHANGED
|
@@ -1,44 +1,38 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
source 'https://rubygems.org'
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
source 'https://rubygems.org'
|
|
3
|
+
# Please see hyrax.gemspec for dependency information.
|
|
4
|
+
gemspec
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
end
|
|
6
|
+
group :development, :test do
|
|
7
|
+
gem 'benchmark-ips'
|
|
8
|
+
gem 'easy_translate'
|
|
9
|
+
gem 'i18n-tasks'
|
|
10
|
+
gem 'okcomputer'
|
|
11
|
+
gem 'pry' unless ENV['CI']
|
|
12
|
+
gem 'pry-byebug' unless ENV['CI']
|
|
13
|
+
gem 'ruby-prof', require: false
|
|
14
|
+
gem "simplecov", require: false
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
test_app_path = ENV['RAILS_ROOT'] ||
|
|
19
18
|
ENV.fetch('ENGINE_CART_DESTINATION', File.expand_path('.internal_test_app', File.dirname(__FILE__)))
|
|
20
19
|
test_app_gemfile = File.expand_path('Gemfile', test_app_path)
|
|
21
20
|
|
|
21
|
+
# rubocop:disable Bundler/DuplicatedGem
|
|
22
22
|
if File.exist?(test_app_gemfile)
|
|
23
23
|
begin
|
|
24
|
+
Bundler.ui.info "[Hyrax] Including test application dependencies from #{test_app_gemfile}"
|
|
24
25
|
eval_gemfile test_app_gemfile
|
|
25
26
|
rescue Bundler::GemfileError => e
|
|
26
27
|
Bundler.ui.warn '[Hyrax] Skipping Rails application dependencies:'
|
|
27
28
|
Bundler.ui.warn e.message
|
|
28
29
|
end
|
|
30
|
+
elsif ENV['RAILS_VERSION'] == 'edge'
|
|
31
|
+
gem 'rails', github: 'rails/rails', source: 'https://rubygems.org'
|
|
32
|
+
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks'
|
|
33
|
+
elsif ENV['RAILS_VERSION']
|
|
34
|
+
gem 'rails', ENV['RAILS_VERSION'], source: 'https://rubygems.org'
|
|
29
35
|
else
|
|
30
|
-
Bundler.ui.warn
|
|
31
|
-
|
|
32
|
-
# rubocop:disable Bundler/DuplicatedGem
|
|
33
|
-
if ENV['RAILS_VERSION']
|
|
34
|
-
if ENV['RAILS_VERSION'] == 'edge'
|
|
35
|
-
gem 'rails', github: 'rails/rails', source: 'https://rubygems.org'
|
|
36
|
-
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks'
|
|
37
|
-
else
|
|
38
|
-
gem 'rails', ENV['RAILS_VERSION'], source: 'https://rubygems.org'
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
# rubocop:enable Bundler/DuplicatedGem
|
|
42
|
-
|
|
43
|
-
eval_gemfile File.expand_path('spec/test_app_templates/Gemfile.extra', File.dirname(__FILE__))
|
|
36
|
+
Bundler.ui.warn '[Hyrax] Skipping all Rails dependency injection'
|
|
44
37
|
end
|
|
38
|
+
# rubocop:enable Bundler/DuplicatedGem
|
|
@@ -95,7 +95,7 @@ module Hyrax
|
|
|
95
95
|
def clean_attributes(attributes)
|
|
96
96
|
attributes[:license] = Array(attributes[:license]) if attributes.key? :license
|
|
97
97
|
attributes[:rights_statement] = Array(attributes[:rights_statement]) if attributes.key? :rights_statement
|
|
98
|
-
remove_blank_attributes!(attributes)
|
|
98
|
+
remove_blank_attributes!(attributes).except('file_set')
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
# If any attributes are blank remove them
|
|
@@ -26,90 +26,112 @@ module Hyrax
|
|
|
26
26
|
|
|
27
27
|
private
|
|
28
28
|
|
|
29
|
-
def
|
|
30
|
-
|
|
29
|
+
def attach_files(env, remote_files)
|
|
30
|
+
ingest_remote_files_service_class.new(user: env.user,
|
|
31
|
+
curation_concern: env.curation_concern,
|
|
32
|
+
remote_files: remote_files,
|
|
33
|
+
file_set_actor_class: file_set_actor_class).attach!
|
|
31
34
|
end
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
class IngestRemoteFilesService
|
|
37
|
+
##
|
|
38
|
+
# @parm user [User]
|
|
39
|
+
# @parm curation_concern [Hyrax::Work]
|
|
40
|
+
# @param remote_files [HashWithIndifferentAccess]
|
|
41
|
+
# @param file_set_actor_class
|
|
42
|
+
# @param ordered_members [Array]
|
|
43
|
+
# @param ordered [Boolean]
|
|
44
|
+
# rubocop:disable Metrics/ParameterLists
|
|
45
|
+
def initialize(user:, curation_concern:, remote_files:, file_set_actor_class:, ordered_members: [], ordered: false)
|
|
46
|
+
@remote_files = remote_files
|
|
47
|
+
@user = user
|
|
48
|
+
@curation_concern = curation_concern
|
|
49
|
+
@file_set_actor_class = file_set_actor_class
|
|
50
|
+
@ordered_members = ordered_members
|
|
51
|
+
@ordered = ordered
|
|
52
|
+
end
|
|
53
|
+
# rubocop:enable Metrics/ParameterLists
|
|
54
|
+
attr_reader :remote_files, :user, :curation_concern, :ordered_members, :ordered, :file_set_actor_class
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# @return true
|
|
58
|
+
def attach!
|
|
59
|
+
return true unless remote_files
|
|
60
|
+
remote_files.each do |file_info|
|
|
61
|
+
next if file_info.blank? || file_info[:url].blank?
|
|
62
|
+
# Escape any space characters, so that this is a legal URI
|
|
63
|
+
uri = URI.parse(Addressable::URI.escape(file_info[:url]))
|
|
64
|
+
unless self.class.validate_remote_url(uri)
|
|
65
|
+
Rails.logger.error "User #{user.user_key} attempted to ingest file from url #{file_info[:url]}, which doesn't pass validation"
|
|
66
|
+
return false
|
|
67
|
+
end
|
|
68
|
+
auth_header = file_info.fetch(:auth_header, {})
|
|
69
|
+
create_file_from_url(uri, file_info[:file_name], auth_header)
|
|
39
70
|
end
|
|
40
|
-
|
|
41
|
-
Rails.logger.debug "Assuming #{uri.scheme} uri is valid without a serious attempt to validate: #{uri}"
|
|
71
|
+
add_ordered_members! if ordered
|
|
42
72
|
true
|
|
43
73
|
end
|
|
44
|
-
end
|
|
45
74
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
def self.registered_ingest_dirs
|
|
76
|
+
Hyrax.config.registered_ingest_dirs
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# @param uri [URI] the uri fo the resource to import
|
|
80
|
+
def self.validate_remote_url(uri)
|
|
81
|
+
if uri.scheme == 'file'
|
|
82
|
+
path = File.absolute_path(CGI.unescape(uri.path))
|
|
83
|
+
registered_ingest_dirs.any? do |dir|
|
|
84
|
+
path.start_with?(dir) && path.length > dir.length
|
|
85
|
+
end
|
|
86
|
+
else
|
|
87
|
+
Rails.logger.debug "Assuming #{uri.scheme} uri is valid without a serious attempt to validate: #{uri}"
|
|
88
|
+
true
|
|
57
89
|
end
|
|
58
|
-
auth_header = file_info.fetch(:auth_header, {})
|
|
59
|
-
create_file_from_url(env, uri, file_info[:file_name], auth_header)
|
|
60
90
|
end
|
|
61
|
-
true
|
|
62
|
-
end
|
|
63
91
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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(
|
|
117
|
+
IngestLocalFileJob.perform_later(file_set, file_path, user)
|
|
86
118
|
else
|
|
87
|
-
ImportUrlJob.perform_later(
|
|
119
|
+
ImportUrlJob.perform_later(file_set, operation_for(user: user), auth_header)
|
|
88
120
|
end
|
|
89
121
|
end
|
|
90
|
-
end
|
|
91
122
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return false
|
|
55
|
-
end
|
|
56
|
-
auth_header = file_info.fetch(:auth_header, {})
|
|
57
|
-
create_file_from_url(env, uri, file_info[:file_name], auth_header)
|
|
58
|
-
end
|
|
59
|
-
add_ordered_members(env.user, env.curation_concern)
|
|
60
|
-
true
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Generic utility for creating FileSet from a URL
|
|
64
|
-
# Used in to import files using URLs from a file picker like browse_everything
|
|
65
|
-
def create_file_from_url(env, uri, file_name, auth_header = {})
|
|
66
|
-
::FileSet.new(import_url: uri.to_s, label: file_name) do |fs|
|
|
67
|
-
actor = file_set_actor_class.new(fs, env.user)
|
|
68
|
-
actor.create_metadata(visibility: env.curation_concern.visibility)
|
|
69
|
-
actor.attach_to_work(env.curation_concern)
|
|
70
|
-
fs.save!
|
|
71
|
-
ordered_members << fs
|
|
72
|
-
if uri.scheme == 'file'
|
|
73
|
-
# Turn any %20 into spaces.
|
|
74
|
-
file_path = CGI.unescape(uri.path)
|
|
75
|
-
IngestLocalFileJob.perform_later(fs, file_path, env.user)
|
|
76
|
-
else
|
|
77
|
-
ImportUrlJob.perform_later(fs, operation_for(user: actor.user), auth_header)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
48
|
+
ingest_remote_files_service_class.new(user: env.user,
|
|
49
|
+
curation_concern: env.curation_concern,
|
|
50
|
+
remote_files: remote_files,
|
|
51
|
+
ordered_members: @ordered_members,
|
|
52
|
+
ordered: true,
|
|
53
|
+
file_set_actor_class: file_set_actor_class).attach!
|
|
80
54
|
end
|
|
81
|
-
|
|
82
|
-
# Add all file_sets as ordered_members in a single action
|
|
83
|
-
def add_ordered_members(user, work)
|
|
84
|
-
actor = Hyrax::Actors::OrderedMembersActor.new(ordered_members, user)
|
|
85
|
-
actor.attach_ordered_members_to_work(work)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
class_attribute :file_set_actor_class
|
|
89
|
-
self.file_set_actor_class = Hyrax::Actors::FileSetOrderedMembersActor
|
|
90
55
|
end
|
|
91
56
|
end
|
|
92
57
|
end
|