curation_concerns 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -9
- data/.rspec +1 -1
- data/.rubocop.yml +185 -0
- data/.travis.yml +0 -10
- data/CONTRIBUTING.md +117 -0
- data/Gemfile +5 -2
- data/README.md +18 -11
- data/Rakefile +23 -11
- data/VERSION +1 -1
- data/app/assets/images/audio.png +0 -0
- data/app/assets/images/loading.gif +0 -0
- data/app/assets/images/progressbar.gif +0 -0
- data/app/assets/javascripts/curation_concerns/application.js +2 -8
- data/app/assets/javascripts/curation_concerns/curation_concerns.js +1 -15
- data/app/assets/javascripts/curation_concerns/facet_mine.js +4 -10
- data/app/assets/javascripts/curation_concerns/fileupload.js +6 -0
- data/app/assets/javascripts/curation_concerns/uploader.js +183 -0
- data/app/assets/stylesheets/curation_concerns/_curation_concerns.scss +3 -0
- data/app/assets/stylesheets/curation_concerns/_positioning.scss +6 -0
- data/app/assets/stylesheets/curation_concerns/fileupload/jquery.fileupload-ui.scss +86 -0
- data/app/assets/stylesheets/curation_concerns/fileupload/thumbnail-scaling.css +3 -0
- data/app/assets/stylesheets/curation_concerns/fileupload.scss +48 -0
- data/app/assets/stylesheets/curation_concerns/modules/attributes.scss +10 -0
- data/app/assets/stylesheets/curation_concerns/modules/embargoes.scss +1 -1
- data/app/assets/stylesheets/curation_concerns/modules/forms.scss +0 -10
- data/app/assets/stylesheets/curation_concerns/modules/search_results.scss +7 -8
- data/app/controllers/concerns/curation_concerns/api.rb +77 -0
- data/app/controllers/concerns/curation_concerns/application_controller_behavior.rb +30 -12
- data/app/controllers/concerns/curation_concerns/catalog_controller.rb +9 -276
- data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +51 -40
- data/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +60 -30
- data/app/controllers/concerns/curation_concerns/download_behavior.rb +51 -37
- data/app/controllers/concerns/curation_concerns/embargoes_controller_behavior.rb +29 -29
- data/app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb +198 -0
- data/app/controllers/concerns/curation_concerns/leases_controller_behavior.rb +27 -20
- data/app/controllers/concerns/curation_concerns/manages_embargoes.rb +2 -7
- data/app/controllers/concerns/curation_concerns/parent_container.rb +20 -4
- data/app/controllers/concerns/curation_concerns/single_use_links_controller_behavior.rb +48 -0
- data/app/controllers/concerns/curation_concerns/single_use_links_viewer_controller_behavior.rb +75 -0
- data/app/controllers/concerns/curation_concerns/themed_layout_controller.rb +0 -1
- data/app/controllers/concerns/curation_concerns/upload_sets_controller_behavior.rb +38 -0
- data/app/controllers/concerns/curation_concerns/welcome_controller_behavior.rb +8 -0
- data/app/controllers/concerns/curation_concerns/without_namespace.rb +2 -1
- data/app/controllers/curation_concerns/classify_concerns_controller.rb +9 -9
- data/app/controllers/curation_concerns/file_sets_controller.rb +5 -0
- data/app/controllers/curation_concerns/permissions_controller.rb +2 -3
- data/app/controllers/curation_concerns/single_use_links_controller.rb +5 -0
- data/app/controllers/curation_concerns/single_use_links_viewer_controller.rb +21 -0
- data/app/controllers/downloads_controller.rb +0 -1
- data/app/controllers/embargoes_controller.rb +0 -2
- data/app/controllers/leases_controller.rb +0 -2
- data/app/controllers/registrations_controller.rb +1 -2
- data/app/controllers/upload_sets_controller.rb +3 -0
- data/app/controllers/welcome_controller.rb +3 -0
- data/app/forms/curation_concerns/forms/collection_edit_form.rb +18 -2
- data/app/forms/curation_concerns/forms/file_set_edit_form.rb +15 -0
- data/app/forms/curation_concerns/forms/work_form.rb +57 -0
- data/app/helpers/curation_concerns/ability_helper.rb +24 -24
- data/app/helpers/curation_concerns/catalog_helper.rb +9 -8
- data/app/helpers/curation_concerns/collections_helper.rb +9 -12
- data/app/helpers/curation_concerns/embargo_helper.rb +0 -2
- data/app/helpers/curation_concerns/file_set_helper.rb +31 -0
- data/app/helpers/curation_concerns/lease_helper.rb +0 -3
- data/app/helpers/curation_concerns/main_app_helpers.rb +1 -3
- data/app/helpers/curation_concerns/render_constraints_helper.rb +5 -5
- data/app/helpers/curation_concerns/search_paths_helper.rb +5 -7
- data/app/helpers/curation_concerns/title_helper.rb +3 -7
- data/app/helpers/curation_concerns/url_helper.rb +4 -6
- data/app/inputs/multifile_input.rb +8 -0
- data/app/jobs/visibility_copy_job.rb +22 -0
- data/app/presenters/curation_concerns/collection_presenter.rb +14 -32
- data/app/presenters/curation_concerns/embargo_presenter.rb +26 -0
- data/app/presenters/curation_concerns/file_set_presenter.rb +34 -0
- data/app/presenters/curation_concerns/lease_presenter.rb +30 -0
- data/app/presenters/curation_concerns/model_proxy.rb +27 -0
- data/app/presenters/curation_concerns/permission_badge.rb +61 -0
- data/app/presenters/curation_concerns/presenter_factory.rb +45 -0
- data/app/presenters/curation_concerns/presents_attributes.rb +25 -0
- data/app/presenters/curation_concerns/version_list_presenter.rb +18 -0
- data/app/presenters/curation_concerns/version_presenter.rb +27 -0
- data/app/presenters/curation_concerns/work_show_presenter.rb +33 -0
- data/app/renderers/curation_concerns/attribute_renderer.rb +75 -0
- data/app/search_builders/curation_concerns/deactivated_embargo_search_builder.rb +10 -0
- data/app/search_builders/curation_concerns/deactivated_lease_search_builder.rb +10 -0
- data/app/search_builders/curation_concerns/embargo_search_builder.rb +23 -0
- data/app/search_builders/curation_concerns/expired_embargo_search_builder.rb +11 -0
- data/app/search_builders/curation_concerns/expired_lease_search_builder.rb +11 -0
- data/app/search_builders/curation_concerns/lease_search_builder.rb +23 -0
- data/app/search_builders/curation_concerns/search_builder.rb +10 -16
- data/app/services/curation_concerns/curation_concern.rb +0 -5
- data/app/services/curation_concerns/embargo_service.rb +26 -4
- data/app/services/curation_concerns/lease_service.rb +14 -5
- data/app/services/curation_concerns/parent_service.rb +19 -0
- data/app/services/curation_concerns/restriction_service.rb +24 -0
- data/app/services/rights_service.rb +14 -0
- data/app/views/catalog/_action_menu_partials/_collection.html.erb +1 -1
- data/app/views/catalog/_action_menu_partials/_default.html.erb +5 -3
- data/app/views/catalog/_document_list.html.erb +1 -1
- data/app/views/catalog/index.html.erb +1 -35
- data/app/views/collections/_edit_descriptions.html.erb +3 -4
- data/app/views/collections/_form.html.erb +1 -1
- data/app/views/collections/_form_permission.html.erb +1 -1
- data/app/views/collections/_search_form.html.erb +10 -0
- data/app/views/collections/_show_actions.html.erb +3 -3
- data/app/views/collections/_sort_and_per_page.html.erb +2 -2
- data/app/views/collections/show.html.erb +6 -6
- data/app/views/curation_concerns/base/_attribute_rows.html.erb +7 -0
- data/app/views/curation_concerns/base/_attributes.html.erb +6 -13
- data/app/views/curation_concerns/base/_form.html.erb +4 -5
- data/app/views/curation_concerns/base/_form_descriptive_fields.erb +2 -4
- data/app/views/curation_concerns/base/_form_files_and_links.html.erb +3 -5
- data/app/views/curation_concerns/base/_form_permission.html.erb +13 -26
- data/app/views/curation_concerns/base/_form_permission_note.html.erb +15 -0
- data/app/views/curation_concerns/base/_form_permission_under_embargo.html.erb +2 -2
- data/app/views/curation_concerns/base/_form_permission_under_lease.html.erb +2 -2
- data/app/views/curation_concerns/base/_form_representative_image.html.erb +16 -4
- data/app/views/curation_concerns/base/_form_rights.html.erb +17 -0
- data/app/views/curation_concerns/base/_form_supplementary_fields.html.erb +4 -9
- data/app/views/curation_concerns/base/_related_files.html.erb +4 -4
- data/app/views/curation_concerns/base/_representative_media.html.erb +2 -4
- data/app/views/curation_concerns/base/_versioning.html.erb +23 -0
- data/app/views/curation_concerns/base/show.html.erb +13 -10
- data/app/views/curation_concerns/base/show.json.jbuilder +1 -0
- data/app/views/curation_concerns/base/versions.html.erb +6 -0
- data/app/views/curation_concerns/file_sets/_actions.html.erb +16 -0
- data/app/views/curation_concerns/file_sets/_file_set.html.erb +12 -0
- data/app/views/curation_concerns/{generic_files → file_sets}/_form.html.erb +7 -7
- data/app/views/curation_concerns/file_sets/_multiple_upload.html.erb +3 -0
- data/app/views/curation_concerns/{generic_files → file_sets}/edit.html.erb +0 -0
- data/app/views/curation_concerns/file_sets/jq_upload.json.jbuilder +8 -0
- data/app/views/curation_concerns/file_sets/media_display/_audio.html.erb +6 -0
- data/app/views/curation_concerns/file_sets/media_display/_default.html.erb +4 -0
- data/app/views/curation_concerns/file_sets/media_display/_image.html.erb +8 -0
- data/app/views/curation_concerns/file_sets/media_display/_office_document.html.erb +7 -0
- data/app/views/curation_concerns/file_sets/media_display/_pdf.html.erb +7 -0
- data/app/views/curation_concerns/file_sets/media_display/_video.html.erb +6 -0
- data/app/views/curation_concerns/file_sets/show.html.erb +15 -0
- data/app/views/curation_concerns/file_sets/show.json.jbuilder +1 -0
- data/app/views/curation_concerns/file_sets/upload/_alerts.html.erb +19 -0
- data/app/views/curation_concerns/file_sets/upload/_form.html.erb +6 -0
- data/app/views/curation_concerns/file_sets/upload/_form_fields.html.erb +45 -0
- data/app/views/curation_concerns/file_sets/upload/_script_templates.html.erb +61 -0
- data/app/views/curation_concerns/single_use_links/new_download.html.erb +5 -0
- data/app/views/curation_concerns/single_use_links/new_show.html.erb +5 -0
- data/app/views/curation_concerns/single_use_links_viewer/show.html.erb +10 -0
- data/app/views/error/single_use_error.html.erb +19 -0
- data/app/views/layouts/error.html.erb +33 -0
- data/app/views/leases/_list_expired_active_leases.html.erb +6 -1
- data/app/views/records/_rights_modal.html.erb +1 -0
- data/app/views/records/edit_fields/_default.html.erb +5 -0
- data/app/views/records/show_fields/_default.html.erb +6 -0
- data/app/views/shared/_add_content.html.erb +2 -14
- data/app/views/shared/_add_works.html.erb +14 -0
- data/app/views/shared/_my_actions.html.erb +9 -1
- data/app/views/shared/_site_actions.html.erb +1 -1
- data/app/views/shared/_site_search.html.erb +7 -7
- data/app/views/upload_sets/_edit.js.erb +15 -0
- data/app/views/upload_sets/_metadata.html.erb +50 -0
- data/app/views/upload_sets/_more_metadata.html.erb +7 -0
- data/app/views/upload_sets/edit.html.erb +26 -0
- data/app/views/{catalog/_home_text.html.erb → welcome/index.html.erb} +1 -0
- data/config/initializers/simple_form.rb +14 -0
- data/config/jetty.yml +5 -0
- data/config/locales/curation_concerns.en.yml +25 -4
- data/config/routes.rb +5 -0
- data/curation_concerns.gemspec +4 -6
- data/lib/curation_concerns/callbacks/registry.rb +48 -0
- data/lib/curation_concerns/callbacks.rb +26 -0
- data/lib/curation_concerns/controller_resource.rb +4 -4
- data/lib/curation_concerns/engine.rb +4 -2
- data/lib/curation_concerns/rails/routes.rb +23 -19
- data/lib/curation_concerns/single_use_error.rb +3 -0
- data/lib/curation_concerns/spec_support.rb +0 -2
- data/lib/curation_concerns/version.rb +1 -1
- data/lib/curation_concerns.rb +1 -2
- data/lib/generators/curation_concerns/install_generator.rb +34 -30
- data/lib/generators/curation_concerns/templates/catalog_controller.rb +236 -0
- data/lib/generators/curation_concerns/templates/config/authorities/rights.yml +19 -0
- data/lib/generators/curation_concerns/templates/{curation_concerns.css.scss → curation_concerns.scss} +0 -0
- data/lib/generators/curation_concerns/work/templates/actor_spec.rb.erb +1 -1
- data/lib/generators/curation_concerns/work/templates/controller_spec.rb.erb +1 -1
- data/lib/generators/curation_concerns/work/templates/form.rb.erb +8 -0
- data/lib/generators/curation_concerns/work/templates/form_spec.rb.erb +10 -0
- data/lib/generators/curation_concerns/work/templates/model.rb.erb +2 -2
- data/lib/generators/curation_concerns/work/templates/model_spec.rb.erb +1 -1
- data/lib/generators/curation_concerns/work/work_generator.rb +31 -26
- data/spec/abilities/collection_abilities_spec.rb +13 -13
- data/spec/abilities/embargo_and_lease_ability_spec.rb +23 -0
- data/spec/abilities/file_set_abilities_spec.rb +67 -0
- data/spec/abilities/generic_work_abilities_spec.rb +12 -12
- data/spec/actors/curation_concerns/embargo_actor_spec.rb +38 -0
- data/spec/actors/curation_concerns/file_set_actor_spec.rb +180 -0
- data/spec/actors/curation_concerns/lease_actor_spec.rb +39 -0
- data/spec/actors/curation_concerns/manages_embargoes_actor_spec.rb +44 -38
- data/spec/actors/curation_concerns/work_actor_spec.rb +121 -63
- data/spec/controllers/catalog_controller_spec.rb +30 -32
- data/spec/controllers/curation_concerns/classify_concerns_controller_spec.rb +2 -3
- data/spec/controllers/curation_concerns/collections_controller_spec.rb +93 -76
- data/spec/controllers/curation_concerns/file_sets_controller_json_spec.rb +106 -0
- data/spec/controllers/curation_concerns/file_sets_controller_spec.rb +237 -0
- data/spec/controllers/curation_concerns/generic_works_controller_json_spec.rb +85 -0
- data/spec/controllers/curation_concerns/generic_works_controller_spec.rb +84 -72
- data/spec/controllers/curation_concerns/permissions_controller_spec.rb +8 -11
- data/spec/controllers/curation_concerns/single_use_links_controller_spec.rb +79 -0
- data/spec/controllers/curation_concerns/single_use_links_viewer_controller_spec.rb +74 -0
- data/spec/controllers/downloads_controller_spec.rb +49 -24
- data/spec/controllers/embargoes_controller_spec.rb +42 -51
- data/spec/controllers/leases_controller_spec.rb +53 -42
- data/spec/controllers/upload_sets_controller_spec.rb +76 -0
- data/spec/controllers/welcome_controller_spec.rb +12 -0
- data/spec/factories/collections.rb +5 -1
- data/spec/factories/{generic_files.rb → file_sets.rb} +6 -6
- data/spec/factories/generic_works.rb +5 -6
- data/spec/factories/users.rb +2 -4
- data/spec/features/add_file_spec.rb +11 -12
- data/spec/features/catalog_search_spec.rb +43 -0
- data/spec/features/collection_spec.rb +61 -46
- data/spec/features/create_work_spec.rb +26 -19
- data/spec/features/embargo_spec.rb +13 -12
- data/spec/features/lease_spec.rb +15 -16
- data/spec/features/update_file_spec.rb +11 -13
- data/spec/features/work_generator_spec.rb +34 -26
- data/spec/{helpers/curation_concerns/.keep → fixtures/empty_file.txt} +0 -0
- data/spec/fixtures/test.pdf +0 -0
- data/spec/forms/collection_edit_form_spec.rb +53 -9
- data/spec/forms/file_set_edit_form_spec.rb +53 -0
- data/spec/forms/work_form_spec.rb +54 -0
- data/spec/helpers/catalog_helper_spec.rb +9 -10
- data/spec/helpers/configuration_helper_spec.rb +1 -2
- data/spec/helpers/curation_concerns/collections_helper_spec.rb +8 -9
- data/spec/helpers/curation_concerns/file_set_helper_spec.rb +61 -0
- data/spec/helpers/render_constraints_helper_spec.rb +4 -4
- data/spec/helpers/url_helper_spec.rb +8 -7
- data/spec/indexers/collection_indexer_spec.rb +14 -0
- data/spec/indexers/file_set_indexing_service_spec.rb +69 -0
- data/spec/indexers/generic_work_indexing_service_spec.rb +22 -0
- data/spec/inputs/multifile_input_spec.rb +32 -0
- data/spec/jobs/active_fedora_id_based_job_spec.rb +10 -8
- data/spec/jobs/audit_job_spec.rb +28 -20
- data/spec/jobs/characterize_job_spec.rb +10 -15
- data/spec/jobs/create_derivatives_job_spec.rb +11 -9
- data/spec/jobs/import_url_job_spec.rb +14 -21
- data/spec/jobs/ingest_file_job_spec.rb +45 -0
- data/spec/jobs/ingest_local_file_job_spec.rb +13 -15
- data/spec/jobs/upload_set_update_job_spec.rb +30 -0
- data/spec/jobs/visibility_copy_job_spec.rb +61 -0
- data/spec/lib/curation_concerns/callbacks/registry_spec.rb +54 -0
- data/spec/lib/curation_concerns/callbacks_spec.rb +27 -0
- data/spec/lib/curation_concerns/messages_spec.rb +29 -30
- data/spec/lib/curation_concerns/readable_permissions_spec.rb +18 -20
- data/spec/lib/curation_concerns/writable_permissions_spec.rb +2 -4
- data/spec/matchers/metadata_field_matchers.rb +1 -1
- data/spec/matchers/response_matchers.rb +2 -2
- data/spec/matchers.rb +3 -2
- data/spec/models/checksum_audit_log_spec.rb +37 -32
- data/spec/models/curation_concerns/collection_behavior_spec.rb +50 -37
- data/spec/models/curation_concerns/file_set/derivatives_spec.rb +84 -0
- data/spec/models/curation_concerns/work_behavior_spec.rb +53 -0
- data/spec/models/file_set_spec.rb +601 -0
- data/spec/models/generic_work_spec.rb +15 -14
- data/spec/models/single_use_link_spec.rb +69 -0
- data/spec/models/solr_document_spec.rb +67 -0
- data/spec/models/upload_set_spec.rb +39 -0
- data/spec/models/user_spec.rb +7 -8
- data/spec/presenters/curation_concerns/collection_presenter_spec.rb +8 -24
- data/spec/presenters/curation_concerns/file_set_presenter_spec.rb +59 -0
- data/spec/presenters/curation_concerns/permission_badge_spec.rb +29 -0
- data/spec/presenters/curation_concerns/presenter_factory_spec.rb +29 -0
- data/spec/presenters/curation_concerns/version_list_presenter_spec.rb +32 -0
- data/spec/presenters/curation_concerns/version_presenter_spec.rb +51 -0
- data/spec/presenters/curation_concerns/work_show_presenter_spec.rb +35 -0
- data/spec/presenters/embargo_presenter_spec.rb +48 -0
- data/spec/presenters/lease_presenter_spec.rb +48 -0
- data/spec/renderers/curation_concerns/attribute_renderer_spec.rb +14 -0
- data/spec/routing/curation_concerns/routes_spec.rb +38 -12
- data/spec/routing/route_spec.rb +38 -39
- data/spec/search_builders/curation_concerns/embargo_search_builder_spec.rb +17 -0
- data/spec/search_builders/curation_concerns/lease_search_builder_spec.rb +17 -0
- data/spec/search_builders/curation_concerns/search_builder_spec.rb +60 -0
- data/spec/services/derivative_path_spec.rb +16 -0
- data/spec/services/embargo_service_spec.rb +15 -14
- data/spec/services/file_set_audit_service_spec.rb +71 -0
- data/spec/services/lease_service_spec.rb +13 -13
- data/spec/services/lock_manager_spec.rb +12 -0
- data/spec/services/parent_service_spec.rb +13 -0
- data/spec/services/persist_derivatives_spec.rb +24 -0
- data/spec/services/persist_directly_contained_output_file_service_spec.rb +14 -0
- data/spec/services/repository_audit_service_spec.rb +8 -7
- data/spec/services/rights_service_spec.rb +17 -0
- data/spec/services/thumbnail_path_service_spec.rb +43 -0
- data/spec/services/versioning_service_spec.rb +8 -9
- data/spec/spec_helper.rb +21 -13
- data/spec/support/curation_concerns/factory_helpers.rb +1 -0
- data/spec/support/features/fixture_file_upload.rb +3 -1
- data/spec/support/features/session_helpers.rb +3 -4
- data/spec/support/features.rb +1 -4
- data/spec/support/input_support.rb +11 -0
- data/spec/support/matchers/api_responses.rb +22 -0
- data/spec/support/shared/shared_examples_has_dc_metadata.rb +0 -2
- data/spec/support/shared/shared_examples_is_embargoable.rb +1 -3
- data/spec/support/shared/shared_examples_with_access_rights.rb +13 -16
- data/spec/tasks/rake_spec.rb +9 -11
- data/spec/test_app_templates/Gemfile.extra +4 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +3 -35
- data/spec/views/catalog/index.html.erb_spec.rb +7 -10
- data/spec/views/curation_concerns/base/_attributes.html.erb_spec.rb +9 -6
- data/spec/views/curation_concerns/base/_form_permission.html.erb_spec.rb +13 -0
- data/spec/views/curation_concerns/base/show.html.erb_spec.rb +35 -15
- data/spec/views/curation_concerns/base/show.json.jbuilder_spec.rb +21 -0
- data/spec/views/curation_concerns/file_sets/_file_set.html.erb_spec.rb +37 -0
- data/spec/views/curation_concerns/file_sets/show.json.jbuilder_spec.rb +21 -0
- data/spec/views/curation_concerns/permissions/confirm.html.erb_spec.rb +6 -6
- data/spec/views/error/single_use_error.html.erb_spec.rb +8 -0
- data/spec/views/layouts/error.html.erb_spec.rb +8 -0
- data/spec/views/shared/_add_content.html.erb_spec.rb +33 -20
- data/spec/views/shared/_my_actions.html.erb_spec.rb +18 -6
- data/spec/views/single_use_links/new_download.html.erb_spec.rb +29 -0
- data/spec/views/single_use_links_viewer/show.html.erb_spec.rb +32 -0
- data/tasks/jetty.rake +1 -1
- data/vendor/assets/javascrips/fileupload/jquery.fileupload-process.js +175 -0
- data/vendor/assets/javascrips/fileupload/jquery.fileupload-ui.js +710 -0
- data/vendor/assets/javascrips/fileupload/jquery.fileupload-validate.js +122 -0
- data/vendor/assets/javascrips/fileupload/jquery.fileupload.js +1477 -0
- data/vendor/assets/javascrips/fileupload/locale.js +27 -0
- data/vendor/assets/javascrips/fileupload/tmpl.js +87 -0
- metadata +242 -213
- data/app/assets/javascripts/curation_concerns/help_modal.js +0 -36
- data/app/assets/javascripts/curation_concerns/link_groups.js.coffee +0 -123
- data/app/assets/javascripts/curation_concerns/link_users.js.coffee +0 -126
- data/app/assets/javascripts/curation_concerns/proxy_rights.js.coffee +0 -95
- data/app/assets/javascripts/curation_concerns/proxy_submission.js +0 -23
- data/app/assets/javascripts/curation_concerns/select_works.js.coffee +0 -20
- data/app/controllers/catalog_controller.rb +0 -3
- data/app/controllers/concerns/curation_concerns/generic_files_controller_behavior.rb +0 -149
- data/app/controllers/curation_concerns/generic_files_controller.rb +0 -13
- data/app/datastreams/curation_concerns/generic_work_rdf_properties.rb +0 -57
- data/app/datastreams/generic_work_metadata.rb +0 -3
- data/app/forms/curation_concerns/forms/generic_file_edit_form.rb +0 -15
- data/app/forms/curation_concerns/forms/generic_work_edit_form.rb +0 -9
- data/app/helpers/curation_concerns/attribute_helper.rb +0 -67
- data/app/helpers/curation_concerns/generic_file_helper.rb +0 -19
- data/app/helpers/curation_concerns/thumbnail_helper.rb +0 -11
- data/app/presenters/curation_concerns/generic_file_presenter.rb +0 -14
- data/app/presenters/curation_concerns/generic_work_presenter.rb +0 -13
- data/app/views/catalog/_index_default.html.erb +0 -17
- data/app/views/collections/_form_representative_image.html.erb +0 -13
- data/app/views/collections/_identifier_and_action.html.erb +0 -15
- data/app/views/curation_concerns/base/_form_content_license.html.erb +0 -16
- data/app/views/curation_concerns/base/_form_editors.html.erb +0 -15
- data/app/views/curation_concerns/generic_files/_actions.html.erb +0 -16
- data/app/views/curation_concerns/generic_files/_generic_file.html.erb +0 -12
- data/app/views/curation_concerns/generic_files/_media_display.html.erb +0 -19
- data/app/views/curation_concerns/generic_files/jq_upload.json.jbuilder +0 -8
- data/app/views/curation_concerns/generic_files/show.html.erb +0 -15
- data/app/workers/visibility_copy_worker.rb +0 -30
- data/curation_concerns-models/.gitignore +0 -17
- data/curation_concerns-models/Gemfile +0 -4
- data/curation_concerns-models/LICENSE.md +0 -177
- data/curation_concerns-models/README.md +0 -42
- data/curation_concerns-models/Rakefile +0 -1
- data/curation_concerns-models/app/actors/concerns/curation_concerns/manages_embargoes_actor.rb +0 -99
- data/curation_concerns-models/app/actors/curation_concerns/base_actor.rb +0 -90
- data/curation_concerns-models/app/actors/curation_concerns/generic_file_actor.rb +0 -150
- data/curation_concerns-models/app/actors/curation_concerns/work_actor_behavior.rb +0 -88
- data/curation_concerns-models/app/jobs/active_fedora_id_based_job.rb +0 -22
- data/curation_concerns-models/app/jobs/active_fedora_pid_based_job.rb +0 -6
- data/curation_concerns-models/app/jobs/audit_job.rb +0 -58
- data/curation_concerns-models/app/jobs/characterize_job.rb +0 -11
- data/curation_concerns-models/app/jobs/copy_permissions_job.rb +0 -24
- data/curation_concerns-models/app/jobs/create_derivatives_job.rb +0 -15
- data/curation_concerns-models/app/jobs/import_url_job.rb +0 -56
- data/curation_concerns-models/app/jobs/ingest_local_file_job.rb +0 -48
- data/curation_concerns-models/app/jobs/resolrize_job.rb +0 -9
- data/curation_concerns-models/app/models/checksum_audit_log.rb +0 -21
- data/curation_concerns-models/app/models/concerns/curation_concerns/ability.rb +0 -34
- data/curation_concerns-models/app/models/concerns/curation_concerns/basic_metadata.rb +0 -87
- data/curation_concerns-models/app/models/concerns/curation_concerns/collection_behavior.rb +0 -47
- data/curation_concerns-models/app/models/concerns/curation_concerns/generic_file/belongs_to_works.rb +0 -53
- data/curation_concerns-models/app/models/concerns/curation_concerns/generic_file/characterization.rb +0 -89
- data/curation_concerns-models/app/models/concerns/curation_concerns/generic_file/content.rb +0 -8
- data/curation_concerns-models/app/models/concerns/curation_concerns/generic_file/export.rb +0 -343
- data/curation_concerns-models/app/models/concerns/curation_concerns/generic_file/full_text_indexing.rb +0 -12
- data/curation_concerns-models/app/models/concerns/curation_concerns/generic_file/indexing.rb +0 -14
- data/curation_concerns-models/app/models/concerns/curation_concerns/generic_file/versions.rb +0 -16
- data/curation_concerns-models/app/models/concerns/curation_concerns/generic_file.rb +0 -5
- data/curation_concerns-models/app/models/concerns/curation_concerns/generic_file_behavior.rb +0 -44
- data/curation_concerns-models/app/models/concerns/curation_concerns/generic_work_behavior.rb +0 -38
- data/curation_concerns-models/app/models/concerns/curation_concerns/has_representative.rb +0 -14
- data/curation_concerns-models/app/models/concerns/curation_concerns/human_readable_type.rb +0 -23
- data/curation_concerns-models/app/models/concerns/curation_concerns/permissions/readable.rb +0 -19
- data/curation_concerns-models/app/models/concerns/curation_concerns/permissions/writable.rb +0 -75
- data/curation_concerns-models/app/models/concerns/curation_concerns/permissions.rb +0 -7
- data/curation_concerns-models/app/models/concerns/curation_concerns/serializers.rb +0 -15
- data/curation_concerns-models/app/models/concerns/curation_concerns/solr_document_behavior.rb +0 -135
- data/curation_concerns-models/app/models/concerns/curation_concerns/user.rb +0 -65
- data/curation_concerns-models/app/models/concerns/curation_concerns/with_basic_metadata.rb +0 -98
- data/curation_concerns-models/app/models/concerns/curation_concerns/with_generic_files.rb +0 -29
- data/curation_concerns-models/app/models/curation_concerns/classify_concern.rb +0 -47
- data/curation_concerns-models/app/models/curation_concerns/quick_classification_query.rb +0 -31
- data/curation_concerns-models/app/models/datastreams/fits_datastream.rb +0 -148
- data/curation_concerns-models/app/models/version_committer.rb +0 -2
- data/curation_concerns-models/app/services/curation_concerns/characterization_service.rb +0 -71
- data/curation_concerns-models/app/services/curation_concerns/full_text_extraction_service.rb +0 -38
- data/curation_concerns-models/app/services/curation_concerns/generic_file_audit_service.rb +0 -85
- data/curation_concerns-models/app/services/curation_concerns/generic_file_indexing_service.rb +0 -14
- data/curation_concerns-models/app/services/curation_concerns/generic_work_indexing_service.rb +0 -16
- data/curation_concerns-models/app/services/curation_concerns/noid.rb +0 -23
- data/curation_concerns-models/app/services/curation_concerns/repository_audit_service.rb +0 -9
- data/curation_concerns-models/app/services/curation_concerns/versioning_service.rb +0 -27
- data/curation_concerns-models/config/locales/curation_concerns.en.yml +0 -6
- data/curation_concerns-models/curation_concerns-models.gemspec +0 -34
- data/curation_concerns-models/lib/curation_concerns/messages.rb +0 -66
- data/curation_concerns-models/lib/curation_concerns/models/engine.rb +0 -61
- data/curation_concerns-models/lib/curation_concerns/models/resque.rb +0 -36
- data/curation_concerns-models/lib/curation_concerns/models/utils.rb +0 -22
- data/curation_concerns-models/lib/curation_concerns/models/version.rb +0 -5
- data/curation_concerns-models/lib/curation_concerns/models.rb +0 -32
- data/curation_concerns-models/lib/generators/curation_concerns/models/abstract_migration_generator.rb +0 -30
- data/curation_concerns-models/lib/generators/curation_concerns/models/clamav_generator.rb +0 -19
- data/curation_concerns-models/lib/generators/curation_concerns/models/fulltext_generator.rb +0 -28
- data/curation_concerns-models/lib/generators/curation_concerns/models/install_generator.rb +0 -70
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/app/models/collection.rb +0 -4
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/app/models/generic_file.rb +0 -4
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/config/clamav.rb +0 -1
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/config/curation_concerns.rb +0 -123
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/config/mime_types.rb +0 -6
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/config/redis.yml +0 -9
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/config/redis_config.rb +0 -32
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/config/resque-pool.yml +0 -1
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/config/resque_admin.rb +0 -10
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/config/resque_config.rb +0 -5
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/migrations/create_checksum_audit_logs.rb +0 -19
- data/curation_concerns-models/lib/generators/curation_concerns/models/templates/migrations/create_version_committers.rb +0 -15
- data/curation_concerns-models/lib/tasks/curation_concerns-models_tasks.rake +0 -75
- data/curation_concerns-models/lib/tasks/migrate.rake +0 -13
- data/curation_concerns-models/lib/tasks/resque.rake +0 -13
- data/curation_concerns-models/lib/tasks/solr_reindex.rake +0 -8
- data/lib/curation_concerns/configuration.rb +0 -74
- data/lib/generators/curation_concerns/templates/curation_concerns_config.rb +0 -2
- data/solr_conf/conf/solrconfig.xml +0 -223
- data/spec/abilities/generic_file_abilities_spec.rb +0 -62
- data/spec/actors/curation_concerns/generic_file_actor_spec.rb +0 -116
- data/spec/controllers/curation_concerns/generic_files_controller_spec.rb +0 -251
- data/spec/forms/generic_file_edit_form_spec.rb +0 -33
- data/spec/helpers/thumbnail_helper_spec.rb +0 -21
- data/spec/jobs/copy_permissions_job_spec.rb +0 -49
- data/spec/jobs/curation_concerns_resque_queue_spec.rb +0 -49
- data/spec/models/curation_concerns/generic_file/derivatives_spec.rb +0 -88
- data/spec/models/curation_concerns/generic_work_behavior_spec.rb +0 -35
- data/spec/models/fits_datastream_spec.rb +0 -127
- data/spec/models/generic_file_spec.rb +0 -619
- data/spec/presenters/curation_concerns/generic_file_presenter_spec.rb +0 -16
- data/spec/services/characterization_service_spec.rb +0 -30
- data/spec/services/full_text_extraction_service_spec.rb +0 -5
- data/spec/services/generic_file_audit_service_spec.rb +0 -71
- data/spec/services/generic_file_indexing_service_spec.rb +0 -57
- data/spec/services/generic_work_indexing_service_spec.rb +0 -18
- data/spec/workers/visibility_copy_worker_spec.rb +0 -70
- data/vendor/assets/javascripts/handlebars.js +0 -2278
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.autocomplete.js +0 -602
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.core.js +0 -356
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.effect-highlight.js +0 -50
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.effect.js +0 -1276
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.menu.js +0 -610
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.position.js +0 -498
- data/vendor/assets/javascripts/jquery-ui-1.9.2/jquery.ui.widget.js +0 -528
- data/vendor/assets/javascripts/jquery.tokeninput.js +0 -1061
- data/vendor/assets/stylesheets/jquery-ui-lightness.css +0 -474
- data/vendor/assets/stylesheets/token-input-facebook.css +0 -122
- data/vendor/assets/stylesheets/token-input-mac.css +0 -204
- data/vendor/assets/stylesheets/token-input.css +0 -127
data/curation_concerns-models/app/actors/concerns/curation_concerns/manages_embargoes_actor.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
module CurationConcerns
|
2
|
-
# To use this module, include it in your Actor class
|
3
|
-
# and then add its interpreters wherever you want them to run.
|
4
|
-
# They should be called _before_ apply_attributes is called because
|
5
|
-
# they intercept values in the attributes Hash.
|
6
|
-
#
|
7
|
-
# @example
|
8
|
-
# class MyActorClass < BaseActor
|
9
|
-
# include Worthwile::ManagesEmbargoesActor
|
10
|
-
#
|
11
|
-
# def create
|
12
|
-
# interpret_visibility && super && copy_visibility
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# def update
|
16
|
-
# interpret_visibility && super && copy_visibility
|
17
|
-
# end
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
module ManagesEmbargoesActor
|
21
|
-
extend ActiveSupport::Concern
|
22
|
-
|
23
|
-
# Interprets embargo & lease visibility if necessary
|
24
|
-
# returns false if there are any errors
|
25
|
-
def interpret_visibility(attributes=self.attributes)
|
26
|
-
should_continue = interpret_embargo_visibility(attributes) && interpret_lease_visibility(attributes)
|
27
|
-
if attributes[:visibility]
|
28
|
-
curation_concern.visibility = attributes[:visibility]
|
29
|
-
end
|
30
|
-
return should_continue
|
31
|
-
end
|
32
|
-
|
33
|
-
# If user has set visibility to embargo, interprets the relevant information and applies it
|
34
|
-
# Returns false if there are any errors and sets an error on the curation_concern
|
35
|
-
def interpret_embargo_visibility(attributes=self.attributes)
|
36
|
-
if attributes[:visibility] == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO
|
37
|
-
if !attributes[:embargo_release_date]
|
38
|
-
curation_concern.errors.add(:visibility, 'When setting visibility to "embargo" you must also specify embargo release date.')
|
39
|
-
should_continue = false
|
40
|
-
else
|
41
|
-
attributes.delete(:visibility)
|
42
|
-
curation_concern.apply_embargo(attributes[:embargo_release_date], attributes.delete(:visibility_during_embargo),
|
43
|
-
attributes.delete(:visibility_after_embargo))
|
44
|
-
if curation_concern.embargo
|
45
|
-
curation_concern.embargo.save # See https://github.com/projecthydra/hydra-head/issues/226
|
46
|
-
end
|
47
|
-
@needs_to_copy_visibility = true
|
48
|
-
should_continue = true
|
49
|
-
end
|
50
|
-
else
|
51
|
-
should_continue = true
|
52
|
-
# clear embargo_release_date if it isn't being used. Otherwise it sets the embargo_date
|
53
|
-
# even though they didn't select embargo on the form.
|
54
|
-
attributes.delete(:embargo_release_date)
|
55
|
-
end
|
56
|
-
|
57
|
-
attributes.delete(:visibility_during_embargo)
|
58
|
-
attributes.delete(:visibility_after_embargo)
|
59
|
-
|
60
|
-
return should_continue
|
61
|
-
end
|
62
|
-
|
63
|
-
# If user has set visibility to lease, interprets the relevant information and applies it
|
64
|
-
# Returns false if there are any errors and sets an error on the curation_concern
|
65
|
-
def interpret_lease_visibility(attributes=self.attributes)
|
66
|
-
if attributes[:visibility] == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE
|
67
|
-
if !attributes[:lease_expiration_date]
|
68
|
-
curation_concern.errors.add(:visibility, 'When setting visibility to "lease" you must also specify lease expiration date.')
|
69
|
-
should_continue = false
|
70
|
-
else
|
71
|
-
curation_concern.apply_lease(attributes[:lease_expiration_date], attributes.delete(:visibility_during_lease),
|
72
|
-
attributes.delete(:visibility_after_lease))
|
73
|
-
if curation_concern.lease
|
74
|
-
curation_concern.lease.save # See https://github.com/projecthydra/hydra-head/issues/226
|
75
|
-
end
|
76
|
-
@needs_to_copy_visibility = true
|
77
|
-
attributes.delete(:visibility)
|
78
|
-
should_continue = true
|
79
|
-
end
|
80
|
-
else
|
81
|
-
# clear lease_expiration_date if it isn't being used. Otherwise it sets the lease_expiration
|
82
|
-
# even though they didn't select lease on the form.
|
83
|
-
attributes.delete(:lease_expiration_date)
|
84
|
-
should_continue = true
|
85
|
-
end
|
86
|
-
|
87
|
-
attributes.delete(:visibility_during_lease)
|
88
|
-
attributes.delete(:visibility_after_lease)
|
89
|
-
|
90
|
-
return should_continue
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
def copy_visibility
|
95
|
-
CurationConcerns.queue.push(VisibilityCopyWorker.new(curation_concern.id)) if @needs_to_copy_visibility
|
96
|
-
true
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
|
2
|
-
module CurationConcerns
|
3
|
-
# The CurationConcern base actor should respond to three primary actions:
|
4
|
-
# * #create
|
5
|
-
# * #update
|
6
|
-
# * #delete
|
7
|
-
class BaseActor
|
8
|
-
attr_reader :curation_concern, :user, :attributes, :cloud_resources
|
9
|
-
def initialize(curation_concern, user, input_attributes)
|
10
|
-
@curation_concern = curation_concern
|
11
|
-
@user = user
|
12
|
-
@attributes = input_attributes.dup.with_indifferent_access
|
13
|
-
@visibility = attributes[:visibility]
|
14
|
-
@cloud_resources= attributes.delete(:cloud_resources.to_s)
|
15
|
-
end
|
16
|
-
|
17
|
-
attr_reader :visibility
|
18
|
-
protected :visibility
|
19
|
-
|
20
|
-
delegate :visibility_changed?, to: :curation_concern
|
21
|
-
|
22
|
-
def create
|
23
|
-
apply_creation_data_to_curation_concern
|
24
|
-
apply_save_data_to_curation_concern
|
25
|
-
save
|
26
|
-
end
|
27
|
-
|
28
|
-
def update
|
29
|
-
apply_update_data_to_curation_concern
|
30
|
-
apply_save_data_to_curation_concern
|
31
|
-
save
|
32
|
-
end
|
33
|
-
|
34
|
-
protected
|
35
|
-
def apply_creation_data_to_curation_concern
|
36
|
-
apply_depositor_metadata
|
37
|
-
apply_deposit_date
|
38
|
-
end
|
39
|
-
|
40
|
-
def apply_update_data_to_curation_concern
|
41
|
-
true
|
42
|
-
end
|
43
|
-
|
44
|
-
def apply_depositor_metadata
|
45
|
-
curation_concern.apply_depositor_metadata(user.user_key)
|
46
|
-
curation_concern.edit_users += [user.user_key]
|
47
|
-
end
|
48
|
-
|
49
|
-
def apply_deposit_date
|
50
|
-
curation_concern.date_uploaded = Date.today
|
51
|
-
end
|
52
|
-
|
53
|
-
def save
|
54
|
-
curation_concern.save
|
55
|
-
end
|
56
|
-
|
57
|
-
def apply_save_data_to_curation_concern
|
58
|
-
attributes[:rights] = Array(attributes[:rights]) if attributes.key? :rights
|
59
|
-
remove_blank_attributes!
|
60
|
-
curation_concern.attributes = attributes.symbolize_keys
|
61
|
-
curation_concern.date_modified = Date.today
|
62
|
-
end
|
63
|
-
|
64
|
-
def attach_file(generic_file, file_to_attach)
|
65
|
-
ActiveSupport::Deprecation.warn("removing #{self.class}#attach_file, use CurationConcern.attach_file instead")
|
66
|
-
CurationConcern.attach_file(generic_file, user, file_to_attach)
|
67
|
-
end
|
68
|
-
|
69
|
-
# If any attributes are blank remove them
|
70
|
-
# e.g.:
|
71
|
-
# self.attributes = { 'title' => ['first', 'second', ''] }
|
72
|
-
# remove_blank_attributes!
|
73
|
-
# self.attributes
|
74
|
-
# => { 'title' => ['first', 'second'] }
|
75
|
-
def remove_blank_attributes!
|
76
|
-
multivalued_form_attributes.each_with_object(attributes) do |(k, v), h|
|
77
|
-
if v.instance_of? Array
|
78
|
-
h[k] = v.select(&:present?)
|
79
|
-
else
|
80
|
-
h[k] = v
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# Return the hash of attributes that are multivalued and not uploaded files
|
86
|
-
def multivalued_form_attributes
|
87
|
-
attributes.select {|_, v| v.respond_to?(:select) && !v.respond_to?(:read) }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,150 +0,0 @@
|
|
1
|
-
module CurationConcerns
|
2
|
-
# Actions are decoupled from controller logic so that they may be called from a controller or a background job.
|
3
|
-
class GenericFileActor
|
4
|
-
include CurationConcerns::ManagesEmbargoesActor
|
5
|
-
|
6
|
-
attr_reader :generic_file, :user, :attributes, :curation_concern
|
7
|
-
|
8
|
-
def initialize(generic_file, user)
|
9
|
-
# we're setting attributes and curation_concern to bridge the difference
|
10
|
-
# between CurationConcerns::GenericFileActor and ManagesEmbargoesActor
|
11
|
-
@curation_concern = generic_file
|
12
|
-
@generic_file = generic_file
|
13
|
-
@user = user
|
14
|
-
end
|
15
|
-
|
16
|
-
# Adds the appropriate metadata, visibility and relationships to generic_file
|
17
|
-
#
|
18
|
-
# *Note*: In past versions of Sufia this method did not perform a save because it is mainly used in conjunction with
|
19
|
-
# create_content, which also performs a save. However, due to the relationship between Hydra::PCDM objects,
|
20
|
-
# we have to save both the parent work and the generic_file in order to record the "metadata" relationship
|
21
|
-
# between them.
|
22
|
-
# @param [String] batch_id id of the batch that the file was uploaded within
|
23
|
-
# @param [String] work_id id of the parent work that will contain the generic_file.
|
24
|
-
# @param [Hash] generic_file_params specifying the visibility, lease and/or embargo of the generic file. If you don't provide at least one of visibility, embargo_release_date or lease_expiration_date, visibility will be copied from the parent.
|
25
|
-
|
26
|
-
def create_metadata(batch_id, work_id, generic_file_params={})
|
27
|
-
generic_file.apply_depositor_metadata(user)
|
28
|
-
time_in_utc = DateTime.now.new_offset(0)
|
29
|
-
generic_file.date_uploaded = time_in_utc
|
30
|
-
generic_file.date_modified = time_in_utc
|
31
|
-
generic_file.creator = [user.name]
|
32
|
-
# TODO: Remove this? see https://github.com/projecthydra-labs/curation_concerns/issues/27
|
33
|
-
if batch_id && generic_file.respond_to?(:batch_id=)
|
34
|
-
generic_file.batch_id = batch_id
|
35
|
-
else
|
36
|
-
ActiveFedora::Base.logger.warn "unable to find batch to attach to"
|
37
|
-
end
|
38
|
-
|
39
|
-
unless work_id.blank?
|
40
|
-
work = ActiveFedora::Base.find(work_id)
|
41
|
-
|
42
|
-
if !((generic_file_params || {}).keys & ["visibility", "embargo_release_date", "lease_expiration_date"]).empty?
|
43
|
-
interpret_visibility generic_file_params
|
44
|
-
else
|
45
|
-
copy_visibility(work, generic_file)
|
46
|
-
end
|
47
|
-
work.generic_files << generic_file
|
48
|
-
# Save the work so the association between the work and the generic_file is persisted (head_id)
|
49
|
-
work.save
|
50
|
-
end
|
51
|
-
yield(generic_file) if block_given?
|
52
|
-
end
|
53
|
-
|
54
|
-
def create_content(file)
|
55
|
-
# Tell UploadFileToGenericFile service to skip versioning because versions will be minted by VersionCommitter (called by save_characterize_and_record_committer) when necessary
|
56
|
-
Hydra::Works::UploadFileToGenericFile.call(generic_file, file, versioning: false)
|
57
|
-
generic_file.label ||= file.original_filename
|
58
|
-
generic_file.title = [generic_file.label] if generic_file.title.blank?
|
59
|
-
save_characterize_and_record_committer do
|
60
|
-
if CurationConcerns.config.respond_to?(:after_create_content)
|
61
|
-
CurationConcerns.config.after_create_content.call(generic_file, user)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def revert_content(revision_id)
|
67
|
-
generic_file.original_file.restore_version(revision_id)
|
68
|
-
save_characterize_and_record_committer do
|
69
|
-
if CurationConcerns.config.respond_to?(:after_revert_content)
|
70
|
-
CurationConcerns.config.after_revert_content.call(generic_file, user, revision_id)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def update_content(file)
|
76
|
-
# Tell UploadFileToGenericFile service to skip versioning because versions will be minted by VersionCommitter (called by save_characterize_and_record_committer) when necessary
|
77
|
-
Hydra::Works::UploadFileToGenericFile.call(generic_file, file, versioning: false)
|
78
|
-
save_characterize_and_record_committer do
|
79
|
-
if CurationConcerns.config.respond_to?(:after_update_content)
|
80
|
-
CurationConcerns.config.after_update_content.call(generic_file, user)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def update_metadata(model_attributes, all_attributes)
|
86
|
-
update_visibility(all_attributes)
|
87
|
-
model_attributes.delete(:visibility) # Applying this attribute is handled by update_visibility
|
88
|
-
generic_file.attributes = model_attributes
|
89
|
-
generic_file.date_modified = DateTime.now
|
90
|
-
save do
|
91
|
-
if CurationConcerns.config.respond_to?(:after_update_metadata)
|
92
|
-
CurationConcerns.config.after_update_metadata.call(generic_file, user)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def destroy
|
98
|
-
generic_file.destroy
|
99
|
-
if CurationConcerns.config.respond_to?(:after_destroy)
|
100
|
-
CurationConcerns.config.after_destroy.call(generic_file.id, user)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# Saves the generic file, queues a job to characterize it, and records the committer.
|
105
|
-
# Takes a block which is run if the save was successful.
|
106
|
-
def save_characterize_and_record_committer
|
107
|
-
save do
|
108
|
-
push_characterize_job
|
109
|
-
CurationConcerns::VersioningService.create(generic_file.original_file, user)
|
110
|
-
yield if block_given?
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
# Takes an optional block and executes the block if the save was successful.
|
115
|
-
# returns false if the save was unsuccessful
|
116
|
-
def save
|
117
|
-
save_tries = 0
|
118
|
-
begin
|
119
|
-
return false unless generic_file.save
|
120
|
-
rescue RSolr::Error::Http => error
|
121
|
-
ActiveFedora::Base.logger.warn "CurationConcerns::GenericFileActor#save Caught RSOLR error #{error.inspect}"
|
122
|
-
save_tries+=1
|
123
|
-
# fail for good if the tries is greater than 3
|
124
|
-
raise error if save_tries >=3
|
125
|
-
sleep 0.01
|
126
|
-
retry
|
127
|
-
end
|
128
|
-
yield if block_given?
|
129
|
-
true
|
130
|
-
end
|
131
|
-
|
132
|
-
def push_characterize_job
|
133
|
-
CurationConcerns.queue.push(CharacterizeJob.new(@generic_file.id))
|
134
|
-
end
|
135
|
-
|
136
|
-
protected
|
137
|
-
|
138
|
-
# This method can be overridden in case there is a custom approach for visibility (e.g. embargo)
|
139
|
-
def update_visibility(attributes)
|
140
|
-
interpret_visibility(attributes) # relies on CurationConcerns::ManagesEmbargoesActor to interpret and apply visibility
|
141
|
-
end
|
142
|
-
|
143
|
-
private
|
144
|
-
|
145
|
-
# copy visibility from source_concern to destination_concern
|
146
|
-
def copy_visibility(source_concern, destination_concern)
|
147
|
-
destination_concern.visibility = source_concern.visibility
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
|
2
|
-
module CurationConcerns::WorkActorBehavior
|
3
|
-
include CurationConcerns::ManagesEmbargoesActor
|
4
|
-
|
5
|
-
def create
|
6
|
-
# set the @files ivar then remove the files attribute so it isn't set by default.
|
7
|
-
files && attributes.delete(:files)
|
8
|
-
# Files must be attached before saving in order to persist their relationship to the work
|
9
|
-
assign_pid && interpret_visibility && attach_files && super && assign_representative && copy_visibility
|
10
|
-
end
|
11
|
-
|
12
|
-
def update
|
13
|
-
add_to_collections(attributes.delete(:collection_ids)) &&
|
14
|
-
interpret_visibility && super && attach_files && copy_visibility
|
15
|
-
end
|
16
|
-
|
17
|
-
delegate :visibility_changed?, to: :curation_concern
|
18
|
-
|
19
|
-
protected
|
20
|
-
|
21
|
-
# Is this here to ensure that the curation_concern has a pid set before any of the other methods are executed?
|
22
|
-
def assign_pid
|
23
|
-
curation_concern.send(:assign_id)
|
24
|
-
end
|
25
|
-
|
26
|
-
def files
|
27
|
-
return @files if defined?(@files)
|
28
|
-
@files = [attributes[:files]].flatten.compact
|
29
|
-
end
|
30
|
-
|
31
|
-
def attach_files
|
32
|
-
files.all? do |file|
|
33
|
-
attach_file(file)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# The default behavior of active_fedora's aggregates association,
|
38
|
-
# when assigning the id accessor (e.g. collection_ids = ['foo:1']) is to add
|
39
|
-
# to new collections, but not remove from old collections.
|
40
|
-
# This method ensures it's removed from the old collections.
|
41
|
-
def add_to_collections(new_collection_ids)
|
42
|
-
return true unless new_collection_ids
|
43
|
-
# remove from old collections
|
44
|
-
# TODO Implement parent_collection_ids https://github.com/projecthydra-labs/hydra-pcdm/issues/157
|
45
|
-
(curation_concern.parent_collections.map(&:id) - new_collection_ids).each do |old_id|
|
46
|
-
Collection.find(old_id).members.delete(curation_concern)
|
47
|
-
end
|
48
|
-
|
49
|
-
#add to new
|
50
|
-
new_collection_ids.each do |coll_id|
|
51
|
-
collection = Collection.find(coll_id)
|
52
|
-
collection.members << curation_concern
|
53
|
-
collection.save
|
54
|
-
end
|
55
|
-
true
|
56
|
-
end
|
57
|
-
|
58
|
-
def assign_representative
|
59
|
-
@generic_files ||= []
|
60
|
-
unless curation_concern.representative
|
61
|
-
curation_concern.representative = @generic_files.first.id unless @generic_files.empty?
|
62
|
-
end
|
63
|
-
curation_concern.save
|
64
|
-
end
|
65
|
-
|
66
|
-
private
|
67
|
-
|
68
|
-
def attach_file(file)
|
69
|
-
generic_file = ::GenericFile.new
|
70
|
-
generic_file_actor = CurationConcerns::GenericFileActor.new(generic_file, user)
|
71
|
-
#TODO we're passing an ID rather than an object. This means the actor does an unnecessary lookup
|
72
|
-
generic_file_actor.create_metadata(curation_concern.id, curation_concern.id)
|
73
|
-
generic_file.visibility = visibility
|
74
|
-
generic_file_actor.create_content(file)
|
75
|
-
@generic_files ||= []
|
76
|
-
@generic_files << generic_file # This is so that other methods like assign_representative can access the generic_files wihtout reloading them from fedora
|
77
|
-
curation_concern.generic_files << generic_file
|
78
|
-
end
|
79
|
-
|
80
|
-
def valid_file?(file_path)
|
81
|
-
return file_path.present? && File.exists?(file_path) && !File.zero?(file_path)
|
82
|
-
end
|
83
|
-
|
84
|
-
# The path of the fedora node where we store the file data
|
85
|
-
def file_path
|
86
|
-
'content'
|
87
|
-
end
|
88
|
-
end
|
@@ -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,58 +0,0 @@
|
|
1
|
-
class AuditJob < ActiveFedoraIdBasedJob
|
2
|
-
def queue_name
|
3
|
-
:audit
|
4
|
-
end
|
5
|
-
|
6
|
-
attr_accessor :uri, :id, :file_id
|
7
|
-
|
8
|
-
# URI of the resource to audit.
|
9
|
-
# This URI could include the actual resource (e.g. content) and the version to audit:
|
10
|
-
# http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content/fcr:versions/version1
|
11
|
-
# but it could also just be:
|
12
|
-
# http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content
|
13
|
-
# @param [String] id of the parent object
|
14
|
-
# @param [String] file_id used to find the file within its parent object (usually "original_file")
|
15
|
-
# @param [String] uri of the specific file/version to be audited
|
16
|
-
def initialize(id, file_id, uri)
|
17
|
-
super(id)
|
18
|
-
self.file_id = file_id
|
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
|
-
if CurationConcerns.config.respond_to?(:after_audit_failure)
|
28
|
-
login = generic_file.depositor
|
29
|
-
user = User.find_by_user_key(login)
|
30
|
-
CurationConcerns.config.after_audit_failure.call(generic_file, user, log.created_at)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
fixity_ok
|
34
|
-
end
|
35
|
-
|
36
|
-
protected
|
37
|
-
|
38
|
-
def run_audit
|
39
|
-
begin
|
40
|
-
fixity_ok = ActiveFedora::FixityService.new(uri).check
|
41
|
-
rescue Ldp::NotFound
|
42
|
-
error_msg = "resource not found"
|
43
|
-
end
|
44
|
-
|
45
|
-
if fixity_ok
|
46
|
-
passing = 1
|
47
|
-
ChecksumAuditLog.prune_history(id, file_id)
|
48
|
-
else
|
49
|
-
logger.warn "***AUDIT*** Audit failed for #{uri} #{error_msg}"
|
50
|
-
passing = 0
|
51
|
-
end
|
52
|
-
ChecksumAuditLog.create!(pass: passing, generic_file_id: id, version: uri, file_id: file_id)
|
53
|
-
end
|
54
|
-
|
55
|
-
def logger
|
56
|
-
ActiveFedora::Base.logger
|
57
|
-
end
|
58
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class CharacterizeJob < ActiveFedoraIdBasedJob
|
2
|
-
def queue_name
|
3
|
-
:characterize
|
4
|
-
end
|
5
|
-
|
6
|
-
def run
|
7
|
-
CurationConcerns::CharacterizationService.run(generic_file)
|
8
|
-
generic_file.save
|
9
|
-
CurationConcerns.queue.push(CreateDerivativesJob.new(generic_file.id))
|
10
|
-
end
|
11
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
class CopyPermissionsJob
|
2
|
-
def queue_name
|
3
|
-
:permissions
|
4
|
-
end
|
5
|
-
|
6
|
-
attr_accessor :id
|
7
|
-
|
8
|
-
def initialize(id)
|
9
|
-
self.id = id
|
10
|
-
end
|
11
|
-
|
12
|
-
def run
|
13
|
-
# work = ActiveFedora::Base.load_instance_from_solr(id)
|
14
|
-
work = ActiveFedora::Base.find(id) # Hydra::Works::GenericWork is not compatible with load_instance_from_solr. Using (slower) ActiveFedora::Base.find instead.
|
15
|
-
if work.respond_to?(:generic_files)
|
16
|
-
work.generic_files.each do |file|
|
17
|
-
|
18
|
-
work.permissions.each {|perm| file.permissions << Hydra::AccessControls::Permission.new(perm.to_hash)}
|
19
|
-
new_permissions = file.permissions.uniq! { |item| item.to_hash}
|
20
|
-
file.permissions = new_permissions unless new_permissions.blank?
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class CreateDerivativesJob < ActiveFedoraIdBasedJob
|
2
|
-
def queue_name
|
3
|
-
:derivatives
|
4
|
-
end
|
5
|
-
|
6
|
-
def run
|
7
|
-
return unless generic_file.original_file.has_content?
|
8
|
-
if generic_file.video?
|
9
|
-
return unless CurationConcerns.config.enable_ffmpeg
|
10
|
-
end
|
11
|
-
|
12
|
-
generic_file.create_derivatives
|
13
|
-
generic_file.save
|
14
|
-
end
|
15
|
-
end
|
@@ -1,56 +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
|
-
copy_remote_file(generic_file.import_url, f)
|
16
|
-
# attach downloaded file to generic file stubbed out
|
17
|
-
if CurationConcerns::GenericFileActor.new(generic_file, user).create_content(f)
|
18
|
-
|
19
|
-
# send message to user on download success
|
20
|
-
if CurationConcerns.config.respond_to?(:after_import_url_success)
|
21
|
-
CurationConcerns.config.after_import_url_success.call(generic_file, user)
|
22
|
-
end
|
23
|
-
else
|
24
|
-
|
25
|
-
# send message to user on download failure
|
26
|
-
if CurationConcerns.config.respond_to?(:after_import_url_failure)
|
27
|
-
CurationConcerns.config.after_import_url_failure.call(generic_file, user)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def copy_remote_file(import_url, f)
|
34
|
-
f.binmode
|
35
|
-
# download file from url
|
36
|
-
uri = URI(generic_file.import_url)
|
37
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
38
|
-
http.use_ssl = uri.scheme == "https" # enable SSL/TLS
|
39
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
40
|
-
mime_type = nil
|
41
|
-
|
42
|
-
http.start do
|
43
|
-
http.request_get(uri.request_uri) do |resp|
|
44
|
-
mime_type = resp.content_type
|
45
|
-
resp.read_body do |segment|
|
46
|
-
f.write(segment)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
f.rewind
|
51
|
-
end
|
52
|
-
|
53
|
-
def job_user
|
54
|
-
User.batchuser
|
55
|
-
end
|
56
|
-
end
|
@@ -1,48 +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
|
-
def run
|
16
|
-
user = User.find_by_user_key(user_key)
|
17
|
-
raise "Unable to find user for #{user_key}" unless user
|
18
|
-
generic_file = GenericFile.find(generic_file_id)
|
19
|
-
generic_file.label ||= filename
|
20
|
-
path = File.join(directory, filename)
|
21
|
-
|
22
|
-
actor = CurationConcerns::GenericFileActor.new(generic_file, user)
|
23
|
-
|
24
|
-
if actor.create_content(File.open(path))
|
25
|
-
FileUtils.rm(path)
|
26
|
-
|
27
|
-
# send message to user on import success
|
28
|
-
if CurationConcerns.config.respond_to?(:after_import_local_file_success)
|
29
|
-
CurationConcerns.config.after_import_local_file_success.call(generic_file, user, filename)
|
30
|
-
end
|
31
|
-
else
|
32
|
-
|
33
|
-
# send message to user on import failure
|
34
|
-
if CurationConcerns.config.respond_to?(:after_import_local_file_failure)
|
35
|
-
CurationConcerns.config.after_import_local_file_failure.call(generic_file, user, filename)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def job_user
|
41
|
-
User.batchuser
|
42
|
-
end
|
43
|
-
|
44
|
-
def mime_type(file_name)
|
45
|
-
mime_types = MIME::Types.of(file_name)
|
46
|
-
mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
|
47
|
-
end
|
48
|
-
end
|