active-fedora 11.1.3 → 11.2.1
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 +5 -5
- data/.rubocop.yml +3 -2
- data/.rubocop_todo.yml +73 -18
- data/.travis.yml +4 -4
- data/History.txt +6 -0
- data/README.md +1 -1
- data/active-fedora.gemspec +5 -4
- data/lib/active_fedora.rb +3 -3
- data/lib/active_fedora/aggregation/list_source.rb +1 -1
- data/lib/active_fedora/associations/association.rb +1 -2
- data/lib/active_fedora/associations/basic_contains_association.rb +3 -1
- data/lib/active_fedora/associations/builder/association.rb +1 -2
- data/lib/active_fedora/associations/null_validator.rb +1 -2
- data/lib/active_fedora/attached_files.rb +4 -0
- data/lib/active_fedora/attributes/property_builder.rb +3 -3
- data/lib/active_fedora/containers/container.rb +1 -2
- data/lib/active_fedora/file.rb +2 -3
- data/lib/active_fedora/file_configurator.rb +2 -2
- data/lib/active_fedora/fixity_service.rb +36 -5
- data/lib/active_fedora/indexers/null_indexer.rb +1 -2
- data/lib/active_fedora/indexing.rb +34 -15
- data/lib/active_fedora/indexing/descendant_fetcher.rb +101 -0
- data/lib/active_fedora/indexing/map.rb +11 -3
- data/lib/active_fedora/indexing_service.rb +6 -1
- data/lib/active_fedora/inheritance.rb +1 -1
- data/lib/active_fedora/null_logger.rb +2 -4
- data/lib/active_fedora/persistence.rb +2 -2
- data/lib/active_fedora/property.rb +1 -2
- data/lib/active_fedora/rake_support.rb +1 -1
- data/lib/active_fedora/rdf/field_map.rb +2 -2
- data/lib/active_fedora/rdf/field_map_entry.rb +7 -5
- data/lib/active_fedora/rdf/indexing_service.rb +9 -7
- data/lib/active_fedora/relation/finder_methods.rb +2 -1
- data/lib/active_fedora/solr_service.rb +2 -1
- data/lib/active_fedora/type/value.rb +2 -4
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/with_metadata/metadata_node.rb +2 -0
- data/spec/integration/associations_spec.rb +8 -8
- data/spec/integration/attached_files_spec.rb +1 -2
- data/spec/integration/collection_association_spec.rb +1 -1
- data/spec/integration/direct_container_spec.rb +2 -2
- data/spec/integration/fedora_solr_sync_spec.rb +1 -1
- data/spec/integration/generators/fedora_generator_spec.rb +1 -1
- data/spec/integration/generators/solr_generator_spec.rb +1 -1
- data/spec/integration/has_many_associations_spec.rb +4 -5
- data/spec/integration/indexing_spec.rb +21 -1
- data/spec/integration/indirect_container_spec.rb +2 -2
- data/spec/integration/solr_hit_spec.rb +1 -1
- data/spec/integration/versionable_spec.rb +2 -2
- data/spec/unit/attached_files_spec.rb +36 -8
- data/spec/unit/attributes_spec.rb +5 -13
- data/spec/unit/base_spec.rb +2 -2
- data/spec/unit/callback_spec.rb +2 -2
- data/spec/unit/change_set_spec.rb +1 -2
- data/spec/unit/collection_proxy_spec.rb +2 -1
- data/spec/unit/core_spec.rb +3 -3
- data/spec/unit/default_model_mapper_spec.rb +1 -1
- data/spec/unit/file_path_builder_spec.rb +1 -1
- data/spec/unit/file_spec.rb +23 -25
- data/spec/unit/files_hash_spec.rb +1 -2
- data/spec/unit/filter_spec.rb +2 -2
- data/spec/unit/fixity_service_spec.rb +65 -5
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +1 -2
- data/spec/unit/has_many_association_spec.rb +2 -2
- data/spec/unit/indexing/map/index_object_spec.rb +25 -0
- data/spec/unit/indexing/map_spec.rb +27 -0
- data/spec/unit/indexing_spec.rb +1 -2
- data/spec/unit/inheritance_spec.rb +28 -1
- data/spec/unit/model_classifier_spec.rb +1 -1
- data/spec/unit/pathing_spec.rb +1 -2
- data/spec/unit/query_result_builder_spec.rb +1 -2
- data/spec/unit/query_spec.rb +1 -1
- data/spec/unit/rdf/indexing_service_spec.rb +17 -3
- data/spec/unit/reflection_spec.rb +2 -2
- data/spec/unit/solr_hit_spec.rb +1 -2
- data/spec/unit/solr_service_spec.rb +6 -0
- data/spec/unit/sparql_insert_spec.rb +1 -1
- data/spec/unit/with_metadata/metadata_node_spec.rb +26 -1
- metadata +28 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2a1b653e61034a472c59722925334b0cfa2d83391a5e8f7ed89678fab2f729ac
|
4
|
+
data.tar.gz: 4cd25e244f319ea0eb84e0ea5c5067fc967764695073062ea510c0222dc7814b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86a88288dede46d2a4fe40f1924434004b8f74d0b5452058c9f4aef8256d3147edc4fa62d2a6d1a626451e4cb16b78f9785b8564a694e1c4ded7b03409fdc752
|
7
|
+
data.tar.gz: daeb70527556e50848a9407e9dabaf2e5a051c6e942d5a49e01b4c90b6c3d61f92cdae307a781fe3b1d1a957943dd0eeeaa4a1b479f52addc0202154cec4e3aa
|
data/.rubocop.yml
CHANGED
@@ -106,7 +106,6 @@ Style/AndOr:
|
|
106
106
|
Style/AccessorMethodName:
|
107
107
|
Exclude:
|
108
108
|
- 'lib/active_fedora/with_metadata/metadata_node.rb'
|
109
|
-
- 'lib/active_fedora/predicates.rb'
|
110
109
|
- 'lib/active_fedora/fedora_attributes.rb'
|
111
110
|
- 'lib/active_fedora/attribute_methods/dirty.rb'
|
112
111
|
- 'lib/active_fedora/associations/has_many_association.rb'
|
@@ -207,7 +206,6 @@ Style/ClassVars:
|
|
207
206
|
- 'spec/unit/finder_methods_spec.rb'
|
208
207
|
- 'spec/unit/base_spec.rb'
|
209
208
|
- 'spec/integration/indexing_spec.rb'
|
210
|
-
- 'lib/active_fedora/predicates.rb'
|
211
209
|
- 'lib/active_fedora/identifiable.rb'
|
212
210
|
|
213
211
|
Style/SignalException:
|
@@ -266,3 +264,6 @@ RSpec/DescribedClass:
|
|
266
264
|
|
267
265
|
RSpec/NotToNot:
|
268
266
|
Enabled: false
|
267
|
+
|
268
|
+
RSpec/MessageSpies:
|
269
|
+
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
@@ -1,20 +1,23 @@
|
|
1
|
-
require: rubocop-rspec
|
2
|
-
|
3
1
|
# This configuration was generated by
|
4
2
|
# `rubocop --auto-gen-config`
|
5
|
-
# on
|
3
|
+
# on 2017-02-28 19:30:31 -0600 using RuboCop version 0.47.1.
|
6
4
|
# The point is for the user to remove these configuration records
|
7
5
|
# one by one as the offenses are removed from the code base.
|
8
6
|
# Note that changes in the inspected code, or installation of new
|
9
7
|
# versions of RuboCop, may require this file to be generated again.
|
10
8
|
|
11
|
-
# Offense count:
|
12
|
-
# Configuration parameters:
|
13
|
-
|
9
|
+
# Offense count: 211
|
10
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
11
|
+
Metrics/BlockLength:
|
12
|
+
Max: 577
|
13
|
+
|
14
|
+
# Offense count: 65
|
15
|
+
RSpec/BeforeAfterAll:
|
14
16
|
Enabled: false
|
15
17
|
|
16
|
-
# Offense count:
|
17
|
-
|
18
|
+
# Offense count: 114
|
19
|
+
# Configuration parameters: Max.
|
20
|
+
RSpec/ExampleLength:
|
18
21
|
Enabled: false
|
19
22
|
|
20
23
|
# Offense count: 15
|
@@ -32,24 +35,76 @@ RSpec/MessageChain:
|
|
32
35
|
Exclude:
|
33
36
|
- 'spec/unit/file_spec.rb'
|
34
37
|
|
35
|
-
# Offense count:
|
36
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
37
|
-
# SupportedStyles: allow, expect
|
38
|
-
RSpec/MessageExpectation:
|
39
|
-
Enabled: false
|
40
|
-
|
41
|
-
# Offense count: 238
|
38
|
+
# Offense count: 241
|
42
39
|
RSpec/MultipleExpectations:
|
43
40
|
Max: 8
|
44
41
|
|
45
|
-
# Offense count:
|
46
|
-
# Configuration parameters:
|
42
|
+
# Offense count: 181
|
43
|
+
# Configuration parameters: Max.
|
47
44
|
RSpec/NestedGroups:
|
48
45
|
Enabled: false
|
49
46
|
|
47
|
+
# Offense count: 24
|
48
|
+
RSpec/ScatteredSetup:
|
49
|
+
Exclude:
|
50
|
+
- 'spec/integration/base_spec.rb'
|
51
|
+
- 'spec/integration/direct_container_spec.rb'
|
52
|
+
- 'spec/integration/has_and_belongs_to_many_associations_spec.rb'
|
53
|
+
- 'spec/integration/indexing_spec.rb'
|
54
|
+
- 'spec/integration/indirect_container_spec.rb'
|
55
|
+
- 'spec/integration/json_serialization_spec.rb'
|
56
|
+
- 'spec/unit/attached_files_spec.rb'
|
57
|
+
- 'spec/unit/base_spec.rb'
|
58
|
+
- 'spec/unit/loadable_from_json_spec.rb'
|
59
|
+
- 'spec/unit/rdf/indexing_service_spec.rb'
|
60
|
+
|
50
61
|
# Offense count: 94
|
51
62
|
RSpec/SubjectStub:
|
52
|
-
|
63
|
+
Exclude:
|
64
|
+
- 'spec/integration/associations_spec.rb'
|
65
|
+
- 'spec/integration/autosave_association_spec.rb'
|
66
|
+
- 'spec/integration/versionable_spec.rb'
|
67
|
+
- 'spec/unit/attached_files_spec.rb'
|
68
|
+
- 'spec/unit/base_extra_spec.rb'
|
69
|
+
- 'spec/unit/file_configurator_spec.rb'
|
70
|
+
- 'spec/unit/file_spec.rb'
|
71
|
+
- 'spec/unit/has_and_belongs_to_many_association_spec.rb'
|
72
|
+
- 'spec/unit/persistence_spec.rb'
|
73
|
+
- 'spec/unit/solr_config_options_spec.rb'
|
74
|
+
- 'spec/unit/validations_spec.rb'
|
53
75
|
|
76
|
+
# Offense count: 20
|
77
|
+
# Configuration parameters: IgnoreSymbolicNames.
|
54
78
|
RSpec/VerifiedDoubles:
|
79
|
+
Exclude:
|
80
|
+
- 'spec/unit/association_hash_spec.rb'
|
81
|
+
- 'spec/unit/files_hash_spec.rb'
|
82
|
+
- 'spec/unit/query_spec.rb'
|
83
|
+
- 'spec/unit/schema_indexing_strategy_spec.rb'
|
84
|
+
- 'spec/unit/solr_config_options_spec.rb'
|
85
|
+
- 'spec/unit/solr_service_spec.rb'
|
86
|
+
|
87
|
+
# Offense count: 3
|
88
|
+
Rails/FilePath:
|
89
|
+
Exclude:
|
90
|
+
- 'lib/active_fedora/file_configurator.rb'
|
91
|
+
- 'spec/unit/file_configurator_spec.rb'
|
92
|
+
|
93
|
+
# Offense count: 2
|
94
|
+
Security/MarshalLoad:
|
95
|
+
Exclude:
|
96
|
+
- 'spec/integration/marshal_spec.rb'
|
97
|
+
|
98
|
+
# Offense count: 20
|
99
|
+
# Configuration parameters: MinBodyLength.
|
100
|
+
Style/GuardClause:
|
55
101
|
Enabled: false
|
102
|
+
|
103
|
+
# Offense count: 20
|
104
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
105
|
+
# SupportedStyles: snake_case, normalcase, non_integer
|
106
|
+
Style/VariableNumber:
|
107
|
+
Exclude:
|
108
|
+
- 'spec/integration/associations_spec.rb'
|
109
|
+
- 'spec/unit/ordered_spec.rb'
|
110
|
+
- 'spec/unit/orders/ordered_list_spec.rb'
|
data/.travis.yml
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
sudo: false
|
4
|
-
rvm: 2.4.
|
4
|
+
rvm: 2.4.1
|
5
5
|
matrix:
|
6
6
|
include:
|
7
|
-
- rvm: 2.3.
|
8
|
-
env: "RAILS_VERSION=4.2.
|
9
|
-
- env: "RSOLR_VERSION=2.0.
|
7
|
+
- rvm: 2.3.4
|
8
|
+
env: "RAILS_VERSION=4.2.8"
|
9
|
+
- env: "RSOLR_VERSION=2.0.1"
|
10
10
|
global_env:
|
11
11
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
12
12
|
before_install:
|
data/History.txt
CHANGED
data/README.md
CHANGED
data/active-fedora.gemspec
CHANGED
@@ -20,20 +20,21 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_dependency "activemodel", '>= 4.2', '< 6'
|
21
21
|
s.add_dependency "active-triples", '~> 0.11.0'
|
22
22
|
s.add_dependency "deprecation"
|
23
|
-
s.add_dependency "ldp", '~> 0.
|
23
|
+
s.add_dependency "ldp", '~> 0.7.0'
|
24
|
+
s.add_dependency "ruby-progressbar", '~> 1.0'
|
24
25
|
|
25
26
|
s.add_development_dependency "rails"
|
26
27
|
s.add_development_dependency "rdoc"
|
27
28
|
s.add_development_dependency "yard"
|
28
29
|
s.add_development_dependency "rake"
|
29
|
-
s.add_development_dependency "solr_wrapper", "~> 0
|
30
|
+
s.add_development_dependency "solr_wrapper", "~> 1.0"
|
30
31
|
s.add_development_dependency 'fcrepo_wrapper', '~> 0.2'
|
31
32
|
s.add_development_dependency "rspec", "~> 3.0"
|
32
33
|
s.add_development_dependency "rspec-its"
|
33
34
|
s.add_development_dependency "equivalent-xml"
|
34
35
|
s.add_development_dependency "simplecov", '~> 0.8'
|
35
|
-
s.add_development_dependency "rubocop", '~> 0.
|
36
|
-
s.add_development_dependency "rubocop-rspec", '~> 1.
|
36
|
+
s.add_development_dependency "rubocop", '~> 0.47.1'
|
37
|
+
s.add_development_dependency "rubocop-rspec", '~> 1.12.0'
|
37
38
|
|
38
39
|
s.files = `git ls-files`.split("\n")
|
39
40
|
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
data/lib/active_fedora.rb
CHANGED
@@ -196,11 +196,11 @@ module ActiveFedora #:nodoc:
|
|
196
196
|
# ActiveFedora.environment => "test"
|
197
197
|
def environment
|
198
198
|
if config_options.fetch(:environment, nil)
|
199
|
-
|
199
|
+
config_options[:environment]
|
200
200
|
elsif defined?(Rails.env) && !Rails.env.nil?
|
201
|
-
|
201
|
+
Rails.env.to_s
|
202
202
|
elsif defined?(ENV['environment']) && !ENV['environment'].nil?
|
203
|
-
|
203
|
+
ENV['environment']
|
204
204
|
elsif defined?(ENV['RAILS_ENV']) && !ENV['RAILS_ENV'].nil?
|
205
205
|
raise "You're depending on RAILS_ENV for setting your environment. Please use ENV['environment'] for non-rails environment setting: 'rake foo:bar environment=test'"
|
206
206
|
else
|
@@ -80,7 +80,7 @@ module ActiveFedora
|
|
80
80
|
# Set node subjects to a term in AF JUST so that AF will persist the
|
81
81
|
# sub-graphs.
|
82
82
|
# TODO: Find a way to fix this.
|
83
|
-
|
83
|
+
resource.set_value(:nodes, [])
|
84
84
|
self.nodes += graph.subjects.to_a
|
85
85
|
ordered_self.changes_committed!
|
86
86
|
end
|
@@ -202,8 +202,7 @@ module ActiveFedora
|
|
202
202
|
# the target is stale.
|
203
203
|
#
|
204
204
|
# This is only relevant to certain associations, which is why it returns nil by default.
|
205
|
-
def stale_state
|
206
|
-
end
|
205
|
+
def stale_state; end
|
207
206
|
|
208
207
|
def build_record(attributes)
|
209
208
|
reflection.build_association(attributes) do |record|
|
@@ -22,7 +22,9 @@ module ActiveFedora
|
|
22
22
|
# Update the membership triples (and no other triples) on the the owner's resource
|
23
23
|
if owner.persisted?
|
24
24
|
pattern = ::RDF::Query::Pattern.new(predicate: options[:predicate])
|
25
|
-
new_resource =
|
25
|
+
new_resource = ActiveFedora::Base.uncached do
|
26
|
+
owner.dup.reload.resource
|
27
|
+
end
|
26
28
|
owner.resource.delete_insert([pattern], new_resource.query(pattern))
|
27
29
|
end
|
28
30
|
super
|
@@ -63,8 +63,7 @@ module ActiveFedora::Associations::Builder
|
|
63
63
|
name
|
64
64
|
end
|
65
65
|
|
66
|
-
def self.define_extensions(_model, _name)
|
67
|
-
end
|
66
|
+
def self.define_extensions(_model, _name); end
|
68
67
|
|
69
68
|
def self.define_callbacks(model, reflection)
|
70
69
|
if dependent = reflection.options[:dependent]
|
@@ -33,7 +33,11 @@ module ActiveFedora
|
|
33
33
|
resource.query(subject: resource, predicate: ::RDF::Vocab::LDP.contains).objects.map(&:to_s)
|
34
34
|
end
|
35
35
|
|
36
|
+
# Load any undeclared relationships or has_subresource relationships. These are non-idiomatic LDP
|
37
|
+
# because we are going to find the subresource by knowing it's subpath ahead of time.
|
38
|
+
# Does nothing if this object is using idiomatic basic containment, by declaring `is_a_container`
|
36
39
|
def load_attached_files
|
40
|
+
return if reflections[:contains] && reflections[:contains].macro == :is_a_container
|
37
41
|
contains_assertions.each do |file_uri|
|
38
42
|
path = file_uri.to_s.sub(uri + '/', '')
|
39
43
|
next if association(path.to_sym)
|
@@ -16,7 +16,7 @@ module ActiveFedora::Attributes
|
|
16
16
|
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
|
17
17
|
def #{name}=(value)
|
18
18
|
if value.present? && !value.respond_to?(:each)
|
19
|
-
raise ArgumentError, "You attempted to set the property `#{name}' to a scalar value. However, this property is declared as being multivalued."
|
19
|
+
raise ArgumentError, "You attempted to set the property `#{name}' of \#{id} to a scalar value. However, this property is declared as being multivalued."
|
20
20
|
end
|
21
21
|
set_value(:#{name}, value)
|
22
22
|
end
|
@@ -28,7 +28,7 @@ module ActiveFedora::Attributes
|
|
28
28
|
def #{name}(*args)
|
29
29
|
vals = get_values(:#{name})
|
30
30
|
return nil unless vals
|
31
|
-
raise ActiveFedora::ConstraintError, "Expected \\"#{name}\\" to have 0-1 statements, but there are \#{vals.size}" if vals.size > 1
|
31
|
+
raise ActiveFedora::ConstraintError, "Expected \\"#{name}\\" of \#{id} to have 0-1 statements, but there are \#{vals.size}" if vals.size > 1
|
32
32
|
vals.first
|
33
33
|
end
|
34
34
|
CODE
|
@@ -46,7 +46,7 @@ module ActiveFedora::Attributes
|
|
46
46
|
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
|
47
47
|
def #{name}=(value)
|
48
48
|
if value.respond_to?(:each) # singular
|
49
|
-
raise ArgumentError, "You attempted to set the property `#{name}' to an enumerable value. However, this property is declared as singular."
|
49
|
+
raise ArgumentError, "You attempted to set the property `#{name}' of \#{id} to an enumerable value. However, this property is declared as singular."
|
50
50
|
end
|
51
51
|
set_value(:#{name}, value)
|
52
52
|
end
|
data/lib/active_fedora/file.rb
CHANGED
@@ -40,7 +40,7 @@ module ActiveFedora
|
|
40
40
|
id = ActiveFedora::Associations::IDComposite.new([identifier], translate_uri_to_id).first
|
41
41
|
@ldp_source = build_ldp_resource id
|
42
42
|
else
|
43
|
-
raise "The first argument to #{self} must be a Hash, String or RDF::URI. You provided a #{
|
43
|
+
raise "The first argument to #{self} must be a Hash, String or RDF::URI. You provided a #{identifier.class}"
|
44
44
|
end
|
45
45
|
|
46
46
|
@attributes = {}.with_indifferent_access
|
@@ -140,8 +140,7 @@ module ActiveFedora
|
|
140
140
|
end
|
141
141
|
|
142
142
|
# serializes any changed data into the content field
|
143
|
-
def serialize
|
144
|
-
end
|
143
|
+
def serialize!; end
|
145
144
|
|
146
145
|
def to_solr(solr_doc = {}, _opts = {})
|
147
146
|
solr_doc
|
@@ -108,7 +108,7 @@ module ActiveFedora
|
|
108
108
|
end
|
109
109
|
|
110
110
|
begin
|
111
|
-
fedora_yml = YAML.
|
111
|
+
fedora_yml = YAML.safe_load(config_erb, [], [], true) # allow YAML aliases
|
112
112
|
rescue Psych::SyntaxError => e
|
113
113
|
raise "fedora.yml was found, but could not be parsed. " \
|
114
114
|
"Error #{e.message}"
|
@@ -132,7 +132,7 @@ module ActiveFedora
|
|
132
132
|
end
|
133
133
|
|
134
134
|
begin
|
135
|
-
solr_yml = YAML.
|
135
|
+
solr_yml = YAML.safe_load(config_erb, [], [], true) # allow YAML aliases
|
136
136
|
rescue StandardError
|
137
137
|
raise("solr.yml was found, but could not be parsed.\n")
|
138
138
|
end
|
@@ -2,26 +2,57 @@ module ActiveFedora
|
|
2
2
|
class FixityService
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
-
attr_accessor :target
|
5
|
+
attr_accessor :target
|
6
6
|
|
7
|
-
# @param [String, RDF::URI] target url for a Fedora resource
|
7
|
+
# @param [String, RDF::URI] target url for a Fedora resource.
|
8
8
|
def initialize(target)
|
9
9
|
raise ArgumentError, 'You must provide a uri' unless target
|
10
10
|
@target = target.to_s
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
def response
|
14
|
+
@response ||= fixity_response_from_fedora
|
15
|
+
end
|
16
|
+
|
17
|
+
# For backwards compat, check always insists on doing a new request.
|
18
|
+
# you might want verified? instead which uses a cached request.
|
14
19
|
# @return true or false
|
15
20
|
def check
|
16
|
-
@response =
|
21
|
+
@response = nil
|
22
|
+
verified?
|
23
|
+
end
|
24
|
+
|
25
|
+
# Executes a fixity check on Fedora
|
26
|
+
# @return true or false
|
27
|
+
def verified?
|
17
28
|
status.include?(success)
|
18
29
|
end
|
19
30
|
|
31
|
+
# An array of 1 or more literals reported by Fedora.
|
32
|
+
# See 'success' for which one indicates fixity check is good.
|
20
33
|
def status
|
21
34
|
fixity_graph.query(predicate: premis_status_predicate).map(&:object) +
|
22
35
|
fixity_graph.query(predicate: fedora_status_predicate).map(&:object)
|
23
36
|
end
|
24
37
|
|
38
|
+
# the currently calculated checksum, as a string URI, like
|
39
|
+
# "urn:sha1:09a848b79f86f3a4f3f301b8baafde455d6f8e0e"
|
40
|
+
def expected_message_digest
|
41
|
+
fixity_graph.query(predicate: ::RDF::Vocab::PREMIS.hasMessageDigest).first.try(:object).try(:to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
# integer, as reported by fedora. bytes maybe?
|
45
|
+
def expected_size
|
46
|
+
fixity_graph.query(predicate: ::RDF::Vocab::PREMIS.hasSize).first.try(:object).try(:to_s).try(:to_i)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Fedora response as an ::RDF::Graph object. Public API, so consumers
|
50
|
+
# can do with it what they will, especially if future fedora versions
|
51
|
+
# add more things to it.
|
52
|
+
def response_graph
|
53
|
+
fixity_graph
|
54
|
+
end
|
55
|
+
|
25
56
|
private
|
26
57
|
|
27
58
|
def premis_status_predicate
|
@@ -46,7 +77,7 @@ module ActiveFedora
|
|
46
77
|
end
|
47
78
|
|
48
79
|
def fixity_graph
|
49
|
-
::RDF::Graph.new << ::RDF::Reader.for(:ttl).new(response.body)
|
80
|
+
@fixity_graph ||= ::RDF::Graph.new << ::RDF::Reader.for(:ttl).new(response.body)
|
50
81
|
end
|
51
82
|
|
52
83
|
# See https://jira.duraspace.org/browse/FCREPO-1247
|