curation_concerns-models 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3519b3ed462c460a07f19055e6c852cc5a062b33
4
- data.tar.gz: 4e3956164fe04bc1209f6dbe683c1c8a0ab245c9
3
+ metadata.gz: a1dc6348bb2734470db744f9c7b4532f6410890c
4
+ data.tar.gz: 424331ad60e04ccad8f5bb7f3d917231707e8fa1
5
5
  SHA512:
6
- metadata.gz: d79cdcb836c3e8d6dc60da0074bcf763652311b774373bb7f3db77157868d3fb162df850e23f1a9b0376717176b636f444cb5ab4eb25d85402bddcec8258161a
7
- data.tar.gz: c7262a624b1f4d52c52cc371480513fe1520b87091be157d8f180cb711cdf34da9c45846c56b28c390015110b70032f8f028f64683d9ebfa53c40c2a92d5fc80
6
+ metadata.gz: 5e4cb52ebf896972e4a735c237c913ddb8cadebb801f49ae4746fedcd15ce34c61d178ce1b577561dbd3504d8e53c55ad71ce8b582231b599d6d80099ec0bceb
7
+ data.tar.gz: 39528c6857a9c92c36e16119c3ec1d95a35f8969feeadde030b1ae97f86b9de6288400dc586e56f159862c030f0a042837e283de73876201655f33497f0b1c05
@@ -2,6 +2,7 @@ module CurationConcerns
2
2
  # Actions are decoupled from controller logic so that they may be called from a controller or a background job.
3
3
  class FileSetActor
4
4
  include CurationConcerns::ManagesEmbargoesActor
5
+ include CurationConcerns::Lockable
5
6
 
6
7
  attr_reader :file_set, :user, :attributes, :curation_concern
7
8
 
@@ -169,17 +170,6 @@ module CurationConcerns
169
170
  end
170
171
  end
171
172
 
172
- def acquire_lock_for(lock_key, &block)
173
- lock_manager.lock(lock_key, &block)
174
- end
175
-
176
- def lock_manager
177
- @lock_manager ||= CurationConcerns::LockManager.new(
178
- CurationConcerns.config.lock_time_to_live,
179
- CurationConcerns.config.lock_retry_count,
180
- CurationConcerns.config.lock_retry_delay)
181
- end
182
-
183
173
  def assign_visibility?(file_set_params = {})
184
174
  !((file_set_params || {}).keys & %w(visibility embargo_release_date lease_expiration_date)).empty?
185
175
  end
@@ -1,12 +1,15 @@
1
1
  module CurationConcerns
2
2
  class CollectionIndexer < Hydra::PCDM::CollectionIndexer
3
+ include IndexesThumbnails
3
4
  STORED_INTEGER = Solrizer::Descriptor.new(:integer, :stored)
5
+
4
6
  def generate_solr_document
5
7
  super.tap do |solr_doc|
6
8
  # Makes Collections show under the "Collections" tab
7
9
  Solrizer.set_field(solr_doc, 'generic_type', 'Collection', :facetable)
8
10
  # Index the size of the collection in bytes
9
11
  solr_doc[Solrizer.solr_name(:bytes, STORED_INTEGER)] = object.bytes
12
+ solr_doc['thumbnail_path_ss'] = thumbnail_path
10
13
  end
11
14
  end
12
15
  end
@@ -5,7 +5,7 @@ module CurationConcerns
5
5
 
6
6
  included do
7
7
  # The file_sets association and its accessor methods comes from Hydra::Works::AggregatesFileSets
8
- before_destroy :before_destroy_cleanup_file_sets
8
+ before_destroy :cleanup_file_sets
9
9
  end
10
10
 
11
11
  # Stopgap unil ActiveFedora ContainerAssociation includes an *_ids accessor.
@@ -14,7 +14,11 @@ module CurationConcerns
14
14
  file_sets.map(&:id)
15
15
  end
16
16
 
17
- def before_destroy_cleanup_file_sets
17
+ def cleanup_file_sets
18
+ # Destroy the list source first. This prevents each file_set from attemping to
19
+ # remove itself individually from the work. If hundreds of files are attached,
20
+ # this would take too long.
21
+ list_source.destroy
18
22
  file_sets.each(&:destroy)
19
23
  end
20
24
 
@@ -12,7 +12,6 @@ module CurationConcerns::WorkBehavior
12
12
  include CurationConcerns::WithFileSets
13
13
  include CurationConcerns::Naming
