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
['.', '..', '.keep'].freeze
- DATA_DIR =
"data".freeze
- EXPECTED_VERSION_SUB_DIRS =
[DATA_DIR, "manifests"].freeze
- MANIFEST_INVENTORY_PATH =
'manifests/manifestInventory.xml'.freeze
- SIGNATURE_CATALOG_PATH =
'manifests/signatureCatalog.xml'.freeze
- INCORRECT_DIR =
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
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 ⇒ Object
Constructor Details
#initialize(storage_object) ⇒ StorageObjectValidator
Returns a new instance of StorageObjectValidator.
35 36 37 38 |
# File 'lib/moab/storage_object_validator.rb', line 35 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.
33 34 35 |
# File 'lib/moab/storage_object_validator.rb', line 33 def storage_obj_path @storage_obj_path end |
Class Method Details
.error_code_to_messages ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/moab/storage_object_validator.rb', line 48 def self. @error_code_to_messages ||= { INCORRECT_DIR => "Incorrect items in path", MISSING_DIR => "Missing directory: %{addl}", EXTRA_CHILD_DETECTED => "Unexpected item in path: %{addl}", VERSION_DIR_BAD_FORMAT => "Version directory name not in 'v00xx' format", FILES_IN_VERSION_DIR => "Top level should contain only sequential version directories. Also contains files: %{addl}", 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 => "Should only contain files, but directories were present in the metadata directory", 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 => "Should only contain files, but directories were present in the content directory" }.freeze end |
Instance Method Details
#validation_errors ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/moab/storage_object_validator.rb', line 40 def validation_errors errors = [] errors.concat check_correctly_named_version_dirs errors.concat check_sequential_version_dirs if errors.empty? errors.concat check_correctly_formed_moabs if errors.empty? errors end |