Class: Moab::StorageServices

Inherits:
Object
  • Object
show all
Defined in:
lib/moab/storage_services.rb

Overview

Note:

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

Stanford::StorageServices

Constant Summary collapse

@@repository =

Returns an instance of the interface to SDR storage.

Returns:

Moab::StorageRepository.new

Class Method Summary collapse

Class Method Details

.current_version(object_id) ⇒ Integer

Returns The version number of the currently highest version.

Parameters:

  • object_id (String)

    The digital object identifier

Returns:

  • (Integer)

    The version number of the currently highest version


82
83
84
# File 'lib/moab/storage_services.rb', line 82

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.

Parameters:

  • object_id (String)

    The identifier of the digital object

Returns:

  • (Pathname)

    The branch segment of the object deposit path


35
36
37
# File 'lib/moab/storage_services.rb', line 35

def self.deposit_branch(object_id)
  @@repository.deposit_branch(object_id)
end

.deposit_trunkString

Returns The trunk segment of the object deposit path.

Returns:

  • (String)

    The trunk segment of the object deposit path


29
30
31
# File 'lib/moab/storage_services.rb', line 29

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.

Parameters:

  • object_id (String)

    The identifier of the digital object

  • include_deposit (Object) (defaults to: false)

Returns:

  • (StorageObject)

    The representation of a digitial object's storage directory, which might not exist yet.


42
43
44
# File 'lib/moab/storage_services.rb', line 42

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.

Parameters:

  • object_id (String)

    The digital object identifier of the object

Returns:

  • (String)

    the location of the storage object


69
70
71
# File 'lib/moab/storage_services.rb', line 69

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).

Parameters:

  • object_id (String)

    The identifier of the digital object whose size is desired

  • include_deposit (Boolean) (defaults to: false)

    specifies whether to look in deposit areas for objects in process of initial ingest

Returns:

  • (Integer)

    the size occupied on disk by the storage object, in bytes. this is the entire moab (all versions).


56
57
58
# File 'lib/moab/storage_services.rb', line 56

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.

Parameters:

  • object_id (String)

    The digital object identifier of the object

  • version_id (Integer) (defaults to: nil)

    The ID of the version, if nil use latest version

Returns:

  • (String)

    the location of the storage object version


76
77
78
# File 'lib/moab/storage_services.rb', line 76

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

.repositoryObject


19
20
21
# File 'lib/moab/storage_services.rb', line 19

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.

Parameters:

  • file_category (String)

    The category of file ('content', 'metdata', or 'manifest')

  • file_id (String)

    The name of the file (path relative to base directory)

  • object_id (String)

    The digital object identifier of the object

  • version_id (Integer) (defaults to: nil)

    The ID of the version, if nil use latest version

Returns:

  • (Pathname)

    Pathname object containing the full path for the specified file


111
112
113
114
# File 'lib/moab/storage_services.rb', line 111

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.

Parameters:

  • object_id (String)

    The digital object identifier of the object

  • version_id (Integer) (defaults to: nil)

    The ID of the version, if nil use latest version

Returns:

  • (FileInventory)

    the file inventory for the specified object version


95
96
97
98
99
100
101
102
103
104
# File 'lib/moab/storage_services.rb', line 95

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.

Parameters:

  • file_category (String)

    The category of file ('content', 'metdata', or 'manifest')

  • file_id (String)

    The name of the file (path relative to base directory)

  • object_id (String)

    The digital object identifier of the object

  • version_id (Integer) (defaults to: nil)

    The ID of the version, if nil use latest version

Returns:


131
132
133
134
# File 'lib/moab/storage_services.rb', line 131

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.

Parameters:

  • file_category (String)

    The category of file ('content', 'metdata', or 'manifest')

  • file_signature (FileSignature)

    The signature of the file

  • object_id (String)

    The digital object identifier of the object

  • version_id (Integer) (defaults to: nil)

    The ID of the version, if nil use latest version

Returns:

  • (Pathname)

    Pathname object containing the full path for the specified file


121
122
123
124
# File 'lib/moab/storage_services.rb', line 121

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

.search_storage_objects(object_id, include_deposit = false) ⇒ Array<StorageObject>

Returns Representations of a digitial object's storage directories, or an empty array if none found.

Parameters:

  • object_id (String)

    The identifier of the digital object

  • include_deposit (Object) (defaults to: false)

Returns:

  • (Array<StorageObject>)

    Representations of a digitial object's storage directories, or an empty array if none found.


49
50
51
# File 'lib/moab/storage_services.rb', line 49

def self.search_storage_objects(object_id, include_deposit = false)
  @@repository.search_storage_objects(object_id, include_deposit)
end

.storage_object(object_id, create = false) ⇒ StorageObject

Returns The representation of a digitial object's storage directory, which must exist.

Parameters:

  • object_id (String)

    The identifier of the digital object whose version is desired

  • create (Boolean) (defaults to: false)

    If true, the object home directory should be created if it does not exist

Returns:

  • (StorageObject)

    The representation of a digitial object's storage directory, which must exist.


63
64
65
# File 'lib/moab/storage_services.rb', line 63

def self.storage_object(object_id, create = false)
  @@repository.storage_object(object_id, create)
end

.storage_rootsArray<Pathname>

Returns A list of the filesystems currently used for storage.

Returns:

  • (Array<Pathname>)

    A list of the filesystems currently used for storage


24
25
26
# File 'lib/moab/storage_services.rb', line 24

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.

Parameters:

  • object_id (String)

    The digital object identifier of the object

  • base_version_id (Object)

    The identifier of the base version to be compared

  • compare_version_id (Object)

    The identifier of the version to be compared to the base version

Returns:


140
141
142
143
144
145
146
# File 'lib/moab/storage_services.rb', line 140

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.

Parameters:

  • object_id (String)

    The digital object identifier of the object

Returns:

  • (Pathname)

    Pathname object containing the full path for the specified file


88
89
90
# File 'lib/moab/storage_services.rb', line 88

def self.(object_id)
  retrieve_file('metadata', 'versionMetadata.xml', object_id)
end