14
14
  include CurationConcerns::RequiredMetadata
15
- include CurationConcerns::BelongsToUploadSets
16
15
  include Hydra::AccessControls::Embargoable
17
16
 
18
17
  included do
@@ -15,13 +15,15 @@ module CurationConcerns
15
15
 
16
16
  # Blocks until lock is acquired or timeout.
17
17
  def lock(key)
18
+ returned_from_block = nil
18
19
  client.lock(key, @ttl) do |locked|
19
20
  if locked
20
- yield
21
+ returned_from_block = yield
21
22
  else
22
23
  raise UnableToAcquireLockError
23
24
  end
24
25
  end
26
+ returned_from_block
25
27
  end
26
28
 
27
29
  private
@@ -0,0 +1,16 @@
1
+ module CurationConcerns
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 ||= CurationConcerns::LockManager.new(
11
+ CurationConcerns.config.lock_time_to_live,
12
+ CurationConcerns.config.lock_retry_count,
13
+ CurationConcerns.config.lock_retry_delay)
14
+ end
15
+ end
16
+ end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency 'active_attr'
23
- spec.add_dependency 'hydra-collections', '~> 6.0.0.rc1'
23
+ spec.add_dependency 'hydra-collections', '~> 6.0.0'
24
24
  spec.add_dependency 'hydra-head', '~> 9.3'
25
25
  spec.add_dependency 'hydra-works', '~> 0.6'
26
26
  spec.add_dependency 'active_fedora-noid', '~> 1.0'
@@ -11,6 +11,7 @@ module CurationConcerns
11
11
  require 'active_fedora/noid'
12
12
  require 'curation_concerns/noid'
13
13
  require 'curation_concerns/permissions'
14
+ require 'curation_concerns/lockable'
14
15
  end
15
16
 
16
17
  initializer 'configure' do
@@ -1,5 +1,5 @@
1
1
  module CurationConcerns
2
2
  module Models
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curation_concerns-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2016-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 6.0.0.rc1
33
+ version: 6.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 6.0.0.rc1
40
+ version: 6.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hydra-head
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -194,11 +194,9 @@ files:
194
194
  - app/jobs/ingest_file_job.rb
195
195
  - app/jobs/ingest_local_file_job.rb
196
196
  - app/jobs/resolrize_job.rb
197
- - app/jobs/upload_set_update_job.rb
198
197
  - app/models/checksum_audit_log.rb
199
198
  - app/models/concerns/curation_concerns/ability.rb
200
199
  - app/models/concerns/curation_concerns/basic_metadata.rb
201
- - app/models/concerns/curation_concerns/belongs_to_upload_sets.rb
202
200
  - app/models/concerns/curation_concerns/collection_behavior.rb
203
201
  - app/models/concerns/curation_concerns/file_set/belongs_to_works.rb
204
202
  - app/models/concerns/curation_concerns/file_set/derivatives.rb
@@ -216,20 +214,19 @@ files:
216
214
  - app/models/concerns/curation_concerns/required_metadata.rb
217
215
  - app/models/concerns/curation_concerns/serializers.rb
218
216
  - app/models/concerns/curation_concerns/solr_document_behavior.rb
219
- - app/models/concerns/curation_concerns/upload_set_behavior.rb
220
217
  - app/models/concerns/curation_concerns/user.rb
221
218
  - app/models/concerns/curation_concerns/with_file_sets.rb
222
219
  - app/models/concerns/curation_concerns/work_behavior.rb
223
220
  - app/models/curation_concerns/classify_concern.rb
224
221
  - app/models/curation_concerns/quick_classification_query.rb
225
222
  - app/models/single_use_link.rb
226
- - app/models/upload_set.rb
227
223
  - app/models/version_committer.rb
228
224
  - app/services/curation_concerns/derivative_path.rb
229
225
  - app/services/curation_concerns/file_set_audit_service.rb
230
226
  - app/services/curation_concerns/indexes_thumbnails.rb
231
227
  - app/services/curation_concerns/local_file_service.rb
232
228
  - app/services/curation_concerns/lock_manager.rb
229
+ - app/services/curation_concerns/lockable.rb
233
230
  - app/services/curation_concerns/noid.rb
234
231
  - app/services/curation_concerns/persist_derivatives.rb
235
232
  - app/services/curation_concerns/persist_directly_contained_output_file_service.rb
@@ -286,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
283
  version: '0'
287
284
  requirements: []
288
285
  rubyforge_project:
