sufia-models 6.0.0.rc2 → 6.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/actors/sufia/generic_file/actor.rb +12 -8
- data/app/jobs/batch_update_job.rb +2 -2
- data/app/jobs/import_url_job.rb +5 -3
- data/app/jobs/ingest_local_file_job.rb +46 -0
- data/app/jobs/resolrize_job.rb +1 -8
- data/app/models/batch.rb +0 -7
- data/app/models/concerns/sufia/ability.rb +1 -1
- data/app/models/concerns/sufia/{collection.rb → collection_behavior.rb} +1 -13
- data/app/models/concerns/sufia/generic_file/batches.rb +3 -4
- data/app/models/concerns/sufia/generic_file/export.rb +1 -1
- data/app/models/concerns/sufia/generic_file/featured.rb +1 -4
- data/app/models/concerns/sufia/generic_file/metadata.rb +7 -7
- data/app/models/concerns/sufia/generic_file/trophies.rb +1 -2
- data/app/models/concerns/sufia/generic_file/virus_check.rb +16 -11
- data/app/models/concerns/sufia/model_methods.rb +1 -14
- data/app/models/concerns/sufia/user.rb +5 -0
- data/app/models/file_usage.rb +1 -1
- data/app/models/file_view_stat.rb +1 -1
- data/app/models/sufia/collection.rb +5 -0
- data/app/services/sufia/generic_file_indexing_service.rb +1 -1
- data/app/services/sufia/id_service.rb +1 -2
- data/app/services/sufia/noid.rb +4 -24
- data/lib/generators/sufia/models/install_generator.rb +6 -1
- data/lib/generators/sufia/models/templates/app/models/collection.rb +2 -0
- data/lib/generators/sufia/models/templates/config/resque_config.rb +1 -1
- data/lib/generators/sufia/models/templates/config/solrconfig.xml +46 -0
- data/lib/generators/sufia/models/templates/config/sufia.rb +9 -5
- data/lib/generators/sufia/models/templates/migrations/add_external_key_to_content_blocks.rb +6 -0
- data/lib/generators/sufia/models/update_content_blocks_generator.rb +18 -0
- data/lib/sufia/messages.rb +11 -12
- data/lib/sufia/models/engine.rb +2 -1
- data/lib/sufia/models/stats/user_stat_importer.rb +9 -5
- data/lib/sufia/models/version.rb +1 -1
- data/sufia-models.gemspec +5 -5
- metadata +17 -20
- data/app/models/collection.rb +0 -3
- data/app/services/sufia/indexing_service.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51e106549a813b6bf42150ec4287e9579e171dad
|
4
|
+
data.tar.gz: 987fd56596a1da6b517205ddb9581b8c21fae645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1fd765adfeacd91d0ccb197e4b9920f82d3ddf1aba32d1fabf0c403ea35eb0c6d28b3a7304e3b3850abf1a1ddec9c67b1076c764cf5e13b1388674cff138417
|
7
|
+
data.tar.gz: 3b399d52d64a204e6151833a0bb87bb22e61b50464767faba06e3d67084d6ddaa11acfe9abfd2047ec08b36251b372c059cabc0183fc6c7672421d292ca96943
|
@@ -15,8 +15,9 @@ module Sufia::GenericFile
|
|
15
15
|
# create_metadata(batch_id) { |gf| gf.save }
|
16
16
|
def create_metadata(batch_id)
|
17
17
|
generic_file.apply_depositor_metadata(user)
|
18
|
-
|
19
|
-
generic_file.
|
18
|
+
time_in_utc = DateTime.now.new_offset(0)
|
19
|
+
generic_file.date_uploaded = time_in_utc
|
20
|
+
generic_file.date_modified = time_in_utc
|
20
21
|
generic_file.creator = [user.name]
|
21
22
|
|
22
23
|
if batch_id
|
@@ -27,8 +28,10 @@ module Sufia::GenericFile
|
|
27
28
|
yield(generic_file) if block_given?
|
28
29
|
end
|
29
30
|
|
30
|
-
def create_content(file, file_name,
|
31
|
-
generic_file.add_file(file,
|
31
|
+
def create_content(file, file_name, path, mime_type)
|
32
|
+
generic_file.add_file(file, path: path, original_name: file_name, mime_type: mime_type)
|
33
|
+
generic_file.label ||= file_name
|
34
|
+
generic_file.title = [file_name] if generic_file.title.blank?
|
32
35
|
save_characterize_and_record_committer do
|
33
36
|
if Sufia.config.respond_to?(:after_create_content)
|
34
37
|
Sufia.config.after_create_content.call(generic_file, user)
|
@@ -46,8 +49,8 @@ module Sufia::GenericFile
|
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
49
|
-
def update_content(file,
|
50
|
-
generic_file.add_file(file,
|
52
|
+
def update_content(file, path)
|
53
|
+
generic_file.add_file(file, path: path, original_name: file.original_filename, mime_type: file.content_type)
|
51
54
|
save_characterize_and_record_committer do
|
52
55
|
if Sufia.config.respond_to?(:after_update_content)
|
53
56
|
Sufia.config.after_update_content.call(generic_file, user)
|
@@ -83,6 +86,7 @@ module Sufia::GenericFile
|
|
83
86
|
end
|
84
87
|
|
85
88
|
# Takes an optional block and executes the block if the save was successful.
|
89
|
+
# returns false if the save was unsuccessful
|
86
90
|
def save_and_record_committer
|
87
91
|
save_tries = 0
|
88
92
|
begin
|
@@ -124,10 +128,10 @@ module Sufia::GenericFile
|
|
124
128
|
end
|
125
129
|
|
126
130
|
private
|
131
|
+
|
127
132
|
def remove_from_feature_works
|
128
|
-
featured_work = FeaturedWork.find_by_generic_file_id(generic_file.
|
133
|
+
featured_work = FeaturedWork.find_by_generic_file_id(generic_file.id)
|
129
134
|
featured_work.destroy unless featured_work.nil?
|
130
135
|
end
|
131
|
-
|
132
136
|
end
|
133
137
|
end
|
@@ -61,12 +61,12 @@ class BatchUpdateJob
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def send_user_success_message user, batch
|
64
|
-
message = saved.count > 1 ? multiple_success(batch.
|
64
|
+
message = saved.count > 1 ? multiple_success(batch.id, saved) : single_success(batch.id, saved.first)
|
65
65
|
User.batchuser.send_message(user, message, success_subject, sanitize_text = false)
|
66
66
|
end
|
67
67
|
|
68
68
|
def send_user_failure_message user, batch
|
69
|
-
message = denied.count > 1 ? multiple_failure(batch.
|
69
|
+
message = denied.count > 1 ? multiple_failure(batch.id, denied) : single_failure(batch.id, denied.first)
|
70
70
|
User.batchuser.send_message(user, message, failure_subject, sanitize_text = false)
|
71
71
|
end
|
72
72
|
end
|
data/app/jobs/import_url_job.rb
CHANGED
@@ -12,9 +12,9 @@ class ImportUrlJob < ActiveFedoraPidBasedJob
|
|
12
12
|
user = User.find_by_user_key(generic_file.depositor)
|
13
13
|
|
14
14
|
Tempfile.open(pid.gsub('/', '_')) do |f|
|
15
|
-
path = copy_remote_file(generic_file.import_url, f)
|
15
|
+
path, mime_type = copy_remote_file(generic_file.import_url, f)
|
16
16
|
# attach downloaded file to generic file stubbed out
|
17
|
-
if Sufia::GenericFile::Actor.new(generic_file, user).create_content(f, path, 'content')
|
17
|
+
if Sufia::GenericFile::Actor.new(generic_file, user).create_content(f, path, 'content', mime_type)
|
18
18
|
# add message to user for downloaded file
|
19
19
|
message = "The file (#{generic_file.label}) was successfully imported."
|
20
20
|
job_user.send_message(user, message, 'File Import')
|
@@ -31,9 +31,11 @@ class ImportUrlJob < ActiveFedoraPidBasedJob
|
|
31
31
|
http = Net::HTTP.new(uri.host, uri.port)
|
32
32
|
http.use_ssl = uri.scheme == "https" # enable SSL/TLS
|
33
33
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
34
|
+
mime_type = nil
|
34
35
|
|
35
36
|
http.start do
|
36
37
|
http.request_get(uri.request_uri) do |resp|
|
38
|
+
mime_type = resp.content_type
|
37
39
|
resp.read_body do |segment|
|
38
40
|
f.write(segment)
|
39
41
|
end
|
@@ -41,7 +43,7 @@ class ImportUrlJob < ActiveFedoraPidBasedJob
|
|
41
43
|
end
|
42
44
|
|
43
45
|
f.rewind
|
44
|
-
uri.path
|
46
|
+
return uri.path, mime_type
|
45
47
|
end
|
46
48
|
|
47
49
|
def job_user
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class IngestLocalFileJob
|
2
|
+
attr_accessor :directory, :filename, :user_key, :generic_file_id
|
3
|
+
|
4
|
+
def queue_name
|
5
|
+
:ingest
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(generic_file_id, directory, filename, user_key)
|
9
|
+
self.generic_file_id = generic_file_id
|
10
|
+
self.directory = directory
|
11
|
+
self.filename = filename
|
12
|
+
self.user_key = user_key
|
13
|
+
end
|
14
|
+
|
15
|
+
#TODO this should use Actor#create_content
|
16
|
+
def run
|
17
|
+
user = User.find_by_user_key(user_key)
|
18
|
+
raise "Unable to find user for #{user_key}" unless user
|
19
|
+
generic_file = GenericFile.find(generic_file_id)
|
20
|
+
path = File.join(directory, filename)
|
21
|
+
|
22
|
+
actor = Sufia::GenericFile::Actor.new(generic_file, user)
|
23
|
+
|
24
|
+
if actor.create_content(File.open(path), filename, 'content', mime_type(filename))
|
25
|
+
FileUtils.rm(path)
|
26
|
+
Sufia.queue.push(ContentDepositEventJob.new(generic_file.id, user_key))
|
27
|
+
|
28
|
+
message = "The file (#{File.basename(filename)}) was successfully deposited."
|
29
|
+
subject = 'Local file ingest'
|
30
|
+
else
|
31
|
+
message = "There was a problem depositing #{File.basename(filename)}. Please contact a system admin."
|
32
|
+
subject = 'Local file ingest error'
|
33
|
+
end
|
34
|
+
|
35
|
+
job_user.send_message(user, message, subject)
|
36
|
+
end
|
37
|
+
|
38
|
+
def job_user
|
39
|
+
User.batchuser
|
40
|
+
end
|
41
|
+
|
42
|
+
def mime_type(file_name)
|
43
|
+
mime_types = MIME::Types.of(file_name)
|
44
|
+
mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
|
45
|
+
end
|
46
|
+
end
|
data/app/jobs/resolrize_job.rb
CHANGED
@@ -4,13 +4,6 @@ class ResolrizeJob
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def run
|
7
|
-
|
8
|
-
active_fedora_version = Gem::Version.new(ActiveFedora::VERSION)
|
9
|
-
minimum_feature_version = Gem::Version.new('6.4.4')
|
10
|
-
if active_fedora_version >= minimum_feature_version
|
11
|
-
ActiveFedora::Base.reindex_everything("pid~#{Sufia.config.id_namespace}:*")
|
12
|
-
else
|
13
|
-
ActiveFedora::Base.reindex_everything
|
14
|
-
end
|
7
|
+
ActiveFedora::Base.reindex_everything
|
15
8
|
end
|
16
9
|
end
|
data/app/models/batch.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Sufia
|
2
|
-
module
|
2
|
+
module CollectionBehavior
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
include Hydra::Collection
|
5
5
|
include Sufia::ModelMethods
|
@@ -11,10 +11,6 @@ module Sufia
|
|
11
11
|
validates :title, presence: true
|
12
12
|
end
|
13
13
|
|
14
|
-
def to_param
|
15
|
-
noid
|
16
|
-
end
|
17
|
-
|
18
14
|
def update_permissions
|
19
15
|
self.visibility = "open"
|
20
16
|
end
|
@@ -24,13 +20,5 @@ module Sufia
|
|
24
20
|
def bytes
|
25
21
|
members.reduce(0) { |sum, gf| sum + gf.file_size.first.to_i }
|
26
22
|
end
|
27
|
-
|
28
|
-
module ClassMethods
|
29
|
-
# override the default indexing service
|
30
|
-
def indexer
|
31
|
-
Sufia::IndexingService
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
23
|
end
|
36
24
|
end
|
@@ -11,16 +11,15 @@ module Sufia
|
|
11
11
|
# to each file when it is done uploading. The Batch object is not created
|
12
12
|
# until all objects are done uploading and the user is redirected to
|
13
13
|
# BatchController#edit. Therefore, we must handle the case where
|
14
|
-
#
|
14
|
+
# batch_id is set but batch returns nil.
|
15
15
|
def related_files
|
16
|
-
return []
|
16
|
+
return [] unless batch
|
17
17
|
batch.generic_files.reject { |sibling| sibling.id == id }
|
18
18
|
end
|
19
19
|
|
20
20
|
# Is this file in the middle of being processed by a batch?
|
21
21
|
def processing?
|
22
|
-
|
23
|
-
(!self.batch.status.empty?) && (self.batch.status.count == 1) && (self.batch.status[0] == "processing")
|
22
|
+
try(:batch).try(:status) == ['processing'.freeze]
|
24
23
|
end
|
25
24
|
|
26
25
|
end
|
@@ -46,10 +46,17 @@ module Sufia
|
|
46
46
|
property :date_created, predicate: ::RDF::DC.created do |index|
|
47
47
|
index.as :stored_searchable
|
48
48
|
end
|
49
|
+
|
50
|
+
# We reserve date_uploaded for the original creation date of the record.
|
51
|
+
# For example, when migrating data from a fedora3 repo to fedora4,
|
52
|
+
# fedora's system created date will reflect the date when the record
|
53
|
+
# was created in fedora4, but the date_uploaded will preserve the
|
54
|
+
# original creation date from the old repository.
|
49
55
|
property :date_uploaded, predicate: ::RDF::DC.dateSubmitted, multiple: false do |index|
|
50
56
|
index.type :date
|
51
57
|
index.as :stored_sortable
|
52
58
|
end
|
59
|
+
|
53
60
|
property :date_modified, predicate: ::RDF::DC.modified, multiple: false do |index|
|
54
61
|
index.type :date
|
55
62
|
index.as :stored_sortable
|
@@ -86,13 +93,6 @@ module Sufia
|
|
86
93
|
end
|
87
94
|
end
|
88
95
|
|
89
|
-
# Add a schema.org itemtype
|
90
|
-
def itemtype
|
91
|
-
# Look up the first non-empty resource type value in a hash from the config
|
92
|
-
Sufia.config.resource_types_to_schema[resource_type.to_a.reject { |type| type.empty? }.first] || 'http://schema.org/CreativeWork'
|
93
|
-
rescue
|
94
|
-
'http://schema.org/CreativeWork'
|
95
|
-
end
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
@@ -10,23 +10,28 @@ module Sufia
|
|
10
10
|
# Default behavior is to raise a validation error and halt the save if a virus is found
|
11
11
|
def detect_viruses
|
12
12
|
return unless content.changed?
|
13
|
-
|
14
|
-
content.content.path
|
15
|
-
else
|
16
|
-
Tempfile.open('') do |t|
|
17
|
-
t.binmode
|
18
|
-
t.write(content.content)
|
19
|
-
t.close
|
20
|
-
t.path
|
21
|
-
end
|
22
|
-
end
|
23
|
-
Sufia::GenericFile::Actor.virus_check(path)
|
13
|
+
Sufia::GenericFile::Actor.virus_check(local_path_for_content)
|
24
14
|
true
|
25
15
|
rescue Sufia::VirusFoundError => virus
|
26
16
|
logger.warn(virus.message)
|
27
17
|
errors.add(:base, virus.message)
|
28
18
|
false
|
29
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def local_path_for_content
|
24
|
+
if content.content.respond_to?(:path)
|
25
|
+
content.content.path
|
26
|
+
else
|
27
|
+
Tempfile.open('') do |t|
|
28
|
+
t.binmode
|
29
|
+
t.write(content.content)
|
30
|
+
t.close
|
31
|
+
t.path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
@@ -3,20 +3,7 @@ module Sufia
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
include Hydra::
|
7
|
-
end
|
8
|
-
|
9
|
-
# OVERRIDE to support Hydra::Datastream::Properties which does not
|
10
|
-
# respond to :depositor_values but :depositor
|
11
|
-
# Adds metadata about the depositor to the asset and ads +depositor_id+ to
|
12
|
-
# its individual edit permissions.
|
13
|
-
def apply_depositor_metadata(depositor)
|
14
|
-
depositor_id = depositor.respond_to?(:user_key) ? depositor.user_key : depositor
|
15
|
-
|
16
|
-
self.edit_users += [depositor_id]
|
17
|
-
self.depositor = depositor_id
|
18
|
-
|
19
|
-
return true
|
6
|
+
include Hydra::WithDepositor
|
20
7
|
end
|
21
8
|
|
22
9
|
def to_s
|
@@ -54,6 +54,11 @@ module Sufia::User
|
|
54
54
|
{ id: user_key, text: display_name ? "#{display_name} (#{user_key})" : user_key }
|
55
55
|
end
|
56
56
|
|
57
|
+
# Populate user instance with attributes from remote system (e.g., LDAP)
|
58
|
+
# There is no default implementation -- override this in your application
|
59
|
+
def populate_attributes
|
60
|
+
end
|
61
|
+
|
57
62
|
def email_address
|
58
63
|
self.email
|
59
64
|
end
|
data/app/models/file_usage.rb
CHANGED
@@ -8,7 +8,7 @@ class FileUsage
|
|
8
8
|
user_id = user ? user.id : nil
|
9
9
|
|
10
10
|
self.id = id
|
11
|
-
self.path = Sufia::Engine.routes.url_helpers.generic_file_path(
|
11
|
+
self.path = Sufia::Engine.routes.url_helpers.generic_file_path(id)
|
12
12
|
earliest = Sufia.config.analytic_start_date
|
13
13
|
self.created = ::GenericFile.find(id).create_date
|
14
14
|
self.created = earliest > created ? earliest : created unless earliest.blank?
|
@@ -12,7 +12,7 @@ class FileViewStat < ActiveRecord::Base
|
|
12
12
|
# Sufia::Download is sent to Sufia::Analytics.profile as #sufia__download
|
13
13
|
# see Legato::ProfileMethods.method_name_from_klass
|
14
14
|
def self.ga_statistics start_date, file_id
|
15
|
-
path = Sufia::Engine.routes.url_helpers.generic_file_path(
|
15
|
+
path = Sufia::Engine.routes.url_helpers.generic_file_path(file_id)
|
16
16
|
Sufia::Analytics.profile.sufia__pageview(sort: 'date', start_date: start_date).for_path(path)
|
17
17
|
end
|
18
18
|
end
|
@@ -9,12 +9,11 @@ module Sufia
|
|
9
9
|
|
10
10
|
@minter = ::Noid::Minter.new(template: noid_template)
|
11
11
|
@pid = $$
|
12
|
-
#@namespace = Sufia.config.id_namespace
|
13
12
|
@semaphore = Mutex.new
|
14
13
|
def self.valid?(identifier)
|
15
14
|
# remove the fedora namespace since it's not part of the noid
|
16
15
|
noid = identifier#.split(":").last
|
17
|
-
|
16
|
+
@minter.valid? noid
|
18
17
|
end
|
19
18
|
def self.mint
|
20
19
|
@semaphore.synchronize do
|
data/app/services/sufia/noid.rb
CHANGED
@@ -3,40 +3,20 @@ module Sufia
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
## This overrides the default behavior, which is to ask Fedora for a pid
|
6
|
-
# @see ActiveFedora::
|
7
|
-
def
|
8
|
-
Sufia::IdService.mint
|
6
|
+
# @see ActiveFedora::Persistence.assign_id
|
7
|
+
def assign_id
|
8
|
+
Sufia::IdService.mint if Sufia.config.enable_noids
|
9
9
|
end
|
10
10
|
|
11
|
-
def noid
|
12
|
-
Noid.noidify(id)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Redefine this for more intuitive keys in Redis
|
16
11
|
def to_param
|
17
|
-
|
12
|
+
id
|
18
13
|
end
|
19
14
|
|
20
15
|
class << self
|
21
|
-
def noidify(identifier)
|
22
|
-
String(identifier).split(":").last
|
23
|
-
end
|
24
|
-
|
25
16
|
# Create a pairtree like path for the given identifier
|
26
17
|
def treeify(identifier)
|
27
18
|
(identifier.scan(/..?/).first(4) + [identifier]).join('/')
|
28
19
|
end
|
29
|
-
|
30
|
-
def namespaceize(identifier)
|
31
|
-
return identifier if identifier.include?(':')
|
32
|
-
"#{namespace}:#{identifier}"
|
33
|
-
end
|
34
|
-
|
35
|
-
protected
|
36
|
-
|
37
|
-
def namespace
|
38
|
-
Sufia.config.id_namespace
|
39
|
-
end
|
40
20
|
end
|
41
21
|
end
|
42
22
|
end
|
@@ -37,7 +37,8 @@ This generator makes the following changes to your application:
|
|
37
37
|
'add_linkedin_to_users.rb',
|
38
38
|
'create_tinymce_assets.rb',
|
39
39
|
'create_content_blocks.rb',
|
40
|
-
'create_featured_works.rb'
|
40
|
+
'create_featured_works.rb',
|
41
|
+
'add_external_key_to_content_blocks.rb'
|
41
42
|
].each do |file|
|
42
43
|
better_migration_template file
|
43
44
|
end
|
@@ -67,6 +68,10 @@ This generator makes the following changes to your application:
|
|
67
68
|
copy_file 'config/resque_config.rb', 'config/initializers/resque_config.rb'
|
68
69
|
end
|
69
70
|
|
71
|
+
def create_collection
|
72
|
+
copy_file 'app/models/collection.rb', 'app/models/collection.rb'
|
73
|
+
end
|
74
|
+
|
70
75
|
def install_mailboxer
|
71
76
|
generate "mailboxer:install"
|
72
77
|
end
|
@@ -2,4 +2,4 @@ config = YAML::load(ERB.new(IO.read(File.join(Rails.root, 'config', 'redis.yml')
|
|
2
2
|
Resque.redis = Redis.new(host: config[:host], port: config[:port], thread_safe: true)
|
3
3
|
|
4
4
|
Resque.inline = Rails.env.test?
|
5
|
-
Resque.redis.namespace = "#{Sufia.config.
|
5
|
+
Resque.redis.namespace = "#{Sufia.config.redis_namespace}:#{Rails.env}"
|
@@ -18,6 +18,52 @@
|
|
18
18
|
|
19
19
|
<dataDir>${solr.data.dir:}</dataDir>
|
20
20
|
|
21
|
+
<!-- The default high-performance update handler -->
|
22
|
+
<updateHandler class="solr.DirectUpdateHandler2">
|
23
|
+
|
24
|
+
<!-- Enables a transaction log, used for real-time get, durability, and
|
25
|
+
and solr cloud replica recovery. The log can grow as big as
|
26
|
+
uncommitted changes to the index, so use of a hard autoCommit
|
27
|
+
is recommended (see below).
|
28
|
+
"dir" - the target directory for transaction logs, defaults to the
|
29
|
+
solr data directory. -->
|
30
|
+
<updateLog>
|
31
|
+
<str name="dir">${solr.ulog.dir:}</str>
|
32
|
+
</updateLog>
|
33
|
+
|
34
|
+
<!-- AutoCommit
|
35
|
+
Perform a hard commit automatically under certain conditions.
|
36
|
+
Instead of enabling autoCommit, consider using "commitWithin"
|
37
|
+
when adding documents.
|
38
|
+
http://wiki.apache.org/solr/UpdateXmlMessages
|
39
|
+
maxDocs - Maximum number of documents to add since the last
|
40
|
+
commit before automatically triggering a new commit.
|
41
|
+
maxTime - Maximum amount of time in ms that is allowed to pass
|
42
|
+
since a document was added before automatically
|
43
|
+
triggering a new commit.
|
44
|
+
openSearcher - if false, the commit causes recent index changes
|
45
|
+
to be flushed to stable storage, but does not cause a new
|
46
|
+
searcher to be opened to make those changes visible.
|
47
|
+
If the updateLog is enabled, then it's highly recommended to
|
48
|
+
have some sort of hard autoCommit to limit the log size.
|
49
|
+
-->
|
50
|
+
<autoCommit>
|
51
|
+
<maxTime>${solr.autoCommit.maxTime:15000}</maxTime>
|
52
|
+
<openSearcher>false</openSearcher>
|
53
|
+
</autoCommit>
|
54
|
+
|
55
|
+
<!-- softAutoCommit is like autoCommit except it causes a
|
56
|
+
'soft' commit which only ensures that changes are visible
|
57
|
+
but does not ensure that data is synced to disk. This is
|
58
|
+
faster and more near-realtime friendly than a hard commit.
|
59
|
+
-->
|
60
|
+
|
61
|
+
<autoSoftCommit>
|
62
|
+
<maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>
|
63
|
+
</autoSoftCommit>
|
64
|
+
|
65
|
+
</updateHandler>
|
66
|
+
|
21
67
|
<requestHandler name="search" class="solr.SearchHandler" default="true">
|
22
68
|
<!-- default values for query parameters can be specified, these
|
23
69
|
will be overridden by parameters in the request
|
@@ -6,9 +6,6 @@ Sufia.config do |config|
|
|
6
6
|
file_author: :creator
|
7
7
|
}
|
8
8
|
|
9
|
-
# Specify a different template for your repositories unique identifiers
|
10
|
-
# config.noid_template = ".reeddeeddk"
|
11
|
-
|
12
9
|
config.max_days_between_audits = 7
|
13
10
|
|
14
11
|
config.max_notifications_for_dashboard = 5
|
@@ -105,8 +102,15 @@ Sufia.config do |config|
|
|
105
102
|
# If you have ffmpeg installed and want to transcode audio and video uncomment this line
|
106
103
|
# config.enable_ffmpeg = true
|
107
104
|
|
108
|
-
#
|
109
|
-
#
|
105
|
+
# Sufia uses NOIDs for files and collections instead of Fedora UUIDs
|
106
|
+
# where NOID = 10-character string and UUID = 32-character string w/ hyphens
|
107
|
+
# config.enable_noids = true
|
108
|
+
|
109
|
+
# Specify a different template for your repository's NOID IDs
|
110
|
+
# config.noid_template = ".reeddeeddk"
|
111
|
+
|
112
|
+
# Specify the prefix for Redis keys:
|
113
|
+
# config.redis_namespace = "sufia"
|
110
114
|
|
111
115
|
# Specify the path to the file characterization tool:
|
112
116
|
# config.fits_path = "fits.sh"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'abstract_migration_generator'
|
2
|
+
|
3
|
+
class Sufia::Models::UpdateContentBlocksGenerator < Sufia::Models::AbstractMigrationGenerator
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc """
|
7
|
+
This generator creates a database migration to add an external_key column to the content_blocks table (if the migration doesn't already exist). This allows you to associate a user_key with a featured_researcher entry.
|
8
|
+
"""
|
9
|
+
|
10
|
+
def banner
|
11
|
+
say_status("warning", "CREATING MIGRATION FILE", :yellow)
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_migrations
|
15
|
+
better_migration_template 'add_external_key_to_content_blocks.rb'
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/lib/sufia/messages.rb
CHANGED
@@ -46,22 +46,21 @@ module Sufia
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def link_to_file file
|
49
|
-
link_to(file.to_s, Sufia::Engine.routes.url_helpers.generic_file_path(file
|
49
|
+
link_to(file.to_s, Sufia::Engine.routes.url_helpers.generic_file_path(file))
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
def failure_link files
|
61
|
-
link_to I18n.t("sufia.messages.failure.multiple.link"), "#",
|
62
|
-
rel: "popover",
|
63
|
-
data: { content: file_list(files).html_safe, title: I18n.t("sufia.messages.failure.title") }
|
64
|
-
end
|
54
|
+
def success_link files
|
55
|
+
link_to I18n.t("sufia.messages.success.multiple.link"), "#",
|
56
|
+
rel: "popover",
|
57
|
+
data: { content: file_list(files).html_safe, title: I18n.t("sufia.messages.success.title") }
|
58
|
+
end
|
65
59
|
|
60
|
+
def failure_link files
|
61
|
+
link_to I18n.t("sufia.messages.failure.multiple.link"), "#",
|
62
|
+
rel: "popover",
|
63
|
+
data: { content: file_list(files).html_safe, title: I18n.t("sufia.messages.failure.title") }
|
64
|
+
end
|
66
65
|
end
|
67
66
|
end
|
data/lib/sufia/models/engine.rb
CHANGED
@@ -18,8 +18,9 @@ module Sufia
|
|
18
18
|
config.ffmpeg_path = 'ffmpeg'
|
19
19
|
config.fits_message_length = 5
|
20
20
|
config.temp_file_base = nil
|
21
|
+
config.enable_noids = true
|
21
22
|
config.minter_statefile = '/tmp/minter-state'
|
22
|
-
config.
|
23
|
+
config.redis_namespace = "sufia"
|
23
24
|
config.fits_path = "fits.sh"
|
24
25
|
config.enable_contact_form_delivery = false
|
25
26
|
config.browse_everything = nil
|
@@ -12,11 +12,11 @@ module Sufia
|
|
12
12
|
start_date = date_since_last_cache(user)
|
13
13
|
|
14
14
|
stats = {}
|
15
|
-
|
16
|
-
view_stats = FileViewStat.statistics(
|
15
|
+
file_ids_for_user(user).each do |file_id|
|
16
|
+
view_stats = FileViewStat.statistics(file_id, start_date, user.id)
|
17
17
|
stats = tally_results(view_stats, :views, stats)
|
18
18
|
|
19
|
-
dl_stats = FileDownloadStat.statistics(
|
19
|
+
dl_stats = FileDownloadStat.statistics(file_id, start_date, user.id)
|
20
20
|
stats = tally_results(dl_stats, :downloads, stats)
|
21
21
|
end
|
22
22
|
|
@@ -38,8 +38,12 @@ private
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
|
41
|
+
def file_ids_for_user(user)
|
42
|
+
ids = []
|
43
|
+
::GenericFile.find_in_batches("#{Solrizer.solr_name('depositor', :symbol)}:\"#{user.user_key}\"", fl:"id") do |group|
|
44
|
+
ids.concat group.map { |doc| doc["id"] }
|
45
|
+
end
|
46
|
+
ids
|
43
47
|
end
|
44
48
|
|
45
49
|
# For each date, add the view and download counts for this
|
data/lib/sufia/models/version.rb
CHANGED
data/sufia-models.gemspec
CHANGED
@@ -26,13 +26,13 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
27
|
spec.add_development_dependency "rake", "~> 10.3"
|
28
28
|
|
29
|
-
spec.add_dependency 'rails', '~> 4.0'
|
29
|
+
spec.add_dependency 'rails', '~> 4.0'
|
30
30
|
spec.add_dependency 'activeresource', "~> 4.0" # No longer a dependency of rails 4.0
|
31
31
|
|
32
|
-
spec.add_dependency "hydra-head", "~> 9.0
|
33
|
-
spec.add_dependency "active-fedora", "~> 9.0
|
34
|
-
spec.add_dependency "hydra-collections", "~> 4.0
|
35
|
-
spec.add_dependency 'hydra-derivatives', '~> 1.0
|
32
|
+
spec.add_dependency "hydra-head", "~> 9.0"
|
33
|
+
spec.add_dependency "active-fedora", "~> 9.0"
|
34
|
+
spec.add_dependency "hydra-collections", "~> 4.0"
|
35
|
+
spec.add_dependency 'hydra-derivatives', '~> 1.0'
|
36
36
|
spec.add_dependency 'nest', '~> 1.1'
|
37
37
|
spec.add_dependency 'resque', '~> 1.23'
|
38
38
|
spec.add_dependency 'resque-pool', '~> 0.3'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sufia-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.0.
|
4
|
+
version: 6.0.0.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -45,9 +45,6 @@ dependencies:
|
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4.0'
|
48
|
-
- - "<"
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 5.0.0
|
51
48
|
type: :runtime
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -55,9 +52,6 @@ dependencies:
|
|
55
52
|
- - "~>"
|
56
53
|
- !ruby/object:Gem::Version
|
57
54
|
version: '4.0'
|
58
|
-
- - "<"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 5.0.0
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: activeresource
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,56 +72,56 @@ dependencies:
|
|
78
72
|
requirements:
|
79
73
|
- - "~>"
|
80
74
|
- !ruby/object:Gem::Version
|
81
|
-
version: 9.0
|
75
|
+
version: '9.0'
|
82
76
|
type: :runtime
|
83
77
|
prerelease: false
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
85
79
|
requirements:
|
86
80
|
- - "~>"
|
87
81
|
- !ruby/object:Gem::Version
|
88
|
-
version: 9.0
|
82
|
+
version: '9.0'
|
89
83
|
- !ruby/object:Gem::Dependency
|
90
84
|
name: active-fedora
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
92
86
|
requirements:
|
93
87
|
- - "~>"
|
94
88
|
- !ruby/object:Gem::Version
|
95
|
-
version: 9.0
|
89
|
+
version: '9.0'
|
96
90
|
type: :runtime
|
97
91
|
prerelease: false
|
98
92
|
version_requirements: !ruby/object:Gem::Requirement
|
99
93
|
requirements:
|
100
94
|
- - "~>"
|
101
95
|
- !ruby/object:Gem::Version
|
102
|
-
version: 9.0
|
96
|
+
version: '9.0'
|
103
97
|
- !ruby/object:Gem::Dependency
|
104
98
|
name: hydra-collections
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
106
100
|
requirements:
|
107
101
|
- - "~>"
|
108
102
|
- !ruby/object:Gem::Version
|
109
|
-
version: 4.0
|
103
|
+
version: '4.0'
|
110
104
|
type: :runtime
|
111
105
|
prerelease: false
|
112
106
|
version_requirements: !ruby/object:Gem::Requirement
|
113
107
|
requirements:
|
114
108
|
- - "~>"
|
115
109
|
- !ruby/object:Gem::Version
|
116
|
-
version: 4.0
|
110
|
+
version: '4.0'
|
117
111
|
- !ruby/object:Gem::Dependency
|
118
112
|
name: hydra-derivatives
|
119
113
|
requirement: !ruby/object:Gem::Requirement
|
120
114
|
requirements:
|
121
115
|
- - "~>"
|
122
116
|
- !ruby/object:Gem::Version
|
123
|
-
version: 1.0
|
117
|
+
version: '1.0'
|
124
118
|
type: :runtime
|
125
119
|
prerelease: false
|
126
120
|
version_requirements: !ruby/object:Gem::Requirement
|
127
121
|
requirements:
|
128
122
|
- - "~>"
|
129
123
|
- !ruby/object:Gem::Version
|
130
|
-
version: 1.0
|
124
|
+
version: '1.0'
|
131
125
|
- !ruby/object:Gem::Dependency
|
132
126
|
name: nest
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -321,12 +315,12 @@ files:
|
|
321
315
|
- app/jobs/characterize_job.rb
|
322
316
|
- app/jobs/create_derivatives_job.rb
|
323
317
|
- app/jobs/import_url_job.rb
|
318
|
+
- app/jobs/ingest_local_file_job.rb
|
324
319
|
- app/jobs/resolrize_job.rb
|
325
320
|
- app/models/batch.rb
|
326
321
|
- app/models/checksum_audit_log.rb
|
327
|
-
- app/models/collection.rb
|
328
322
|
- app/models/concerns/sufia/ability.rb
|
329
|
-
- app/models/concerns/sufia/
|
323
|
+
- app/models/concerns/sufia/collection_behavior.rb
|
330
324
|
- app/models/concerns/sufia/file_stat_utils.rb
|
331
325
|
- app/models/concerns/sufia/generic_file.rb
|
332
326
|
- app/models/concerns/sufia/generic_file/batches.rb
|
@@ -366,6 +360,7 @@ files:
|
|
366
360
|
- app/models/subject_local_authority_entry.rb
|
367
361
|
- app/models/sufia/avatar_uploader.rb
|
368
362
|
- app/models/sufia/avatar_validator.rb
|
363
|
+
- app/models/sufia/collection.rb
|
369
364
|
- app/models/sufia/download.rb
|
370
365
|
- app/models/sufia/orcid_validator.rb
|
371
366
|
- app/models/sufia/pageview.rb
|
@@ -376,7 +371,6 @@ files:
|
|
376
371
|
- app/services/sufia/generic_file_audit_service.rb
|
377
372
|
- app/services/sufia/generic_file_indexing_service.rb
|
378
373
|
- app/services/sufia/id_service.rb
|
379
|
-
- app/services/sufia/indexing_service.rb
|
380
374
|
- app/services/sufia/noid.rb
|
381
375
|
- app/services/sufia/repository_audit_service.rb
|
382
376
|
- config/locales/sufia.en.yml
|
@@ -386,6 +380,7 @@ files:
|
|
386
380
|
- lib/generators/sufia/models/install_generator.rb
|
387
381
|
- lib/generators/sufia/models/orcid_field_generator.rb
|
388
382
|
- lib/generators/sufia/models/proxies_generator.rb
|
383
|
+
- lib/generators/sufia/models/templates/app/models/collection.rb
|
389
384
|
- lib/generators/sufia/models/templates/config/analytics.yml
|
390
385
|
- lib/generators/sufia/models/templates/config/clamav.rb
|
391
386
|
- lib/generators/sufia/models/templates/config/mailboxer.rb
|
@@ -400,6 +395,7 @@ files:
|
|
400
395
|
- lib/generators/sufia/models/templates/config/sufia.rb
|
401
396
|
- lib/generators/sufia/models/templates/migrations/acts_as_follower_migration.rb
|
402
397
|
- lib/generators/sufia/models/templates/migrations/add_avatars_to_users.rb
|
398
|
+
- lib/generators/sufia/models/templates/migrations/add_external_key_to_content_blocks.rb
|
403
399
|
- lib/generators/sufia/models/templates/migrations/add_groups_to_users.rb
|
404
400
|
- lib/generators/sufia/models/templates/migrations/add_ldap_attrs_to_user.rb
|
405
401
|
- lib/generators/sufia/models/templates/migrations/add_linkedin_to_users.rb
|
@@ -418,6 +414,7 @@ files:
|
|
418
414
|
- lib/generators/sufia/models/templates/migrations/create_trophies.rb
|
419
415
|
- lib/generators/sufia/models/templates/migrations/create_user_stats.rb
|
420
416
|
- lib/generators/sufia/models/templates/migrations/create_version_committers.rb
|
417
|
+
- lib/generators/sufia/models/update_content_blocks_generator.rb
|
421
418
|
- lib/generators/sufia/models/upgrade400_generator.rb
|
422
419
|
- lib/generators/sufia/models/usagestats_generator.rb
|
423
420
|
- lib/generators/sufia/models/user_stats_generator.rb
|
@@ -461,7 +458,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
461
458
|
version: 1.3.1
|
462
459
|
requirements: []
|
463
460
|
rubyforge_project:
|
464
|
-
rubygems_version: 2.
|
461
|
+
rubygems_version: 2.2.2
|
465
462
|
signing_key:
|
466
463
|
specification_version: 4
|
467
464
|
summary: Models and services for sufia
|
data/app/models/collection.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module Sufia
|
2
|
-
class IndexingService < ActiveFedora::IndexingService
|
3
|
-
|
4
|
-
# Unstemmed, searchable, stored
|
5
|
-
def self.noid_indexer
|
6
|
-
@noid_indexer ||= Solrizer::Descriptor.new(:text, :indexed, :stored)
|
7
|
-
end
|
8
|
-
|
9
|
-
def generate_solr_document
|
10
|
-
super.tap do |solr_doc|
|
11
|
-
solr_doc[Solrizer.solr_name("noid", Sufia::IndexingService.noid_indexer)] = object.noid
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|