curation_concerns-models 0.10.0 → 0.11.0.rc1

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: afd415c4152d3eb3fc25a1d5d63c0261c820ae07
4
- data.tar.gz: 051471568f9ab3d2d27ff62a8d8faa5d469c3139
3
+ metadata.gz: 5d2ce952ca856172a242fb615ba373ddf63110fb
4
+ data.tar.gz: 40858e4e383e4064df595aa3ae835339dbc8f765
5
5
  SHA512:
6
- metadata.gz: c2607d15592fe9f7e6acb243256cc33f6b29132b201660328cb427840b3efba3453f5f5c40ce44bab48a8cc5d55cc8b1d685b62143edd0492136ee2cca310483
7
- data.tar.gz: 2db872e858e8705f6af5e1060c686b80e01d595125c01492066080916b6e3bd1695bdd72cca78e063fd50c8d81c80a65dcf32ee181653526a810df6ece97964b
6
+ metadata.gz: 843e33effb12627dd61670f19a4427d0e8211d1be63cd01421fbacca2b6d8d35d8a93cecac53d67a7b95e22eaf8a659ff165227851717a94a96536f5aca190a9
7
+ data.tar.gz: 6bab1ad84e209f202980a9361aab5629f66e343b3f2baa0b2e8438a97aaa07a088f9e887bb13c59b39b17661ca5d77de999e06f797be962ba2fb261f621922a0
@@ -1,5 +1,5 @@
1
1
  module CurationConcerns
2
- # actions for a file identified by file_set_id and relation (maps to use predicate)
2
+ # actions for a file identified by file_set and relation (maps to use predicate)
3
3
  class FileActor
4
4
  attr_reader :file_set, :relation, :user
5
5
 
@@ -19,10 +19,10 @@ module CurationConcerns
19
19
  # have made it to the repo
20
20
  # @param [File, ActionDigest::HTTP::UploadedFile, Tempfile] file the file to save in the repository
21
21
  def ingest_file(file)
22
- working_file = copy_file_to_working_directory(file, file_set_id)
22
+ working_file = copy_file_to_working_directory(file, file_set.id)
23
23
  mime_type = file.respond_to?(:content_type) ? file.content_type : nil
24
- IngestFileJob.perform_later(file_set_id, working_file, mime_type, user.user_key, relation)
25
- make_derivative(file_set.id, working_file)
24
+ IngestFileJob.perform_later(file_set, working_file, mime_type, user.user_key, relation)
25
+ make_derivative(file_set, working_file)
26
26
  true
27
27
  end
28
28
 
@@ -36,18 +36,14 @@ module CurationConcerns
36
36
 
37
37
  # Retrieve a copy of the orginal file from the repository
38
38
  working_file = copy_repository_resource_to_working_directory(repository_file)
39
- make_derivative(file_set_id, working_file)
39
+ make_derivative(file_set, working_file)
40
40
  true
41
41
  end
42
42
 
43
43
  private
44
44
 
45
- def file_set_id
46
- file_set.id
47
- end
48
-
49
- def make_derivative(file_set_id, working_file)
50
- CharacterizeJob.perform_later(file_set_id, working_file)
45
+ def make_derivative(file_set, working_file)
46
+ CharacterizeJob.perform_later(file_set, working_file)
51
47
  end
52
48
 
53
49
  # @param [File, ActionDispatch::Http::UploadedFile] file
@@ -61,7 +57,7 @@ module CurationConcerns
61
57
  # @param [ActiveFedora::File] file the resource in the repo
62
58
  # @return [String] path of the working file
63
59
  def copy_repository_resource_to_working_directory(file)
64
- copy_stream_to_working_directory(file_set_id, file.original_name, StringIO.new(file.content))
60
+ copy_stream_to_working_directory(file_set.id, file.original_name, StringIO.new(file.content))
65
61
  end
66
62
 
67
63
  # @param [String] id the identifer
@@ -1,14 +1,14 @@
1
1
  module CurationConcerns
2
2
  class CollectionIndexer < Hydra::PCDM::CollectionIndexer
3
3
  include IndexesThumbnails
4
- STORED_INTEGER = Solrizer::Descriptor.new(:integer, :stored)
4
+ STORED_LONG = Solrizer::Descriptor.new(:long, :stored)
5
5
 