289
- rubygems_version: 2.5.0
286
+ rubygems_version: 2.4.5.1
290
287
  signing_key:
291
288
  specification_version: 4
292
289
  summary: Simple institutional repository models for Hydra
@@ -1,77 +0,0 @@
1
- class UploadSetUpdateJob < ActiveJob::Base
2
- include Hydra::PermissionsQuery
3
- include CurationConcerns::Messages
4
-
5
- queue_as :upload_set_update
6
-
7
- attr_accessor :saved, :denied
8
-
9
- # This copies metadata from the passed in attribute to all of the works that
10
- # are members of the given upload set
11
- def perform(login, upload_set_id, titles, attributes, visibility)
12
- @login = login
13
- @saved = []
14
- @denied = []
15
- @upload_set_id = upload_set_id
16
-
17
- titles ||= {}
18
- attributes = attributes.merge(visibility: visibility)
19
-
20
- update(upload_set, titles, attributes)
21
- send_user_message
22
- end
23
-
24
- private
25
-
26
- def upload_set
27
- @upload_set ||= UploadSet.find_or_create(@upload_set_id)
28
- end
29
-
30
- def update(upload_set, titles, attributes)
31
- upload_set.works.each do |work|
32
- title = titles[work.id] if titles[work.id]
33
- next unless update_work(work, title, attributes)
34
- # TODO: stop assuming that files only belong to one work
35
- saved << work
36
- end
37
-
38
- upload_set.update(status: ["Complete"])
39
- end
40
-
41
- def send_user_success_message
42
- return unless CurationConcerns.config.callback.set?(:after_upload_set_update_success)
43
- CurationConcerns.config.callback.run(:after_upload_set_update_success, user, upload_set)
44
- end
45
-
46
- def send_user_failure_message
47
- return unless CurationConcerns.config.callback.set?(:after_upload_set_update_failure)
48
- CurationConcerns.config.callback.run(:after_upload_set_update_failure, user, upload_set)
49
- end
50
-
51
- def send_user_message
52
- if denied.empty?
53
- send_user_success_message unless saved.empty?
54
- else
55
- send_user_failure_message
56
- end
57
- end
58
-
59
- def user
60
- @user ||= User.find_by_user_key(@login)
61
- end
62
-
63
- def update_work(work, title, attributes)
64
- unless user.can? :edit, work
65
- ActiveFedora::Base.logger.error "User #{user.user_key} DENIED access to #{work.id}!"
66
- denied << work
67
- return
68
- end
69
-
70
- work.title = title if title
71
- work_actor(work, attributes).update
72
- end
73
-
74
- def work_actor(work, attributes)
75
- CurationConcerns::GenericWorkActor.new(work, user, attributes)
76
- end
77
- end
@@ -1,13 +0,0 @@
1
- module CurationConcerns
2
- module BelongsToUploadSets
3
- extend ActiveSupport::Concern
4
- included do
5
- belongs_to :upload_set, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
6
- end
7
-
8
- # Is this file in the middle of being processed by an UploadSet?
9
- def processing?
10
- try(:upload_set).try(:status) == ['processing'.freeze]
11
- end
12
- end
13
- end
@@ -1,37 +0,0 @@
1
- module CurationConcerns
2
- module UploadSetBehavior
3
- extend ActiveSupport::Concern
4
- include Hydra::AccessControls::Permissions
5
- include CurationConcerns::Noid
6
-
7
- included do
8
- has_many :works, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
9
-
10
- property :title, predicate: ::RDF::DC.title
11
- property :status, predicate: ::RDF::DC.type
12
- end
13
-
14
- module ClassMethods
15
- def find_or_create(id)
16
- UploadSet.find(id)
17
- rescue ActiveFedora::ObjectNotFoundError
18
- safe_create(id)
19
- end
20
-
21
- private
22
-
23
- # This method handles most race conditions gracefully.
24
- # If an upload_set with the same ID is created by another thread
25
- # we fetch the upload_set that was created (rather than throwing
26
- # an error) and continute.
27
- def safe_create(id)
28
- UploadSet.create(id: id)
29
- rescue ActiveFedora::IllegalOperation
30
- # This is the exception thrown by LDP when we attempt to
31
- # create a duplicate object. If we can find the object
32
- # then we are good to go.
33
- UploadSet.find(id)
34
- end
35
- end
36
- end
37
- end
@@ -1,3 +0,0 @@
1
- class UploadSet < ActiveFedora::Base
2
- include CurationConcerns::UploadSetBehavior
3
- end