moab-versioning 2.4.0 → 2.5.0
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 +4 -4
- data/lib/moab/stanford.rb +1 -0
- data/lib/moab/storage_object_validator.rb +24 -13
- data/lib/stanford/storage_object_validator.rb +35 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b141f93a04b4ad8240f247a8a060c6b4b9ebb413
|
4
|
+
data.tar.gz: 7cc328d69cc4589730e5b8b35350ef327fd1ea3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8fcd9e0ad6d4fce690fbc88af68474e28693eb7e9bea7abf41beff93322fce78716d49ade6fb3a1c3410aaf3c55ec4262c411906e0efb8678e59fb0d1f2e792
|
7
|
+
data.tar.gz: fd3fab12cac688a8685aee5f30b50dba29d6ae2115adc2918b329c8a749577c6a1fb394fdf51c226c2c8e3fd5d6a716523928f2c0decb0d1ee7d585d6a575536
|
data/lib/moab/stanford.rb
CHANGED
@@ -5,6 +5,7 @@ require 'stanford/storage_repository'
|
|
5
5
|
require 'stanford/storage_services'
|
6
6
|
require 'stanford/active_fedora_object'
|
7
7
|
require 'stanford/moab_storage_directory'
|
8
|
+
require 'stanford/storage_object_validator'
|
8
9
|
|
9
10
|
# Stanford is a module that isolates classes specific to the Stanford Digital Repository
|
10
11
|
#
|
@@ -23,18 +23,6 @@ module Moab
|
|
23
23
|
VERSIONS_NOT_IN_ORDER = 7
|
24
24
|
FILES_IN_VERSION_DIR = 8
|
25
25
|
|
26
|
-
ERROR_CODE_TO_MESSAGES = {
|
27
|
-
INCORRECT_DIR=> "Incorrect items in path",
|
28
|
-
MISSING_DIR => "Missing directory: %{addl}",
|
29
|
-
EXTRA_CHILD_DETECTED => "Unexpected item in path: %{addl}",
|
30
|
-
VERSION_DIR_BAD_FORMAT => "Version directory name not in 'v00xx' format",
|
31
|
-
FILES_IN_VERSION_DIR => "Top level should contain only sequential version directories. Also contains files: %{addl}",
|
32
|
-
NO_SIGNATURE_CATALOG => "Version: %{addl} Missing signatureCatalog.xml",
|
33
|
-
NO_MANIFEST_INVENTORY => "Version: %{addl} Missing manifestInventory.xml",
|
34
|
-
NO_XML_FILES => "Version: %{addl} Missing all required metadata files",
|
35
|
-
VERSIONS_NOT_IN_ORDER => "Should contain only sequential version directories. Current directories: %{addl}"
|
36
|
-
}.freeze
|
37
|
-
|
38
26
|
attr_reader :storage_obj_path
|
39
27
|
|
40
28
|
def initialize(storage_object)
|
@@ -50,6 +38,21 @@ module Moab
|
|
50
38
|
errors
|
51
39
|
end
|
52
40
|
|
41
|
+
def self.error_code_to_messages
|
42
|
+
@error_code_to_messages ||=
|
43
|
+
{
|
44
|
+
INCORRECT_DIR => "Incorrect items in path",
|
45
|
+
MISSING_DIR => "Missing directory: %{addl}",
|
46
|
+
EXTRA_CHILD_DETECTED => "Unexpected item in path: %{addl}",
|
47
|
+
VERSION_DIR_BAD_FORMAT => "Version directory name not in 'v00xx' format",
|
48
|
+
FILES_IN_VERSION_DIR => "Top level should contain only sequential version directories. Also contains files: %{addl}",
|
49
|
+
NO_SIGNATURE_CATALOG => "Version: %{addl} Missing signatureCatalog.xml",
|
50
|
+
NO_MANIFEST_INVENTORY => "Version: %{addl} Missing manifestInventory.xml",
|
51
|
+
NO_XML_FILES => "Version: %{addl} Missing all required metadata files",
|
52
|
+
VERSIONS_NOT_IN_ORDER => "Should contain only sequential version directories. Current directories: %{addl}"
|
53
|
+
}.freeze
|
54
|
+
end
|
55
|
+
|
53
56
|
# TODO: Figure out which methods should be public
|
54
57
|
|
55
58
|
private
|
@@ -157,7 +160,7 @@ module Moab
|
|
157
160
|
end
|
158
161
|
|
159
162
|
def error_code_msg(response_code, addl=nil)
|
160
|
-
format(
|
163
|
+
format(self.class.error_code_to_messages[response_code], addl: addl)
|
161
164
|
end
|
162
165
|
|
163
166
|
def check_required_manifest_files(dir, version)
|
@@ -176,5 +179,13 @@ module Moab
|
|
176
179
|
errors << result if result
|
177
180
|
errors
|
178
181
|
end
|
182
|
+
|
183
|
+
def latest_manifest_inventory
|
184
|
+
"#{storage_obj_path}/#{version_directories.last}/#{MANIFEST_INVENTORY_PATH}"
|
185
|
+
end
|
186
|
+
|
187
|
+
def object_id_from_manifest_inventory
|
188
|
+
Nokogiri::XML(File.open(latest_manifest_inventory)).at_xpath('//fileInventory/@objectId').value
|
189
|
+
end
|
179
190
|
end
|
180
191
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'moab'
|
2
|
+
|
3
|
+
module Stanford
|
4
|
+
# druids are Stanford specific entities
|
5
|
+
class StorageObjectValidator < Moab::StorageObjectValidator
|
6
|
+
|
7
|
+
# TODO: test to make sure constants don't collide on underlying int vals?
|
8
|
+
# keep from stepping on previously defined error code constants.
|
9
|
+
DRUID_MISMATCH = superclass.error_code_to_messages.keys.max + 1
|
10
|
+
|
11
|
+
def validation_errors
|
12
|
+
errors = []
|
13
|
+
errors.concat super
|
14
|
+
errors.concat identify_druid
|
15
|
+
end
|
16
|
+
|
17
|
+
def identify_druid
|
18
|
+
druid_from_filepath == object_id_from_manifest_inventory ? [] : [result_hash(DRUID_MISMATCH)]
|
19
|
+
end
|
20
|
+
|
21
|
+
# the Stanford validator expects keys to be in ascending numerical order
|
22
|
+
def self.error_code_to_messages
|
23
|
+
@error_code_to_messages ||=
|
24
|
+
{
|
25
|
+
DRUID_MISMATCH => 'manifestInventory object_id does not match druid'
|
26
|
+
}.merge!(superclass.error_code_to_messages).freeze
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def druid_from_filepath
|
32
|
+
"druid:#{File.basename(storage_obj_path)}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moab-versioning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Weber
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-11-
|
14
|
+
date: 2017-11-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: confstruct
|
@@ -277,6 +277,7 @@ files:
|
|
277
277
|
- lib/stanford/content_inventory.rb
|
278
278
|
- lib/stanford/dor_metadata.rb
|
279
279
|
- lib/stanford/moab_storage_directory.rb
|
280
|
+
- lib/stanford/storage_object_validator.rb
|
280
281
|
- lib/stanford/storage_repository.rb
|
281
282
|
- lib/stanford/storage_services.rb
|
282
283
|
- lib/tasks/yard.rake
|
@@ -300,7 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
301
|
version: '0'
|
301
302
|
requirements: []
|
302
303
|
rubyforge_project:
|
303
|
-
rubygems_version: 2.6.
|
304
|
+
rubygems_version: 2.6.13
|
304
305
|
signing_key:
|
305
306
|
specification_version: 4
|
306
307
|
summary: Ruby implementation of digital object versioning toolkit used by the SULAIR
|