sufia 6.0.0 → 6.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/.travis.yml +2 -5
- data/CONTRIBUTING.md +4 -4
- data/Gemfile +2 -1
- data/History.md +69 -0
- data/README.md +84 -4
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/zotero.png +0 -0
- data/app/assets/javascripts/sufia/featured_works.js +20 -3
- data/app/assets/stylesheets/generic_files.css.erb +2 -2
- data/app/assets/stylesheets/sufia.css.scss +2 -2
- data/app/assets/stylesheets/sufia/_buttons.scss +2 -2
- data/app/assets/stylesheets/sufia/_collections.scss +4 -4
- data/app/assets/stylesheets/sufia/_dashboard.scss +1 -1
- data/app/assets/stylesheets/sufia/_file-listing.scss +3 -0
- data/app/assets/stylesheets/sufia/_modal.scss +4 -0
- data/app/assets/stylesheets/sufia/_settings.scss +4 -3
- data/app/assets/stylesheets/sufia/_styles.scss +4 -0
- data/app/controllers/admin/stats_controller.rb +68 -0
- data/app/controllers/api/items_controller.rb +78 -0
- data/app/controllers/api/zotero_controller.rb +70 -0
- data/app/controllers/authorities_controller.rb +6 -5
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +2 -1
- data/app/controllers/concerns/sufia/breadcrumbs.rb +1 -1
- data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +11 -0
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +23 -11
- data/app/controllers/concerns/sufia/my_controller_behavior.rb +1 -7
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +1 -2
- data/app/controllers/my/collections_controller.rb +1 -0
- data/app/controllers/my/files_controller.rb +1 -1
- data/app/helpers/sufia/sufia_helper_behavior.rb +28 -16
- data/app/models/my_search_builder.rb +4 -0
- data/app/search_builders/sufia/my_search_builder_behavior.rb +20 -0
- data/app/search_builders/sufia/search_builder.rb +1 -1
- data/app/views/admin/stats/index.html.erb +68 -0
- data/app/views/collections/_action_menu.html.erb +22 -20
- data/app/views/collections/_collection.html.erb +1 -1
- data/app/views/collections/_form_for_select_collection.html.erb +5 -3
- data/app/views/generic_files/_show_actions.html.erb +4 -2
- data/app/views/generic_files/show.html.erb +1 -1
- data/app/views/layouts/sufia-dashboard.html.erb +5 -4
- data/app/views/layouts/sufia-one-column.html.erb +2 -0
- data/app/views/layouts/sufia-two-column.html.erb +6 -4
- data/app/views/my/_facet_layout.html.erb +2 -2
- data/app/views/my/_facets.html.erb +4 -6
- data/app/views/my/index.html.erb +4 -3
- data/app/views/users/_edit_primary.html.erb +18 -17
- data/app/views/users/_follower_modal.html.erb +5 -1
- data/app/views/users/_following_modal.html.erb +5 -1
- data/app/views/users/_user_info.html.erb +6 -1
- data/app/views/users/_zotero.html.erb +12 -0
- data/config/locales/sufia.en.yml +10 -1
- data/config/routes.rb +23 -1
- data/lib/generators/sufia/admin_stat_generator.rb +17 -0
- data/lib/generators/sufia/install_generator.rb +8 -3
- data/{sufia-models/lib/generators/sufia/models/templates/config/resque_admin.rb → lib/generators/sufia/templates/sufia/stats_admin.rb} +3 -3
- data/lib/generators/sufia/upgrade400_generator.rb +2 -2
- data/lib/sufia.rb +3 -0
- data/lib/sufia/arkivo.rb +11 -0
- data/lib/sufia/arkivo/actor.rb +95 -0
- data/lib/sufia/arkivo/config.rb +11 -0
- data/lib/sufia/arkivo/create_subscription_job.rb +67 -0
- data/lib/sufia/arkivo/metadata_munger.rb +51 -0
- data/lib/sufia/arkivo/schema_validator.rb +55 -0
- data/lib/sufia/form_builder.rb +1 -1
- data/lib/sufia/inflections.rb +3 -0
- data/lib/sufia/version.rb +1 -1
- data/lib/sufia/zotero.rb +6 -0
- data/lib/sufia/zotero/config.rb +15 -0
- data/solr_conf/conf/solrconfig.xml +11 -0
- data/spec/controllers/admin_stats_controller_spec.rb +73 -0
- data/spec/controllers/api/items_controller_spec.rb +476 -0
- data/spec/controllers/api/zotero_controller_spec.rb +178 -0
- data/spec/controllers/batch_edits_controller_spec.rb +7 -0
- data/spec/controllers/collections_controller_spec.rb +1 -1
- data/spec/controllers/dashboard_controller_spec.rb +1 -1
- data/spec/controllers/depositors_controller_spec.rb +9 -5
- data/spec/controllers/generic_files_controller_spec.rb +5 -4
- data/spec/controllers/mailbox_controller_spec.rb +2 -2
- data/spec/controllers/my/collections_controller_spec.rb +1 -2
- data/spec/controllers/my/files_controller_spec.rb +5 -5
- data/spec/controllers/my/shares_controller_spec.rb +15 -3
- data/spec/controllers/pages_controller_spec.rb +1 -1
- data/spec/controllers/users_controller_spec.rb +10 -9
- data/spec/factories/api_items.rb +91 -0
- data/spec/factories/generic_files.rb +4 -0
- data/spec/factories/users.rb +4 -4
- data/spec/features/featured_item_spec.rb +26 -0
- data/spec/features/ingest_upload_files_spec.rb +2 -3
- data/spec/features/proxy_spec.rb +0 -1
- data/spec/helpers/permissions_helper_spec.rb +2 -2
- data/spec/helpers/sufia_helper_spec.rb +11 -5
- data/spec/inputs/select_with_help_input_spec.rb +2 -2
- data/spec/javascripts/helpers/.gitkeep +0 -0
- data/spec/javascripts/helpers/jasmine-jquery.js +832 -0
- data/spec/javascripts/jasmine_spec.rb +31 -0
- data/spec/javascripts/notify_update_link_spec.js +8 -0
- data/spec/javascripts/single_use_link_spec.js.coffee +23 -0
- data/spec/javascripts/support/jasmine.yml +124 -0
- data/spec/javascripts/support/jasmine_helper.rb +15 -0
- data/spec/javascripts/terms_of_service_spec.js.coffee +32 -0
- data/spec/javascripts/toggle_icon_spec.js +11 -0
- data/spec/jobs/active_fedora_id_based_job_spec.rb +3 -3
- data/spec/jobs/import_url_job_spec.rb +0 -2
- data/spec/lib/sufia/arkivo/actor_spec.rb +139 -0
- data/spec/lib/sufia/arkivo/create_subscription_job_spec.rb +54 -0
- data/spec/lib/sufia/arkivo/metadata_munger_spec.rb +48 -0
- data/spec/lib/sufia/arkivo/schema_validator_spec.rb +65 -0
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +1 -1
- data/spec/lib/sufia/user_stat_importer_spec.rb +60 -0
- data/spec/lib/sufia/zotero/config_spec.rb +30 -0
- data/spec/models/collection_spec.rb +36 -7
- data/spec/models/file_download_stat_spec.rb +5 -5
- data/spec/models/file_usage_spec.rb +23 -0
- data/spec/models/file_view_stat_spec.rb +6 -6
- data/spec/models/fits_datastream_spec.rb +0 -5
- data/spec/models/generic_file_spec.rb +49 -14
- data/spec/models/local_authority_spec.rb +1 -1
- data/spec/models/proxy_deposit_request_spec.rb +1 -1
- data/spec/models/trophy_spec.rb +8 -8
- data/spec/models/user_spec.rb +33 -0
- data/spec/presenters/sufia/collection_presenter_spec.rb +1 -1
- data/spec/routing/api_route_spec.rb +91 -0
- data/spec/routing/route_spec.rb +1 -1
- data/spec/services/generic_file_audit_service_spec.rb +44 -8
- data/spec/spec_helper.rb +18 -3
- data/spec/support/features.rb +0 -2
- data/spec/support/locations.rb +0 -21
- data/spec/support/rake.rb +41 -0
- data/spec/support/selectors.rb +0 -50
- data/spec/tasks/rake_spec.rb +33 -12
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -0
- data/spec/views/admin/stats/index.html.erb_spec.rb +45 -0
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +0 -1
- data/spec/views/dashboard/index_spec.rb +1 -1
- data/spec/views/generic_file/edit.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/show.html.erb_spec.rb +1 -3
- data/spec/views/users/_follower_modal.html.erb_spec.rb +44 -7
- data/spec/views/users/_following_modal.html.erb_spec.rb +49 -7
- data/spec/views/users/edit.html.erb_spec.rb +72 -0
- data/spec/views/users/show.html.erb_spec.rb +1 -1
- data/sufia.gemspec +6 -2
- data/tasks/sufia-user.rake +14 -0
- metadata +130 -156
- data/spec/lib/sufia/id_service_spec.rb +0 -32
- data/spec/services/noid_spec.rb +0 -9
- data/spec/support/poltergeist.rb +0 -11
- data/spec/support/rake_output.rb +0 -20
- data/sufia-models/.gitignore +0 -17
- data/sufia-models/Gemfile +0 -4
- data/sufia-models/LICENSE.md +0 -177
- data/sufia-models/README.md +0 -39
- data/sufia-models/Rakefile +0 -1
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +0 -137
- data/sufia-models/app/jobs/active_fedora_id_based_job.rb +0 -22
- data/sufia-models/app/jobs/active_fedora_pid_based_job.rb +0 -7
- data/sufia-models/app/jobs/audit_job.rb +0 -62
- data/sufia-models/app/jobs/batch_update_job.rb +0 -72
- data/sufia-models/app/jobs/characterize_job.rb +0 -10
- data/sufia-models/app/jobs/create_derivatives_job.rb +0 -14
- data/sufia-models/app/jobs/import_url_job.rb +0 -52
- data/sufia-models/app/jobs/ingest_local_file_job.rb +0 -46
- data/sufia-models/app/jobs/resolrize_job.rb +0 -9
- data/sufia-models/app/models/batch.rb +0 -36
- data/sufia-models/app/models/checksum_audit_log.rb +0 -21
- data/sufia-models/app/models/concerns/sufia/ability.rb +0 -61
- data/sufia-models/app/models/concerns/sufia/collection_behavior.rb +0 -24
- data/sufia-models/app/models/concerns/sufia/file_stat_utils.rb +0 -35
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +0 -25
- data/sufia-models/app/models/concerns/sufia/generic_file/batches.rb +0 -28
- data/sufia-models/app/models/concerns/sufia/generic_file/characterization.rb +0 -89
- data/sufia-models/app/models/concerns/sufia/generic_file/content.rb +0 -13
- data/sufia-models/app/models/concerns/sufia/generic_file/derivatives.rb +0 -26
- data/sufia-models/app/models/concerns/sufia/generic_file/export.rb +0 -343
- data/sufia-models/app/models/concerns/sufia/generic_file/featured.rb +0 -11
- data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +0 -43
- data/sufia-models/app/models/concerns/sufia/generic_file/indexing.rb +0 -14
- data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +0 -98
- data/sufia-models/app/models/concerns/sufia/generic_file/mime_types.rb +0 -69
- data/sufia-models/app/models/concerns/sufia/generic_file/permissions.rb +0 -11
- data/sufia-models/app/models/concerns/sufia/generic_file/proxy_deposit.rb +0 -31
- data/sufia-models/app/models/concerns/sufia/generic_file/trophies.rb +0 -14
- data/sufia-models/app/models/concerns/sufia/generic_file/versions.rb +0 -16
- data/sufia-models/app/models/concerns/sufia/generic_file/virus_check.rb +0 -37
- data/sufia-models/app/models/concerns/sufia/model_methods.rb +0 -20
- data/sufia-models/app/models/concerns/sufia/user.rb +0 -137
- data/sufia-models/app/models/concerns/sufia/user_usage_stats.rb +0 -15
- data/sufia-models/app/models/datastreams/file_content_datastream.rb +0 -4
- data/sufia-models/app/models/datastreams/fits_datastream.rb +0 -152
- data/sufia-models/app/models/domain_term.rb +0 -5
- data/sufia-models/app/models/featured_work.rb +0 -22
- data/sufia-models/app/models/file_download_stat.rb +0 -18
- data/sufia-models/app/models/file_usage.rb +0 -34
- data/sufia-models/app/models/file_view_stat.rb +0 -18
- data/sufia-models/app/models/follow.rb +0 -12
- data/sufia-models/app/models/generic_file.rb +0 -3
- data/sufia-models/app/models/geo_names_resource.rb +0 -18
- data/sufia-models/app/models/group.rb +0 -8
- data/sufia-models/app/models/local_authority.rb +0 -86
- data/sufia-models/app/models/local_authority_entry.rb +0 -3
- data/sufia-models/app/models/proxy_deposit_request.rb +0 -85
- data/sufia-models/app/models/proxy_deposit_rights.rb +0 -4
- data/sufia-models/app/models/single_use_link.rb +0 -42
- data/sufia-models/app/models/subject_local_authority_entry.rb +0 -2
- data/sufia-models/app/models/sufia/avatar_uploader.rb +0 -20
- data/sufia-models/app/models/sufia/avatar_validator.rb +0 -8
- data/sufia-models/app/models/sufia/collection.rb +0 -5
- data/sufia-models/app/models/sufia/download.rb +0 -9
- data/sufia-models/app/models/sufia/orcid_validator.rb +0 -12
- data/sufia-models/app/models/sufia/pageview.rb +0 -9
- data/sufia-models/app/models/trophy.rb +0 -10
- data/sufia-models/app/models/user_stat.rb +0 -2
- data/sufia-models/app/models/version_committer.rb +0 -2
- data/sufia-models/app/services/sufia/analytics.rb +0 -50
- data/sufia-models/app/services/sufia/generic_file_audit_service.rb +0 -83
- data/sufia-models/app/services/sufia/generic_file_indexing_service.rb +0 -12
- data/sufia-models/app/services/sufia/id_service.rb +0 -45
- data/sufia-models/app/services/sufia/noid.rb +0 -22
- data/sufia-models/app/services/sufia/repository_audit_service.rb +0 -9
- data/sufia-models/config/locales/sufia.en.yml +0 -6
- data/sufia-models/lib/generators/sufia/models/abstract_migration_generator.rb +0 -30
- data/sufia-models/lib/generators/sufia/models/cached_stats_generator.rb +0 -24
- data/sufia-models/lib/generators/sufia/models/fulltext_generator.rb +0 -27
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +0 -106
- data/sufia-models/lib/generators/sufia/models/orcid_field_generator.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/proxies_generator.rb +0 -24
- data/sufia-models/lib/generators/sufia/models/templates/app/models/collection.rb +0 -2
- data/sufia-models/lib/generators/sufia/models/templates/config/analytics.yml +0 -9
- data/sufia-models/lib/generators/sufia/models/templates/config/clamav.rb +0 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/mailboxer.rb +0 -17
- data/sufia-models/lib/generators/sufia/models/templates/config/mime_types.rb +0 -6
- data/sufia-models/lib/generators/sufia/models/templates/config/redis.yml +0 -9
- data/sufia-models/lib/generators/sufia/models/templates/config/redis_config.rb +0 -32
- data/sufia-models/lib/generators/sufia/models/templates/config/resque-pool.yml +0 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/resque_config.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/config/setup_mail.rb +0 -3
- data/sufia-models/lib/generators/sufia/models/templates/config/solrconfig.xml +0 -223
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +0 -144
- data/sufia-models/lib/generators/sufia/models/templates/migrations/acts_as_follower_migration.rb +0 -17
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_avatars_to_users.rb +0 -15
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_external_key_to_content_blocks.rb +0 -6
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_groups_to_users.rb +0 -11
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_ldap_attrs_to_user.rb +0 -27
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_linkedin_to_users.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_orcid_to_users.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_social_to_users.rb +0 -13
- data/sufia-models/lib/generators/sufia/models/templates/migrations/change_audit_log_pid_to_generic_file_id.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/change_proxy_deposit_request_pid_to_generic_file_id.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_checksum_audit_logs.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_content_blocks.rb +0 -10
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_featured_works.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_file_download_stats.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_file_view_stats.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb +0 -50
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_requests.rb +0 -16
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_rights.rb +0 -11
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_single_use_links.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_tinymce_assets.rb +0 -8
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_trophies.rb +0 -10
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_user_stats.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_version_committers.rb +0 -15
- data/sufia-models/lib/generators/sufia/models/update_content_blocks_generator.rb +0 -18
- data/sufia-models/lib/generators/sufia/models/upgrade400_generator.rb +0 -54
- data/sufia-models/lib/generators/sufia/models/upgrade600_generator.rb +0 -21
- data/sufia-models/lib/generators/sufia/models/usagestats_generator.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/user_stats_generator.rb +0 -31
- data/sufia-models/lib/sufia/messages.rb +0 -66
- data/sufia-models/lib/sufia/models.rb +0 -34
- data/sufia-models/lib/sufia/models/active_fedora/redis.rb +0 -43
- data/sufia-models/lib/sufia/models/active_record/redis.rb +0 -56
- data/sufia-models/lib/sufia/models/engine.rb +0 -79
- data/sufia-models/lib/sufia/models/file_content.rb +0 -6
- data/sufia-models/lib/sufia/models/file_content/versions.rb +0 -21
- data/sufia-models/lib/sufia/models/resque.rb +0 -36
- data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +0 -108
- data/sufia-models/lib/sufia/models/user_local_directory_behavior.rb +0 -29
- data/sufia-models/lib/sufia/models/utils.rb +0 -22
- data/sufia-models/lib/sufia/models/version.rb +0 -5
- data/sufia-models/lib/sufia/models/virus_found_error.rb +0 -4
- data/sufia-models/lib/sufia/permissions.rb +0 -9
- data/sufia-models/lib/sufia/permissions/readable.rb +0 -20
- data/sufia-models/lib/sufia/permissions/writable.rb +0 -74
- data/sufia-models/lib/tasks/batch_cleanup.rake +0 -19
- data/sufia-models/lib/tasks/migrate.rake +0 -21
- data/sufia-models/lib/tasks/resque.rake +0 -13
- data/sufia-models/lib/tasks/stats_tasks.rake +0 -12
- data/sufia-models/lib/tasks/sufia-models_tasks.rake +0 -80
- data/sufia-models/sufia-models.gemspec +0 -52
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
class ActiveFedoraIdBasedJob
|
|
2
|
-
def queue_name
|
|
3
|
-
:id_based
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
attr_accessor :id
|
|
7
|
-
|
|
8
|
-
def initialize(id)
|
|
9
|
-
self.id = id
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def object
|
|
13
|
-
@object ||= ActiveFedora::Base.find(id)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
alias_method :generic_file, :object
|
|
17
|
-
alias_method :generic_file_id, :id
|
|
18
|
-
|
|
19
|
-
def run
|
|
20
|
-
raise RuntimeError, "Define #run in a subclass"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
class AuditJob < ActiveFedoraIdBasedJob
|
|
2
|
-
def queue_name
|
|
3
|
-
:audit
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
PASS = 'Passing Audit Run'
|
|
7
|
-
FAIL = 'Failing Audit Run'
|
|
8
|
-
|
|
9
|
-
attr_accessor :uri, :id, :path
|
|
10
|
-
|
|
11
|
-
# URI of the resource to audit.
|
|
12
|
-
# This URI could include the actual resource (e.g. content) and the version to audit:
|
|
13
|
-
# http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content/fcr:versions/version1
|
|
14
|
-
# but it could also just be:
|
|
15
|
-
# http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content
|
|
16
|
-
def initialize(id, path, uri)
|
|
17
|
-
super(id)
|
|
18
|
-
self.path = path
|
|
19
|
-
self.uri = uri
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def run
|
|
23
|
-
fixity_ok = false
|
|
24
|
-
log = run_audit
|
|
25
|
-
fixity_ok = (log.pass == 1)
|
|
26
|
-
unless fixity_ok
|
|
27
|
-
# send the user a message about the failing audit
|
|
28
|
-
login = generic_file.depositor
|
|
29
|
-
user = User.find_by_user_key(login)
|
|
30
|
-
logger.warn "User '#{login}' not found" unless user
|
|
31
|
-
job_user = User.audituser()
|
|
32
|
-
file_title = generic_file.title.first
|
|
33
|
-
message = "The audit run at #{log.created_at} for #{file_title} (#{uri}) failed."
|
|
34
|
-
subject = FAIL
|
|
35
|
-
job_user.send_message(user, message, subject)
|
|
36
|
-
end
|
|
37
|
-
fixity_ok
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
protected
|
|
41
|
-
|
|
42
|
-
def run_audit
|
|
43
|
-
begin
|
|
44
|
-
fixity_ok = ActiveFedora::FixityService.new(uri).check
|
|
45
|
-
rescue Ldp::NotFound
|
|
46
|
-
error_msg = "resource not found"
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
if fixity_ok
|
|
50
|
-
passing = 1
|
|
51
|
-
ChecksumAuditLog.prune_history(id, path)
|
|
52
|
-
else
|
|
53
|
-
logger.warn "***AUDIT*** Audit failed for #{uri} #{error_msg}"
|
|
54
|
-
passing = 0
|
|
55
|
-
end
|
|
56
|
-
ChecksumAuditLog.create!(pass: passing, generic_file_id: id, version: uri, dsid: path)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def logger
|
|
60
|
-
ActiveFedora::Base.logger
|
|
61
|
-
end
|
|
62
|
-
end
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
class BatchUpdateJob
|
|
2
|
-
include Hydra::PermissionsQuery
|
|
3
|
-
include Sufia::Messages
|
|
4
|
-
|
|
5
|
-
def queue_name
|
|
6
|
-
:batch_update
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
attr_accessor :login, :title, :file_attributes, :batch_id, :visibility, :saved, :denied
|
|
10
|
-
|
|
11
|
-
def initialize(login, batch_id, title, file_attributes, visibility)
|
|
12
|
-
self.login = login
|
|
13
|
-
self.title = title || {}
|
|
14
|
-
self.file_attributes = file_attributes
|
|
15
|
-
self.visibility = visibility
|
|
16
|
-
self.batch_id = batch_id
|
|
17
|
-
self.saved = []
|
|
18
|
-
self.denied = []
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def run
|
|
22
|
-
batch = Batch.find_or_create(self.batch_id)
|
|
23
|
-
user = User.find_by_user_key(self.login)
|
|
24
|
-
|
|
25
|
-
batch.generic_files.each do |gf|
|
|
26
|
-
update_file(gf, user)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
batch.update(status: ["Complete"])
|
|
30
|
-
|
|
31
|
-
if denied.empty?
|
|
32
|
-
send_user_success_message(user, batch) unless saved.empty?
|
|
33
|
-
else
|
|
34
|
-
send_user_failure_message(user, batch)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def update_file(gf, user)
|
|
39
|
-
unless user.can? :edit, gf
|
|
40
|
-
ActiveFedora::Base.logger.error "User #{user.user_key} DENIED access to #{gf.id}!"
|
|
41
|
-
denied << gf
|
|
42
|
-
return
|
|
43
|
-
end
|
|
44
|
-
gf.title = title[gf.id] if title[gf.id]
|
|
45
|
-
gf.attributes = file_attributes
|
|
46
|
-
gf.visibility= visibility
|
|
47
|
-
|
|
48
|
-
save_tries = 0
|
|
49
|
-
begin
|
|
50
|
-
gf.save!
|
|
51
|
-
rescue RSolr::Error::Http => error
|
|
52
|
-
save_tries += 1
|
|
53
|
-
ActiveFedora::Base.logger.warn "BatchUpdateJob caught RSOLR error on #{gf.id}: #{error.inspect}"
|
|
54
|
-
# fail for good if the tries is greater than 3
|
|
55
|
-
raise error if save_tries >=3
|
|
56
|
-
sleep 0.01
|
|
57
|
-
retry
|
|
58
|
-
end #
|
|
59
|
-
Sufia.queue.push(ContentUpdateEventJob.new(gf.id, login))
|
|
60
|
-
saved << gf
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def send_user_success_message user, batch
|
|
64
|
-
message = saved.count > 1 ? multiple_success(batch.id, saved) : single_success(batch.id, saved.first)
|
|
65
|
-
User.batchuser.send_message(user, message, success_subject, sanitize_text = false)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def send_user_failure_message user, batch
|
|
69
|
-
message = denied.count > 1 ? multiple_failure(batch.id, denied) : single_failure(batch.id, denied.first)
|
|
70
|
-
User.batchuser.send_message(user, message, failure_subject, sanitize_text = false)
|
|
71
|
-
end
|
|
72
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
class CreateDerivativesJob < ActiveFedoraIdBasedJob
|
|
2
|
-
def queue_name
|
|
3
|
-
:derivatives
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
def run
|
|
7
|
-
return unless generic_file.content.has_content?
|
|
8
|
-
if generic_file.video?
|
|
9
|
-
return unless Sufia.config.enable_ffmpeg
|
|
10
|
-
end
|
|
11
|
-
generic_file.create_derivatives
|
|
12
|
-
generic_file.save
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require 'net/https'
|
|
2
|
-
require 'uri'
|
|
3
|
-
require 'tempfile'
|
|
4
|
-
|
|
5
|
-
class ImportUrlJob < ActiveFedoraIdBasedJob
|
|
6
|
-
|
|
7
|
-
def queue_name
|
|
8
|
-
:import_url
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def run
|
|
12
|
-
user = User.find_by_user_key(generic_file.depositor)
|
|
13
|
-
|
|
14
|
-
Tempfile.open(id.gsub('/', '_')) do |f|
|
|
15
|
-
path, mime_type = copy_remote_file(generic_file.import_url, f)
|
|
16
|
-
# attach downloaded file to generic file stubbed out
|
|
17
|
-
if Sufia::GenericFile::Actor.new(generic_file, user).create_content(f, path, 'content', mime_type)
|
|
18
|
-
# add message to user for downloaded file
|
|
19
|
-
message = "The file (#{generic_file.label}) was successfully imported."
|
|
20
|
-
job_user.send_message(user, message, 'File Import')
|
|
21
|
-
else
|
|
22
|
-
job_user.send_message(user, generic_file.errors.full_messages.join(', '), 'File Import Error')
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def copy_remote_file(import_url, f)
|
|
28
|
-
f.binmode
|
|
29
|
-
# download file from url
|
|
30
|
-
uri = URI(generic_file.import_url)
|
|
31
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
|
32
|
-
http.use_ssl = uri.scheme == "https" # enable SSL/TLS
|
|
33
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
34
|
-
mime_type = nil
|
|
35
|
-
|
|
36
|
-
http.start do
|
|
37
|
-
http.request_get(uri.request_uri) do |resp|
|
|
38
|
-
mime_type = resp.content_type
|
|
39
|
-
resp.read_body do |segment|
|
|
40
|
-
f.write(segment)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
f.rewind
|
|
46
|
-
return uri.path, mime_type
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def job_user
|
|
50
|
-
User.batchuser
|
|
51
|
-
end
|
|
52
|
-
end
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
class IngestLocalFileJob
|
|
2
|
-
attr_accessor :directory, :filename, :user_key, :generic_file_id
|
|
3
|
-
|
|
4
|
-
def queue_name
|
|
5
|
-
:ingest
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def initialize(generic_file_id, directory, filename, user_key)
|
|
9
|
-
self.generic_file_id = generic_file_id
|
|
10
|
-
self.directory = directory
|
|
11
|
-
self.filename = filename
|
|
12
|
-
self.user_key = user_key
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
#TODO this should use Actor#create_content
|
|
16
|
-
def run
|
|
17
|
-
user = User.find_by_user_key(user_key)
|
|
18
|
-
raise "Unable to find user for #{user_key}" unless user
|
|
19
|
-
generic_file = GenericFile.find(generic_file_id)
|
|
20
|
-
path = File.join(directory, filename)
|
|
21
|
-
|
|
22
|
-
actor = Sufia::GenericFile::Actor.new(generic_file, user)
|
|
23
|
-
|
|
24
|
-
if actor.create_content(File.open(path), filename, 'content', mime_type(filename))
|
|
25
|
-
FileUtils.rm(path)
|
|
26
|
-
Sufia.queue.push(ContentDepositEventJob.new(generic_file.id, user_key))
|
|
27
|
-
|
|
28
|
-
message = "The file (#{File.basename(filename)}) was successfully deposited."
|
|
29
|
-
subject = 'Local file ingest'
|
|
30
|
-
else
|
|
31
|
-
message = "There was a problem depositing #{File.basename(filename)}. Please contact a system admin."
|
|
32
|
-
subject = 'Local file ingest error'
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
job_user.send_message(user, message, subject)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def job_user
|
|
39
|
-
User.batchuser
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def mime_type(file_name)
|
|
43
|
-
mime_types = MIME::Types.of(file_name)
|
|
44
|
-
mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
class Batch < ActiveFedora::Base
|
|
2
|
-
include Hydra::AccessControls::Permissions
|
|
3
|
-
include Sufia::ModelMethods
|
|
4
|
-
include Sufia::Noid
|
|
5
|
-
|
|
6
|
-
has_many :generic_files, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
|
7
|
-
|
|
8
|
-
property :creator, predicate: ::RDF::DC.creator
|
|
9
|
-
property :title, predicate: ::RDF::DC.title
|
|
10
|
-
property :status, predicate: ::RDF::DC.type
|
|
11
|
-
|
|
12
|
-
def self.find_or_create(id)
|
|
13
|
-
begin
|
|
14
|
-
Batch.find(id)
|
|
15
|
-
rescue ActiveFedora::ObjectNotFoundError
|
|
16
|
-
safe_create(id)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
# This method handles most race conditions gracefully.
|
|
23
|
-
# If a batch with the same ID is created by another thread
|
|
24
|
-
# we fetch the batch that was created (rather than throwing
|
|
25
|
-
# an error) and continute.
|
|
26
|
-
def self.safe_create(id)
|
|
27
|
-
begin
|
|
28
|
-
Batch.create(id: id)
|
|
29
|
-
rescue ActiveFedora::IllegalOperation => ex
|
|
30
|
-
# This is the exception thrown by LDP when we attempt to
|
|
31
|
-
# create a duplicate object. If we can find the object
|
|
32
|
-
# then we are good to go.
|
|
33
|
-
Batch.find(id)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
class ChecksumAuditLog < ActiveRecord::Base
|
|
2
|
-
|
|
3
|
-
def self.get_audit_log(id, path, version_uri)
|
|
4
|
-
ChecksumAuditLog.find_or_create_by(generic_file_id: id, dsid: path, version: version_uri)
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
# Check to see if there are previous passing logs that we can delete
|
|
8
|
-
# we want to keep the first passing event after a failure, the most current passing event,
|
|
9
|
-
# and all failures so that this table doesn't grow too large
|
|
10
|
-
# Simple way (a little naieve): if the last 2 were passing, delete the first one
|
|
11
|
-
def self.prune_history(id, path)
|
|
12
|
-
list = logs_for(id, path).limit(2)
|
|
13
|
-
if list.size > 1 && (list[0].pass == 1) && (list[1].pass == 1)
|
|
14
|
-
list[0].destroy
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.logs_for(id, path)
|
|
19
|
-
ChecksumAuditLog.where(generic_file_id: id, dsid: path).order('created_at desc, id desc')
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
module Sufia
|
|
2
|
-
module Ability
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
|
|
5
|
-
included do
|
|
6
|
-
self.ability_logic += [:sufia_abilities]
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def sufia_abilities
|
|
10
|
-
generic_file_abilities
|
|
11
|
-
user_abilities
|
|
12
|
-
featured_work_abilities
|
|
13
|
-
editor_abilities
|
|
14
|
-
stats_abilities
|
|
15
|
-
proxy_deposit_abilities
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def proxy_deposit_abilities
|
|
19
|
-
can :transfer, String do |id|
|
|
20
|
-
depositor_for_document(id) == current_user.user_key
|
|
21
|
-
end
|
|
22
|
-
can :create, ProxyDepositRequest if user_groups.include? 'registered'
|
|
23
|
-
can :accept, ProxyDepositRequest, receiving_user_id: current_user.id, status: 'pending'
|
|
24
|
-
can :reject, ProxyDepositRequest, receiving_user_id: current_user.id, status: 'pending'
|
|
25
|
-
# a user who sent a proxy deposit request can cancel it if it's pending.
|
|
26
|
-
can :destroy, ProxyDepositRequest, sending_user_id: current_user.id, status: 'pending'
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def user_abilities
|
|
30
|
-
can [:edit, :update, :toggle_trophy], ::User, id: current_user.id
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def featured_work_abilities
|
|
34
|
-
can [:create, :destroy, :update], FeaturedWork if user_groups.include? 'admin'
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def generic_file_abilities
|
|
38
|
-
can :view_share_work, [GenericFile]
|
|
39
|
-
can :create, [GenericFile, Collection] if user_groups.include? 'registered'
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def editor_abilities
|
|
43
|
-
if user_groups.include? 'admin'
|
|
44
|
-
can :create, TinymceAsset
|
|
45
|
-
can [:create, :update], ContentBlock
|
|
46
|
-
end
|
|
47
|
-
can :read, ContentBlock
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def stats_abilities
|
|
51
|
-
alias_action :stats, to: :read
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
private
|
|
55
|
-
|
|
56
|
-
def depositor_for_document(document_id)
|
|
57
|
-
::GenericFile.load_instance_from_solr(document_id).depositor
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
end
|
|
61
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module Sufia
|
|
2
|
-
module CollectionBehavior
|
|
3
|
-
extend ActiveSupport::Concern
|
|
4
|
-
include Hydra::Collection
|
|
5
|
-
include Sufia::ModelMethods
|
|
6
|
-
include Sufia::Noid
|
|
7
|
-
include Sufia::GenericFile::Permissions
|
|
8
|
-
|
|
9
|
-
included do
|
|
10
|
-
before_save :update_permissions
|
|
11
|
-
validates :title, presence: true
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def update_permissions
|
|
15
|
-
self.visibility = "open"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Compute the sum of each file in the collection
|
|
19
|
-
# Return an integer of the result
|
|
20
|
-
def bytes
|
|
21
|
-
members.reduce(0) { |sum, gf| sum + gf.content.size.to_i }
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|