sufia 4.0.0.rc1 → 4.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +2 -2
- data/Gemfile +9 -17
- data/README.md +18 -9
- data/Rakefile +10 -5
- data/SUFIA_VERSION +1 -1
- data/app/assets/javascripts/jquery.blacklightTagCloud.js +1 -1
- data/app/assets/javascripts/sufia.js +5 -22
- data/app/assets/javascripts/sufia/batch.js +8 -0
- data/app/assets/javascripts/sufia/batch_edit.js +19 -3
- data/app/assets/javascripts/sufia/dashboard_actions.js +23 -10
- data/app/assets/javascripts/sufia/multiForm.js +2 -2
- data/app/assets/javascripts/sufia/permissions.js +10 -9
- data/app/assets/javascripts/sufia/tabs.js +20 -0
- data/app/assets/stylesheets/catalog.css.scss +5 -0
- data/app/assets/stylesheets/collections.css.scss +40 -0
- data/app/assets/stylesheets/file-listing.css.scss +37 -13
- data/app/assets/stylesheets/generic_files.css.erb +5 -0
- data/app/assets/stylesheets/header.css.scss +1 -4
- data/app/assets/stylesheets/settings.css.scss +6 -0
- data/app/assets/stylesheets/styles.css.scss +4 -3
- data/app/assets/stylesheets/sufia-audio-overrides.css +2 -2
- data/app/assets/stylesheets/sufia.css.scss +27 -5
- data/app/assets/stylesheets/tagcloud.css +5 -1
- data/app/controllers/batch_controller.rb +3 -3
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +14 -1
- data/app/controllers/concerns/sufia/catalog.rb +0 -1
- data/app/controllers/concerns/sufia/controller.rb +5 -0
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +2 -9
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +3 -3
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +5 -1
- data/app/controllers/concerns/sufia/homepage_controller.rb +1 -1
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +3 -2
- data/app/helpers/batch_edits_helper.rb +6 -0
- data/app/helpers/generic_file_helper.rb +15 -0
- data/app/helpers/sufia/blacklight_override.rb +19 -3
- data/app/helpers/sufia/dashboard_helper_behavior.rb +25 -3
- data/app/helpers/sufia/records_helper_behavior.rb +13 -5
- data/app/helpers/sufia/sufia_helper_behavior.rb +15 -12
- data/app/models/concerns/sufia/solr_document_behavior.rb +5 -36
- data/app/views/_masthead.html.erb +1 -1
- data/app/views/_user_util_links.html.erb +6 -4
- data/app/views/advanced/_advanced_search_fields.html.erb +4 -4
- data/app/views/advanced/_advanced_search_form.html.erb +14 -17
- data/app/views/advanced/index.html.erb +3 -3
- data/app/views/batch/_metadata.html.erb +22 -24
- data/app/views/batch/_more_metadata.html.erb +1 -1
- data/app/views/batch/edit.html.erb +2 -2
- data/app/views/batch_edits/_check_all.html.erb +7 -9
- data/app/views/batch_edits/_delete_selected.html.erb +1 -0
- data/app/views/batch_edits/edit.html.erb +25 -26
- data/app/views/batch_edits/update_edit.js.erb +1 -1
- data/app/views/catalog/_facet_limit.html.erb +4 -12
- data/app/views/catalog/_search_form.html.erb +8 -13
- data/app/views/collections/_action_menu.html.erb +2 -2
- data/app/views/collections/_collection.html.erb +10 -31
- data/app/views/collections/_document_list.html.erb +1 -1
- data/app/views/collections/_edit_actions.html.erb +2 -2
- data/app/views/collections/_edit_descriptions.html.erb +3 -5
- data/app/views/collections/_form.html.erb +8 -10
- data/app/views/collections/_media_display.html.erb +1 -1
- data/app/views/collections/_show_actions.html.erb +5 -5
- data/app/views/collections/_show_descriptions.html.erb +13 -8
- data/app/views/collections/_show_document_list.html.erb +17 -0
- data/app/views/collections/_show_document_list_menu.html.erb +24 -0
- data/app/views/collections/_show_document_list_row.html.erb +63 -0
- data/app/views/collections/edit.html.erb +2 -2
- data/app/views/collections/show.html.erb +28 -19
- data/app/views/contact_form/new.html.erb +21 -29
- data/app/views/dashboard/_index_partials/_contents.html.erb +14 -0
- data/app/views/dashboard/_index_partials/_heading_actions.html.erb +18 -0
- data/app/views/dashboard/_index_partials/_heading_greetings.html.erb +8 -0
- data/app/views/dashboard/_index_partials/_stats.html.erb +6 -2
- data/app/views/dashboard/index.html.erb +5 -37
- data/app/views/generic_files/_breadcrumbs.html.erb +2 -0
- data/app/views/generic_files/_browse_everything.html.erb +2 -2
- data/app/views/generic_files/_descriptions.html.erb +4 -6
- data/app/views/generic_files/_field_form.html.erb +2 -2
- data/app/views/generic_files/_generic_file.html.erb +8 -29
- data/app/views/generic_files/_groups_description.html.erb +5 -4
- data/app/views/generic_files/_permission.html.erb +2 -2
- data/app/views/generic_files/_permission_form.html.erb +62 -77
- data/app/views/generic_files/_rights_modal.html.erb +0 -2
- data/app/views/generic_files/_share_with.html.erb +14 -0
- data/app/views/generic_files/_show_actions.html.erb +1 -1
- data/app/views/generic_files/_show_collections.html.erb +17 -0
- data/app/views/generic_files/_show_descriptions.html.erb +2 -2
- data/app/views/generic_files/_versioning.html.erb +2 -2
- data/app/views/generic_files/_visibility.html.erb +17 -0
- data/app/views/generic_files/show.html.erb +39 -2
- data/app/views/generic_files/stats.html.erb +1 -1
- data/app/views/generic_files/upload/_form_fields.html.erb +2 -2
- data/app/views/generic_files/upload/_local_file_import_chooser.html.erb +1 -1
- data/app/views/generic_files/upload/_script_templates.html.erb +2 -2
- data/app/views/generic_files/upload/_tos_checkbox.html.erb +3 -3
- data/app/views/homepage/_home_content.html.erb +0 -9
- data/app/views/homepage/_home_header.html.erb +1 -1
- data/app/views/homepage/_recent_document.html.erb +2 -2
- data/app/views/layouts/_head_tag_content.html.erb +7 -1
- data/app/views/layouts/sufia-dashboard.html.erb +4 -2
- data/app/views/layouts/sufia-one-column.html.erb +1 -1
- data/app/views/my/_action_menu.html.erb +1 -1
- data/app/views/my/_collection_action_menu.html.erb +3 -3
- data/app/views/my/_constraints.html.erb +11 -0
- data/app/views/my/_document_list.html.erb +1 -1
- data/app/views/my/_facet_limit.html.erb +4 -12
- data/app/views/my/_facets.html.erb +1 -3
- data/app/views/my/_index_partials/_default_group.html.erb +2 -3
- data/app/views/my/_index_partials/_list_collections.html.erb +17 -11
- data/app/views/my/_index_partials/_list_files.html.erb +20 -24
- data/app/views/my/_search_header.html.erb +5 -0
- data/app/views/my/_sort_and_per_page.html.erb +11 -7
- data/app/views/my/index.html.erb +9 -15
- data/app/views/records/_edit_field.html.erb +14 -10
- data/app/views/records/edit_fields/_default.html.erb +6 -0
- data/app/views/records/edit_fields/_description.html.erb +3 -7
- data/app/views/records/edit_fields/_resource_type.html.erb +4 -6
- data/app/views/records/edit_fields/_rights.html.erb +4 -5
- data/app/views/records/edit_fields/_suffix.html.erb +6 -3
- data/app/views/records/edit_fields/_type.html.erb +7 -12
- data/app/views/{generic_files → records}/show_fields/_based_near.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_contributor.html.erb +2 -2
- data/app/views/records/show_fields/_creator.html.erb +6 -0
- data/app/views/{generic_files → records}/show_fields/_date_created.html.erb +1 -1
- data/app/views/records/show_fields/_default.html.erb +6 -0
- data/app/views/records/show_fields/_description.html.erb +6 -0
- data/app/views/records/show_fields/_identifier.html.erb +4 -0
- data/app/views/{generic_files → records}/show_fields/_language.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_publisher.html.erb +1 -1
- data/app/views/records/show_fields/_related_url.html.erb +6 -0
- data/app/views/{generic_files → records}/show_fields/_resource_type.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_rights.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_subject.html.erb +1 -1
- data/app/views/{generic_files → records}/show_fields/_tag.html.erb +1 -1
- data/app/views/records/show_fields/_title.html.erb +6 -0
- data/app/views/shared/_attributes.html.erb +27 -0
- data/app/views/static/agreement.html.erb +1 -1
- data/app/views/users/_activity_log.html.erb +0 -2
- data/app/views/users/_follower_modal.html.erb +27 -23
- data/app/views/users/_following_modal.html.erb +27 -23
- data/app/views/users/_social_media_info.html.erb +4 -4
- data/app/views/users/_trophy_edit.html.erb +5 -7
- data/app/views/users/_user_info.html.erb +3 -3
- data/app/views/users/_user_util_links_extra.html.erb +4 -0
- data/app/views/users/edit.html.erb +28 -33
- data/app/views/users/index.html.erb +1 -1
- data/app/views/users/show.html.erb +0 -4
- data/config/jetty.yml +1 -1
- data/config/locales/sufia.en.yml +53 -12
- data/lib/generators/sufia/install_generator.rb +89 -0
- data/lib/generators/sufia/templates/catalog_controller.rb +1 -1
- data/lib/generators/sufia/upgrade400_generator.rb +4 -0
- data/lib/sufia.rb +1 -10
- data/lib/sufia/version.rb +1 -1
- data/solr_conf/conf/solrconfig.xml +31 -17
- data/spec/actors/generic_file/actor_spec.rb +17 -0
- data/spec/controllers/batch_controller_spec.rb +2 -2
- data/spec/controllers/batch_edits_controller_spec.rb +24 -19
- data/spec/controllers/catalog_controller_spec.rb +23 -12
- data/spec/controllers/collections_controller_spec.rb +19 -17
- data/spec/controllers/dashboard_controller_spec.rb +5 -19
- data/spec/controllers/generic_files_controller_spec.rb +35 -20
- data/spec/controllers/homepage_controller_spec.rb +25 -2
- data/spec/controllers/users_controller_spec.rb +99 -102
- data/spec/factories/generic_files.rb +2 -2
- data/spec/factories/users.rb +32 -2
- data/spec/features/browse_dashboard_files_spec.rb +14 -2
- data/spec/features/browse_files_spec.rb +5 -1
- data/spec/features/catalog_search_spec.rb +7 -6
- data/spec/features/collection_spec.rb +43 -33
- data/spec/features/display_dashboard_spec.rb +25 -22
- data/spec/features/notifications_spec.rb +9 -4
- data/spec/features/users_spec.rb +34 -25
- data/spec/fixtures/1.5mb-avatar.jpg +0 -0
- data/spec/helpers/batch_edits_helper_spec.rb +38 -0
- data/spec/helpers/dashboard_helper_spec.rb +16 -5
- data/spec/helpers/generic_file_helper_spec.rb +41 -0
- data/spec/helpers/records_helper_spec.rb +12 -0
- data/spec/jobs/active_fedora_pid_based_job_spec.rb +1 -1
- data/spec/jobs/audit_job_spec.rb +2 -3
- data/spec/jobs/batch_update_job_spec.rb +39 -24
- data/spec/jobs/event_jobs_spec.rb +1 -1
- data/spec/lib/sufia/id_service_spec.rb +25 -7
- data/spec/lib/sufia/messages_spec.rb +60 -0
- data/spec/lib/sufia/readable_permissions_spec.rb +56 -0
- data/spec/lib/sufia/writable_permissions_spec.rb +20 -0
- data/spec/models/batch_spec.rb +1 -1
- data/spec/models/collection_spec.rb +24 -2
- data/spec/models/featured_work_spec.rb +2 -2
- data/spec/models/file_content_datastream_spec.rb +5 -5
- data/spec/models/generic_file_spec.rb +149 -133
- data/spec/models/local_authority_spec.rb +1 -1
- data/spec/models/user_spec.rb +33 -6
- data/spec/spec_helper.rb +7 -10
- data/spec/{support → test_app_templates}/lib/generators/test_app_generator.rb +11 -6
- data/spec/views/batch/edit.html.erb_spec.rb +8 -2
- data/spec/views/catalog/index.html.erb_spec.rb +34 -0
- data/spec/views/catalog/{sort_and_per_pange.html.erb_spec.rb → sort_and_per_page.html.erb_spec.rb} +0 -0
- data/spec/views/collections/_form.html.erb_spec.rb +32 -0
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +25 -0
- data/spec/views/dashboard/index_spec.rb +33 -4
- data/spec/views/generic_file/_breadcrumbs.html.erb_spec.rb +32 -0
- data/spec/views/generic_file/show.html.erb_spec.rb +273 -8
- data/spec/views/users/_user_util_links.html.erb_spec.rb +25 -0
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +14 -5
- data/sufia-models/{lib/sufia/models → app}/jobs/active_fedora_pid_based_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/audit_job.rb +4 -10
- data/sufia-models/{lib/sufia/models → app}/jobs/batch_update_job.rb +22 -18
- data/sufia-models/{lib/sufia/models → app}/jobs/characterize_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/create_derivatives_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/import_url_job.rb +0 -0
- data/sufia-models/{lib/sufia/models → app}/jobs/resolrize_job.rb +0 -0
- data/sufia-models/app/models/collection.rb +1 -39
- data/sufia-models/{lib → app/models/concerns}/sufia/ability.rb +0 -0
- data/sufia-models/app/models/concerns/sufia/collection.rb +55 -0
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +5 -11
- data/sufia-models/app/models/concerns/sufia/generic_file/audit.rb +1 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/characterization.rb +4 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +27 -0
- data/sufia-models/app/models/concerns/sufia/generic_file/mime_types.rb +1 -0
- data/sufia-models/app/models/concerns/sufia/generic_file/permissions.rb +2 -49
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/model_methods.rb +0 -0
- data/sufia-models/app/models/concerns/sufia/user.rb +8 -1
- data/sufia-models/app/models/sufia/avatar_uploader.rb +2 -3
- data/sufia-models/app/services/sufia/noid.rb +9 -0
- data/sufia-models/config/locales/sufia.en.yml +1 -0
- data/sufia-models/lib/generators/sufia/models/fulltext_generator.rb +27 -0
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +7 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/analytics.yml +5 -5
- data/sufia-models/lib/generators/sufia/models/templates/config/solrconfig.xml +177 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +3 -1
- data/sufia-models/lib/generators/sufia/models/upgrade400_generator.rb +7 -0
- data/sufia-models/lib/sufia/messages.rb +67 -0
- data/sufia-models/lib/sufia/models.rb +2 -0
- data/sufia-models/lib/sufia/models/active_fedora/redis.rb +0 -6
- data/sufia-models/lib/sufia/models/engine.rb +1 -3
- data/sufia-models/lib/sufia/models/resque.rb +1 -1
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/lib/sufia/permissions.rb +9 -0
- data/sufia-models/lib/sufia/permissions/readable.rb +20 -0
- data/sufia-models/lib/sufia/permissions/writable.rb +56 -0
- data/sufia-models/lib/tasks/sufia-models_tasks.rake +58 -2
- data/sufia-models/sufia-models.gemspec +11 -11
- data/sufia.gemspec +19 -9
- data/tasks/jetty.rake +6 -5
- data/tasks/sufia-dev.rake +4 -77
- metadata +235 -72
- data/app/assets/images/folder.png +0 -0
- data/app/views/collections/show_fields/_creator.html.erb +0 -11
- data/app/views/collections/show_fields/_description.html.erb +0 -8
- data/app/views/collections/show_fields/_title.html.erb +0 -8
- data/app/views/generic_files/edit_fields/_default.html.erb +0 -6
- data/app/views/generic_files/edit_fields/_description.html.erb +0 -5
- data/app/views/generic_files/edit_fields/_resource_type.html.erb +0 -6
- data/app/views/generic_files/edit_fields/_rights.html.erb +0 -6
- data/app/views/generic_files/edit_fields/_suffix.html.erb +0 -9
- data/app/views/generic_files/show_fields/_creator.html.erb +0 -7
- data/app/views/generic_files/show_fields/_default.html.erb +0 -6
- data/app/views/generic_files/show_fields/_description.html.erb +0 -7
- data/app/views/generic_files/show_fields/_identifier.html.erb +0 -4
- data/app/views/generic_files/show_fields/_related_url.html.erb +0 -6
- data/app/views/generic_files/show_fields/_title.html.erb +0 -7
- data/lib/generators/sufia/sufia_generator.rb +0 -89
- data/spec/active_fedora/unsaved_digital_object_spec.rb +0 -35
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '/_user_util_links.html.erb' do
|
4
|
+
|
5
|
+
let(:join_date) { 5.days.ago }
|
6
|
+
before do
|
7
|
+
allow(view).to receive(:user_signed_in?).and_return(true)
|
8
|
+
allow(view).to receive(:current_user).and_return(stub_model(User, user_key: 'userX'))
|
9
|
+
assign :notify_number, 8
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have link to dashboard' do
|
13
|
+
render
|
14
|
+
page = Capybara::Node::Simple.new(rendered)
|
15
|
+
expect(page).to have_link('userX', href: '/dashboard')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have link to user profile' do
|
19
|
+
render
|
20
|
+
page = Capybara::Node::Simple.new(rendered)
|
21
|
+
expect(page).to have_link('my profile', href: '/users/userX')
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
@@ -17,12 +17,12 @@ module Sufia::GenericFile
|
|
17
17
|
generic_file.apply_depositor_metadata(user)
|
18
18
|
generic_file.date_uploaded = Date.today
|
19
19
|
generic_file.date_modified = Date.today
|
20
|
-
generic_file.creator = user.name
|
20
|
+
generic_file.creator = [user.name]
|
21
21
|
|
22
22
|
if batch_id
|
23
|
-
generic_file.
|
23
|
+
generic_file.batch_id = Sufia::Noid.namespaceize(batch_id)
|
24
24
|
else
|
25
|
-
logger.warn "unable to find batch to attach to"
|
25
|
+
ActiveFedora::Base.logger.warn "unable to find batch to attach to"
|
26
26
|
end
|
27
27
|
yield(generic_file) if block_given?
|
28
28
|
end
|
@@ -59,6 +59,7 @@ module Sufia::GenericFile
|
|
59
59
|
generic_file.attributes = generic_file.sanitize_attributes(attributes)
|
60
60
|
generic_file.visibility = visibility
|
61
61
|
generic_file.date_modified = DateTime.now
|
62
|
+
remove_from_feature_works if generic_file.visibility_changed? && !generic_file.public?
|
62
63
|
save_and_record_committer do
|
63
64
|
if Sufia.config.respond_to?(:after_update_metadata)
|
64
65
|
Sufia.config.after_update_metadata.call(generic_file, user)
|
@@ -69,6 +70,7 @@ module Sufia::GenericFile
|
|
69
70
|
def destroy
|
70
71
|
pid = generic_file.pid #Work around for https://github.com/projecthydra/active_fedora/issues/422
|
71
72
|
generic_file.destroy
|
73
|
+
FeaturedWork.where(generic_file_id: pid).destroy_all
|
72
74
|
if Sufia.config.respond_to?(:after_destroy)
|
73
75
|
Sufia.config.after_destroy.call(pid, user)
|
74
76
|
end
|
@@ -87,7 +89,7 @@ module Sufia::GenericFile
|
|
87
89
|
begin
|
88
90
|
return false unless generic_file.save
|
89
91
|
rescue RSolr::Error::Http => error
|
90
|
-
logger.warn "Sufia::GenericFile::Actor::save_and_record_committer Caught RSOLR error #{error.inspect}"
|
92
|
+
ActiveFedora::Base.logger.warn "Sufia::GenericFile::Actor::save_and_record_committer Caught RSOLR error #{error.inspect}"
|
91
93
|
save_tries+=1
|
92
94
|
# fail for good if the tries is greater than 3
|
93
95
|
raise error if save_tries >=3
|
@@ -107,12 +109,19 @@ module Sufia::GenericFile
|
|
107
109
|
def virus_check(file)
|
108
110
|
path = file.is_a?(String) ? file : file.path
|
109
111
|
unless defined?(ClamAV)
|
110
|
-
logger.warn "Virus checking disabled, #{path} not checked"
|
112
|
+
ActiveFedora::Base.logger.warn "Virus checking disabled, #{path} not checked"
|
111
113
|
return
|
112
114
|
end
|
113
115
|
scan_result = ClamAV.instance.scanfile(path)
|
114
116
|
raise Sufia::VirusFoundError.new("A virus was found in #{path}: #{scan_result}") unless scan_result == 0
|
115
117
|
end
|
116
118
|
end
|
119
|
+
|
120
|
+
private
|
121
|
+
def remove_from_feature_works
|
122
|
+
featured_work = FeaturedWork.find_by_generic_file_id(generic_file.noid)
|
123
|
+
featured_work.destroy unless featured_work.nil?
|
124
|
+
end
|
125
|
+
|
117
126
|
end
|
118
127
|
end
|
File without changes
|
@@ -15,25 +15,19 @@ class AuditJob < ActiveFedoraPidBasedJob
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def run
|
18
|
-
#logger.info "GF is #{generic_file.pid}"
|
19
18
|
if generic_file
|
20
19
|
datastream = generic_file.datastreams[datastream_id]
|
21
|
-
#logger.info "DS is #{datastream.inspect}"
|
22
20
|
if datastream
|
23
|
-
#logger.info "Datastream for audit = #{datastream.inspect}"
|
24
21
|
version = datastream.versions.select { |v| v.versionID == version_id}.first
|
25
22
|
log = run_audit(version)
|
26
23
|
|
27
24
|
# look up the user for sending the message to
|
28
25
|
login = generic_file.depositor
|
29
|
-
#logger.info "User login is #{login}"`
|
30
|
-
#logger.info "All users = #{User.all}"
|
31
26
|
if login
|
32
27
|
user = User.find_by_user_key(login)
|
33
|
-
logger.warn "User '#{login}' not found" unless user
|
34
|
-
#logger.info "ZZZ user = #{user.inspect}"
|
28
|
+
ActiveFedora::Base.logger.warn "User '#{login}' not found" unless user
|
35
29
|
job_user = User.audituser()
|
36
|
-
#send the user a message about the failing audit
|
30
|
+
# send the user a message about the failing audit
|
37
31
|
unless (log.pass == 1)
|
38
32
|
message = "The audit run at #{log.created_at} for #{log.pid}:#{log.dsid}:#{log.version} was #{log.pass == 1 ? 'passing' : 'failing'}."
|
39
33
|
subject = (log.pass == 1 ? PASS : FAIL)
|
@@ -41,10 +35,10 @@ class AuditJob < ActiveFedoraPidBasedJob
|
|
41
35
|
end
|
42
36
|
end
|
43
37
|
else
|
44
|
-
logger.warn "No datastream for audit!!!!! pid: #{pid} dsid: #{datastream_id}"
|
38
|
+
ActiveFedora::Base.logger.warn "No datastream for audit!!!!! pid: #{pid} dsid: #{datastream_id}"
|
45
39
|
end
|
46
40
|
else
|
47
|
-
logger.warn "No generic file for data stream audit!!!!! pid: #{pid} dsid: #{datastream_id}"
|
41
|
+
ActiveFedora::Base.logger.warn "No generic file for data stream audit!!!!! pid: #{pid} dsid: #{datastream_id}"
|
48
42
|
end
|
49
43
|
end
|
50
44
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class BatchUpdateJob
|
2
2
|
include Hydra::PermissionsQuery
|
3
|
-
include
|
3
|
+
include Sufia::Messages
|
4
4
|
|
5
5
|
def queue_name
|
6
6
|
:batch_update
|
7
7
|
end
|
8
8
|
|
9
|
-
attr_accessor :login, :title, :file_attributes, :batch_id, :visibility
|
9
|
+
attr_accessor :login, :title, :file_attributes, :batch_id, :visibility, :saved, :denied
|
10
10
|
|
11
11
|
def initialize(login, params)
|
12
12
|
self.login = login
|
@@ -14,32 +14,29 @@ class BatchUpdateJob
|
|
14
14
|
self.file_attributes = params[:generic_file]
|
15
15
|
self.visibility = params[:visibility]
|
16
16
|
self.batch_id = params[:id]
|
17
|
+
self.saved = []
|
18
|
+
self.denied = []
|
17
19
|
end
|
18
20
|
|
19
21
|
def run
|
20
22
|
batch = Batch.find_or_create(self.batch_id)
|
21
23
|
user = User.find_by_user_key(self.login)
|
22
|
-
@saved = []
|
23
|
-
@denied = []
|
24
24
|
|
25
25
|
batch.generic_files.each do |gf|
|
26
26
|
update_file(gf, user)
|
27
27
|
end
|
28
28
|
batch.update_attributes({status:["Complete"]})
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
message = '<span class="batchid ui-helper-hidden">'+batch.noid+'</span>The file(s) '+ file_list(@denied)+" could not be updated. You do not have sufficient privileges to edit it." unless @denied.empty?
|
36
|
-
job_user.send_message(user, message, 'Batch upload permission denied') unless @denied.empty?
|
29
|
+
if denied.empty?
|
30
|
+
send_user_success_message(user, batch) unless saved.empty?
|
31
|
+
else
|
32
|
+
send_user_failure_message(user, batch)
|
33
|
+
end
|
37
34
|
end
|
38
35
|
|
39
36
|
def update_file(gf, user)
|
40
37
|
unless user.can? :edit, gf
|
41
|
-
logger.error "User #{user.user_key} DENIED access to #{gf.pid}!"
|
42
|
-
|
38
|
+
ActiveFedora::Base.logger.error "User #{user.user_key} DENIED access to #{gf.pid}!"
|
39
|
+
denied << gf
|
43
40
|
return
|
44
41
|
end
|
45
42
|
gf.title = title[gf.pid] if title[gf.pid] rescue gf.label
|
@@ -51,17 +48,24 @@ class BatchUpdateJob
|
|
51
48
|
gf.save!
|
52
49
|
rescue RSolr::Error::Http => error
|
53
50
|
save_tries += 1
|
54
|
-
logger.warn "BatchUpdateJob caught RSOLR error on #{gf.pid}: #{error.inspect}"
|
51
|
+
ActiveFedora::Base.logger.warn "BatchUpdateJob caught RSOLR error on #{gf.pid}: #{error.inspect}"
|
55
52
|
# fail for good if the tries is greater than 3
|
56
53
|
raise error if save_tries >=3
|
57
54
|
sleep 0.01
|
58
55
|
retry
|
59
56
|
end #
|
60
57
|
Sufia.queue.push(ContentUpdateEventJob.new(gf.pid, login))
|
61
|
-
|
58
|
+
saved << gf
|
59
|
+
end
|
60
|
+
|
61
|
+
def send_user_success_message user, batch
|
62
|
+
message = saved.count > 1 ? multiple_success(batch.noid, saved) : single_success(batch.noid, saved.first)
|
63
|
+
User.batchuser.send_message(user, message, success_subject, sanitize_text = false)
|
62
64
|
end
|
63
65
|
|
64
|
-
def
|
65
|
-
|
66
|
+
def send_user_failure_message user, batch
|
67
|
+
message = denied.count > 1 ? multiple_failure(batch.noid, denied) : single_failure(batch.noid, denied.first)
|
68
|
+
User.batchuser.send_message(user, message, failure_subject, sanitize_text = false)
|
66
69
|
end
|
70
|
+
|
67
71
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,41 +1,3 @@
|
|
1
1
|
class Collection < ActiveFedora::Base
|
2
|
-
include
|
3
|
-
include Sufia::ModelMethods
|
4
|
-
include Sufia::Noid
|
5
|
-
include Sufia::GenericFile::Permissions
|
6
|
-
include Sufia::GenericFile::WebForm # provides initialize_fields method
|
7
|
-
|
8
|
-
before_save :update_permissions
|
9
|
-
validates :title, presence: true
|
10
|
-
|
11
|
-
has_metadata "properties", type: PropertiesDatastream
|
12
|
-
|
13
|
-
def terms_for_display
|
14
|
-
[:title, :creator, :description, :date_modified, :date_uploaded]
|
15
|
-
end
|
16
|
-
|
17
|
-
def terms_for_editing
|
18
|
-
terms_for_display - [:date_modified, :date_uploaded]
|
19
|
-
end
|
20
|
-
|
21
|
-
# Test to see if the given field is required
|
22
|
-
# @param [Symbol] key a field
|
23
|
-
# @return [Boolean] is it required or not
|
24
|
-
def required?(key)
|
25
|
-
self.class.validators_on(key).any?{|v| v.kind_of? ActiveModel::Validations::PresenceValidator}
|
26
|
-
end
|
27
|
-
|
28
|
-
def to_param
|
29
|
-
noid
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_solr(solr_doc={}, opts={})
|
33
|
-
super(solr_doc, opts)
|
34
|
-
solr_doc[Solrizer.solr_name("noid", Sufia::GenericFile.noid_indexer)] = noid
|
35
|
-
return solr_doc
|
36
|
-
end
|
37
|
-
|
38
|
-
def update_permissions
|
39
|
-
self.visibility = "open"
|
40
|
-
end
|
2
|
+
include Sufia::Collection
|
41
3
|
end
|
File without changes
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Sufia
|
2
|
+
module Collection
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include Hydra::Collection
|
5
|
+
include Sufia::ModelMethods
|
6
|
+
include Sufia::Noid
|
7
|
+
include Sufia::GenericFile::Permissions
|
8
|
+
include Sufia::GenericFile::WebForm # provides initialize_fields method
|
9
|
+
|
10
|
+
included do
|
11
|
+
before_save :update_permissions
|
12
|
+
validates :title, presence: true
|
13
|
+
|
14
|
+
has_metadata "properties", type: PropertiesDatastream
|
15
|
+
end
|
16
|
+
|
17
|
+
def terms_for_display
|
18
|
+
terms_for_editing - [:title, :description]
|
19
|
+
end
|
20
|
+
|
21
|
+
def terms_for_editing
|
22
|
+
[:resource_type, :title, :creator, :contributor, :description, :tag,
|
23
|
+
:rights, :publisher, :date_created, :subject, :language, :identifier,
|
24
|
+
:based_near, :related_url]
|
25
|
+
end
|
26
|
+
|
27
|
+
# Test to see if the given field is required
|
28
|
+
# @param [Symbol] key a field
|
29
|
+
# @return [Boolean] is it required or not
|
30
|
+
def required?(key)
|
31
|
+
self.class.validators_on(key).any?{|v| v.kind_of? ActiveModel::Validations::PresenceValidator}
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_param
|
35
|
+
noid
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_solr(solr_doc={}, opts={})
|
39
|
+
super(solr_doc, opts)
|
40
|
+
solr_doc[Solrizer.solr_name("noid", Sufia::GenericFile.noid_indexer)] = noid
|
41
|
+
return solr_doc
|
42
|
+
end
|
43
|
+
|
44
|
+
def update_permissions
|
45
|
+
self.visibility = "open"
|
46
|
+
end
|
47
|
+
|
48
|
+
# Compute the sum of each file in the collection
|
49
|
+
# Return an integer of the result
|
50
|
+
def bytes
|
51
|
+
members.reduce(0) { |sum, gf| sum + gf.file_size.first.to_i }
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -18,6 +18,7 @@ module Sufia
|
|
18
18
|
include Sufia::GenericFile::Versions
|
19
19
|
include Sufia::GenericFile::VirusCheck
|
20
20
|
include Sufia::GenericFile::ReloadOnSave
|
21
|
+
include Sufia::GenericFile::FullTextIndexing
|
21
22
|
include Hydra::Collections::Collectible
|
22
23
|
|
23
24
|
included do
|
@@ -69,17 +70,9 @@ module Sufia
|
|
69
70
|
# until all objects are done uploading and the user is redirected to
|
70
71
|
# BatchController#edit. Therefore, we must handle the case where
|
71
72
|
# self.batch_id is set but self.batch returns nil.
|
72
|
-
# This can get a major overhaul with ActiveFedora 7
|
73
73
|
def related_files
|
74
|
-
|
75
|
-
|
76
|
-
rescue NoMethodError => e
|
77
|
-
#batch is nil - When would this ever happen?
|
78
|
-
batch_id = self.object_relations["isPartOf"].first || self.object_relations[:is_part_of].first
|
79
|
-
return [] if batch_id.nil?
|
80
|
-
self.class.find(Solrizer.solr_name('is_part_of', :symbol) => batch_id)
|
81
|
-
end
|
82
|
-
relateds.reject { |gf| gf.pid == self.pid }
|
74
|
+
return [] if batch.nil?
|
75
|
+
batch.generic_files.reject { |sibling| sibling.id == id }
|
83
76
|
end
|
84
77
|
|
85
78
|
# Unstemmed, searchable, stored
|
@@ -93,6 +86,7 @@ module Sufia
|
|
93
86
|
solr_doc[Solrizer.solr_name('noid', Sufia::GenericFile.noid_indexer)] = noid
|
94
87
|
solr_doc[Solrizer.solr_name('file_format')] = file_format
|
95
88
|
solr_doc[Solrizer.solr_name('file_format', :facetable)] = file_format
|
89
|
+
solr_doc['all_text_timv'] = full_text.content
|
96
90
|
solr_doc = index_collection_pids(solr_doc)
|
97
91
|
end
|
98
92
|
end
|
@@ -100,7 +94,7 @@ module Sufia
|
|
100
94
|
def label=(new_label)
|
101
95
|
@inner_object.label = new_label
|
102
96
|
if self.title.empty?
|
103
|
-
self.title = new_label
|
97
|
+
self.title = [new_label].compact
|
104
98
|
end
|
105
99
|
end
|
106
100
|
|
@@ -2,8 +2,6 @@ module Sufia
|
|
2
2
|
module GenericFile
|
3
3
|
module Audit
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
included do
|
6
|
-
end
|
7
5
|
|
8
6
|
NO_RUNS = 999
|
9
7
|
|
@@ -17,6 +15,7 @@ module Sufia
|
|
17
15
|
|
18
16
|
def per_version(&block)
|
19
17
|
self.datastreams.each do |dsid, ds|
|
18
|
+
next if ds == full_text
|
20
19
|
ds.versions.each do |ver|
|
21
20
|
block.call(ver)
|
22
21
|
end
|
@@ -42,9 +42,11 @@ module Sufia
|
|
42
42
|
|
43
43
|
## Extract the metadata from the content datastream and record it in the characterization datastream
|
44
44
|
def characterize
|
45
|
-
|
45
|
+
metadata = self.content.extract_metadata
|
46
|
+
self.characterization.ng_xml = metadata if metadata.present?
|
46
47
|
self.append_metadata
|
47
|
-
self.filename = self.label
|
48
|
+
self.filename = [self.label]
|
49
|
+
extract_content
|
48
50
|
save
|
49
51
|
end
|
50
52
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Sufia
|
2
|
+
module GenericFile
|
3
|
+
module FullTextIndexing
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
has_file_datastream 'full_text', versionable: false
|
8
|
+
end
|
9
|
+
|
10
|
+
def extract_content
|
11
|
+
url = Blacklight.solr_config[:url] ? Blacklight.solr_config[:url] : Blacklight.solr_config["url"] ? Blacklight.solr_config["url"] : Blacklight.solr_config[:fulltext] ? Blacklight.solr_config[:fulltext]["url"] : Blacklight.solr_config[:default]["url"]
|
12
|
+
uri = URI("#{url}/update/extract?extractOnly=true&wt=json&extractFormat=text")
|
13
|
+
req = Net::HTTP.new(uri.host, uri.port)
|
14
|
+
resp = req.post(uri.to_s, self.content.content, {
|
15
|
+
'Content-type' => "#{self.mime_type};charset=utf-8",
|
16
|
+
'Content-Length' => self.content.content.size.to_s
|
17
|
+
})
|
18
|
+
raise "URL '#{uri}' returned code #{resp.code}" unless resp.code == "200"
|
19
|
+
self.content.content.rewind if self.content.content.respond_to?(:rewind)
|
20
|
+
extracted_text = JSON.parse(resp.body)[''].rstrip
|
21
|
+
full_text.content = extracted_text if extracted_text.present?
|
22
|
+
rescue => e
|
23
|
+
logger.error("Error extracting content from #{self.pid}: #{e.inspect}")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -53,6 +53,7 @@ module Sufia
|
|
53
53
|
['text/rtf',
|
54
54
|
'application/msword',
|
55
55
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
56
|
+
'application/vnd.oasis.opendocument.text',
|
56
57
|
'application/vnd.ms-excel',
|
57
58
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
58
59
|
'application/vnd.ms-powerpoint',
|
@@ -2,57 +2,10 @@ module Sufia
|
|
2
2
|
module GenericFile
|
3
3
|
module Permissions
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
#we're overriding the permissions= method which is in Hydra::AccessControls::Permissions
|
6
|
-
include Hydra::AccessControls::Permissions
|
7
|
-
include Hydra::AccessControls::Visibility
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
validate :paranoid_permissions
|
12
|
-
end
|
6
|
+
include Sufia::Permissions::Writable
|
7
|
+
include Sufia::Permissions::Readable
|
13
8
|
|
14
|
-
def paranoid_permissions
|
15
|
-
# let the rightsMetadata ds make this determination
|
16
|
-
# - the object instance is passed in for easier access to the props ds
|
17
|
-
rightsMetadata.validate(self)
|
18
|
-
end
|
19
|
-
|
20
|
-
## Updates those permissions that are provided to it. Does not replace any permissions unless they are provided
|
21
|
-
def permissions=(params)
|
22
|
-
perm_hash = permission_hash
|
23
|
-
params[:new_user_name].each { |name, access| perm_hash['person'][name] = access } if params[:new_user_name].present?
|
24
|
-
params[:new_group_name].each { |name, access| perm_hash['group'][name] = access } if params[:new_group_name].present?
|
25
|
-
|
26
|
-
params[:user].each { |name, access| perm_hash['person'][name] = access} if params[:user]
|
27
|
-
params[:group].each { |name, access| perm_hash['group'][name] = access if ['read', 'edit'].include?(access)} if params[:group]
|
28
|
-
|
29
|
-
rightsMetadata.update_permissions(perm_hash)
|
30
|
-
end
|
31
|
-
|
32
|
-
def permissions
|
33
|
-
perms = super
|
34
|
-
perms.map {|p| { name: p.name, access: p.access, type:p.type } }
|
35
|
-
end
|
36
|
-
|
37
|
-
def public?
|
38
|
-
read_groups.include?('public')
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def permission_hash
|
44
|
-
old_perms = self.permissions
|
45
|
-
user_perms = {}
|
46
|
-
old_perms.select{|r| r[:type] == 'user'}.each do |r|
|
47
|
-
user_perms[r[:name]] = r[:access]
|
48
|
-
end
|
49
|
-
user_perms
|
50
|
-
group_perms = {}
|
51
|
-
old_perms.select{|r| r[:type] == 'group'}.each do |r|
|
52
|
-
group_perms[r[:name]] = r[:access]
|
53
|
-
end
|
54
|
-
{'person'=>user_perms, 'group'=>group_perms}
|
55
|
-
end
|
56
9
|
end
|
57
10
|
end
|
58
11
|
end
|