Class: Moab::StorageServices
- Inherits:
-
Object
- Object
- Moab::StorageServices
- Defined in:
- lib/moab/storage_services.rb
Overview
Copyright © 2012 by The Board of Trustees of the Leland Stanford Junior University. All rights reserved. See LICENSE for details.
An interface class to support access to SDR storage via a RESTful server
Data Model
-
StorageRepository = represents a digital object repository storage node
-
StorageServices = supports application layer access to the repository’s objects, data, and metadata
-
StorageObject = represents a digital object’s repository storage location and ingest/dissemination methods
-
StorageObjectVersion [1..*] = represents a version subdirectory within an object’s home directory
-
Bagger [1] = utility for creating bagit packages for ingest or dissemination
-
-
-
Direct Known Subclasses
Constant Summary collapse
- @@repository =
Returns an instance of the interface to SDR storage.
Moab::StorageRepository.new
Class Method Summary collapse
-
.current_version(object_id) ⇒ Integer
The version number of the currently highest version.
-
.deposit_branch(object_id) ⇒ Pathname
The branch segment of the object deposit path.
-
.deposit_trunk ⇒ String
The trunk segment of the object deposit path.
-
.find_storage_object(object_id, include_deposit = false) ⇒ StorageObject
The representation of a digitial object’s storage directory, which might not exist yet.
-
.object_path(object_id) ⇒ String
The location of the storage object.
-
.object_size(object_id, include_deposit = false) ⇒ Integer
The size occupied on disk by the storage object, in bytes.
-
.object_version_path(object_id, version_id = nil) ⇒ String
The location of the storage object version.
- .repository ⇒ Object
-
.retrieve_file(file_category, file_id, object_id, version_id = nil) ⇒ Pathname
Pathname object containing the full path for the specified file.
-
.retrieve_file_group(file_category, object_id, version_id = nil) ⇒ FileInventory
The file inventory for the specified object version.
-
.retrieve_file_signature(file_category, file_id, object_id, version_id = nil) ⇒ FileSignature
The signature of the file.
-
.retrieve_file_using_signature(file_category, file_signature, object_id, version_id = nil) ⇒ Pathname
Pathname object containing the full path for the specified file.
-
.storage_object(object_id, create = false) ⇒ StorageObject
The representation of a digitial object’s storage directory, which must exist.
-
.storage_roots ⇒ Array<Pathname>
A list of the filesystems currently used for storage.
-
.version_differences(object_id, base_version_id, compare_version_id) ⇒ FileInventoryDifference
The report of the version differences.
-
.version_metadata(object_id) ⇒ Pathname
Pathname object containing the full path for the specified file.
Class Method Details
.current_version(object_id) ⇒ Integer
Returns The version number of the currently highest version.
73 74 75 |
# File 'lib/moab/storage_services.rb', line 73 def self.current_version(object_id) @@repository.storage_object(object_id).current_version_id end |
.deposit_branch(object_id) ⇒ Pathname
Returns The branch segment of the object deposit path.
33 34 35 |
# File 'lib/moab/storage_services.rb', line 33 def self.deposit_branch(object_id) @@repository.deposit_branch(object_id) end |
.deposit_trunk ⇒ String
Returns The trunk segment of the object deposit path.
27 28 29 |
# File 'lib/moab/storage_services.rb', line 27 def self.deposit_trunk @@repository.deposit_trunk end |
.find_storage_object(object_id, include_deposit = false) ⇒ StorageObject
Returns The representation of a digitial object’s storage directory, which might not exist yet.
40 41 42 |
# File 'lib/moab/storage_services.rb', line 40 def self.find_storage_object(object_id, include_deposit = false) @@repository.find_storage_object(object_id, include_deposit) end |
.object_path(object_id) ⇒ String
Returns the location of the storage object.
60 61 62 |
# File 'lib/moab/storage_services.rb', line 60 def self.object_path(object_id) @@repository.storage_object(object_id).object_pathname.to_s end |
.object_size(object_id, include_deposit = false) ⇒ Integer
Returns the size occupied on disk by the storage object, in bytes. this is the entire moab (all versions).
47 48 49 |
# File 'lib/moab/storage_services.rb', line 47 def self.object_size(object_id, include_deposit = false) @@repository.object_size(object_id, include_deposit) end |
.object_version_path(object_id, version_id = nil) ⇒ String
Returns the location of the storage object version.
67 68 69 |
# File 'lib/moab/storage_services.rb', line 67 def self.object_version_path(object_id, version_id = nil) @@repository.storage_object(object_id).find_object_version(version_id).version_pathname.to_s end |
.repository ⇒ Object
17 18 19 |
# File 'lib/moab/storage_services.rb', line 17 def self.repository @@repository end |
.retrieve_file(file_category, file_id, object_id, version_id = nil) ⇒ Pathname
Returns Pathname object containing the full path for the specified file.
102 103 104 105 |
# File 'lib/moab/storage_services.rb', line 102 def self.retrieve_file(file_category, file_id, object_id, version_id = nil) storage_object_version = @@repository.storage_object(object_id).find_object_version(version_id) file_pathname = storage_object_version.find_filepath(file_category, file_id) end |
.retrieve_file_group(file_category, object_id, version_id = nil) ⇒ FileInventory
Returns the file inventory for the specified object version.
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/moab/storage_services.rb', line 86 def self.retrieve_file_group(file_category, object_id, version_id = nil) storage_object_version = @@repository.storage_object(object_id).find_object_version(version_id) inventory_type = if file_category =~ /manifest/ file_category = 'manifests' else 'version' end inventory = storage_object_version.file_inventory(inventory_type) inventory.group(file_category) end |
.retrieve_file_signature(file_category, file_id, object_id, version_id = nil) ⇒ FileSignature
Returns The signature of the file.
122 123 124 125 |
# File 'lib/moab/storage_services.rb', line 122 def self.retrieve_file_signature(file_category, file_id, object_id, version_id = nil) storage_object_version = @@repository.storage_object(object_id).find_object_version(version_id) file_pathname = storage_object_version.find_signature(file_category, file_id) end |
.retrieve_file_using_signature(file_category, file_signature, object_id, version_id = nil) ⇒ Pathname
Returns Pathname object containing the full path for the specified file.
112 113 114 115 |
# File 'lib/moab/storage_services.rb', line 112 def self.retrieve_file_using_signature(file_category, file_signature, object_id, version_id = nil) storage_object_version = @@repository.storage_object(object_id).find_object_version(version_id) file_pathname = storage_object_version.find_filepath_using_signature(file_category, file_signature) end |
.storage_object(object_id, create = false) ⇒ StorageObject
Returns The representation of a digitial object’s storage directory, which must exist.
54 55 56 |
# File 'lib/moab/storage_services.rb', line 54 def self.storage_object(object_id, create = false) @@repository.storage_object(object_id, create) end |
.storage_roots ⇒ Array<Pathname>
Returns A list of the filesystems currently used for storage.
22 23 24 |
# File 'lib/moab/storage_services.rb', line 22 def self.storage_roots @@repository.storage_roots end |
.version_differences(object_id, base_version_id, compare_version_id) ⇒ FileInventoryDifference
Returns The report of the version differences.
131 132 133 134 135 136 137 |
# File 'lib/moab/storage_services.rb', line 131 def self.version_differences(object_id, base_version_id, compare_version_id) base_version = @@repository.storage_object(object_id).storage_object_version(base_version_id) compare_version = @@repository.storage_object(object_id).storage_object_version(compare_version_id) base_inventory = base_version.file_inventory('version') compare_inventory = compare_version.file_inventory('version') FileInventoryDifference.new.compare(base_inventory, compare_inventory) end |
.version_metadata(object_id) ⇒ Pathname
Returns Pathname object containing the full path for the specified file.
79 80 81 |
# File 'lib/moab/storage_services.rb', line 79 def self.(object_id) retrieve_file('metadata', 'versionMetadata.xml', object_id) end |