6
6
  def generate_solr_document
7
7
  super.tap do |solr_doc|
8
8
  # Makes Collections show under the "Collections" tab
9
9
  Solrizer.set_field(solr_doc, 'generic_type', 'Collection', :facetable)
10
10
  # Index the size of the collection in bytes
11
- solr_doc[Solrizer.solr_name(:bytes, STORED_INTEGER)] = object.bytes
11
+ solr_doc[Solrizer.solr_name(:bytes, STORED_LONG)] = object.bytes
12
12
  solr_doc['thumbnail_path_ss'] = thumbnail_path
13
13
  end
14
14
  end
@@ -1,21 +1,16 @@
1
- class AuditJob < ActiveFedoraIdBasedJob
1
+ class AuditJob < ActiveJob::Base
2
2
  queue_as :audit
3
3
 
4
- attr_accessor :uri, :id, :file_id
5
-
6
4
  # URI of the resource to audit.
7
5
  # This URI could include the actual resource (e.g. content) and the version to audit:
8
6
  # http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content/fcr:versions/version1
9
7
  # but it could also just be:
10
8
  # http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content
11
- # @param [String] id of the parent object
9
+ # @param [FileSet] the parent object
12
10
  # @param [String] file_id used to find the file within its parent object (usually "original_file")
13
11
  # @param [String] uri of the specific file/version to be audited
14
- def perform(id, file_id, uri)
15
- @id = id
16
- @file_id = file_id
17
- @uri = uri
18
- log = run_audit
12
+ def perform(file_set, file_id, uri)
13
+ log = run_audit(file_set, file_id, uri)
19
14
  fixity_ok = log.pass == 1
20
15
  unless fixity_ok
21
16
  if CurationConcerns.config.callback.set?(:after_audit_failure)
@@ -29,7 +24,7 @@ class AuditJob < ActiveFedoraIdBasedJob
29
24
 
30
25
  protected
31
26
 
32
- def run_audit
27
+ def run_audit(file_set, file_id, uri)
33
28
  begin
34
29
  fixity_ok = ActiveFedora::FixityService.new(uri).check
35
30
  rescue Ldp::NotFound
@@ -38,12 +33,12 @@ class AuditJob < ActiveFedoraIdBasedJob
38
33
 
39
34
  if fixity_ok
40
35
  passing = 1
41
- ChecksumAuditLog.prune_history(id, file_id)
36
+ ChecksumAuditLog.prune_history(file_set.id, file_id)
42
37
  else
43
38
  logger.warn "***AUDIT*** Audit failed for #{uri} #{error_msg}"
44
39
  passing = 0
45
40
  end
46
- ChecksumAuditLog.create!(pass: passing, file_set_id: id, version: uri, file_id: file_id)
41
+ ChecksumAuditLog.create!(pass: passing, file_set_id: file_set.id, version: uri, file_id: file_id)
47
42
  end
48
43
 
49
44
  private
@@ -1,12 +1,11 @@
1
- class CharacterizeJob < ActiveFedoraIdBasedJob
1
+ class CharacterizeJob < ActiveJob::Base
2
2
  queue_as :characterize
3
3
 
4
- # @param [String] id
4
+ # @param [FileSet] file_set
5
5
  # @param [String] filename a local path for the file to characterize. By using this, we don't have to pull a copy out of fedora.
6
- def perform(id, filename)
7
- @id = id
6
+ def perform(file_set, filename)
8
7
  Hydra::Works::CharacterizationService.run(file_set, filename)
9
- file_set.save
10
- CreateDerivativesJob.perform_later(file_set.id, filename)
8
+ file_set.save!
9
+ CreateDerivativesJob.perform_later(file_set, filename)
11
10
  end
12
11
  end
@@ -1,19 +1,20 @@
1
- class CreateDerivativesJob < ActiveFedoraIdBasedJob
1
+ class CreateDerivativesJob < ActiveJob::Base
2
2
  queue_as :derivatives
3
3
 
4
- def perform(id, file_name)
5
- @id = id
4
+ # @param [FileSet] file_set
5
+ # @param [String] file_name
6
+ def perform(file_set, file_name)
6
7
  return if file_set.video? && !CurationConcerns.config.enable_ffmpeg
