hydra-head 3.0.0pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +71 -0
- data/.gitmodules +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +257 -0
- data/README.textile +150 -0
- data/README_RAILS3_CHANGES.textile +42 -0
- data/Rakefile +5 -0
- data/TESTING.textile +85 -0
- data/app/controllers/assets_controller.rb +117 -0
- data/app/controllers/contributors_controller.rb +54 -0
- data/app/controllers/file_assets_controller.rb +152 -0
- data/app/controllers/permissions_controller.rb +137 -0
- data/app/controllers/user_sessions_controller.rb +14 -0
- data/app/helpers/article_metadata_helper.rb +80 -0
- data/app/helpers/blacklight_helper.rb +192 -0
- data/app/helpers/downloads_helper.rb +19 -0
- data/app/helpers/generic_content_objects_helper.rb +16 -0
- data/app/helpers/hydra_assets_helper.rb +75 -0
- data/app/helpers/hydra_djatoka_helper.rb +23 -0
- data/app/helpers/hydra_fedora_metadata_helper.rb +365 -0
- data/app/helpers/hydra_helper.rb +155 -0
- data/app/helpers/hydra_uploader_helper.rb +18 -0
- data/app/helpers/inline_editable_metadata_helper.rb +15 -0
- data/app/helpers/javascript_includes_helper.rb +93 -0
- data/app/helpers/release_process_helper.rb +32 -0
- data/app/models/audio_asset.rb +8 -0
- data/app/models/file_asset.rb +111 -0
- data/app/models/generic_content.rb +21 -0
- data/app/models/generic_image.rb +62 -0
- data/app/models/image_asset.rb +8 -0
- data/app/models/mods_asset.rb +6 -0
- data/app/models/role_mapper.rb +22 -0
- data/app/models/superuser.rb +6 -0
- data/app/models/video_asset.rb +8 -0
- data/app/views/_add_assets_links.html.erb +13 -0
- data/app/views/_brown_sidebar.html +15 -0
- data/app/views/_user_util_links.html.erb +31 -0
- data/app/views/catalog/_citation.html.erb +11 -0
- data/app/views/catalog/_constraints_element.html.erb +34 -0
- data/app/views/catalog/_delete_partials/_default.html.erb +29 -0
- data/app/views/catalog/_document_list.html.erb +11 -0
- data/app/views/catalog/_edit_partials/_default.html.erb +64 -0
- data/app/views/catalog/_edit_partials/_default_details.html.erb +15 -0
- data/app/views/catalog/_email_form.html.erb +9 -0
- data/app/views/catalog/_facets.html.erb +37 -0
- data/app/views/catalog/_flash_msg.html.erb +17 -0
- data/app/views/catalog/_home.html.erb +6 -0
- data/app/views/catalog/_home_text.html.erb +10 -0
- data/app/views/catalog/_index_partials/_default.html.erb +20 -0
- data/app/views/catalog/_index_partials/_default_details.html.erb +11 -0
- data/app/views/catalog/_index_partials/_default_group.html.erb +15 -0
- data/app/views/catalog/_search_form.html.erb +12 -0
- data/app/views/catalog/_show_partials/_default.html.erb +23 -0
- data/app/views/catalog/_show_partials/_default_details.html.erb +12 -0
- data/app/views/catalog/_show_partials/_facets.html.erb +52 -0
- data/app/views/catalog/_sms_form.html.erb +21 -0
- data/app/views/catalog/_sort_and_per_page.html.erb +22 -0
- data/app/views/catalog/_uva_tabs.html.erb +10 -0
- data/app/views/catalog/about.html.erb +0 -0
- data/app/views/catalog/show.html.erb +48 -0
- data/app/views/contributors/_add_contributor_split_button.html.erb +10 -0
- data/app/views/contributors/_edit_conference.html.erb +29 -0
- data/app/views/contributors/_edit_organization.html.erb +29 -0
- data/app/views/contributors/_edit_person.html.erb +42 -0
- data/app/views/contributors/_index.html.erb +12 -0
- data/app/views/contributors/_new.html.erb +10 -0
- data/app/views/contributors/_show_conference.html.erb +22 -0
- data/app/views/contributors/_show_organization.html.erb +29 -0
- data/app/views/contributors/_show_person.html.erb +17 -0
- data/app/views/contributors/new.html.erb +13 -0
- data/app/views/downloads/index.html.erb +1 -0
- data/app/views/file_assets/_deletable_result.html.erb +5 -0
- data/app/views/file_assets/_index.html.erb +15 -0
- data/app/views/file_assets/_new.html.erb +2 -0
- data/app/views/file_assets/_result.html.erb +16 -0
- data/app/views/file_assets/index.html.erb +5 -0
- data/app/views/fluid_infusion/_uploader.html.erb +81 -0
- data/app/views/fluid_infusion/_uploader_generic_content_objects.js.erb +38 -0
- data/app/views/fluid_infusion/_uploader_js.erb +45 -0
- data/app/views/generic_content_objects/_edit_description.html.erb +50 -0
- data/app/views/generic_content_objects/_new.html.erb +0 -0
- data/app/views/generic_content_objects/_show_description.html.erb +68 -0
- data/app/views/generic_content_objects/contributors/_edit_conference.html.erb +29 -0
- data/app/views/generic_content_objects/contributors/_edit_organization.html.erb +29 -0
- data/app/views/generic_content_objects/contributors/_edit_person.html.erb +37 -0
- data/app/views/generic_content_objects/contributors/_new.html.erb +10 -0
- data/app/views/generic_content_objects/contributors/_show_conference.html.erb +22 -0
- data/app/views/generic_content_objects/contributors/_show_organization.html.erb +22 -0
- data/app/views/generic_content_objects/contributors/_show_person.html.erb +38 -0
- data/app/views/generic_contents/_edit.html.erb +59 -0
- data/app/views/generic_contents/_index.html.erb +23 -0
- data/app/views/generic_contents/_show.html.erb +18 -0
- data/app/views/generic_contents/_show_content.html.erb +4 -0
- data/app/views/generic_images/_edit.html.erb +59 -0
- data/app/views/generic_images/_index.html.erb +24 -0
- data/app/views/generic_images/_show.html.erb +18 -0
- data/app/views/generic_images/_show_all.html.erb +14 -0
- data/app/views/generic_images/_show_content.html.erb +7 -0
- data/app/views/layouts/application.html.erb +57 -0
- data/app/views/layouts/hydra-head.html.erb +12 -0
- data/app/views/mods_assets/_edit.html.erb +49 -0
- data/app/views/mods_assets/_edit_description.html.erb +82 -0
- data/app/views/mods_assets/_edit_journal.html.erb +72 -0
- data/app/views/mods_assets/_index.html.erb +1 -0
- data/app/views/mods_assets/_index_list.html.erb +37 -0
- data/app/views/mods_assets/_index_table.html.erb +7 -0
- data/app/views/mods_assets/_progress_box.html.erb +82 -0
- data/app/views/mods_assets/_show.html.erb +44 -0
- data/app/views/mods_assets/_show_description.html.erb +44 -0
- data/app/views/mods_assets/_show_journal.html.erb +42 -0
- data/app/views/mods_assets/_show_permissions.html.erb +14 -0
- data/app/views/permissions/_edit_person_permissions.html.erb +35 -0
- data/app/views/permissions/_index.html.erb +55 -0
- data/app/views/permissions/_new.html.erb +18 -0
- data/app/views/permissions/index.html.erb +1 -0
- data/app/views/permissions/new.html.erb +1 -0
- data/app/views/shared/_delete_asset_confirmation.html.erb +17 -0
- data/app/views/user_sessions/_login_form.html.erb +10 -0
- data/app/views/user_sessions/logged_out.html.erb +1 -0
- data/config/routes.rb +12 -0
- data/fedora_conf/conf/fedora.fcfg +1021 -0
- data/hydra-head.gemspec +70 -0
- data/lib/application_controller.rb +25 -0
- data/lib/application_helper.rb +2 -0
- data/lib/engine.rb +30 -0
- data/lib/generators/hydra/head_generator.rb +152 -0
- data/lib/generators/hydra/templates/config/fedora.yml +17 -0
- data/lib/generators/hydra/templates/config/initializers/blacklight_config.rb +246 -0
- data/lib/generators/hydra/templates/config/initializers/fedora_config.rb +23 -0
- data/lib/generators/hydra/templates/config/initializers/hydra_config.rb +29 -0
- data/lib/generators/hydra/templates/config/role_map_cucumber.yml +10 -0
- data/lib/generators/hydra/templates/config/role_map_development.yml +12 -0
- data/lib/generators/hydra/templates/config/role_map_production.yml +2 -0
- data/lib/generators/hydra/templates/config/role_map_test.yml +15 -0
- data/lib/generators/hydra/templates/config/solr.yml +10 -0
- data/lib/generators/hydra/templates/config/solr_mappings.yml +22 -0
- data/lib/generators/hydra/templates/fedora_conf/conf/fedora.fcfg +1021 -0
- data/lib/generators/hydra/templates/migrations/add_user_attributes_table.rb +15 -0
- data/lib/generators/hydra/templates/migrations/create_superusers.rb +12 -0
- data/lib/generators/hydra/templates/solr_conf/conf/schema.xml +118 -0
- data/lib/generators/hydra/templates/solr_conf/conf/solrconfig.xml +332 -0
- data/lib/generators/hydra/templates/solr_conf/solr.xml +35 -0
- data/lib/hydra-head.rb +29 -0
- data/lib/hydra-head/engine.rb +9 -0
- data/lib/hydra-head/routes.rb +87 -0
- data/lib/hydra-head/version.rb +4 -0
- data/lib/hydra.rb +22 -0
- data/lib/hydra/access_controls_enforcement.rb +236 -0
- data/lib/hydra/access_controls_evaluation.rb +97 -0
- data/lib/hydra/assets_controller_helper.rb +144 -0
- data/lib/hydra/catalog.rb +64 -0
- data/lib/hydra/common_mods_index_methods.rb +42 -0
- data/lib/hydra/controller.rb +7 -0
- data/lib/hydra/file_assets_helper.rb +144 -0
- data/lib/hydra/fixtures.rb +43 -0
- data/lib/hydra/generic_content.rb +113 -0
- data/lib/hydra/generic_image.rb +100 -0
- data/lib/hydra/image.rb +177 -0
- data/lib/hydra/model_methods.rb +95 -0
- data/lib/hydra/model_mixins.rb +2 -0
- data/lib/hydra/model_mixins/common_metadata.rb +24 -0
- data/lib/hydra/model_mixins/mods_object.rb +16 -0
- data/lib/hydra/mods_article.rb +505 -0
- data/lib/hydra/mods_dataset.rb +165 -0
- data/lib/hydra/mods_generic_content.rb +494 -0
- data/lib/hydra/mods_image.rb +494 -0
- data/lib/hydra/repository_controller.rb +102 -0
- data/lib/hydra/rights_metadata.rb +189 -0
- data/lib/hydra/superuser_attributes.rb +12 -0
- data/lib/hydra/testing_server.rb +183 -0
- data/lib/hydra/user.rb +22 -0
- data/lib/mediashelf/active_fedora_helper.rb +72 -0
- data/lib/railties/all_tests.rake +23 -0
- data/lib/railties/hydra-fixtures.rake +184 -0
- data/lib/railties/hydra_jetty.rake +79 -0
- data/lib/railties/hyhead_cucumber.rake +127 -0
- data/lib/railties/hyhead_rspec.rake +137 -0
- data/lib/stanford/searchworks_helper.rb +1338 -0
- data/lib/stanford/solr_helper.rb +108 -0
- data/lib/uva/mods_index_methods.rb +24 -0
- data/solr_conf/conf/schema.xml +122 -0
- data/solr_conf/conf/solrconfig.xml +332 -0
- data/solr_conf/solr.xml +35 -0
- data/tasks/hydra-head-fixtures.rake +54 -0
- data/tasks/hydra-head.rake +247 -0
- data/tasks/hydra_jetty.rake +79 -0
- data/tasks/replicator.rake +27 -0
- data/tasks/solrizer-fedora.rake +53 -0
- data/tasks/solrizer.rake +13 -0
- data/test_support/etc/Gemfile +29 -0
- data/test_support/etc/rvmrc +32 -0
- data/test_support/features/button_add_assets.feature +22 -0
- data/test_support/features/button_add_generic_content.feature +11 -0
- data/test_support/features/button_add_image.feature +11 -0
- data/test_support/features/button_add_mods_asset.feature +11 -0
- data/test_support/features/contributor_add.feature +39 -0
- data/test_support/features/file_assets_list.feature +32 -0
- data/test_support/features/file_upload.feature +40 -0
- data/test_support/features/home_page.feature +9 -0
- data/test_support/features/html_validity.feature +47 -0
- data/test_support/features/mods_asset_contributors_edit.feature +80 -0
- data/test_support/features/mods_asset_create.feature +12 -0
- data/test_support/features/mods_asset_edit.feature +33 -0
- data/test_support/features/mods_asset_edit_without_permission.feature +10 -0
- data/test_support/features/mods_asset_search_result.feature +13 -0
- data/test_support/features/mods_asset_show.feature +39 -0
- data/test_support/features/permissions_add.feature +15 -0
- data/test_support/features/permissions_edit.feature +63 -0
- data/test_support/features/step_definitions/catalog_index_steps.rb +14 -0
- data/test_support/features/step_definitions/create_asset_steps.rb +7 -0
- data/test_support/features/step_definitions/edit_metadata_steps.rb +73 -0
- data/test_support/features/step_definitions/file_list_steps.rb +28 -0
- data/test_support/features/step_definitions/hydra_metadata_steps.rb +3 -0
- data/test_support/features/step_definitions/hydra_steps.rb +8 -0
- data/test_support/features/step_definitions/inline_editable_edit_steps.rb +77 -0
- data/test_support/features/step_definitions/search_steps.rb +88 -0
- data/test_support/features/step_definitions/searching_steps.rb +22 -0
- data/test_support/features/step_definitions/show_document_steps.rb +85 -0
- data/test_support/features/step_definitions/user_steps.rb +36 -0
- data/test_support/features/step_definitions/web_steps.rb +219 -0
- data/test_support/features/support/env.rb +55 -0
- data/test_support/features/support/paths.rb +80 -0
- data/test_support/features/switch_users.feature +14 -0
- data/test_support/features/view_catalog_index.feature +18 -0
- data/test_support/fixtures/empty_file.txt +0 -0
- data/test_support/fixtures/hydrangea_fixture_archivist_only_mods_article.foxml.xml +1212 -0
- data/test_support/fixtures/hydrangea_fixture_file_asset1.foxml.xml +4946 -0
- data/test_support/fixtures/hydrangea_fixture_mods_article1.foxml.xml +234 -0
- data/test_support/fixtures/hydrangea_fixture_mods_article2.foxml.xml +177 -0
- data/test_support/fixtures/hydrangea_fixture_mods_article3.foxml.xml +170 -0
- data/test_support/fixtures/hydrangea_fixture_mods_dataset1.foxml.xml +187 -0
- data/test_support/fixtures/hydrangea_fixture_uploaded_svg1.foxml.xml +676 -0
- data/test_support/fixtures/image.jp2 +0 -0
- data/test_support/fixtures/libra-oa_1.foxml.xml +2324 -0
- data/test_support/fixtures/libra-oa_2.foxml.xml +2422 -0
- data/test_support/spec/controllers/assets_controller_spec.rb +113 -0
- data/test_support/spec/controllers/catalog_controller_spec.rb +148 -0
- data/test_support/spec/controllers/catalog_controller_viewing_context_spec.rb +62 -0
- data/test_support/spec/controllers/contributors_controller_spec.rb +47 -0
- data/test_support/spec/controllers/file_assets_controller_spec.rb +189 -0
- data/test_support/spec/controllers/hydra_controller_spec.rb +15 -0
- data/test_support/spec/controllers/permissions_controller_spec.rb +80 -0
- data/test_support/spec/controllers/user_sessions_controller_spec.rb +35 -0
- data/test_support/spec/generators/hydra-head_generator_spec.rb +14 -0
- data/test_support/spec/helpers/access_controls_enforcement_spec.rb +212 -0
- data/test_support/spec/helpers/access_controls_evaluation_spec.rb +35 -0
- data/test_support/spec/helpers/assets_controller_helper_spec.rb +71 -0
- data/test_support/spec/helpers/blacklight_helper_spec.rb +64 -0
- data/test_support/spec/helpers/file_assets_helper_spec.rb +107 -0
- data/test_support/spec/helpers/hydra-repository_controller_spec.rb +32 -0
- data/test_support/spec/helpers/hydra_assets_helper_spec.rb +195 -0
- data/test_support/spec/helpers/hydra_djatoka_helper_spec.rb +32 -0
- data/test_support/spec/helpers/hydra_fedora_metadata_helper_spec.rb +215 -0
- data/test_support/spec/helpers/hydra_helper_spec.rb +73 -0
- data/test_support/spec/helpers/hydra_model_methods_spec.rb +95 -0
- data/test_support/spec/helpers/hydra_uploader_helper_spec.rb +18 -0
- data/test_support/spec/helpers/javascript_includes_helper_spec.rb +43 -0
- data/test_support/spec/integration/file_asset_spec.rb +150 -0
- data/test_support/spec/lib/active_fedora_helper_spec.rb +56 -0
- data/test_support/spec/lib/catalog_spec.rb +16 -0
- data/test_support/spec/lib/common_mods_index_methods_spec.rb +28 -0
- data/test_support/spec/models/audio_asset_spec.rb +23 -0
- data/test_support/spec/models/file_asset_spec.rb +42 -0
- data/test_support/spec/models/generic_content_spec.rb +29 -0
- data/test_support/spec/models/generic_image_spec.rb +58 -0
- data/test_support/spec/models/hydra_rights_metadata_spec.rb +162 -0
- data/test_support/spec/models/image_asset_spec.rb +23 -0
- data/test_support/spec/models/mods_asset_spec.rb +29 -0
- data/test_support/spec/models/role_mapper_spec.rb +22 -0
- data/test_support/spec/models/user_spec.rb +52 -0
- data/test_support/spec/models/video_asset_spec.rb +23 -0
- data/test_support/spec/rcov.opts +3 -0
- data/test_support/spec/spec.opts +4 -0
- data/test_support/spec/spec_helper.rb +44 -0
- data/test_support/spec/support/matchers/helper_matcher.rb +14 -0
- data/test_support/spec/support/matchers/solr_matchers.rb +60 -0
- data/test_support/spec/unit/hydra-head-engine_spec.rb +8 -0
- data/test_support/spec/unit/hydra-head_spec.rb +8 -0
- data/test_support/spec/utilities/hydra_testing_server_spec.rb +49 -0
- data/test_support/spec/views/uploader.html.erb_spec.rb +30 -0
- data/vendor/cache/RedCloth-4.2.3.gem +0 -0
- data/vendor/cache/abstract-1.0.0.gem +0 -0
- data/vendor/cache/actionmailer-3.0.9.gem +0 -0
- data/vendor/cache/actionpack-3.0.9.gem +0 -0
- data/vendor/cache/active-fedora-2.3.3.gem +0 -0
- data/vendor/cache/activemodel-3.0.9.gem +0 -0
- data/vendor/cache/activerecord-3.0.9.gem +0 -0
- data/vendor/cache/activeresource-3.0.9.gem +0 -0
- data/vendor/cache/activesupport-3.0.9.gem +0 -0
- data/vendor/cache/arel-2.0.10.gem +0 -0
- data/vendor/cache/blacklight-3.0.0.gem +0 -0
- data/vendor/cache/block_helpers-0.3.3.gem +0 -0
- data/vendor/cache/builder-2.1.2.gem +0 -0
- data/vendor/cache/capybara-1.0.0.gem +0 -0
- data/vendor/cache/childprocess-0.2.0.gem +0 -0
- data/vendor/cache/columnize-0.3.4.gem +0 -0
- data/vendor/cache/crack-0.1.8.gem +0 -0
- data/vendor/cache/cucumber-1.0.2.gem +0 -0
- data/vendor/cache/cucumber-rails-1.0.2.gem +0 -0
- data/vendor/cache/curb-0.7.15.gem +0 -0
- data/vendor/cache/daemons-1.1.4.gem +0 -0
- data/vendor/cache/database_cleaner-0.6.7.gem +0 -0
- data/vendor/cache/diff-lcs-1.1.2.gem +0 -0
- data/vendor/cache/equivalent-xml-0.2.7.gem +0 -0
- data/vendor/cache/erubis-2.6.6.gem +0 -0
- data/vendor/cache/facets-2.8.4.gem +0 -0
- data/vendor/cache/factory_girl-1.3.3.gem +0 -0
- data/vendor/cache/fastercsv-1.5.4.gem +0 -0
- data/vendor/cache/ffi-1.0.9.gem +0 -0
- data/vendor/cache/gherkin-2.4.5.gem +0 -0
- data/vendor/cache/haml-3.1.2.gem +0 -0
- data/vendor/cache/httparty-0.7.8.gem +0 -0
- data/vendor/cache/i18n-0.5.0.gem +0 -0
- data/vendor/cache/jettywrapper-0.0.10.gem +0 -0
- data/vendor/cache/json-1.5.3.gem +0 -0
- data/vendor/cache/json_pure-1.5.3.gem +0 -0
- data/vendor/cache/kaminari-0.12.4.gem +0 -0
- data/vendor/cache/launchy-2.0.3.gem +0 -0
- data/vendor/cache/linecache-0.46.gem +0 -0
- data/vendor/cache/logger-1.2.8.gem +0 -0
- data/vendor/cache/mail-2.2.19.gem +0 -0
- data/vendor/cache/marc-0.4.3.gem +0 -0
- data/vendor/cache/mediashelf-loggable-0.4.2.gem +0 -0
- data/vendor/cache/mime-types-1.16.gem +0 -0
- data/vendor/cache/mocha-0.9.12.gem +0 -0
- data/vendor/cache/multipart-post-1.1.2.gem +0 -0
- data/vendor/cache/nokogiri-1.5.0.gem +0 -0
- data/vendor/cache/om-1.2.5.gem +0 -0
- data/vendor/cache/polyglot-0.3.1.gem +0 -0
- data/vendor/cache/rack-1.2.3.gem +0 -0
- data/vendor/cache/rack-mount-0.6.14.gem +0 -0
- data/vendor/cache/rack-test-0.5.7.gem +0 -0
- data/vendor/cache/rails-3.0.9.gem +0 -0
- data/vendor/cache/railties-3.0.9.gem +0 -0
- data/vendor/cache/rake-0.9.2.gem +0 -0
- data/vendor/cache/rbx-require-relative-0.0.5.gem +0 -0
- data/vendor/cache/rcov-0.9.9.gem +0 -0
- data/vendor/cache/rdoc-3.8.gem +0 -0
- data/vendor/cache/rsolr-1.0.2.gem +0 -0
- data/vendor/cache/rsolr-ext-1.0.3.gem +0 -0
- data/vendor/cache/rspec-2.6.0.gem +0 -0
- data/vendor/cache/rspec-core-2.6.4.gem +0 -0
- data/vendor/cache/rspec-expectations-2.6.0.gem +0 -0
- data/vendor/cache/rspec-mocks-2.6.0.gem +0 -0
- data/vendor/cache/rspec-rails-2.6.1.gem +0 -0
- data/vendor/cache/ruby-debug-0.10.4.gem +0 -0
- data/vendor/cache/ruby-debug-base-0.10.4.gem +0 -0
- data/vendor/cache/rubyzip-0.9.4.gem +0 -0
- data/vendor/cache/sanitize-2.0.3.gem +0 -0
- data/vendor/cache/selenium-webdriver-0.2.2.gem +0 -0
- data/vendor/cache/solr-ruby-0.0.8.gem +0 -0
- data/vendor/cache/solrizer-1.1.0.gem +0 -0
- data/vendor/cache/solrizer-fedora-1.1.0.gem +0 -0
- data/vendor/cache/sqlite3-ruby-1.2.5.gem +0 -0
- data/vendor/cache/stomp-1.1.9.gem +0 -0
- data/vendor/cache/term-ansicolor-1.0.5.gem +0 -0
- data/vendor/cache/thor-0.14.6.gem +0 -0
- data/vendor/cache/treetop-1.4.9.gem +0 -0
- data/vendor/cache/trollop-1.16.2.gem +0 -0
- data/vendor/cache/tzinfo-0.3.29.gem +0 -0
- data/vendor/cache/unicode-0.4.0.gem +0 -0
- data/vendor/cache/will_paginate-2.3.15.gem +0 -0
- data/vendor/cache/xml-simple-1.1.0.gem +0 -0
- data/vendor/cache/xpath-0.1.4.gem +0 -0
- data/vendor/cache/yard-0.7.2.gem +0 -0
- metadata +1110 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
require "mediashelf/active_fedora_helper"
|
2
|
+
# Hydra-repository Contoller is a controller layer mixin. It is in the controller scope: request params, session etc.
|
3
|
+
#
|
4
|
+
# NOTE: Be careful when creating variables here as they may be overriding something that already exists.
|
5
|
+
# The ActionController docs: http://api.rubyonrails.org/classes/ActionController/Base.html
|
6
|
+
#
|
7
|
+
# Override these methods in your own controller for customizations:
|
8
|
+
#
|
9
|
+
# class HomeController < ActionController::Base
|
10
|
+
#
|
11
|
+
# include Stanford::SolrHelper
|
12
|
+
#
|
13
|
+
# def solr_search_params
|
14
|
+
# super.merge :per_page=>10
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
module Hydra::RepositoryController
|
20
|
+
|
21
|
+
include MediaShelf::ActiveFedoraHelper
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
def self.included(c)
|
27
|
+
if c.respond_to?(:helper_method)
|
28
|
+
c.helper_method :solr_name
|
29
|
+
c.helper_method :format_pid
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
#
|
35
|
+
# This method converts pid strings into xhtml safe IDs, since xhmlt expects namespaces to be defined.
|
36
|
+
# I.E. hydrus:123 = hydrus_123
|
37
|
+
def format_pid(pid)
|
38
|
+
pid.gsub(":", "_")
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
def solr_name(field_name, field_type = :text)
|
44
|
+
::ActiveFedora::SolrService.solr_name(field_name, field_type)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Uses submitted params Hash to figure out what Model to load
|
48
|
+
# params should contain :content_type and :id
|
49
|
+
def load_document_from_params
|
50
|
+
af_model = retrieve_af_model(params[:content_type])
|
51
|
+
unless af_model
|
52
|
+
af_model = ModsAsset
|
53
|
+
end
|
54
|
+
return af_model.find(params[:id])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns a list of datastreams for download.
|
58
|
+
# Uses user's roles and "mime_type" value in submitted params to decide what to return.
|
59
|
+
# if you pass the optional argument of :canonical=>true, it will return the canonical datastream for this object (a single object not a hash of datastreams)
|
60
|
+
def downloadables(fedora_object=@fedora_object, opts={})
|
61
|
+
if opts[:canonical]
|
62
|
+
mime_type = opts[:mime_type] ? opts[:mime_type] : "application/pdf"
|
63
|
+
result = filter_datastreams_for_mime_type(fedora_object.datastreams, mime_type).sort.first[1]
|
64
|
+
elsif editor?
|
65
|
+
if params["mime_type"] == "all"
|
66
|
+
result = fedora_object.datastreams
|
67
|
+
else
|
68
|
+
result = Hash[]
|
69
|
+
fedora_object.datastreams.each_pair do |dsid,ds|
|
70
|
+
if !ds.new_object?
|
71
|
+
mime_type = ds.attributes["mimeType"] ? ds.attributes["mimeType"] : ""
|
72
|
+
if mime_type.include?("pdf") || ds.label.include?("_TEXT.xml") || ds.label.include?("_METS.xml")
|
73
|
+
result[dsid] = ds
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
else
|
79
|
+
result = Hash[]
|
80
|
+
fedora_object.datastreams.each_pair do |dsid,ds|
|
81
|
+
if ds.attributes["mimeType"].include?("pdf")
|
82
|
+
result[dsid] = ds
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
# puts "downloadables result: #{result}"
|
87
|
+
return result
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def filter_datastreams_for_mime_type(datastreams_hash, mime_type)
|
93
|
+
result = Hash[]
|
94
|
+
datastreams_hash.each_pair do |dsid,ds|
|
95
|
+
ds_mime_type = ds.attributes["mimeType"] ? ds.attributes["mimeType"] : ""
|
96
|
+
if ds_mime_type == mime_type
|
97
|
+
result[dsid] = ds
|
98
|
+
end
|
99
|
+
end
|
100
|
+
return result
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
require "active-fedora"
|
2
|
+
module Hydra
|
3
|
+
class RightsMetadata < ActiveFedora::NokogiriDatastream
|
4
|
+
|
5
|
+
set_terminology do |t|
|
6
|
+
t.root(:path=>"rightsMetadata", :xmlns=>"http://hydra-collab.stanford.edu/schemas/rightsMetadata/v1", :schema=>"http://github.com/projecthydra/schemas/tree/v1/rightsMetadata.xsd")
|
7
|
+
t.copyright {
|
8
|
+
t.machine {
|
9
|
+
t.uvalicense
|
10
|
+
t.cclicense
|
11
|
+
t.license
|
12
|
+
}
|
13
|
+
t.human_readable(:path=>"human")
|
14
|
+
t.license(:proxy=>[:machine, :license ])
|
15
|
+
t.cclicense(:proxy=>[:machine, :cclicense ])
|
16
|
+
}
|
17
|
+
t.access {
|
18
|
+
t.human_readable(:path=>"human")
|
19
|
+
t.machine {
|
20
|
+
t.group
|
21
|
+
t.person
|
22
|
+
}
|
23
|
+
t.person(:proxy=>[:machine, :person])
|
24
|
+
t.group(:proxy=>[:machine, :group])
|
25
|
+
# accessor :access_person, :term=>[:access, :machine, :person]
|
26
|
+
}
|
27
|
+
t.discover_access(:ref=>[:access], :attributes=>{:type=>"discover"})
|
28
|
+
t.read_access(:ref=>[:access], :attributes=>{:type=>"read"})
|
29
|
+
t.edit_access(:ref=>[:access], :attributes=>{:type=>"edit"})
|
30
|
+
# A bug in OM prevnts us from declaring proxy terms at the root of a Terminology
|
31
|
+
# t.access_person(:proxy=>[:access,:machine,:person])
|
32
|
+
# t.access_group(:proxy=>[:access,:machine,:group])
|
33
|
+
|
34
|
+
t.embargo {
|
35
|
+
t.human_readable(:path=>"human")
|
36
|
+
t.machine{
|
37
|
+
t.date(:type =>"release")
|
38
|
+
}
|
39
|
+
t.embargo_release_date(:proxy => [:machine, :date])
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Generates an empty Mods Article (used when you call ModsArticle.new without passing in existing xml)
|
44
|
+
def self.xml_template
|
45
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
46
|
+
xml.rightsMetadata(:version=>"0.1", "xmlns"=>"http://hydra-collab.stanford.edu/schemas/rightsMetadata/v1") {
|
47
|
+
xml.copyright {
|
48
|
+
xml.human
|
49
|
+
xml.machine {
|
50
|
+
xml.uvalicense "no"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
xml.access(:type=>"discover") {
|
54
|
+
xml.human
|
55
|
+
xml.machine
|
56
|
+
}
|
57
|
+
xml.access(:type=>"read") {
|
58
|
+
xml.human
|
59
|
+
xml.machine
|
60
|
+
}
|
61
|
+
xml.access(:type=>"edit") {
|
62
|
+
xml.human
|
63
|
+
xml.machine
|
64
|
+
}
|
65
|
+
xml.embargo{
|
66
|
+
xml.human
|
67
|
+
xml.machine
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
return builder.doc
|
72
|
+
end
|
73
|
+
|
74
|
+
# Returns the permissions for the selected person/group
|
75
|
+
# If new_access_level is provided, updates the selected person/group access_level to the one specified
|
76
|
+
# A new_access_level of "none" will remove all access_levels for the selected person/group
|
77
|
+
# @param [Hash] selector hash in format {type => identifier}
|
78
|
+
# @param new_access_level (default nil)
|
79
|
+
# @return Hash in format {type => access_level}.
|
80
|
+
#
|
81
|
+
# ie.
|
82
|
+
# permissions({:person=>"person123"})
|
83
|
+
# => {"person123"=>"edit"}
|
84
|
+
# permissions({:person=>"person123"}, "read")
|
85
|
+
# => {"person123"=>"read"}
|
86
|
+
# permissions({:person=>"person123"})
|
87
|
+
# => {"person123"=>"read"}
|
88
|
+
def permissions(selector, new_access_level=nil)
|
89
|
+
|
90
|
+
type = selector.keys.first.to_sym
|
91
|
+
actor = selector.values.first
|
92
|
+
if new_access_level.nil?
|
93
|
+
xpath = self.class.terminology.xpath_for(:access, type, actor)
|
94
|
+
nodeset = self.find_by_terms(xpath)
|
95
|
+
if nodeset.empty?
|
96
|
+
return "none"
|
97
|
+
else
|
98
|
+
return nodeset.first.ancestors("access").first.attributes["type"].text
|
99
|
+
end
|
100
|
+
else
|
101
|
+
remove_all_permissions(selector)
|
102
|
+
unless new_access_level == "none"
|
103
|
+
access_type_symbol = "#{new_access_level}_access".to_sym
|
104
|
+
result = self.update_values([access_type_symbol, type] => {"-1"=>actor})
|
105
|
+
end
|
106
|
+
self.dirty = true
|
107
|
+
return new_access_level
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
# Reports on which groups have which permissions
|
113
|
+
# @return Hash in format {group_name => group_permissions, group_name => group_permissions}
|
114
|
+
def groups
|
115
|
+
return quick_search_by_type(:group)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Reports on which groups have which permissions
|
119
|
+
# @return Hash in format {person_name => person_permissions, person_name => person_permissions}
|
120
|
+
def individuals
|
121
|
+
return quick_search_by_type(:person)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Updates permissions for all of the persons and groups in a hash
|
125
|
+
# @param ex. {"group"=>{"group1"=>"discover","group2"=>"edit"}, "person"=>{"person1"=>"read","person2"=>"discover"}}
|
126
|
+
# Currently restricts actor type to group or person. Any others will be ignored
|
127
|
+
def update_permissions(params)
|
128
|
+
params.fetch("group", {}).each_pair {|group_id, access_level| self.permissions({"group"=>group_id}, access_level)}
|
129
|
+
params.fetch("person", {}).each_pair {|group_id, access_level| self.permissions({"person"=>group_id}, access_level)}
|
130
|
+
end
|
131
|
+
|
132
|
+
# @param [Symbol] symbol (either :group or :person)
|
133
|
+
# @return
|
134
|
+
# This method limits the response to known access levels. Probably runs a bit faster than .permissions().
|
135
|
+
def quick_search_by_type(type)
|
136
|
+
result = {}
|
137
|
+
[{:discover_access=>"discover"},{:read_access=>"read"},{:edit_access=>"edit"}].each do |access_levels_hash|
|
138
|
+
access_level = access_levels_hash.keys.first
|
139
|
+
access_level_name = access_levels_hash.values.first
|
140
|
+
self.find_by_terms(*[access_level, type]).each do |entry|
|
141
|
+
result[entry.text] = access_level_name
|
142
|
+
end
|
143
|
+
end
|
144
|
+
return result
|
145
|
+
end
|
146
|
+
|
147
|
+
attr_reader :embargo_release_date
|
148
|
+
def embargo_release_date=(release_date)
|
149
|
+
release_date = release_date.to_s if release_date.is_a? Date
|
150
|
+
begin
|
151
|
+
Date.parse(release_date)
|
152
|
+
rescue
|
153
|
+
return "INVALID DATE"
|
154
|
+
end
|
155
|
+
self.update_values({[:embargo,:machine,:date]=>release_date})
|
156
|
+
end
|
157
|
+
def embargo_release_date(opts={})
|
158
|
+
embargo_release_date = self.find_by_terms(*[:embargo,:machine,:date]).first ? self.find_by_terms(*[:embargo,:machine,:date]).first.text : nil
|
159
|
+
if opts[:format] && opts[:format] == :solr_date
|
160
|
+
embargo_release_date << "T23:59:59Z"
|
161
|
+
end
|
162
|
+
embargo_release_date
|
163
|
+
end
|
164
|
+
def under_embargo?
|
165
|
+
(embargo_release_date && Date.today < embargo_release_date.to_date) ? true : false
|
166
|
+
end
|
167
|
+
|
168
|
+
def to_solr(solr_doc=Hash.new)
|
169
|
+
super(solr_doc)
|
170
|
+
::Solrizer::Extractor.insert_solr_field_value(solr_doc, "embargo_release_date_dt", embargo_release_date(:format=>:solr_date)) if embargo_release_date
|
171
|
+
solr_doc
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
private
|
179
|
+
# Purge all access given group/person
|
180
|
+
def remove_all_permissions(selector)
|
181
|
+
type = selector.keys.first.to_sym
|
182
|
+
actor = selector.values.first
|
183
|
+
xpath = self.class.terminology.xpath_for(:access, type, actor)
|
184
|
+
nodes_to_purge = self.find_by_terms(xpath)
|
185
|
+
nodes_to_purge.each {|node| node.remove}
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,183 @@
|
|
1
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
2
|
+
# (the "License"); you may not use this file except in compliance with
|
3
|
+
# the License. You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
|
14
|
+
module Hydra
|
15
|
+
# A singleton class for starting/stopping a Jetty server for testing purposes
|
16
|
+
# The behavior of TestSolrServer can be modified prior to start() by changing
|
17
|
+
# port, solr_home, and quiet properties.
|
18
|
+
#
|
19
|
+
# This class is based on Blacklight's TestSolrServer
|
20
|
+
class TestingServer
|
21
|
+
require 'singleton'
|
22
|
+
include Singleton
|
23
|
+
require 'win32/process' if RUBY_PLATFORM =~ /mswin32/
|
24
|
+
attr_accessor :port, :jetty_home, :solr_home, :quiet, :fedora_home, :base_path
|
25
|
+
|
26
|
+
# configure the singleton with some defaults
|
27
|
+
def initialize(params = {})
|
28
|
+
@pid = nil
|
29
|
+
if defined?(Rails.root)
|
30
|
+
@base_path = Rails.root
|
31
|
+
else
|
32
|
+
@base_path = "."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class << self
|
37
|
+
def configure(params = {})
|
38
|
+
hydra_server = self.instance
|
39
|
+
hydra_server.quiet = params[:quiet].nil? ? true : params[:quiet]
|
40
|
+
if defined?(Rails.root)
|
41
|
+
base_path = Rails.root
|
42
|
+
else
|
43
|
+
base_path = "."
|
44
|
+
end
|
45
|
+
hydra_server.jetty_home = params[:jetty_home] || File.expand_path(File.join(base_path, 'jetty'))
|
46
|
+
hydra_server.solr_home = params[:solr_home] || File.join( hydra_server.jetty_home, "solr")
|
47
|
+
hydra_server.fedora_home = params[:fedora_home] || File.join( hydra_server.jetty_home, "fedora","default")
|
48
|
+
hydra_server.port = params[:jetty_port] || 8888
|
49
|
+
return hydra_server
|
50
|
+
end
|
51
|
+
|
52
|
+
def wrap(params = {})
|
53
|
+
error = false
|
54
|
+
hydra_server = self.configure(params)
|
55
|
+
begin
|
56
|
+
puts "starting Hydra jetty server on #{RUBY_PLATFORM}"
|
57
|
+
hydra_server.start
|
58
|
+
sleep params[:startup_wait] || 5
|
59
|
+
yield
|
60
|
+
rescue
|
61
|
+
error = true
|
62
|
+
ensure
|
63
|
+
puts "stopping Hydra jetty server"
|
64
|
+
hydra_server.stop
|
65
|
+
end
|
66
|
+
|
67
|
+
return error
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def jetty_command
|
72
|
+
"java -Djetty.port=#{@port} -Dsolr.solr.home=#{@solr_home} -Dfedora.home=#{@fedora_home} -jar start.jar"
|
73
|
+
end
|
74
|
+
|
75
|
+
def start
|
76
|
+
puts "jetty_home: #{@jetty_home}"
|
77
|
+
puts "solr_home: #{@solr_home}"
|
78
|
+
puts "fedora_home: #{@fedora_home}"
|
79
|
+
puts "jetty_command: #{jetty_command}"
|
80
|
+
if pid
|
81
|
+
begin
|
82
|
+
Process.kill(0,pid)
|
83
|
+
raise("Server is already running with PID #{pid}")
|
84
|
+
rescue Errno::ESRCH
|
85
|
+
STDERR.puts("Removing stale PID file at #{pid_path}")
|
86
|
+
File.delete(pid_path)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
Dir.chdir(@jetty_home) do
|
90
|
+
self.send "#{platform}_process".to_sym
|
91
|
+
end
|
92
|
+
mkpath(pid_dir) unless File.directory?(pid_dir)
|
93
|
+
begin
|
94
|
+
f = File.new(pid_path, "w")
|
95
|
+
rescue Errno::ENOENT, Errno::EACCES
|
96
|
+
f = File.new(File.join(@base_path,'tmp',pid_file),"w")
|
97
|
+
end
|
98
|
+
f.puts "#{@pid}"
|
99
|
+
f.close
|
100
|
+
end
|
101
|
+
|
102
|
+
def stop
|
103
|
+
puts "stopping"
|
104
|
+
if pid
|
105
|
+
begin
|
106
|
+
self.send "#{platform}_stop".to_sym
|
107
|
+
rescue Errno::ESRCH
|
108
|
+
STDERR.puts("Removing stale PID file at #{pid_path}")
|
109
|
+
end
|
110
|
+
FileUtils.rm(pid_path)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def win_process
|
115
|
+
@pid = Process.create(
|
116
|
+
:app_name => jetty_command,
|
117
|
+
:creation_flags => Process::DETACHED_PROCESS,
|
118
|
+
:process_inherit => false,
|
119
|
+
:thread_inherit => true,
|
120
|
+
:cwd => "#{@jetty_home}"
|
121
|
+
).process_id
|
122
|
+
end
|
123
|
+
|
124
|
+
def platform
|
125
|
+
case RUBY_PLATFORM
|
126
|
+
when /mswin32/
|
127
|
+
return 'win'
|
128
|
+
else
|
129
|
+
return 'nix'
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def nix_process
|
134
|
+
@pid = fork do
|
135
|
+
STDERR.close if @quiet
|
136
|
+
exec jetty_command
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# stop a running solr server
|
141
|
+
def win_stop
|
142
|
+
Process.kill(1, @pid)
|
143
|
+
end
|
144
|
+
|
145
|
+
def nix_stop
|
146
|
+
Process.kill('TERM',pid)
|
147
|
+
end
|
148
|
+
|
149
|
+
def pid_path
|
150
|
+
File.join(pid_dir, pid_file)
|
151
|
+
end
|
152
|
+
|
153
|
+
def pid_file
|
154
|
+
@pid_file || 'hydra-jetty.pid'
|
155
|
+
end
|
156
|
+
|
157
|
+
def pid_dir
|
158
|
+
File.expand_path(@pid_dir || File.join(@base_path,'tmp','pids'))
|
159
|
+
end
|
160
|
+
|
161
|
+
def pid
|
162
|
+
@pid || File.open( pid_path ) { |f| return f.gets.to_i } if File.exist?(pid_path)
|
163
|
+
end
|
164
|
+
|
165
|
+
end # class TestingServer
|
166
|
+
end # module Hydra
|
167
|
+
|
168
|
+
#
|
169
|
+
# puts "hello"
|
170
|
+
# SOLR_PARAMS = {
|
171
|
+
# :quiet => ENV['SOLR_CONSOLE'] ? false : true,
|
172
|
+
# :jetty_home => ENV['SOLR_JETTY_HOME'] || File.expand_path('../../jetty'),
|
173
|
+
# :jetty_port => ENV['SOLR_JETTY_PORT'] || 8888,
|
174
|
+
# :solr_home => ENV['SOLR_HOME'] || File.expand_path('test')
|
175
|
+
# }
|
176
|
+
#
|
177
|
+
# # wrap functional tests with a test-specific Solr server
|
178
|
+
# got_error = TestSolrServer.wrap(SOLR_PARAMS) do
|
179
|
+
# puts `ps aux | grep start.jar`
|
180
|
+
# end
|
181
|
+
#
|
182
|
+
# raise "test failures" if got_error
|
183
|
+
#
|