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 
- 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 
- 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
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.
| 36 37 38 39 | # File 'lib/moab/storage_object_validator.rb', line 36 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.
| 34 35 36 | # File 'lib/moab/storage_object_validator.rb', line 34 def storage_obj_path @storage_obj_path end | 
Class Method Details
.error_code_to_messages ⇒ Object
| 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # File 'lib/moab/storage_object_validator.rb', line 49 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 %{addl}: metadata directory should only contain files, not directories", 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 %{addl}: content directory should only contain files, not directories" }.freeze end | 
Instance Method Details
#validation_errors ⇒ Object
| 41 42 43 44 45 46 47 | # File 'lib/moab/storage_object_validator.rb', line 41 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_moab if errors.empty? errors end |