7
8
 
8
9
  file_set.create_derivatives(file_name)
9
10
  # The thumbnail is indexed in the solr document, so reindex
10
11
  file_set.update_index
11
- file_set.parent.update_index if parent_needs_reindex?
12
+ file_set.parent.update_index if parent_needs_reindex?(file_set)
12
13
  end
13
14
 
14
15
  # If this file_set is the thumbnail for the parent work,
15
16
  # then the parent also needs to be reindexed.
16
- def parent_needs_reindex?
17
+ def parent_needs_reindex?(file_set)
17
18
  return false unless file_set.parent
18
19
  file_set.parent.thumbnail_id == file_set.id
19
20
  end
@@ -2,15 +2,14 @@ require 'net/https'
2
2
  require 'uri'
3
3
  require 'tempfile'
4
4
 
5
- class ImportUrlJob < ActiveFedoraIdBasedJob
5
+ class ImportUrlJob < ActiveJob::Base
6
6
  queue_as :import_url
7
7
 
8
- def perform(id)
9
- @id = id
8
+ def perform(file_set)
10
9
  user = User.find_by_user_key(file_set.depositor)
11
10
 
12
- Tempfile.open(id.tr('/', '_')) do |f|
13
- copy_remote_file(file_set.import_url, f)
11
+ Tempfile.open(file_set.id.tr('/', '_')) do |f|
12
+ copy_remote_file(file_set, f)
14
13
 
15
14
  # reload the generic file once the data is copied since this is a long running task
16
15
  file_set.reload
@@ -25,23 +24,25 @@ class ImportUrlJob < ActiveFedoraIdBasedJob
25
24
  end
26
25
  end
27
26
 
28
- def copy_remote_file(_import_url, f)
29
- f.binmode
30
- # download file from url
31
- uri = URI(file_set.import_url)
32
- http = Net::HTTP.new(uri.host, uri.port)
33
- http.use_ssl = uri.scheme == 'https' # enable SSL/TLS
34
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
35
- mime_type = nil
36
-
37
- http.start do
38
- http.request_get(uri.request_uri) do |resp|
39
- mime_type = resp.content_type
40
- resp.read_body do |segment|
41
- f.write(segment)
27
+ protected
28
+
29
+ def copy_remote_file(file_set, f)
30
+ f.binmode
31
+ # download file from url
32
+ uri = URI(file_set.import_url)
33
+ http = Net::HTTP.new(uri.host, uri.port)
34
+ http.use_ssl = uri.scheme == 'https' # enable SSL/TLS
35
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
36
+ mime_type = nil
37
+
38
+ http.start do
39
+ http.request_get(uri.request_uri) do |resp|
40
+ mime_type = resp.content_type
41
+ resp.read_body do |segment|
42
+ f.write(segment)
43
+ end
42
44
  end
43
45
  end
46
+ f.rewind
44
47
  end
45
- f.rewind
46
- end
47
48
  end
@@ -1,14 +1,12 @@
1
1
  class IngestFileJob < ActiveJob::Base
2
2
  queue_as :ingest
3
3
 
4
- # @param [String] file_set_id
4
+ # @param [FileSet] file_set
5
5
  # @param [String] filename
6
6
  # @param [String,NilClass] mime_type
7
7
  # @param [String] user_key
8
8
  # @param [String] relation ('original_file')
9
- def perform(file_set_id, filename, mime_type, user_key, relation = 'original_file')
10
- file_set = FileSet.find(file_set_id)
11
-
9
+ def perform(file_set, filename, mime_type, user_key, relation = 'original_file')
12
10
  file = File.open(filename, "rb")
13
11
  # If mime-type is known, wrap in an IO decorator
14
12
  # Otherwise allow Hydra::Works service to determine mime_type
@@ -18,6 +18,7 @@ module CurationConcerns
18
18
  include CurationConcerns::RequiredMetadata
19
19
  include CurationConcerns::Naming
20
20
  include Hydra::AccessControls::Embargoable
21
+ include GlobalID::Identification
21
22
 
22
23
  included do
23
24
  attr_accessor :file
@@ -13,6 +13,7 @@ module CurationConcerns::WorkBehavior
13
13
  include CurationConcerns::Naming
