curate 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +14 -0
- data/app/controllers/application_controller.rb +69 -0
- data/app/controllers/catalog_controller.rb +336 -0
- data/app/controllers/classify_concerns_controller.rb +29 -0
- data/app/controllers/common_objects_controller.rb +27 -0
- data/app/controllers/curation_concern/base_controller.rb +26 -0
- data/app/controllers/curation_concern/generic_files_controller.rb +82 -0
- data/app/controllers/dashboard_controller.rb +85 -0
- data/app/controllers/downloads_controller.rb +22 -0
- data/app/controllers/errors_controller.rb +19 -0
- data/app/controllers/help_requests_controller.rb +38 -0
- data/app/controllers/terms_of_service_agreements_controller.rb +44 -0
- data/app/controllers/welcome_controller.rb +14 -0
- data/app/helpers/application_helper.rb +89 -0
- data/app/helpers/blacklight_helper.rb +19 -0
- data/app/helpers/common_objects_helper.rb +5 -0
- data/app/inputs/multi_value_input.rb +71 -0
- data/app/models/access_right.rb +53 -0
- data/app/models/classify_concern.rb +30 -0
- data/app/models/contributor_agreement.rb +58 -0
- data/app/models/digital_object_identifier.rb +83 -0
- data/app/models/doi_config.rb +26 -0
- data/app/models/help_request.rb +34 -0
- data/app/models/mint_doi.rb +51 -0
- data/app/models/mint_purl.rb +40 -0
- data/app/models/object_access.rb +17 -0
- data/app/models/purl.rb +18 -0
- data/app/models/purl_config.rb +10 -0
- data/app/models/repo_object.rb +24 -0
- data/app/models/solr_document.rb +35 -0
- data/app/repository_datastreams/file_content_datastream.rb +36 -0
- data/app/repository_models/curation_concern/embargoable.rb +43 -0
- data/app/repository_models/curation_concern/with_access_right.rb +31 -0
- data/app/repository_models/generic_file.rb +36 -0
- data/app/services/anti_virus_scanner.rb +28 -0
- data/app/services/curation_concern.rb +22 -0
- data/app/services/curation_concern/base_actor.rb +48 -0
- data/app/services/curation_concern/generic_file_actor.rb +38 -0
- data/app/validators/future_date_validator.rb +19 -0
- data/app/views/_footer.html.erb +19 -0
- data/app/views/_ga.html.erb +6 -0
- data/app/views/_logo.html.erb +34 -0
- data/app/views/_masthead.html.erb +34 -0
- data/app/views/catalog/_bookmark_control.html.erb +25 -0
- data/app/views/catalog/_bookmark_form.html.erb +8 -0
- data/app/views/catalog/_citation.html.erb +11 -0
- data/app/views/catalog/_constraints.html.erb +6 -0
- data/app/views/catalog/_constraints_element.html.erb +20 -0
- data/app/views/catalog/_delete_partials/_default.html.erb +29 -0
- data/app/views/catalog/_did_you_mean.html.erb +10 -0
- data/app/views/catalog/_document.html.erb +19 -0
- data/app/views/catalog/_document_list.html.erb +2 -0
- data/app/views/catalog/_edit_partials/_default.html.erb +58 -0
- data/app/views/catalog/_edit_partials/_default_details.html.erb +13 -0
- data/app/views/catalog/_email_form.html.erb +11 -0
- data/app/views/catalog/_facet_layout.html.erb +12 -0
- data/app/views/catalog/_facet_limit.html.erb +19 -0
- data/app/views/catalog/_facet_selected.html.erb +12 -0
- data/app/views/catalog/_facets.html.erb +5 -0
- data/app/views/catalog/_folder_control.html.erb +12 -0
- data/app/views/catalog/_home.html.erb +2 -0
- data/app/views/catalog/_home_text.html.erb +10 -0
- data/app/views/catalog/_index_default.html.erb +11 -0
- data/app/views/catalog/_index_partials/_default_group.html.erb +37 -0
- data/app/views/catalog/_marc_view.html.erb +33 -0
- data/app/views/catalog/_opensearch_response_metadata.html.erb +2 -0
- data/app/views/catalog/_previous_next_doc.html.erb +6 -0
- data/app/views/catalog/_refworks_form.html.erb +7 -0
- data/app/views/catalog/_results_pagination.html.erb +6 -0
- data/app/views/catalog/_search_form.html.erb +20 -0
- data/app/views/catalog/_show_default.html.erb +9 -0
- data/app/views/catalog/_show_partials/_default.html.erb +22 -0
- data/app/views/catalog/_show_partials/_default_details.html.erb +15 -0
- data/app/views/catalog/_show_partials/_facets.html.erb +52 -0
- data/app/views/catalog/_show_sidebar.html.erb +1 -0
- data/app/views/catalog/_show_tools.html.erb +46 -0
- data/app/views/catalog/_sms_form.html.erb +21 -0
- data/app/views/catalog/_sort_and_per_page.html.erb +38 -0
- data/app/views/catalog/_uva_tabs.html.erb +10 -0
- data/app/views/catalog/about.html.erb +0 -0
- data/app/views/catalog/citation.html.erb +1 -0
- data/app/views/catalog/email.erb +1 -0
- data/app/views/catalog/endnote.endnote.erb +1 -0
- data/app/views/catalog/index.atom.builder +109 -0
- data/app/views/catalog/index.html.erb +55 -0
- data/app/views/catalog/index.rss.builder +19 -0
- data/app/views/catalog/librarian_view.html.erb +3 -0
- data/app/views/catalog/opensearch.json.erb +0 -0
- data/app/views/catalog/opensearch.xml.builder +10 -0
- data/app/views/catalog/send_email_record.erb +0 -0
- data/app/views/catalog/show.endnote.erb +1 -0
- data/app/views/catalog/show.html.erb +40 -0
- data/app/views/catalog/show.refworks.erb +1 -0
- data/app/views/catalog/sms.erb +1 -0
- data/app/views/classify_concerns/new.html.erb +24 -0
- data/app/views/common_objects/_generic_file.html.erb +0 -0
- data/app/views/common_objects/_senior_thesis.html.erb +2 -0
- data/app/views/common_objects/show.html.erb +11 -0
- data/app/views/common_objects/show_stub_information.html.erb +13 -0
- data/app/views/curation_concern/_content_license.html.erb +16 -0
- data/app/views/curation_concern/_contributor_agreement.html.erb +27 -0
- data/app/views/curation_concern/_doi.html.erb +43 -0
- data/app/views/curation_concern/_media_display.html.erb +1 -0
- data/app/views/curation_concern/_permission.html.erb +39 -0
- data/app/views/curation_concern/_related_files.html.erb +46 -0
- data/app/views/curation_concern/generic_files/_attributes.html.erb +63 -0
- data/app/views/curation_concern/generic_files/_form.html.erb +57 -0
- data/app/views/curation_concern/generic_files/edit.html.erb +5 -0
- data/app/views/curation_concern/generic_files/new.html.erb +5 -0
- data/app/views/curation_concern/generic_files/show.html.erb +12 -0
- data/app/views/curation_concern/senior_theses/_attributes.html.erb +13 -0
- data/app/views/curation_concern/senior_theses/_form.html.erb +88 -0
- data/app/views/curation_concern/senior_theses/edit.html.erb +15 -0
- data/app/views/curation_concern/senior_theses/new.html.erb +14 -0
- data/app/views/curation_concern/senior_theses/show.html.erb +18 -0
- data/app/views/dashboard/_constraints.html.erb +22 -0
- data/app/views/dashboard/_did_you_mean.html.erb +26 -0
- data/app/views/dashboard/_document_list.html.erb +20 -0
- data/app/views/dashboard/_facet_layout.html.erb +27 -0
- data/app/views/dashboard/_facet_limit.html.erb +35 -0
- data/app/views/dashboard/_facet_pagination.html.erb +25 -0
- data/app/views/dashboard/_facet_selected.html.erb +28 -0
- data/app/views/dashboard/_facets.html.erb +22 -0
- data/app/views/dashboard/_index_partials/_default_group.html.erb +37 -0
- data/app/views/dashboard/_index_partials/_list_files.html.erb +66 -0
- data/app/views/dashboard/_index_partials/_thumbnail_display.html.erb +0 -0
- data/app/views/dashboard/_results_pagination.html.erb +22 -0
- data/app/views/dashboard/_search_form.html.erb +36 -0
- data/app/views/dashboard/_show_partials/_default.html.erb +38 -0
- data/app/views/dashboard/_show_partials/_default_details.html.erb +31 -0
- data/app/views/dashboard/_show_partials/_facets.html.erb +103 -0
- data/app/views/dashboard/_sort_and_per_page.html.erb +18 -0
- data/app/views/dashboard/facet.html.erb +38 -0
- data/app/views/dashboard/get_related_file.html.erb +4 -0
- data/app/views/dashboard/index.html.erb +60 -0
- data/app/views/errors/401.html.erb +5 -0
- data/app/views/errors/404.html.erb +16 -0
- data/app/views/errors/500.html.erb +10 -0
- data/app/views/help_requests/new.html.erb +60 -0
- data/app/views/layouts/application.html.erb +14 -0
- data/app/views/layouts/boilerplate.html.erb +28 -0
- data/app/views/layouts/common_objects.html.erb +45 -0
- data/app/views/layouts/curate_nd.html.erb +55 -0
- data/app/views/layouts/curate_nd/1_column.html.erb +22 -0
- data/app/views/layouts/curate_nd/2_column.html.erb +26 -0
- data/app/views/layouts/curate_nd/catalog.html.erb +22 -0
- data/app/views/layouts/curate_nd/dashboard.html.erb +22 -0
- data/app/views/layouts/hydra-head.html.erb +95 -0
- data/app/views/shared/_action_bar.html.erb +30 -0
- data/app/views/shared/_flash_message.html.erb +9 -0
- data/app/views/shared/_site_search.html.erb +18 -0
- data/app/views/terms_of_service_agreements/new.html.erb +136 -0
- data/app/views/welcome/index.html.erb +21 -0
- data/app/workers/characterize_job.rb +4 -0
- data/app/workers/doi_worker.rb +16 -0
- data/config/routes.rb +35 -0
- data/lib/curate.rb +6 -0
- data/lib/curate/engine.rb +46 -0
- data/lib/curate/version.rb +1 -1
- data/spec/abilities/generic_file_abilities_spec.rb +55 -0
- data/spec/controllers/application_controller_spec.rb +38 -0
- data/spec/controllers/classify_concerns_controller_spec.rb +36 -0
- data/spec/controllers/common_objects_controller_spec.rb +112 -0
- data/spec/controllers/curation_concern/base_controller_spec.rb +14 -0
- data/spec/controllers/curation_concern/generic_files_controller_spec.rb +156 -0
- data/spec/controllers/dashboard_controller_spec.rb +85 -0
- data/spec/controllers/downloads_controller_spec.rb +42 -0
- data/spec/controllers/help_requests_controller_spec.rb +42 -0
- data/spec/controllers/terms_of_service_agreements_controller_spec.rb +30 -0
- data/spec/controllers/welcome_controller_spec.rb +10 -0
- data/spec/dummy/app/models/solr_document.rb +4 -0
- data/spec/dummy/app/models/user.rb +13 -0
- data/spec/dummy/config/application.rb +8 -1
- data/spec/dummy/config/database.yml +21 -22
- data/spec/dummy/config/doi.yml +11 -0
- data/spec/dummy/config/fedora.yml +20 -0
- data/spec/dummy/config/initializers/devise.rb +232 -0
- data/spec/dummy/config/initializers/hydra_config.rb +41 -0
- data/spec/dummy/config/initializers/mailboxer.rb +17 -0
- data/spec/dummy/config/initializers/redis_config.rb +45 -0
- data/spec/dummy/config/initializers/sufia.rb +66 -0
- data/spec/dummy/config/purl.yml +15 -0
- data/spec/dummy/config/redis.yml +6 -0
- data/spec/dummy/config/role_map_ci.yml +15 -0
- data/spec/dummy/config/role_map_cucumber.yml +10 -0
- data/spec/dummy/config/role_map_development.yml +12 -0
- data/spec/dummy/config/role_map_pre_production.yml +2 -0
- data/spec/dummy/config/role_map_production.yml +2 -0
- data/spec/dummy/config/role_map_test.yml +15 -0
- data/spec/dummy/config/routes.rb +4 -55
- data/spec/dummy/config/solr.yml +17 -0
- data/spec/dummy/db/migrate/20130130142162_create_purl.rb +55 -0
- data/spec/dummy/db/migrate/20130312135359_create_help_requests.rb +22 -0
- data/spec/dummy/db/migrate/20130408165008_create_users.rb +11 -0
- data/spec/dummy/db/migrate/20130408165009_acts_as_follower_migration.rb +31 -0
- data/spec/dummy/db/migrate/20130408165010_add_social_to_users.rb +27 -0
- data/spec/dummy/db/migrate/20130408165011_create_single_use_links.rb +12 -0
- data/spec/dummy/db/migrate/20130408165012_add_ldap_attrs_to_user.rb +41 -0
- data/spec/dummy/db/migrate/20130408165013_add_avatars_to_users.rb +23 -0
- data/spec/dummy/db/migrate/20130408165014_create_checksum_audit_logs.rb +34 -0
- data/spec/dummy/db/migrate/20130408165015_create_version_committers.rb +29 -0
- data/spec/dummy/db/migrate/20130408165016_add_groups_to_users.rb +25 -0
- data/spec/dummy/db/migrate/20130408165017_create_local_authorities.rb +64 -0
- data/spec/dummy/db/migrate/20130408165018_create_trophies.rb +10 -0
- data/spec/dummy/db/migrate/20130408165022_create_mailboxer.mailboxer_engine.rb +62 -0
- data/spec/dummy/db/migrate/20130408165023_add_notified_object.mailboxer_engine.rb +18 -0
- data/spec/dummy/db/migrate/20130408165024_add_notification_code.mailboxer_engine.rb +14 -0
- data/spec/dummy/db/migrate/20130408165025_add_attachments.mailboxer_engine.rb +10 -0
- data/spec/dummy/db/migrate/20130408165026_rename_receipts_read.mailboxer_engine.rb +10 -0
- data/spec/dummy/db/schema.rb +197 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/fedora_conf/conf/development/fedora.fcfg +953 -0
- data/spec/dummy/fedora_conf/conf/test/fedora.fcfg +953 -0
- data/spec/dummy/log/development.log +1791 -0
- data/spec/dummy/log/test.log +176333 -0
- data/spec/dummy/solr_conf/conf/schema.xml +692 -0
- data/spec/dummy/solr_conf/conf/solrconfig.xml +299 -0
- data/spec/dummy/solr_conf/solr.xml +35 -0
- data/spec/factories/create_curation_concern.rb +11 -0
- data/spec/factories/create_generic_file.rb +36 -0
- data/spec/factories/help_requests.rb +10 -0
- data/spec/factories/mock_curation_concerns.rb +4 -0
- data/spec/factories/users.rb +8 -0
- data/spec/helpers/application_helper_spec.rb +139 -0
- data/spec/helpers/common_objects_helper_spec.rb +9 -0
- data/spec/models/access_right_spec.rb +47 -0
- data/spec/models/classify_concern_spec.rb +30 -0
- data/spec/models/contributor_agreement_spec.rb +45 -0
- data/spec/models/digital_object_identifier_spec.rb +50 -0
- data/spec/models/help_request_spec.rb +5 -0
- data/spec/models/mint_doi_spec.rb +79 -0
- data/spec/models/mint_purl_spec.rb +38 -0
- data/spec/models/object_access_spec.rb +24 -0
- data/spec/models/purl_spec.rb +22 -0
- data/spec/models/repo_object_spec.rb +39 -0
- data/spec/repository_models/curation_concern/embargoable_spec.rb +69 -0
- data/spec/repository_models/generic_file_spec.rb +38 -0
- data/spec/services/anti_virus_scanner_spec.rb +26 -0
- data/spec/services/curation_concern/base_actor_spec.rb +28 -0
- data/spec/services/curation_concern/generic_file_actor_spec.rb +75 -0
- data/spec/services/curation_concern_spec.rb +34 -0
- data/spec/spec_helper.rb +54 -1
- data/spec/support/environment_override.rb +17 -0
- data/spec/support/matchers/raise_rescue_response_type_matcher.rb +42 -0
- data/spec/support/mock_curation_concern.rb +61 -0
- data/spec/support/shared/shared_examples_is_embargoable.rb +9 -0
- data/spec/support/shared/shared_examples_with_access_rights.rb +33 -0
- data/spec/workers/characterize_job_spec.rb +26 -0
- metadata +686 -10
- data/MIT-LICENSE +0 -20
@@ -0,0 +1,17 @@
|
|
1
|
+
class ObjectAccess < ActiveRecord::Base
|
2
|
+
self.establish_connection("#{Rails.env}_remote_purl_database".to_sym)
|
3
|
+
self.table_name = "object_access"
|
4
|
+
|
5
|
+
attr_accessible :date_accessed
|
6
|
+
|
7
|
+
def self.create_from_purl(purl)
|
8
|
+
if purl.nil?
|
9
|
+
return
|
10
|
+
end
|
11
|
+
create do |object_access|
|
12
|
+
object_access.date_accessed= purl.date_created
|
13
|
+
object_access.repo_object_id= purl.repo_object_id
|
14
|
+
object_access.purl_id= purl.purl_id
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/app/models/purl.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class Purl < ActiveRecord::Base
|
2
|
+
self.establish_connection("#{Rails.env}_remote_purl_database".to_sym)
|
3
|
+
self.table_name = "purl"
|
4
|
+
|
5
|
+
attr_accessible :date_created
|
6
|
+
|
7
|
+
def self.create_from_repo_object(repo_object)
|
8
|
+
if repo_object.nil?
|
9
|
+
return
|
10
|
+
end
|
11
|
+
create do |purl|
|
12
|
+
purl.repo_object_id= repo_object.repo_object_id
|
13
|
+
purl.access_count= 0
|
14
|
+
purl.date_created= repo_object.date_added
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'method_decorators/precondition'
|
2
|
+
|
3
|
+
class RepoObject < ActiveRecord::Base
|
4
|
+
extend MethodDecorators
|
5
|
+
self.establish_connection("#{Rails.env}_remote_purl_database".to_sym)
|
6
|
+
self.table_name = "repo_object"
|
7
|
+
# this is the id for the record, NOT for the repository object (which is :pid)
|
8
|
+
attr_accessible :add_source_ip
|
9
|
+
alias_attribute :pid, :filename
|
10
|
+
|
11
|
+
class << self
|
12
|
+
+MethodDecorators::Precondition.new {|fedora_object| fedora_object.present? }
|
13
|
+
def create_from_fedora_object(fedora_object)
|
14
|
+
create do |repo_object|
|
15
|
+
repo_object.url = File.join(Rails.configuration.application_url, "show", fedora_object.to_param)
|
16
|
+
repo_object.pid = fedora_object.to_param
|
17
|
+
repo_object.date_added= fedora_object.create_date
|
18
|
+
repo_object.date_modified= fedora_object.modified_date
|
19
|
+
repo_object.information= "CurateND - #{fedora_object.to_param}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
class SolrDocument
|
3
|
+
# Adds Sufia behaviors to the SolrDocument.
|
4
|
+
include Sufia::SolrDocumentBehavior
|
5
|
+
|
6
|
+
include Blacklight::Solr::Document
|
7
|
+
|
8
|
+
# self.unique_key = 'id'
|
9
|
+
|
10
|
+
# The following shows how to setup this blacklight document to display marc documents
|
11
|
+
extension_parameters[:marc_source_field] = :marc_display
|
12
|
+
extension_parameters[:marc_format_type] = :marcxml
|
13
|
+
use_extension( Blacklight::Solr::Document::Marc) do |document|
|
14
|
+
document.key?( :marc_display )
|
15
|
+
end
|
16
|
+
|
17
|
+
# Email uses the semantic field mappings below to generate the body of an email.
|
18
|
+
SolrDocument.use_extension( Blacklight::Solr::Document::Email )
|
19
|
+
|
20
|
+
# SMS uses the semantic field mappings below to generate the body of an SMS email.
|
21
|
+
SolrDocument.use_extension( Blacklight::Solr::Document::Sms )
|
22
|
+
|
23
|
+
# DublinCore uses the semantic field mappings below to assemble an OAI-compliant Dublin Core document
|
24
|
+
# Semantic mappings of solr stored fields. Fields may be multi or
|
25
|
+
# single valued. See Blacklight::Solr::Document::ExtendableClassMethods#field_semantics
|
26
|
+
# and Blacklight::Solr::Document#to_semantic_values
|
27
|
+
# Recommendation: Use field names from Dublin Core
|
28
|
+
use_extension( Blacklight::Solr::Document::DublinCore)
|
29
|
+
field_semantics.merge!(
|
30
|
+
:title => "title_display",
|
31
|
+
:author => "author_display",
|
32
|
+
:language => "language_facet",
|
33
|
+
:format => "format"
|
34
|
+
)
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require Sufia::Engine.root.join('app/models/datastreams/file_content_datastream')
|
2
|
+
# I really don't want to touch much of Sufia's underworkings. In doing this
|
3
|
+
# I'm able to mimic the #super behavior.
|
4
|
+
#
|
5
|
+
# More on this method at:
|
6
|
+
# http://blog.jayfields.com/2006/12/ruby-alias-method-alternative.html
|
7
|
+
class FileContentDatastream
|
8
|
+
|
9
|
+
# Yes, I could be using super, however that assumes a working knowledge
|
10
|
+
# of how the FileContentDatastream is actually crafted (namely via
|
11
|
+
# ActiveSupport::Concern)
|
12
|
+
sufia_run_fits = self.instance_method(:run_fits!)
|
13
|
+
|
14
|
+
# This is where I chose to insert the anti-virus. My reason being that the
|
15
|
+
# caller of this method is getting the Fedora datastream and writing it to
|
16
|
+
# a temp file for characterization; So to ease the load, I'm piggy backing
|
17
|
+
# on that behavior and first running an Anti-Virus scanner
|
18
|
+
def run_fits!(file_path)
|
19
|
+
anti_virus_scanner.call(file_path)
|
20
|
+
characterization_runner.call(file_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
def anti_virus_scanner
|
25
|
+
AntiVirusScanner.new(self)
|
26
|
+
end
|
27
|
+
|
28
|
+
define_method :characterization_runner do
|
29
|
+
if Rails.configuration.respond_to?(:default_characterization_runner)
|
30
|
+
Rails.configuration.default_characterization_runner
|
31
|
+
else
|
32
|
+
sufia_run_fits.bind(self)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path('../../../validators/future_date_validator', __FILE__)
|
2
|
+
module CurationConcern
|
3
|
+
module Embargoable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
validates :embargo_release_date, future_date: true
|
8
|
+
before_save :write_embargo_release_date, prepend: true
|
9
|
+
end
|
10
|
+
|
11
|
+
def write_embargo_release_date
|
12
|
+
if defined?(@embargo_release_date)
|
13
|
+
embargoable_persistence_container.embargo_release_date = embargo_release_date
|
14
|
+
end
|
15
|
+
true
|
16
|
+
end
|
17
|
+
protected :write_embargo_release_date
|
18
|
+
|
19
|
+
def embargo_release_date=(value)
|
20
|
+
@embargo_release_date = begin
|
21
|
+
value.to_date
|
22
|
+
rescue NoMethodError
|
23
|
+
value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def embargo_release_date
|
28
|
+
@embargo_release_date || embargoable_persistence_container.embargo_release_date
|
29
|
+
end
|
30
|
+
|
31
|
+
if ! included_modules.include?('Morphine')
|
32
|
+
require 'morphine'
|
33
|
+
include Morphine
|
34
|
+
end
|
35
|
+
register :embargoable_persistence_container do
|
36
|
+
if ! self.class.included_modules.include?('Sufia::GenericFile::Permissions')
|
37
|
+
self.class.send(:include, Sufia::GenericFile::Permissions)
|
38
|
+
end
|
39
|
+
self.datastreams["rightsMetadata"]
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module CurationConcern
|
2
|
+
module WithAccessRight
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attr_accessor :visibility
|
7
|
+
end
|
8
|
+
|
9
|
+
def under_embargo?
|
10
|
+
@under_embargo ||= rightsMetadata.under_embargo?
|
11
|
+
end
|
12
|
+
|
13
|
+
def open_access?
|
14
|
+
access_rights.open_access?
|
15
|
+
end
|
16
|
+
|
17
|
+
def authenticated_only_access?
|
18
|
+
access_rights.authenticated_only?
|
19
|
+
end
|
20
|
+
|
21
|
+
def private_access?
|
22
|
+
access_rights.private?
|
23
|
+
end
|
24
|
+
|
25
|
+
def access_rights
|
26
|
+
@access_rights ||= AccessRight.new(self)
|
27
|
+
end
|
28
|
+
protected :access_rights
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require Sufia::Engine.root.join('app/models/generic_file')
|
2
|
+
require File.expand_path("../curation_concern/with_access_right", __FILE__)
|
3
|
+
require File.expand_path("../curation_concern/embargoable", __FILE__)
|
4
|
+
require File.expand_path("../../repository_datastreams/file_content_datastream", __FILE__)
|
5
|
+
|
6
|
+
class GenericFile
|
7
|
+
include CurationConcern::WithAccessRight
|
8
|
+
include CurationConcern::Embargoable
|
9
|
+
|
10
|
+
belongs_to :batch, property: :is_part_of, class_name: 'ActiveFedora::Base'
|
11
|
+
|
12
|
+
validates :batch, presence: true
|
13
|
+
validates :file, presence: true, on: :create
|
14
|
+
|
15
|
+
attr_accessor :file, :version
|
16
|
+
|
17
|
+
def filename
|
18
|
+
content.label
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
title || label || "No Title"
|
23
|
+
end
|
24
|
+
|
25
|
+
def versions
|
26
|
+
content.versions
|
27
|
+
end
|
28
|
+
|
29
|
+
def current_version_id
|
30
|
+
content.latest_version.versionID
|
31
|
+
end
|
32
|
+
|
33
|
+
def human_readable_type
|
34
|
+
self.class.to_s.demodulize.titleize
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# This is a simple wrapper for an underlying scanner; Without it, we'll
|
2
|
+
# always going to be running actual anti-virus
|
3
|
+
class AntiVirusScanner
|
4
|
+
NO_VIRUS_FOUND_RETURN_VALUE = 0 unless defined?(NO_VIRUS_FOUND_RETURN_VALUE)
|
5
|
+
|
6
|
+
class VirusDetected < RuntimeError
|
7
|
+
def initialize(pid, file_path)
|
8
|
+
super("A virus was found for PID=#{pid.inspect} (#{file_path.inspect})")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
attr_reader :object
|
12
|
+
def initialize(object_with_pid)
|
13
|
+
@object = object_with_pid
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(file_path)
|
17
|
+
if scanner_instance.call(file_path) == NO_VIRUS_FOUND_RETURN_VALUE
|
18
|
+
return true
|
19
|
+
else
|
20
|
+
raise VirusDetected.new(object.pid, file_path)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
include Morphine
|
25
|
+
register :scanner_instance do
|
26
|
+
Rails.configuration.default_antivirus_instance
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module CurationConcern
|
2
|
+
module_function
|
3
|
+
def mint_a_pid
|
4
|
+
Sufia::Noid.namespaceize(Sufia::Noid.noidify(Sufia::IdService.mint))
|
5
|
+
end
|
6
|
+
|
7
|
+
def actor(curation_concern, *args)
|
8
|
+
actor_identifier = curation_concern.class.to_s
|
9
|
+
klass = const_get("#{actor_identifier}Actor")
|
10
|
+
klass.new(curation_concern, *args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def attach_file(generic_file, user, file_to_attach)
|
14
|
+
Sufia::GenericFile::Actions.create_content(
|
15
|
+
generic_file,
|
16
|
+
file_to_attach,
|
17
|
+
file_to_attach.original_filename,
|
18
|
+
'content',
|
19
|
+
user
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module CurationConcern
|
2
|
+
# The CurationConcern base actor should respond to three primary actions:
|
3
|
+
# * #create
|
4
|
+
# * #update
|
5
|
+
# * #delete
|
6
|
+
class BaseActor
|
7
|
+
attr_reader :curation_concern, :user, :attributes
|
8
|
+
def initialize(curation_concern, user, input_attributes)
|
9
|
+
@curation_concern = curation_concern
|
10
|
+
@user = user
|
11
|
+
@attributes = input_attributes.dup
|
12
|
+
@visibility = attributes[:visibility]
|
13
|
+
end
|
14
|
+
|
15
|
+
def create!
|
16
|
+
curation_concern.apply_depositor_metadata(user.user_key)
|
17
|
+
curation_concern.creator = user.name
|
18
|
+
curation_concern.date_uploaded = Date.today
|
19
|
+
save
|
20
|
+
end
|
21
|
+
|
22
|
+
def update!
|
23
|
+
save
|
24
|
+
end
|
25
|
+
|
26
|
+
def save
|
27
|
+
curation_concern.attributes = attributes
|
28
|
+
curation_concern.date_modified = Date.today
|
29
|
+
curation_concern.set_visibility(visibility)
|
30
|
+
curation_concern.save!
|
31
|
+
end
|
32
|
+
protected :save
|
33
|
+
|
34
|
+
attr_reader :visibility
|
35
|
+
protected :visibility
|
36
|
+
|
37
|
+
def visibility_may_have_changed?
|
38
|
+
!!@visibility
|
39
|
+
end
|
40
|
+
protected :visibility_may_have_changed?
|
41
|
+
|
42
|
+
def attach_file(generic_file, file_to_attach)
|
43
|
+
ActiveSupport::Deprecation.warn("removing #{self.class}#attach_file, use CurationConcern.attach_file instead")
|
44
|
+
CurationConcern.attach_file(generic_file, user, file_to_attach)
|
45
|
+
end
|
46
|
+
protected :attach_file
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module CurationConcern
|
2
|
+
class GenericFileActor < CurationConcern::BaseActor
|
3
|
+
def create!
|
4
|
+
super
|
5
|
+
update_file
|
6
|
+
end
|
7
|
+
|
8
|
+
def update!
|
9
|
+
super
|
10
|
+
update_file
|
11
|
+
update_version
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
def update_file
|
16
|
+
file = attributes.delete(:file)
|
17
|
+
title = attributes[:title]
|
18
|
+
title ||= file.original_filename if file
|
19
|
+
curation_concern.label = title
|
20
|
+
if file
|
21
|
+
CurationConcern.attach_file(curation_concern, user, file)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def update_version
|
26
|
+
version_to_revert = attributes.delete(:version)
|
27
|
+
return true if version_to_revert.blank?
|
28
|
+
return true if version_to_revert.to_s == curation_concern.current_version_id
|
29
|
+
|
30
|
+
revision = curation_concern.content.get_version(version_to_revert)
|
31
|
+
mime_type = revision.mimeType.empty? ? "application/octet-stream" : revision.mimeType
|
32
|
+
options = { label: revision.label, mimeType: mime_type, dsid: 'content' }
|
33
|
+
curation_concern.add_file_datastream(revision.content, options)
|
34
|
+
curation_concern.record_version_committer(user)
|
35
|
+
curation_concern.save!
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class FutureDateValidator < ActiveModel::EachValidator
|
2
|
+
|
3
|
+
def validate_each(record, attribute, value)
|
4
|
+
if value.present?
|
5
|
+
begin
|
6
|
+
if date = value.to_date
|
7
|
+
if date <= Date.today
|
8
|
+
record.errors[:embargo_release_date] << "Must be a future date"
|
9
|
+
end
|
10
|
+
else
|
11
|
+
record.errors[:embargo_release_date] << "Invalid Date Format"
|
12
|
+
end
|
13
|
+
rescue NoMethodError
|
14
|
+
record.errors[:embargo_release_date] << "Invalid Date Format"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
<footer id="footer" class="container">
|
3
|
+
<div class="row">
|
4
|
+
<div class="span12">
|
5
|
+
<p>
|
6
|
+
CurateND is a service of the <a href="http://www.library.nd.edu">Hesburgh Libraries of Notre Dame</a>.
|
7
|
+
</p>
|
8
|
+
<p>
|
9
|
+
<a href="http://www.nd.edu/copyright/">Copyright</a> © <%= Time.now.year %> <a href="http://www.nd.edu">University of Notre Dame</a>
|
10
|
+
</p>
|
11
|
+
<p>
|
12
|
+
Powered by <a href="https://github.com/curationexperts/sufia">Sufia</a>, a <a href="http://projecthydra.org">Hydra</a> project.
|
13
|
+
</p>
|
14
|
+
<p>
|
15
|
+
Build: <%= Rails.configuration.build_identifier %>
|
16
|
+
</p>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</footer>
|