class Moab::StorageServices

An interface class to support access to SDR storage via a RESTful server

Data Model

@note Copyright © 2012 by The Board of Trustees of the Leland Stanford Junior University.

All rights reserved.  See {file:LICENSE.rdoc} for details.

Public Class Methods

current_version(object_id) click to toggle source

@param object_id [String] The digital object identifier @return [Integer] The version number of the currently highest version

# File lib/moab/storage_services.rb, line 84
def self.current_version(object_id)
  repository.storage_object(object_id).current_version_id
end
deposit_branch(object_id) click to toggle source

@param object_id [String] The identifier of the digital object @return [Pathname] The branch segment of the object deposit path

# File lib/moab/storage_services.rb, line 44
def self.deposit_branch(object_id)
  repository.deposit_branch(object_id)
end
deposit_trunk() click to toggle source

@return [String] The trunk segment of the object deposit path

# File lib/moab/storage_services.rb, line 38
def self.deposit_trunk
  repository.deposit_trunk
end
find_storage_object(object_id, include_deposit = false) click to toggle source

@param object_id [String] The identifier of the digital object @param [Object] include_deposit @return [StorageObject] The representation of a digitial object’s storage directory, which might not exist yet.

# File lib/moab/storage_services.rb, line 51
def self.find_storage_object(object_id, include_deposit = false)
  repository.find_storage_object(object_id, include_deposit)
end
object_path(object_id) click to toggle source

@param object_id [String] The digital object identifier of the object @return [String] the location of the storage object

# File lib/moab/storage_services.rb, line 71
def self.object_path(object_id)
  repository.storage_object(object_id).object_pathname.to_s
end
object_size(object_id, include_deposit = false) click to toggle source

@param object_id [String] The identifier of the digital object whose size is desired @param include_deposit [Boolean] specifies whether to look in deposit areas for objects in process of initial ingest @return [Integer] the size occupied on disk by the storage object, in bytes. this is the entire moab (all versions).

# File lib/moab/storage_services.rb, line 58
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) click to toggle source

@param object_id [String] The digital object identifier of the object @param [Integer] version_id The ID of the version, if nil use latest version @return [String] the location of the storage object version

# File lib/moab/storage_services.rb, line 78
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() click to toggle source

@return [StorageRepository] an instance of the interface to SDR storage

# File lib/moab/storage_services.rb, line 28
def self.repository
  @@repository
end
retrieve_file(file_category, file_id, object_id, version_id = nil) click to toggle source

@param [String] file_category The category of file (‘content’, ‘metdata’, or ‘manifest’) @param [String] file_id The name of the file (path relative to base directory) @param [String] object_id The digital object identifier of the object @param [Integer] version_id The ID of the version, if nil use latest version @return [Pathname] Pathname object containing the full path for the specified file

# File lib/moab/storage_services.rb, line 107
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)
  storage_object_version.find_filepath(file_category, file_id)
end
retrieve_file_group(file_category, object_id, version_id = nil) click to toggle source

@param [String] object_id The digital object identifier of the object @param [Integer] version_id The ID of the version, if nil use latest version @return [FileInventory] the file inventory for the specified object version

# File lib/moab/storage_services.rb, line 91
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) click to toggle source

@param [String] file_category The category of file (‘content’, ‘metdata’, or ‘manifest’) @param [String] file_id The name of the file (path relative to base directory) @param [String] object_id The digital object identifier of the object @param [Integer] version_id The ID of the version, if nil use latest version @return [FileSignature] The signature of the file

# File lib/moab/storage_services.rb, line 127
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)
  storage_object_version.find_signature(file_category, file_id)
end
retrieve_file_using_signature(file_category, file_signature, object_id, version_id = nil) click to toggle source

@param [String] file_category The category of file (‘content’, ‘metdata’, or ‘manifest’) @param [FileSignature] file_signature The signature of the file @param [String] object_id The digital object identifier of the object @param [Integer] version_id The ID of the version, if nil use latest version @return [Pathname] Pathname object containing the full path for the specified file

# File lib/moab/storage_services.rb, line 117
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)
  storage_object_version.find_filepath_using_signature(file_category, file_signature)
end
storage_object(object_id, create = false) click to toggle source

@param object_id [String] The identifier of the digital object whose version is desired @param create [Boolean] If true, the object home directory should be created if it does not exist @return [StorageObject] The representation of a digitial object’s storage directory, which must exist.

# File lib/moab/storage_services.rb, line 65
def self.storage_object(object_id, create = false)
  repository.storage_object(object_id, create)
end
storage_roots() click to toggle source

@return [Array<Pathname>] A list of the filesystems currently used for storage

# File lib/moab/storage_services.rb, line 33
def self.storage_roots
  repository.storage_roots
end
version_differences(object_id, base_version_id, compare_version_id) click to toggle source

@param [String] object_id The digital object identifier of the object @param [Object] base_version_id The identifier of the base version to be compared @param [Object] compare_version_id The identifier of the version to be compared to the base version @return [FileInventoryDifference] The report of the version differences

# File lib/moab/storage_services.rb, line 136
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