14
14
  include CurationConcerns::RequiredMetadata
15
15
  include Hydra::AccessControls::Embargoable
16
+ include GlobalID::Identification
16
17
 
17
18
  included do
18
19
  property :owner, predicate: RDF::URI.new('http://opaquenamespace.org/ns/hydra/owner'), multiple: false
@@ -81,7 +81,7 @@ module CurationConcerns
81
81
  def audit_file_version(file_id, version_uri)
82
82
  latest_audit = ChecksumAuditLog.logs_for(file_set.id, file_id).first
83
83
  return latest_audit unless needs_audit?(latest_audit)
84
- AuditJob.perform_later(file_set.id, file_id, version_uri.to_s)
84
+ AuditJob.perform_later(file_set, file_id, version_uri.to_s)
85
85
  latest_audit || ChecksumAuditLog.new(pass: NO_RUNS, file_set_id: file_set.id, file_id: file_id, version: version_uri)
86
86
  end
87
87
 
@@ -22,12 +22,13 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'active_attr'
23
23
  spec.add_dependency 'hydra-collections', '~> 8.1'
24
24
  spec.add_dependency 'hydra-head', '~> 9.3'
25
- spec.add_dependency 'hydra-works', '~> 0.7'
25
+ spec.add_dependency 'hydra-works', '~> 0.8', '>= 0.8.1'
26
26
  spec.add_dependency 'active_fedora-noid', '~> 1.0'
27
27
  spec.add_dependency 'resque', '~> 1.23'
28
28
  spec.add_dependency 'resque-pool', '~> 0.3'
29
29
  spec.add_dependency 'qa', '~> 0.5'
30
30
  spec.add_dependency 'redlock', '~> 0.1.2'
31
+ spec.add_dependency 'solrizer', '~> 3.4'
31
32
 
32
33
  spec.add_development_dependency 'bundler', '~> 1.6'
33
34
  spec.add_development_dependency 'rake'
@@ -1,5 +1,5 @@
1
1
  module CurationConcerns
2
2
  module Models
3
- VERSION = "0.10.0".freeze
3
+ VERSION = "0.11.0.rc1".freeze
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.10.0
4
+ version: 0.11.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-04 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr
@@ -58,14 +58,20 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.7'
61
+ version: '0.8'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 0.8.1
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
69
  - - "~>"
67
70
  - !ruby/object:Gem::Version
68
- version: '0.7'
71
+ version: '0.8'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 0.8.1
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: active_fedora-noid
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +142,20 @@ dependencies:
136
142
  - - "~>"
137
143
  - !ruby/object:Gem::Version
138
144
  version: 0.1.2
145
+ - !ruby/object:Gem::Dependency
146
+ name: solrizer
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '3.4'
152
+ type: :runtime
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '3.4'
139
159
  - !ruby/object:Gem::Dependency
140
160
  name: bundler
141
161
  requirement: !ruby/object:Gem::Requirement
@@ -187,7 +207,6 @@ files:
187
207
  - app/indexers/curation_concerns/collection_indexer.rb
188
208
  - app/indexers/curation_concerns/file_set_indexer.rb
189
209
  - app/indexers/curation_concerns/work_indexer.rb
190
- - app/jobs/active_fedora_id_based_job.rb
191
210
  - app/jobs/audit_job.rb
192
211
  - app/jobs/characterize_job.rb
193
212
  - app/jobs/create_derivatives_job.rb
@@ -278,9 +297,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
278
297
  version: '0'
279
298
  required_rubygems_version: !ruby/object:Gem::Requirement
280
299
  requirements:
281
- - - ">="
300
+ - - ">"
282
301
  - !ruby/object:Gem::Version
283
- version: '0'
302
+ version: 1.3.1
284
303
  requirements: []
285
304
  rubyforge_project:
286
305
  rubygems_version: 2.5.1
@@ -1,15 +0,0 @@
1
- class ActiveFedoraIdBasedJob < ActiveJob::Base
2
- queue_as :id_based
3
-
4
- attr_accessor :id
5
-
6
- def object
7
- @object ||= ActiveFedora::Base.find(id)
8
- end
9
-
10
- alias file_set object
11
-
12
- def perform(_)
13
- fail 'Define #run in a subclass'
14
- end
15
- end