ddr-models 2.3.2 → 2.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/ddr-models.gemspec +1 -1
- data/lib/ddr/auth.rb +10 -6
- data/lib/ddr/auth/group.rb +2 -1
- data/lib/ddr/auth/grouper_gateway.rb +7 -6
- data/lib/ddr/auth/permissions.rb +2 -1
- data/lib/ddr/auth/roles.rb +3 -2
- data/lib/ddr/auth/roles/role_set.rb +3 -2
- data/lib/ddr/datastreams/administrative_metadata_datastream.rb +3 -0
- data/lib/ddr/derivatives/png_generator.rb +1 -1
- data/lib/ddr/index/fields.rb +11 -1
- data/lib/ddr/index/filter.rb +4 -3
- data/lib/ddr/index/legacy_license_fields.rb +0 -2
- data/lib/ddr/index/query_clause.rb +2 -2
- data/lib/ddr/index/query_value.rb +6 -3
- data/lib/ddr/jobs.rb +5 -1
- data/lib/ddr/jobs/fits_file_characterization.rb +2 -40
- data/lib/ddr/jobs/fixity_check.rb +13 -0
- data/lib/ddr/jobs/job.rb +36 -0
- data/lib/ddr/jobs/queue.rb +27 -0
- data/lib/ddr/jobs/update_index.rb +13 -0
- data/lib/ddr/managers/derivatives_manager.rb +21 -17
- data/lib/ddr/models.rb +14 -2
- data/lib/ddr/models/access_controllable.rb +3 -6
- data/lib/ddr/models/admin_set.rb +5 -3
- data/lib/ddr/models/base.rb +2 -3
- data/lib/ddr/models/contact.rb +17 -0
- data/lib/ddr/models/file_characterization.rb +37 -0
- data/lib/ddr/models/has_admin_metadata.rb +2 -1
- data/lib/ddr/models/has_content.rb +4 -2
- data/lib/ddr/models/indexing.rb +5 -0
- data/lib/ddr/models/licenses/license.rb +5 -3
- data/lib/ddr/models/solr_document.rb +1 -1
- data/lib/ddr/models/version.rb +1 -1
- data/lib/ddr/models/with_content_file.rb +37 -0
- data/lib/ddr/vocab/asset.rb +3 -0
- data/spec/derivatives/png_generator_spec.rb +7 -0
- data/spec/factories/test_model_factories.rb +1 -1
- data/spec/fixtures/arrow1rightred_e0.gif +0 -0
- data/spec/fixtures/bird.jpg +0 -0
- data/spec/index/query_value_spec.rb +33 -0
- data/spec/jobs/fits_file_characterization_spec.rb +8 -44
- data/spec/jobs/fixity_check_spec.rb +22 -0
- data/spec/jobs/job_spec.rb +40 -0
- data/spec/jobs/update_index_spec.rb +22 -0
- data/spec/managers/derivatives_manager_spec.rb +16 -12
- data/spec/models/admin_set_spec.rb +3 -3
- data/spec/models/contact_spec.rb +22 -0
- data/spec/models/effective_license_spec.rb +17 -7
- data/spec/models/file_characterization_spec.rb +39 -0
- data/spec/models/has_admin_metadata_spec.rb +8 -5
- data/spec/models/indexing_spec.rb +2 -0
- data/spec/models/license_spec.rb +3 -1
- data/spec/models/solr_document_spec.rb +6 -3
- data/spec/models/with_content_file_spec.rb +37 -0
- data/spec/spec_helper.rb +2 -0
- metadata +43 -30
- data/lib/ddr/contacts.rb +0 -25
- data/lib/ddr/index_fields.rb +0 -14
- data/spec/auth/ldap_gateway_spec.rb +0 -9
- data/spec/contacts/contacts_spec.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1f085bb5aae0c19afb4bb644fd674800bce2a9e
|
4
|
+
data.tar.gz: 11d41a2e56d71b9087d5cc8d7154f52c86a2f28c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50dd901a973431067800bbbbc33f1f4b9fb2fd8f1a53eb6797132197b410bccefdf9a6f5d6d5717d6c03441e0bded2e4e0ce59e5394e929f1b26d2809194c0bc
|
7
|
+
data.tar.gz: 587d288987202fd4c8f9375bdd4d37e1bcc044ac11573a76d7b84730618ee2cbd234f0c4cb7e8e845ec8b69711c468ac824f5640de47822981aaa0ffaa353dac
|
data/.travis.yml
CHANGED
data/ddr-models.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib", "app/models"]
|
20
20
|
|
21
21
|
s.add_dependency "rails", "~> 4.1.6"
|
22
|
+
s.add_dependency "activeresource"
|
22
23
|
s.add_dependency "active-fedora", "~> 7.0"
|
23
24
|
s.add_dependency "hydra-core", "~> 7.2"
|
24
25
|
s.add_dependency "hydra-validations", "~> 0.5"
|
@@ -30,7 +31,6 @@ Gem::Specification.new do |s|
|
|
30
31
|
s.add_dependency "rdf-vocab", "~> 0.8"
|
31
32
|
s.add_dependency "net-ldap", "~> 0.11"
|
32
33
|
s.add_dependency "cancancan", "~> 1.12"
|
33
|
-
s.add_dependency "ddr-aux-client", "~> 1.2", ">= 1.2.2"
|
34
34
|
s.add_dependency "ddr-antivirus", "~> 2.1.1"
|
35
35
|
|
36
36
|
s.add_development_dependency "bundler", "~> 1.7"
|
data/lib/ddr/auth.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Ddr
|
2
2
|
module Auth
|
3
3
|
extend ActiveSupport::Autoload
|
4
|
+
extend Deprecation
|
4
5
|
|
5
6
|
autoload :Ability
|
6
7
|
autoload :AbilityDefinitions
|
@@ -58,22 +59,25 @@ module Ddr
|
|
58
59
|
|
59
60
|
# Group of which everyone (including anonymous users) is a member
|
60
61
|
def self.everyone_group
|
61
|
-
warn
|
62
|
-
|
62
|
+
Deprecation.warn(Ddr::Auth,
|
63
|
+
"`Ddr::Auth.everyone_group` is deprecated and will be removed in ddr-models 3.0." \
|
64
|
+
" Use `Ddr::Auth::Groups::PUBLIC` instead.")
|
63
65
|
Groups::PUBLIC
|
64
66
|
end
|
65
67
|
|
66
68
|
# Group of authenticated users
|
67
69
|
def self.authenticated_users_group
|
68
|
-
warn
|
69
|
-
|
70
|
+
Deprecation.warn(Ddr::Auth,
|
71
|
+
"`Ddr::Auth.authenticated_users_group` is deprecated and will be removed in ddr-models 3.0." \
|
72
|
+
" Use `Ddr::Auth::Groups::REGISTERED` instead.")
|
70
73
|
Groups::REGISTERED
|
71
74
|
end
|
72
75
|
|
73
76
|
def self.const_missing(name)
|
74
77
|
if name == :Superuser
|
75
|
-
warn
|
76
|
-
|
78
|
+
Deprecation.warn(Ddr::Auth,
|
79
|
+
"`Ddr::Auth::Superuser` is deprecated and will be removed in ddr-models 3.0." \
|
80
|
+
" Use `Ddr::Auth::SuperuserAbility` instead.")
|
77
81
|
return SuperuserAbility
|
78
82
|
end
|
79
83
|
super
|
data/lib/ddr/auth/group.rb
CHANGED
@@ -4,6 +4,7 @@ module Ddr
|
|
4
4
|
module Auth
|
5
5
|
# Wraps a String
|
6
6
|
class Group < SimpleDelegator
|
7
|
+
extend Deprecation
|
7
8
|
|
8
9
|
attr_reader :rule
|
9
10
|
|
@@ -32,7 +33,7 @@ module Ddr
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def to_agent
|
35
|
-
warn
|
36
|
+
Deprecation.warn(self.class, "`to_agent` is deprecated. Use `agent` instead.")
|
36
37
|
agent
|
37
38
|
end
|
38
39
|
|
@@ -4,14 +4,15 @@ require "delegate"
|
|
4
4
|
module Ddr
|
5
5
|
module Auth
|
6
6
|
class GrouperGateway < SimpleDelegator
|
7
|
+
extend Deprecation
|
7
8
|
|
8
9
|
SUBJECT_ID_RE = Regexp.new('[^@]+(?=@duke\.edu)')
|
9
10
|
DEFAULT_TIMEOUT = 5
|
10
11
|
|
11
12
|
def self.const_missing(name)
|
12
13
|
if name == :REPOSITORY_GROUP_FILTER
|
13
|
-
warn "
|
14
|
-
|
14
|
+
Deprecation.warn(self, "The constant `#{name}` is deprecated and will be removed in ddr-models 3.0." \
|
15
|
+
" Use `Ddr::Auth.repository_group_filter` instead.")
|
15
16
|
return Ddr::Auth.repository_group_filter
|
16
17
|
end
|
17
18
|
super
|
@@ -47,8 +48,8 @@ module Ddr
|
|
47
48
|
|
48
49
|
# @deprecated Use {#repository_groups} instead.
|
49
50
|
def repository_group_names
|
50
|
-
warn "
|
51
|
-
|
51
|
+
Deprecation.warn(self.class, "`Ddr::Auth::GrouperGateway#repository_group_names` is deprecated." \
|
52
|
+
" Use `#repository_groups` instead.")
|
52
53
|
repository_groups
|
53
54
|
end
|
54
55
|
|
@@ -83,8 +84,8 @@ module Ddr
|
|
83
84
|
|
84
85
|
# @deprecated Use {#user_groups} instead.
|
85
86
|
def user_group_names(user)
|
86
|
-
warn "
|
87
|
-
|
87
|
+
Deprecation.warn(self.class, "`Ddr::Auth::GrouperGateway#user_group_names` is deprecated." \
|
88
|
+
" Use `#user_groups` instead.")
|
88
89
|
user_groups(user)
|
89
90
|
end
|
90
91
|
|
data/lib/ddr/auth/permissions.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Ddr::Auth
|
2
2
|
class Permissions
|
3
|
+
extend Deprecation
|
3
4
|
|
4
5
|
READ = :read
|
5
6
|
DOWNLOAD = :download
|
@@ -14,7 +15,7 @@ module Ddr::Auth
|
|
14
15
|
|
15
16
|
def self.const_missing(name)
|
16
17
|
if name == :EDIT
|
17
|
-
warn "
|
18
|
+
Deprecation.warn(self, "`EDIT` is deprecated. Use `UPDATE` instead.")
|
18
19
|
return UPDATE
|
19
20
|
end
|
20
21
|
super
|
data/lib/ddr/auth/roles.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Ddr::Auth
|
2
2
|
module Roles
|
3
3
|
extend ActiveSupport::Autoload
|
4
|
+
extend Deprecation
|
4
5
|
|
5
6
|
autoload :DetachedRoleSet
|
6
7
|
autoload :PropertyRoleSet
|
@@ -20,8 +21,8 @@ module Ddr::Auth
|
|
20
21
|
|
21
22
|
def const_missing(name)
|
22
23
|
if name == :ArrayRoleSet
|
23
|
-
warn "
|
24
|
-
|
24
|
+
Deprecation.warn(Ddr::Auth::Roles, "`Ddr::Auth::Roles::ArrayRoleSet` is deprecated." \
|
25
|
+
" Use `Ddr::Auth::Roles::DetachedRoleSet` instead.")
|
25
26
|
DetachedRoleSet
|
26
27
|
else
|
27
28
|
super
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Ddr::Auth
|
2
2
|
module Roles
|
3
|
+
extend Deprecation
|
3
4
|
#
|
4
5
|
# Wraps a set of Roles
|
5
6
|
#
|
@@ -21,8 +22,8 @@ module Ddr::Auth
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def granted
|
24
|
-
warn "
|
25
|
-
|
25
|
+
Deprecation.warn(self.class, "`granted` is deprecated." \
|
26
|
+
" Use the RoleSet object directly.")
|
26
27
|
self
|
27
28
|
end
|
28
29
|
|
@@ -9,7 +9,7 @@ module Ddr
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def generate
|
12
|
-
command = "convert #{Ddr::Utils.file_path(source)} #{options} png:#{Ddr::Utils.file_path(output)}"
|
12
|
+
command = "convert #{Ddr::Utils.file_path(source)}[0] #{options} png:#{Ddr::Utils.file_path(output)}"
|
13
13
|
out, err, s = Open3.capture3(command)
|
14
14
|
GeneratorResult.new(out, err, s)
|
15
15
|
end
|
data/lib/ddr/index/fields.rb
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
module Ddr::Index
|
2
2
|
module Fields
|
3
|
+
extend Deprecation
|
3
4
|
|
4
|
-
|
5
|
+
def self.const_missing(name)
|
6
|
+
if const = LegacyLicenseFields.const_get(name)
|
7
|
+
Deprecation.warn(Ddr::Index::Fields,
|
8
|
+
"The constant `#{name}` is deprecated and will be removed in ddr-models 3.0.")
|
9
|
+
const
|
10
|
+
else
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
5
14
|
|
6
15
|
def self.get(name)
|
7
16
|
const_get(name.to_s.upcase, false)
|
@@ -20,6 +29,7 @@ module Ddr::Index
|
|
20
29
|
ACTIVE_FEDORA_MODEL = Field.new :active_fedora_model, :stored_sortable
|
21
30
|
ADMIN_SET = Field.new :admin_set, :stored_sortable
|
22
31
|
ADMIN_SET_FACET = Field.new :admin_set_facet, :facetable
|
32
|
+
ASPACE_ID = Field.new :aspace_id, :stored_sortable
|
23
33
|
BOX_NUMBER_FACET = Field.new :box_number_facet, :facetable
|
24
34
|
COLLECTION_FACET = Field.new :collection_facet, :facetable
|
25
35
|
COLLECTION_URI = Field.new :collection_uri, :symbol
|
data/lib/ddr/index/filter.rb
CHANGED
@@ -13,10 +13,11 @@ module Ddr::Index
|
|
13
13
|
|
14
14
|
def where(conditions)
|
15
15
|
clauses = conditions.map do |field, value|
|
16
|
-
|
17
|
-
|
16
|
+
values = Array(value)
|
17
|
+
if values.size > 1
|
18
|
+
QueryClause.or_values(field, values)
|
18
19
|
else
|
19
|
-
QueryClause.term(field,
|
20
|
+
QueryClause.term(field, values.first)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
raw *clauses
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Ddr::Index
|
2
2
|
module LegacyLicenseFields
|
3
3
|
|
4
|
-
warn "[DEPRECATION] `Ddr::Index::LegacyLicenseFields` is deprecated and will be removed from ddr-models 3.0."
|
5
|
-
|
6
4
|
DEFAULT_LICENSE_DESCRIPTION = Field.new :default_license_description, type: :string
|
7
5
|
DEFAULT_LICENSE_TITLE = Field.new :default_license_title, type: :string
|
8
6
|
DEFAULT_LICENSE_URL = Field.new :default_license_url, type: :string
|
@@ -6,9 +6,12 @@ module Ddr::Index
|
|
6
6
|
RSolr.solr_escape(value)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
# @param values [Enumerable<String>]
|
10
|
+
def or_values(values)
|
11
|
+
unless values.is_a?(::Enumerable) && values.present?
|
12
|
+
raise ArgumentError, "`#{self.name}.or_values` requires a non-empty enumerable of strings."
|
13
|
+
end
|
14
|
+
"(%s)" % values.map { |value| build(value) }.join(" OR ")
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
data/lib/ddr/jobs.rb
CHANGED
@@ -2,8 +2,12 @@ module Ddr
|
|
2
2
|
module Jobs
|
3
3
|
extend ActiveSupport::Autoload
|
4
4
|
|
5
|
-
autoload :PermanentId
|
6
5
|
autoload :FitsFileCharacterization
|
6
|
+
autoload :FixityCheck
|
7
|
+
autoload :Job
|
8
|
+
autoload :PermanentId
|
9
|
+
autoload :Queue
|
10
|
+
autoload :UpdateIndex
|
7
11
|
|
8
12
|
autoload_at 'ddr/jobs/permanent_id' do
|
9
13
|
autoload :MakeUnavailable
|
@@ -1,50 +1,12 @@
|
|
1
|
-
require 'open3'
|
2
|
-
|
3
1
|
module Ddr::Jobs
|
4
2
|
class FitsFileCharacterization
|
3
|
+
extend Job
|
5
4
|
|
6
5
|
@queue = :file_characterization
|
7
6
|
|
8
|
-
EVENT_SUMMARY = 'FITS characterization of content file'.freeze
|
9
|
-
|
10
7
|
def self.perform(pid)
|
11
8
|
obj = ActiveFedora::Base.find(pid)
|
12
|
-
|
13
|
-
Dir.mktmpdir(nil, Ddr::Models.tempdir) do |dir|
|
14
|
-
infile = create_temp_infile(dir, tmp_filename, obj.content.content)
|
15
|
-
fits_output, err, status = Open3.capture3(fits_command, '-i', infile)
|
16
|
-
if status.success? && fits_output.present?
|
17
|
-
obj.reload
|
18
|
-
obj.fits.content = fits_output
|
19
|
-
obj.save!
|
20
|
-
end
|
21
|
-
notify_event(pid, err, status)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.fits_command
|
26
|
-
File.join(Ddr::Models.fits_home, 'fits.sh')
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.fits_version
|
30
|
-
`#{fits_command} -v`.strip
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def self.create_temp_infile(dir, tmp_filename, content)
|
36
|
-
temp_infile = File.join(dir, tmp_filename)
|
37
|
-
File.open(temp_infile, 'wb') do |f|
|
38
|
-
f.write content
|
39
|
-
end
|
40
|
-
temp_infile
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.notify_event(pid, err, status)
|
44
|
-
details = status.success? ? nil : err
|
45
|
-
event_args = { pid: pid, summary: EVENT_SUMMARY, software: "fits #{fits_version}", detail: details }
|
46
|
-
event_args[:outcome] = status.success? ? Ddr::Events::Event::SUCCESS : Ddr::Events::Event::FAILURE
|
47
|
-
Ddr::Notifications.notify_event(:update, event_args)
|
9
|
+
Ddr::Models::FileCharacterization.call(obj)
|
48
10
|
end
|
49
11
|
|
50
12
|
end
|
data/lib/ddr/jobs/job.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "resque"
|
2
|
+
|
3
|
+
module Ddr::Jobs
|
4
|
+
module Job
|
5
|
+
|
6
|
+
def self.extended(base)
|
7
|
+
base.extend ClassMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
# @return [Array<String>] list of object ids queued for this job type.
|
12
|
+
# @note Assumes that the object_id is the first argument of the .perform method.
|
13
|
+
def queued_object_ids(**args)
|
14
|
+
args[:type] = self
|
15
|
+
__queue__.jobs(**args).map { |job| job["args"].first }
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def method_missing(name, *args, &block)
|
21
|
+
# If .queue method not defined, do the right thing
|
22
|
+
if name == :queue
|
23
|
+
return Resque.queue_from_class(self)
|
24
|
+
end
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def __queue__
|
31
|
+
Queue.new(queue)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "resque"
|
2
|
+
|
3
|
+
module Ddr::Jobs
|
4
|
+
class Queue
|
5
|
+
|
6
|
+
attr_reader :name
|
7
|
+
|
8
|
+
def initialize(name)
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
|
12
|
+
def size
|
13
|
+
Resque.size(name)
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Array<Hash>] jobs in the queue, optionally filtered by type,
|
17
|
+
# start position, and count.
|
18
|
+
def jobs(type: nil, start: 0, count: nil)
|
19
|
+
jobs = Resque.peek(name, start, count || size)
|
20
|
+
if type
|
21
|
+
jobs.select! { |job| job["class"] == type.to_s }
|
22
|
+
end
|
23
|
+
jobs
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|