Class: Moab::StorageObjectValidator
- Inherits:
-
Object
- Object
- Moab::StorageObjectValidator
- Defined in:
- lib/moab/storage_object_validator.rb
Overview
Given a druid path, are the contents actually a well-formed Moab? Shameless green: repetitious code included.
Direct Known Subclasses
Constant Summary collapse
- METADATA_DIR =
"metadata".freeze
- CONTENT_DIR =
"content".freeze
- EXPECTED_DATA_SUB_DIRS =
[CONTENT_DIR, METADATA_DIR].freeze
- IMPLICIT_DIRS =
unlike Find.find, Dir.entries returns the current/parent dirs
['.', '..'].freeze
- DATA_DIR =
"data".freeze
- MANIFESTS_DIR =
'manifests'.freeze
- EXPECTED_VERSION_SUB_DIRS =
[DATA_DIR, MANIFESTS_DIR].freeze
- MANIFEST_INVENTORY_PATH =
File.join(MANIFESTS_DIR, "manifestInventory.xml").freeze
- SIGNATURE_CATALOG_PATH =
File.join(MANIFESTS_DIR, "signatureCatalog.xml").freeze
- FORBIDDEN_CONTENT_SUB_DIRS =
([DATA_DIR, MANIFESTS_DIR] + EXPECTED_DATA_SUB_DIRS).freeze
- INCORRECT_DIR_CONTENTS =
error codes
0
- MISSING_DIR =
1
- EXTRA_CHILD_DETECTED =
2
- VERSION_DIR_BAD_FORMAT =
3
- NO_SIGNATURE_CATALOG =
4
- NO_MANIFEST_INVENTORY =
5
- NO_FILES_IN_MANIFEST_DIR =
6
- VERSIONS_NOT_IN_ORDER =
7
- METADATA_SUB_DIRS_DETECTED =
8
- FILES_IN_VERSION_DIR =
9
- NO_FILES_IN_METADATA_DIR =
10
- NO_FILES_IN_CONTENT_DIR =
11
- CONTENT_SUB_DIRS_DETECTED =
12
- BAD_SUB_DIR_IN_CONTENT_DIR =
13
Instance Attribute Summary collapse
-
#storage_obj_path ⇒ Object
readonly
Returns the value of attribute storage_obj_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(storage_object) ⇒ StorageObjectValidator
constructor
A new instance of StorageObjectValidator.
- #validation_errors(allow_content_subdirs = true) ⇒ Object
Constructor Details
#initialize(storage_object) ⇒ StorageObjectValidator
Returns a new instance of StorageObjectValidator.
37 38 39 40 |
# File 'lib/moab/storage_object_validator.rb', line 37 def initialize(storage_object) @storage_obj_path = storage_object.object_pathname @directory_entries_hash = {} end |
Instance Attribute Details
#storage_obj_path ⇒ Object (readonly)
Returns the value of attribute storage_obj_path.
35 36 37 |
# File 'lib/moab/storage_object_validator.rb', line 35 def storage_obj_path @storage_obj_path end |
Class Method Details
.error_code_to_messages ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/moab/storage_object_validator.rb', line 50 def self. @error_code_to_messages ||= { INCORRECT_DIR_CONTENTS => "Incorrect items under %{addl} directory", MISSING_DIR => "Missing directory: %{addl}", EXTRA_CHILD_DETECTED => "Unexpected item in path: %{addl}", VERSION_DIR_BAD_FORMAT => "Version directory name not in 'v00xx' format: %{addl}", FILES_IN_VERSION_DIR => "Version directory %{addl} should not contain files; only the manifests and data directories", NO_SIGNATURE_CATALOG => "Version %{addl}: Missing signatureCatalog.xml", NO_MANIFEST_INVENTORY => "Version %{addl}: Missing manifestInventory.xml", NO_FILES_IN_MANIFEST_DIR => "Version %{addl}: No files present in manifest dir", METADATA_SUB_DIRS_DETECTED => "Version %{version}: metadata directory should only contain files, not directories. Found directory: %{dir}", VERSIONS_NOT_IN_ORDER => "Should contain only sequential version directories. Current directories: %{addl}", NO_FILES_IN_METADATA_DIR => "Version %{addl}: No files present in metadata dir", NO_FILES_IN_CONTENT_DIR => "Version %{addl}: No files present in content dir", CONTENT_SUB_DIRS_DETECTED => "Version %{version}: content directory should only contain files, not directories. Found directory: %{dir}", BAD_SUB_DIR_IN_CONTENT_DIR => "Version %{addl}: content directory has forbidden sub-directory name: vnnnn or #{FORBIDDEN_CONTENT_SUB_DIRS}" }.freeze end |
Instance Method Details
#validation_errors(allow_content_subdirs = true) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/moab/storage_object_validator.rb', line 42 def validation_errors(allow_content_subdirs = true) errors = [] errors.concat check_correctly_named_version_dirs errors.concat check_sequential_version_dirs if errors.empty? errors.concat check_correctly_formed_moab(allow_content_subdirs) if errors.empty? errors end |