sufia-models 6.3.0 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/actors/sufia/generic_file/actor.rb +25 -2
- data/app/jobs/batch_update_job.rb +78 -41
- data/app/models/concerns/sufia/generic_file/metadata.rb +18 -18
- data/app/models/concerns/sufia/generic_file/querying.rb +8 -0
- data/app/models/geo_names_resource.rb +1 -1
- data/app/services/sufia/generic_file_csv_service.rb +41 -0
- data/app/services/sufia/generic_file_indexing_service.rb +11 -0
- data/app/services/sufia/lock_manager.rb +43 -0
- data/lib/generators/sufia/models/citation_config_generator.rb +22 -0
- data/lib/generators/sufia/models/geonames_username_config_generator.rb +20 -0
- data/lib/generators/sufia/models/install_generator.rb +6 -0
- data/lib/generators/sufia/models/lock_manager_config_generator.rb +28 -0
- data/lib/generators/sufia/models/minimagick_config_generator.rb +18 -0
- data/lib/generators/sufia/models/templates/config/mini_magick.rb +5 -0
- data/lib/generators/sufia/models/templates/config/sufia.rb +22 -0
- data/lib/generators/sufia/models/upload_to_collection_config_generator.rb +22 -0
- data/lib/sufia/models/engine.rb +6 -0
- data/lib/sufia/models/version.rb +1 -1
- data/sufia-models.gemspec +3 -2
- metadata +28 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8330c2299c06f65449dfb7ce36e3d011667d4c2f
|
4
|
+
data.tar.gz: cd37e02c1d1d2be11c039430332a5bf103b2f6ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5021bfd98929e7fcbbc1619274308ca853343fc38f974623d809242aa8c6b45d2cfd7897f9cba4df5eb986fc51e060c742c3a0f94a0c63afaa8034dc94bb285e
|
7
|
+
data.tar.gz: 8cbbefc5ff16a747880dea64437c343b7420bc103d50db813e632f6288d51d4d8098a2876c9cffacaa6f8c930b4812817b9ba91f4c0ee76016836e2055d04206
|
@@ -27,15 +27,27 @@ module Sufia::GenericFile
|
|
27
27
|
yield(generic_file) if block_given?
|
28
28
|
end
|
29
29
|
|
30
|
-
def create_content(file, file_name, path, mime_type)
|
30
|
+
def create_content(file, file_name, path, mime_type, collection_id = nil)
|
31
31
|
generic_file.add_file(file, path: path, original_name: file_name, mime_type: mime_type)
|
32
32
|
generic_file.label ||= file_name
|
33
33
|
generic_file.title = [generic_file.label] if generic_file.title.blank?
|
34
|
-
save_characterize_and_record_committer do
|
34
|
+
saved = save_characterize_and_record_committer do
|
35
35
|
if Sufia.config.respond_to?(:after_create_content)
|
36
36
|
Sufia.config.after_create_content.call(generic_file, user)
|
37
37
|
end
|
38
38
|
end
|
39
|
+
add_file_to_collection(collection_id) if saved
|
40
|
+
saved
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_file_to_collection(collection_id)
|
44
|
+
return if collection_id.nil? || collection_id == "-1"
|
45
|
+
collection = Collection.find(collection_id)
|
46
|
+
return unless user.can? :edit, collection
|
47
|
+
acquire_lock_for(collection_id) do
|
48
|
+
collection.add_members [generic_file.id]
|
49
|
+
collection.save
|
50
|
+
end
|
39
51
|
end
|
40
52
|
|
41
53
|
def revert_content(revision_id)
|
@@ -130,5 +142,16 @@ module Sufia::GenericFile
|
|
130
142
|
featured_work = FeaturedWork.find_by_generic_file_id(generic_file.id)
|
131
143
|
featured_work.destroy unless featured_work.nil?
|
132
144
|
end
|
145
|
+
|
146
|
+
def acquire_lock_for(lock_key, &block)
|
147
|
+
lock_manager.lock(lock_key, &block)
|
148
|
+
end
|
149
|
+
|
150
|
+
def lock_manager
|
151
|
+
@lock_manager ||= Sufia::LockManager.new(
|
152
|
+
Sufia.config.lock_time_to_live,
|
153
|
+
Sufia.config.lock_retry_count,
|
154
|
+
Sufia.config.lock_retry_delay)
|
155
|
+
end
|
133
156
|
end
|
134
157
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# Resque job that updates files uploaded via the BatchController
|
1
2
|
class BatchUpdateJob
|
2
3
|
include Hydra::PermissionsQuery
|
3
4
|
include Sufia::Messages
|
@@ -6,67 +7,103 @@ class BatchUpdateJob
|
|
6
7
|
:batch_update
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
+
attr_reader :login, :batch_id, :title, :file_attributes, :visibility
|
11
|
+
attr_writer :saved, :denied
|
10
12
|
|
13
|
+
# Called from BatchController
|
14
|
+
# @param [String] login of the current user
|
15
|
+
# @param [String] batch_id for the Batch object containing the files
|
16
|
+
# @param [Hash] title contains the filename of each file
|
17
|
+
# @param [Hash] file_attributes applied to every file in the batch
|
18
|
+
# @param [String] visibility
|
11
19
|
def initialize(login, batch_id, title, file_attributes, visibility)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
self.saved = []
|
18
|
-
self.denied = []
|
20
|
+
@login = login
|
21
|
+
@batch_id = batch_id
|
22
|
+
@title = title || {}
|
23
|
+
@file_attributes = file_attributes
|
24
|
+
@visibility = visibility
|
19
25
|
end
|
20
26
|
|
21
27
|
def run
|
22
|
-
batch
|
23
|
-
user = User.find_by_user_key(login)
|
24
|
-
|
25
|
-
batch.generic_files.each do |gf|
|
26
|
-
update_file(gf, user)
|
27
|
-
end
|
28
|
-
|
28
|
+
batch.generic_files.each { |gf| update_file(gf) }
|
29
29
|
batch.update(status: ["Complete"])
|
30
|
-
|
31
|
-
if denied.empty?
|
32
|
-
send_user_success_message(user, batch) unless saved.empty?
|
33
|
-
else
|
34
|
-
send_user_failure_message(user, batch)
|
35
|
-
end
|
30
|
+
send_user_message
|
36
31
|
end
|
37
32
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
return
|
43
|
-
end
|
33
|
+
# Updates the metadata for one file in the batch. Override this method if you wish to perform
|
34
|
+
# additional operations to these files.
|
35
|
+
# @param [GenericFile] gf
|
36
|
+
def apply_metadata(gf)
|
44
37
|
gf.title = title[gf.id] if title[gf.id]
|
45
38
|
gf.attributes = file_attributes
|
46
39
|
gf.visibility = visibility
|
40
|
+
end
|
47
41
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
save_tries += 1
|
53
|
-
ActiveFedora::Base.logger.warn "BatchUpdateJob caught RSOLR error on #{gf.id}: #{error.inspect}"
|
54
|
-
# fail for good if the tries is greater than 3
|
55
|
-
raise error if save_tries >= 3
|
56
|
-
sleep 0.01
|
57
|
-
retry
|
58
|
-
end #
|
42
|
+
# Queues jobs to run on each file. By default, this includes ContentUpdateEventJob, but
|
43
|
+
# can be augmented with additional custom jobs
|
44
|
+
# @param [GenericFile] gf
|
45
|
+
def queue_additional_jobs(gf)
|
59
46
|
Sufia.queue.push(ContentUpdateEventJob.new(gf.id, login))
|
60
|
-
saved << gf
|
61
47
|
end
|
62
48
|
|
63
|
-
def send_user_success_message
|
49
|
+
def send_user_success_message
|
64
50
|
message = saved.count > 1 ? multiple_success(batch.id, saved) : single_success(batch.id, saved.first)
|
65
51
|
User.batchuser.send_message(user, message, success_subject, false)
|
66
52
|
end
|
67
53
|
|
68
|
-
def send_user_failure_message
|
54
|
+
def send_user_failure_message
|
69
55
|
message = denied.count > 1 ? multiple_failure(batch.id, denied) : single_failure(batch.id, denied.first)
|
70
56
|
User.batchuser.send_message(user, message, failure_subject, false)
|
71
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def update_file(gf, you = nil)
|
62
|
+
you ||= user
|
63
|
+
unless you.can? :edit, gf
|
64
|
+
ActiveFedora::Base.logger.error "User #{you.user_key} DENIED access to #{gf.id}!"
|
65
|
+
denied << gf
|
66
|
+
return
|
67
|
+
end
|
68
|
+
|
69
|
+
apply_metadata(gf)
|
70
|
+
|
71
|
+
save_tries = 0
|
72
|
+
begin
|
73
|
+
gf.save!
|
74
|
+
rescue RSolr::Error::Http => error
|
75
|
+
save_tries += 1
|
76
|
+
ActiveFedora::Base.logger.warn "BatchUpdateJob caught RSOLR error on #{gf.id}: #{error.inspect}"
|
77
|
+
# fail for good if the tries is greater than 3
|
78
|
+
raise error if save_tries >= 3
|
79
|
+
sleep 0.01
|
80
|
+
retry
|
81
|
+
end
|
82
|
+
queue_additional_jobs(gf)
|
83
|
+
saved << gf
|
84
|
+
end
|
85
|
+
|
86
|
+
def send_user_message
|
87
|
+
if denied.empty?
|
88
|
+
send_user_success_message unless saved.empty?
|
89
|
+
else
|
90
|
+
send_user_failure_message
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def batch
|
95
|
+
@batch ||= Batch.find_or_create(batch_id)
|
96
|
+
end
|
97
|
+
|
98
|
+
def user
|
99
|
+
@user ||= User.find_by_user_key(login)
|
100
|
+
end
|
101
|
+
|
102
|
+
def saved
|
103
|
+
@saved ||= []
|
104
|
+
end
|
105
|
+
|
106
|
+
def denied
|
107
|
+
@denied ||= []
|
108
|
+
end
|
72
109
|
end
|
@@ -18,33 +18,33 @@ module Sufia
|
|
18
18
|
index.as :symbol
|
19
19
|
end
|
20
20
|
|
21
|
-
property :part_of, predicate:
|
22
|
-
property :resource_type, predicate:
|
21
|
+
property :part_of, predicate: RDF::Vocab::DC.isPartOf
|
22
|
+
property :resource_type, predicate: RDF::Vocab::DC.type do |index|
|
23
23
|
index.as :stored_searchable, :facetable
|
24
24
|
end
|
25
|
-
property :title, predicate:
|
25
|
+
property :title, predicate: RDF::Vocab::DC.title do |index|
|
26
26
|
index.as :stored_searchable, :facetable
|
27
27
|
end
|
28
|
-
property :creator, predicate:
|
28
|
+
property :creator, predicate: RDF::Vocab::DC.creator do |index|
|
29
29
|
index.as :stored_searchable, :facetable
|
30
30
|
end
|
31
|
-
property :contributor, predicate:
|
31
|
+
property :contributor, predicate: RDF::Vocab::DC.contributor do |index|
|
32
32
|
index.as :stored_searchable, :facetable
|
33
33
|
end
|
34
|
-
property :description, predicate:
|
34
|
+
property :description, predicate: RDF::Vocab::DC.description do |index|
|
35
35
|
index.type :text
|
36
36
|
index.as :stored_searchable
|
37
37
|
end
|
38
|
-
property :tag, predicate:
|
38
|
+
property :tag, predicate: RDF::Vocab::DC.relation do |index|
|
39
39
|
index.as :stored_searchable, :facetable
|
40
40
|
end
|
41
|
-
property :rights, predicate:
|
41
|
+
property :rights, predicate: RDF::Vocab::DC.rights do |index|
|
42
42
|
index.as :stored_searchable
|
43
43
|
end
|
44
|
-
property :publisher, predicate:
|
44
|
+
property :publisher, predicate: RDF::Vocab::DC.publisher do |index|
|
45
45
|
index.as :stored_searchable, :facetable
|
46
46
|
end
|
47
|
-
property :date_created, predicate:
|
47
|
+
property :date_created, predicate: RDF::Vocab::DC.created do |index|
|
48
48
|
index.as :stored_searchable
|
49
49
|
end
|
50
50
|
|
@@ -53,34 +53,34 @@ module Sufia
|
|
53
53
|
# fedora's system created date will reflect the date when the record
|
54
54
|
# was created in fedora4, but the date_uploaded will preserve the
|
55
55
|
# original creation date from the old repository.
|
56
|
-
property :date_uploaded, predicate:
|
56
|
+
property :date_uploaded, predicate: RDF::Vocab::DC.dateSubmitted, multiple: false do |index|
|
57
57
|
index.type :date
|
58
58
|
index.as :stored_sortable
|
59
59
|
end
|
60
60
|
|
61
|
-
property :date_modified, predicate:
|
61
|
+
property :date_modified, predicate: RDF::Vocab::DC.modified, multiple: false do |index|
|
62
62
|
index.type :date
|
63
63
|
index.as :stored_sortable
|
64
64
|
end
|
65
|
-
property :subject, predicate:
|
65
|
+
property :subject, predicate: RDF::Vocab::DC.subject do |index|
|
66
66
|
index.as :stored_searchable, :facetable
|
67
67
|
end
|
68
|
-
property :language, predicate:
|
68
|
+
property :language, predicate: RDF::Vocab::DC.language do |index|
|
69
69
|
index.as :stored_searchable, :facetable
|
70
70
|
end
|
71
|
-
property :identifier, predicate:
|
71
|
+
property :identifier, predicate: RDF::Vocab::DC.identifier do |index|
|
72
72
|
index.as :stored_searchable
|
73
73
|
end
|
74
|
-
property :based_near, predicate:
|
74
|
+
property :based_near, predicate: RDF::Vocab::FOAF.based_near do |index|
|
75
75
|
index.as :stored_searchable, :facetable
|
76
76
|
end
|
77
77
|
property :related_url, predicate: ::RDF::RDFS.seeAlso do |index|
|
78
78
|
index.as :stored_searchable
|
79
79
|
end
|
80
|
-
property :bibliographic_citation, predicate:
|
80
|
+
property :bibliographic_citation, predicate: RDF::Vocab::DC.bibliographicCitation do |index|
|
81
81
|
index.as :stored_searchable
|
82
82
|
end
|
83
|
-
property :source, predicate:
|
83
|
+
property :source, predicate: RDF::Vocab::DC.source do |index|
|
84
84
|
index.as :stored_searchable
|
85
85
|
end
|
86
86
|
|
@@ -38,6 +38,14 @@ module Sufia
|
|
38
38
|
where Solrizer.solr_name('read_access_group', :symbol) => access_level
|
39
39
|
end
|
40
40
|
|
41
|
+
def where_digest_is(digest_string)
|
42
|
+
where Solrizer.solr_name('digest', :symbol) => urnify(digest_string)
|
43
|
+
end
|
44
|
+
|
45
|
+
def urnify(digest_string)
|
46
|
+
"urn:sha1:#{digest_string}"
|
47
|
+
end
|
48
|
+
|
41
49
|
def date_format
|
42
50
|
"%Y-%m-%dT%H:%M:%SZ"
|
43
51
|
end
|
@@ -13,6 +13,6 @@ class GeoNamesResource < ActiveResource::Base
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.find_location(location)
|
16
|
-
GeoNamesResource.find(:all, params: { q: location, username:
|
16
|
+
GeoNamesResource.find(:all, params: { q: location, username: Sufia.config.geonames_username, maxRows: 10 })
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Sufia
|
2
|
+
#
|
3
|
+
# Generates CSV from a Generic_File
|
4
|
+
#
|
5
|
+
# @attr_reader [GenericFile] generic_file file that will be examined to generate the CSVs
|
6
|
+
# @attr_reader [Array] terms list of terms that will be output in CSV form
|
7
|
+
# @attr_reader [String] multi_value_separator separator for terms that have more than one value
|
8
|
+
class GenericFileCSVService
|
9
|
+
attr_reader :generic_file, :terms, :multi_value_separator
|
10
|
+
|
11
|
+
# @param [GenericFile] generic_file file that will be examined to generate the CSVs
|
12
|
+
# @param [Array] terms list of terms that will be output in CSV form
|
13
|
+
# defaults if nil to list below
|
14
|
+
# @param [String] multi_value_separator separator for terms that have more than one value
|
15
|
+
# defaults to '|'
|
16
|
+
def initialize(file, terms = nil, multi_value_separator = '|')
|
17
|
+
@generic_file = file
|
18
|
+
@terms = terms
|
19
|
+
@terms ||= [:id, :title, :depositor, :creator, :visibility, :resource_type, :rights, :file_format]
|
20
|
+
@multi_value_separator = multi_value_separator
|
21
|
+
end
|
22
|
+
|
23
|
+
# provide csv version of the GenericFile
|
24
|
+
def csv
|
25
|
+
::CSV.generate do |csv|
|
26
|
+
csv << terms.map do |term|
|
27
|
+
values = generic_file.send(term)
|
28
|
+
values = Array(values) # make sure we have an array
|
29
|
+
values.join(multi_value_separator)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# provide csv header line for a GenericFile
|
35
|
+
def csv_header
|
36
|
+
::CSV.generate do |csv|
|
37
|
+
csv << terms
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -9,7 +9,18 @@ module Sufia
|
|
9
9
|
solr_doc[Solrizer.solr_name('file_format', :facetable)] = object.file_format
|
10
10
|
solr_doc['all_text_timv'] = object.full_text.content
|
11
11
|
solr_doc[Solrizer.solr_name('file_size', STORED_INTEGER)] = object.content.size.to_i
|
12
|
+
# Index the Fedora-generated SHA1 digest to create a linkage
|
13
|
+
# between files on disk (in fcrepo.binary-store-path) and objects
|
14
|
+
# in the repository.
|
15
|
+
solr_doc[Solrizer.solr_name('digest', :symbol)] = digest_from_content
|
12
16
|
end
|
13
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def digest_from_content
|
22
|
+
return unless object.content.has_content?
|
23
|
+
object.content.digest.first.to_s
|
24
|
+
end
|
14
25
|
end
|
15
26
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'redlock'
|
2
|
+
module Sufia
|
3
|
+
class LockManager
|
4
|
+
class UnableToAcquireLockError < StandardError; end
|
5
|
+
|
6
|
+
# TODO: This file is the same as curation_concerns/curation_concerns-models/app/services/curation_concerns/lock_manager.rb.
|
7
|
+
# During the merge of Sufia to use Curation Concerns, this file may be replaced by the Curation Concerns version.
|
8
|
+
|
9
|
+
attr_reader :client
|
10
|
+
|
11
|
+
# @param [Fixnum] time_to_live How long to hold the lock in milliseconds
|
12
|
+
# @param [Fixnum] retry_count How many times to retry to acquire the lock before raising UnableToAcquireLockError
|
13
|
+
# @param [Fixnum] retry_delay Maximum wait time in milliseconds before retrying. Wait time is a random value between 0 and retry_delay.
|
14
|
+
def initialize(time_to_live, retry_count, retry_delay)
|
15
|
+
@ttl = time_to_live
|
16
|
+
@client = Redlock::Client.new([uri], retry_count: retry_count, retry_delay: retry_delay)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Blocks until lock is acquired or timeout.
|
20
|
+
def lock(key)
|
21
|
+
client.lock(key, @ttl) do |locked|
|
22
|
+
if locked
|
23
|
+
yield
|
24
|
+
else
|
25
|
+
raise UnableToAcquireLockError
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def uri
|
33
|
+
@uri ||= begin
|
34
|
+
opts = options
|
35
|
+
URI("#{opts[:scheme]}://#{opts[:host]}:#{opts[:port]}").to_s
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def options
|
40
|
+
::Resque.redis.redis.client.options
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class Sufia::Models::CitationConfigGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc """
|
7
|
+
This Generator makes the following changes to your application:
|
8
|
+
1. Updates existing sufia.rb initializer to include a citation configuration
|
9
|
+
"""
|
10
|
+
|
11
|
+
def banner
|
12
|
+
say_status("info", "ADDING CITATIONS OPTION TO SUFIA CONFIG", :blue)
|
13
|
+
end
|
14
|
+
|
15
|
+
def inject_config_initializer
|
16
|
+
inject_into_file 'config/initializers/sufia.rb', before: "# Where to store tempfiles, leave blank for the system temp directory (e.g. /tmp)" do
|
17
|
+
"# Enables a link to the citations page for a generic_file.\n" +
|
18
|
+
"# Default is false\n" +
|
19
|
+
"# config.citations = false\n"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class Sufia::Models::GeonamesUsernameConfigGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc """
|
7
|
+
This Generator makes the following changes to your application:
|
8
|
+
1. Updates existing sufia.rb initializer to include a geonames_username configuration
|
9
|
+
"""
|
10
|
+
|
11
|
+
def banner
|
12
|
+
say_status("info", "ADDING GEONAMES_USERNAME OPTION TO SUFIA CONFIG", :blue)
|
13
|
+
end
|
14
|
+
|
15
|
+
def inject_config_initializer
|
16
|
+
inject_into_file 'config/initializers/sufia.rb', before: "# Where to store tempfiles, leave blank for the system temp directory (e.g. /tmp)" do
|
17
|
+
"config.geonames_username = ''\n"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -15,6 +15,7 @@ This generator makes the following changes to your application:
|
|
15
15
|
8. Runs cached stats generator
|
16
16
|
9. Runs ORCID field generator
|
17
17
|
10. Runs user stats generator
|
18
|
+
11. Generates mini-magick config
|
18
19
|
"""
|
19
20
|
def banner
|
20
21
|
say_status("info", "GENERATING SUFIA MODELS", :blue)
|
@@ -109,4 +110,9 @@ This generator makes the following changes to your application:
|
|
109
110
|
def clamav
|
110
111
|
generate 'sufia:models:clamav'
|
111
112
|
end
|
113
|
+
|
114
|
+
# Add mini-magick configuration
|
115
|
+
def minimagick_config
|
116
|
+
generate 'sufia:models:minimagick_config'
|
117
|
+
end
|
112
118
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class Sufia::Models::LockManagerConfigGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc """
|
7
|
+
This Generator makes the following changes to your application:
|
8
|
+
1. Updates existing sufia.rb initializer to include lock manager configurations
|
9
|
+
"""
|
10
|
+
|
11
|
+
def banner
|
12
|
+
say_status("info", "ADDING LOCK MANAGER OPTION TO SUFIA CONFIG", :blue)
|
13
|
+
end
|
14
|
+
|
15
|
+
def inject_config_initializer
|
16
|
+
inject_into_file 'config/initializers/sufia.rb', before: "# Where to store tempfiles, leave blank for the system temp directory (e.g. /tmp)" do
|
17
|
+
"\n # How many times to retry to acquire the lock before raising UnableToAcquireLockError\n" +
|
18
|
+
" # Default is 600ms\n" +
|
19
|
+
" # config.lock_retry_count = 600 # Up to 2 minutes of trying at intervals up to 200ms\n" +
|
20
|
+
"\n # How long to hold the lock in milliseconds\n" +
|
21
|
+
" # Default is 60_000ms\n" +
|
22
|
+
" # config.lock_time_to_live = 60_000 # milliseconds\n" +
|
23
|
+
"\n # Maximum wait time in milliseconds before retrying. Wait time is a random value between 0 and retry_delay.\n" +
|
24
|
+
" # Default is 200ms\n" +
|
25
|
+
" # config.lock_retry_delay = 200 # milliseconds\n\n"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class Sufia::Models::MinimagickConfigGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc """
|
7
|
+
This Generator makes the following changes to your application:
|
8
|
+
1. Creates new mini_magick.rb initializer configuring use of posix-spawn
|
9
|
+
"""
|
10
|
+
|
11
|
+
def banner
|
12
|
+
say_status("info", "ADDING MINIMAGICK CONFIG", :blue)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_configuration_file
|
16
|
+
copy_file 'config/mini_magick.rb', 'config/initializers/mini_magick.rb'
|
17
|
+
end
|
18
|
+
end
|
@@ -91,6 +91,26 @@ Sufia.config do |config|
|
|
91
91
|
# Specify a date you wish to start collecting Google Analytic statistics for.
|
92
92
|
# config.analytic_start_date = DateTime.new(2014,9,10)
|
93
93
|
|
94
|
+
# Enables a link to the citations page for a generic_file.
|
95
|
+
# Default is false
|
96
|
+
# config.citations = false
|
97
|
+
|
98
|
+
# Enables a select menu on the batch upload page to select a collection into which to add newly uploaded files.
|
99
|
+
# Default is false
|
100
|
+
# config.upload_to_collection = false
|
101
|
+
|
102
|
+
# How many times to retry to acquire the lock before raising UnableToAcquireLockError
|
103
|
+
# Default is 600ms
|
104
|
+
# config.lock_retry_count = 600 # Up to 2 minutes of trying at intervals up to 200ms
|
105
|
+
|
106
|
+
# How long to hold the lock in milliseconds
|
107
|
+
# Default is 60_000ms
|
108
|
+
# config.lock_time_to_live = 60_000 # milliseconds
|
109
|
+
|
110
|
+
# Maximum wait time in milliseconds before retrying. Wait time is a random value between 0 and retry_delay.
|
111
|
+
# Default is 200ms
|
112
|
+
# config.lock_retry_delay = 200 # milliseconds
|
113
|
+
|
94
114
|
# Where to store tempfiles, leave blank for the system temp directory (e.g. /tmp)
|
95
115
|
# config.temp_file_base = '/home/developer1'
|
96
116
|
|
@@ -132,6 +152,8 @@ Sufia.config do |config|
|
|
132
152
|
# NOTE: if you have always sent analytics to GA for downloads and page views leave this commented out
|
133
153
|
# config.analytic_start_date = DateTime.new(2014,9,10)
|
134
154
|
|
155
|
+
config.geonames_username = ''
|
156
|
+
|
135
157
|
# If browse-everything has been configured, load the configs. Otherwise, set to nil.
|
136
158
|
begin
|
137
159
|
if defined? BrowseEverything
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class Sufia::Models::UploadToCollectionConfigGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc """
|
7
|
+
This Generator makes the following changes to your application:
|
8
|
+
1. Updates existing sufia.rb initializer to include a update_to_collection configuration
|
9
|
+
"""
|
10
|
+
|
11
|
+
def banner
|
12
|
+
say_status("info", "ADDING UPLOAD_TO_COLLECTION OPTION TO SUFIA CONFIG", :blue)
|
13
|
+
end
|
14
|
+
|
15
|
+
def inject_config_initializer
|
16
|
+
inject_into_file 'config/initializers/sufia.rb', before: "# Where to store tempfiles, leave blank for the system temp directory (e.g. /tmp)" do
|
17
|
+
"# Enables a select menu on the batch upload page to select a collection into which to add newly uploaded files.\n" +
|
18
|
+
"# Default is false\n" +
|
19
|
+
"# config.upload_to_collection = false\n"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/sufia/models/engine.rb
CHANGED
@@ -24,11 +24,17 @@ module Sufia
|
|
24
24
|
config.browse_everything = nil
|
25
25
|
config.enable_local_ingest = nil
|
26
26
|
config.analytics = false
|
27
|
+
config.citations = false
|
28
|
+
config.upload_to_collection = false
|
29
|
+
config.lock_retry_count = 600 # Up to 2 minutes of trying at intervals up to 200ms
|
30
|
+
config.lock_time_to_live = 60_000 # milliseconds
|
31
|
+
config.lock_retry_delay = 200 # milliseconds
|
27
32
|
config.queue = Sufia::Resque::Queue
|
28
33
|
config.max_notifications_for_dashboard = 5
|
29
34
|
config.activity_to_show_default_seconds_since_now = 24 * 60 * 60
|
30
35
|
config.arkivo_api = false
|
31
36
|
config.retry_unless_sleep = 0.0
|
37
|
+
config.geonames_username = ""
|
32
38
|
|
33
39
|
# Noid identifiers
|
34
40
|
config.enable_noids = true
|
data/lib/sufia/models/version.rb
CHANGED
data/sufia-models.gemspec
CHANGED
@@ -30,8 +30,8 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency 'activeresource', "~> 4.0" # No longer a dependency of rails 4.0
|
31
31
|
|
32
32
|
spec.add_dependency "hydra-head", "~> 9.0"
|
33
|
-
spec.add_dependency "active-fedora", "~> 9.
|
34
|
-
spec.add_dependency "hydra-collections", [">= 5.0.
|
33
|
+
spec.add_dependency "active-fedora", "~> 9.4"
|
34
|
+
spec.add_dependency "hydra-collections", [">= 5.0.3", "< 6.0"]
|
35
35
|
spec.add_dependency 'hydra-derivatives', '~> 1.0'
|
36
36
|
spec.add_dependency 'active_fedora-noid', '~> 1.0'
|
37
37
|
spec.add_dependency 'nest', '~> 1.1'
|
@@ -49,4 +49,5 @@ Gem::Specification.new do |spec|
|
|
49
49
|
else
|
50
50
|
spec.add_dependency 'mini_magick'
|
51
51
|
end
|
52
|
+
spec.add_dependency 'posix-spawn'
|
52
53
|
end
|
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.
|
4
|
+
version: 6.4.0
|
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-
|
11
|
+
date: 2015-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,27 +86,21 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '9.
|
90
|
-
- - ">="
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: 9.1.1
|
89
|
+
version: '9.4'
|
93
90
|
type: :runtime
|
94
91
|
prerelease: false
|
95
92
|
version_requirements: !ruby/object:Gem::Requirement
|
96
93
|
requirements:
|
97
94
|
- - "~>"
|
98
95
|
- !ruby/object:Gem::Version
|
99
|
-
version: '9.
|
100
|
-
- - ">="
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 9.1.1
|
96
|
+
version: '9.4'
|
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: 5.0.
|
103
|
+
version: 5.0.3
|
110
104
|
- - "<"
|
111
105
|
- !ruby/object:Gem::Version
|
112
106
|
version: '6.0'
|
@@ -116,7 +110,7 @@ dependencies:
|
|
116
110
|
requirements:
|
117
111
|
- - ">="
|
118
112
|
- !ruby/object:Gem::Version
|
119
|
-
version: 5.0.
|
113
|
+
version: 5.0.3
|
120
114
|
- - "<"
|
121
115
|
- !ruby/object:Gem::Version
|
122
116
|
version: '6.0'
|
@@ -308,6 +302,20 @@ dependencies:
|
|
308
302
|
- - ">="
|
309
303
|
- !ruby/object:Gem::Version
|
310
304
|
version: '0'
|
305
|
+
- !ruby/object:Gem::Dependency
|
306
|
+
name: posix-spawn
|
307
|
+
requirement: !ruby/object:Gem::Requirement
|
308
|
+
requirements:
|
309
|
+
- - ">="
|
310
|
+
- !ruby/object:Gem::Version
|
311
|
+
version: '0'
|
312
|
+
type: :runtime
|
313
|
+
prerelease: false
|
314
|
+
version_requirements: !ruby/object:Gem::Requirement
|
315
|
+
requirements:
|
316
|
+
- - ">="
|
317
|
+
- !ruby/object:Gem::Version
|
318
|
+
version: '0'
|
311
319
|
description: Models and services for sufia
|
312
320
|
email:
|
313
321
|
|
@@ -383,16 +391,22 @@ files:
|
|
383
391
|
- app/models/version_committer.rb
|
384
392
|
- app/services/sufia/analytics.rb
|
385
393
|
- app/services/sufia/generic_file_audit_service.rb
|
394
|
+
- app/services/sufia/generic_file_csv_service.rb
|
386
395
|
- app/services/sufia/generic_file_indexing_service.rb
|
396
|
+
- app/services/sufia/lock_manager.rb
|
387
397
|
- app/services/sufia/noid.rb
|
388
398
|
- app/services/sufia/repository_audit_service.rb
|
389
399
|
- config/locales/sufia.en.yml
|
390
400
|
- lib/generators/sufia/models/abstract_migration_generator.rb
|
391
401
|
- lib/generators/sufia/models/arkivo_api_generator.rb
|
392
402
|
- lib/generators/sufia/models/cached_stats_generator.rb
|
403
|
+
- lib/generators/sufia/models/citation_config_generator.rb
|
393
404
|
- lib/generators/sufia/models/clamav_generator.rb
|
394
405
|
- lib/generators/sufia/models/fulltext_generator.rb
|
406
|
+
- lib/generators/sufia/models/geonames_username_config_generator.rb
|
395
407
|
- lib/generators/sufia/models/install_generator.rb
|
408
|
+
- lib/generators/sufia/models/lock_manager_config_generator.rb
|
409
|
+
- lib/generators/sufia/models/minimagick_config_generator.rb
|
396
410
|
- lib/generators/sufia/models/orcid_field_generator.rb
|
397
411
|
- lib/generators/sufia/models/proxies_generator.rb
|
398
412
|
- lib/generators/sufia/models/templates/app/models/collection.rb
|
@@ -401,6 +415,7 @@ files:
|
|
401
415
|
- lib/generators/sufia/models/templates/config/arkivo_constraint.rb
|
402
416
|
- lib/generators/sufia/models/templates/config/clamav.rb
|
403
417
|
- lib/generators/sufia/models/templates/config/mime_types.rb
|
418
|
+
- lib/generators/sufia/models/templates/config/mini_magick.rb
|
404
419
|
- lib/generators/sufia/models/templates/config/redis.yml
|
405
420
|
- lib/generators/sufia/models/templates/config/redis_config.rb
|
406
421
|
- lib/generators/sufia/models/templates/config/resque-pool.yml
|
@@ -438,6 +453,7 @@ files:
|
|
438
453
|
- lib/generators/sufia/models/update_content_blocks_generator.rb
|
439
454
|
- lib/generators/sufia/models/upgrade400_generator.rb
|
440
455
|
- lib/generators/sufia/models/upgrade600_generator.rb
|
456
|
+
- lib/generators/sufia/models/upload_to_collection_config_generator.rb
|
441
457
|
- lib/generators/sufia/models/usagestats_generator.rb
|
442
458
|
- lib/generators/sufia/models/user_stats_generator.rb
|
443
459
|
- lib/sufia/messages.rb
|