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



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

def self.current_version(object_id)
  @@repository.storage_object(object_id).current_version_id
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



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

def self.object_path(object_id)
  @@repository.storage_object(object_id).object_pathname.to_s
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



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

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

.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



65
66
67
68
# File 'lib/moab/storage_services.rb', line 65

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



49
50
51
52
53
54
55
56
57
58
# File 'lib/moab/storage_services.rb', line 49

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)
  if file_category =~ /manifest/
    inventory_type = file_category = 'manifests'
  else
    inventory_type = '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:



85
86
87
88
# File 'lib/moab/storage_services.rb', line 85

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



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

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

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



94
95
96
97
98
99
100
# File 'lib/moab/storage_services.rb', line 94

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



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

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