sufia-models 6.5.0 → 6.6.0
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 +4 -13
- data/app/jobs/active_fedora_id_based_job.rb +2 -2
- data/app/jobs/audit_job.rb +2 -2
- data/app/jobs/batch_update_job.rb +1 -0
- data/app/models/batch.rb +9 -16
- data/app/models/concerns/sufia/user.rb +6 -6
- data/app/services/sufia/lock_manager.rb +4 -5
- data/app/services/sufia/lockable.rb +16 -0
- data/lib/generators/sufia/models/abstract_migration_generator.rb +5 -5
- data/lib/sufia/models/engine.rb +1 -0
- data/lib/sufia/models/utils.rb +2 -2
- data/lib/sufia/models/version.rb +1 -1
- data/sufia-models.gemspec +2 -2
- metadata +14 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5003a564167c7def27510e562932d48c1da6d9de
|
4
|
+
data.tar.gz: 042427fade03dc5c1db99556b1ba5ed5d4588497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 654344b3315b6676b8930f570551e9c80c1894a2d6cecb51720415bf670757401a9b10eba279b9e4f3f4be19b29e95c8736e49a4923d350abdccdb1f1b9df59d
|
7
|
+
data.tar.gz: ac5f4c4950ef94041df7b28f598bc429e2eca52c642877a53dbf956ac04321e0076759bc9bac329e4927e9e09935de9de3fe03ae8b7f395fe58ec0228c83c6fd
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Sufia::GenericFile
|
2
2
|
# Actions are decoupled from controller logic so that they may be called from a controller or a background job.
|
3
3
|
class Actor
|
4
|
+
include Sufia::Lockable
|
5
|
+
|
4
6
|
attr_reader :generic_file, :user
|
5
7
|
|
6
8
|
def initialize(generic_file, user)
|
@@ -42,9 +44,9 @@ module Sufia::GenericFile
|
|
42
44
|
|
43
45
|
def add_file_to_collection(collection_id)
|
44
46
|
return if collection_id.nil? || collection_id == "-1"
|
45
|
-
collection = Collection.find(collection_id)
|
46
|
-
return unless user.can? :edit, collection
|
47
47
|
acquire_lock_for(collection_id) do
|
48
|
+
collection = ::Collection.find(collection_id)
|
49
|
+
return unless user.can? :edit, collection
|
48
50
|
collection.add_members [generic_file.id]
|
49
51
|
collection.save
|
50
52
|
end
|
@@ -142,16 +144,5 @@ module Sufia::GenericFile
|
|
142
144
|
featured_work = FeaturedWork.find_by_generic_file_id(generic_file.id)
|
143
145
|
featured_work.destroy unless featured_work.nil?
|
144
146
|
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
|
156
147
|
end
|
157
148
|
end
|
@@ -13,8 +13,8 @@ class ActiveFedoraIdBasedJob
|
|
13
13
|
@object ||= ActiveFedora::Base.find(id)
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
alias generic_file object
|
17
|
+
alias generic_file_id id
|
18
18
|
|
19
19
|
def run
|
20
20
|
raise "Define #run in a subclass"
|
data/app/jobs/audit_job.rb
CHANGED
@@ -44,6 +44,7 @@ class BatchUpdateJob
|
|
44
44
|
# @param [GenericFile] gf
|
45
45
|
def queue_additional_jobs(gf)
|
46
46
|
Sufia.queue.push(ContentUpdateEventJob.new(gf.id, login))
|
47
|
+
Sufia.queue.push(ResolrizeGenericFileJob.new(gf.id)) unless Sufia.config.collection_facet.nil?
|
47
48
|
end
|
48
49
|
|
49
50
|
def send_user_success_message
|
data/app/models/batch.rb
CHANGED
@@ -2,6 +2,7 @@ class Batch < ActiveFedora::Base
|
|
2
2
|
include Hydra::AccessControls::Permissions
|
3
3
|
include Sufia::ModelMethods
|
4
4
|
include Sufia::Noid
|
5
|
+
extend Sufia::Lockable
|
5
6
|
|
6
7
|
has_many :generic_files, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
7
8
|
|
@@ -9,22 +10,14 @@ class Batch < ActiveFedora::Base
|
|
9
10
|
property :title, predicate: ::RDF::DC.title
|
10
11
|
property :status, predicate: ::RDF::DC.type
|
11
12
|
|
12
|
-
def self.find_or_create(id)
|
13
|
-
Batch.find(id)
|
14
|
-
rescue ActiveFedora::ObjectNotFoundError
|
15
|
-
safe_create(id)
|
16
|
-
end
|
17
|
-
|
18
13
|
# This method handles most race conditions gracefully.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
# then we are good to go.
|
28
|
-
Batch.find(id)
|
14
|
+
def self.find_or_create(id)
|
15
|
+
acquire_lock_for(id) do
|
16
|
+
begin
|
17
|
+
Batch.find(id)
|
18
|
+
rescue ActiveFedora::ObjectNotFoundError
|
19
|
+
Batch.create(id: id)
|
20
|
+
end
|
21
|
+
end
|
29
22
|
end
|
30
23
|
end
|
@@ -47,12 +47,12 @@ module Sufia::User
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def zotero_token=(value)
|
50
|
-
if value.blank?
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
self[:zotero_token] = if value.blank?
|
51
|
+
# Resetting the token
|
52
|
+
value
|
53
|
+
else
|
54
|
+
Marshal.dump(value)
|
55
|
+
end
|
56
56
|
end
|
57
57
|
|
58
58
|
def set_arkivo_token
|
@@ -18,13 +18,12 @@ module Sufia
|
|
18
18
|
|
19
19
|
# Blocks until lock is acquired or timeout.
|
20
20
|
def lock(key)
|
21
|
+
returned_from_block = nil
|
21
22
|
client.lock(key, @ttl) do |locked|
|
22
|
-
|
23
|
-
|
24
|
-
else
|
25
|
-
raise UnableToAcquireLockError
|
26
|
-
end
|
23
|
+
raise UnableToAcquireLockError unless locked
|
24
|
+
returned_from_block = yield
|
27
25
|
end
|
26
|
+
returned_from_block
|
28
27
|
end
|
29
28
|
|
30
29
|
private
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Sufia
|
2
|
+
module Lockable
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def acquire_lock_for(lock_key, &block)
|
6
|
+
lock_manager.lock(lock_key, &block)
|
7
|
+
end
|
8
|
+
|
9
|
+
def lock_manager
|
10
|
+
@lock_manager ||= Sufia::LockManager.new(
|
11
|
+
Sufia.config.lock_time_to_live,
|
12
|
+
Sufia.config.lock_retry_count,
|
13
|
+
Sufia.config.lock_retry_delay)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -12,11 +12,11 @@ class Sufia::Models::AbstractMigrationGenerator < Rails::Generators::Base
|
|
12
12
|
@prev_migration_nr += 1
|
13
13
|
else
|
14
14
|
last_migration = Dir[File.join(path, '*.rb')].sort.last
|
15
|
-
if last_migration
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
@prev_migration_nr = if last_migration
|
16
|
+
last_migration.sub(File.join(path, '/'), '').to_i + 1
|
17
|
+
else
|
18
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
19
|
+
end
|
20
20
|
end
|
21
21
|
@prev_migration_nr.to_s
|
22
22
|
end
|
data/lib/sufia/models/engine.rb
CHANGED
data/lib/sufia/models/utils.rb
CHANGED
@@ -22,12 +22,12 @@ module Sufia
|
|
22
22
|
# @yeild block [] code you want to run and retry
|
23
23
|
#
|
24
24
|
# @return result of the block call
|
25
|
-
def retry_unless(number_of_tries, condition, &
|
25
|
+
def retry_unless(number_of_tries, condition, &_block)
|
26
26
|
raise ArgumentError, "First argument must be an enumerator" unless number_of_tries.is_a? Enumerator
|
27
27
|
raise ArgumentError, "Second argument must be a lambda" unless condition.respond_to? :call
|
28
28
|
raise ArgumentError, "Must pass a block of code to retry" unless block_given?
|
29
29
|
number_of_tries.each do
|
30
|
-
result =
|
30
|
+
result = yield
|
31
31
|
return result unless condition.call
|
32
32
|
sleep(Sufia.config.retry_unless_sleep) if Sufia.config.retry_unless_sleep > 0
|
33
33
|
end
|
data/lib/sufia/models/version.rb
CHANGED
data/sufia-models.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
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", "
|
32
|
+
spec.add_dependency "hydra-head", "< 9.6"
|
33
33
|
spec.add_dependency "active-fedora", "~> 9.4"
|
34
34
|
spec.add_dependency "hydra-collections", [">= 5.0.3", "< 6.0"]
|
35
35
|
spec.add_dependency 'hydra-derivatives', '~> 1.0'
|
@@ -41,7 +41,7 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_dependency 'acts_as_follower', '>= 0.1.1', '< 0.3'
|
42
42
|
spec.add_dependency 'carrierwave', '~> 0.9'
|
43
43
|
spec.add_dependency 'oauth2', '~> 0.9'
|
44
|
-
spec.add_dependency 'google-api-client', '~> 0.7'
|
44
|
+
spec.add_dependency 'google-api-client', '~> 0.7', '< 0.9'
|
45
45
|
spec.add_dependency 'legato', '~> 0.3'
|
46
46
|
spec.add_dependency 'activerecord-import', '~> 0.5'
|
47
47
|
if RUBY_VERSION < '2.1.0'
|
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.6.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:
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: hydra-head
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "<"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '9.
|
75
|
+
version: '9.6'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "<"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '9.
|
82
|
+
version: '9.6'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: active-fedora
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -253,6 +253,9 @@ dependencies:
|
|
253
253
|
- - "~>"
|
254
254
|
- !ruby/object:Gem::Version
|
255
255
|
version: '0.7'
|
256
|
+
- - "<"
|
257
|
+
- !ruby/object:Gem::Version
|
258
|
+
version: '0.9'
|
256
259
|
type: :runtime
|
257
260
|
prerelease: false
|
258
261
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -260,6 +263,9 @@ dependencies:
|
|
260
263
|
- - "~>"
|
261
264
|
- !ruby/object:Gem::Version
|
262
265
|
version: '0.7'
|
266
|
+
- - "<"
|
267
|
+
- !ruby/object:Gem::Version
|
268
|
+
version: '0.9'
|
263
269
|
- !ruby/object:Gem::Dependency
|
264
270
|
name: legato
|
265
271
|
requirement: !ruby/object:Gem::Requirement
|
@@ -395,6 +401,7 @@ files:
|
|
395
401
|
- app/services/sufia/generic_file_csv_service.rb
|
396
402
|
- app/services/sufia/generic_file_indexing_service.rb
|
397
403
|
- app/services/sufia/lock_manager.rb
|
404
|
+
- app/services/sufia/lockable.rb
|
398
405
|
- app/services/sufia/noid.rb
|
399
406
|
- app/services/sufia/repository_audit_service.rb
|
400
407
|
- config/locales/sufia.en.yml
|
@@ -500,7 +507,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
500
507
|
version: '0'
|
501
508
|
requirements: []
|
502
509
|
rubyforge_project:
|
503
|
-
rubygems_version: 2.
|
510
|
+
rubygems_version: 2.2.2
|
504
511
|
signing_key:
|
505
512
|
specification_version: 4
|
506
513
|
summary: Models and services for sufia
|