Class: Stanford::StorageRepository

Inherits:
Moab::StorageRepository show all
Defined in:
lib/stanford/storage_repository.rb

Overview

Note:

Copyright © 2012 by The Board of Trustees of the Leland Stanford Junior University. All rights reserved. See LICENSE for details.

A class to represent the SDR repository store

Data Model

Instance Method Summary collapse

Methods inherited from Moab::StorageRepository

#deposit_trunk, #find_storage_object, #find_storage_root, #object_size, #storage_object, #storage_roots, #storage_trunk, #store_new_object_version

Instance Method Details

#deposit_branch(object_id) ⇒ String

Returns The branch segment of the object deposit path.

Parameters:

  • object_id (String)

    The identifier of the digital object

Returns:

  • (String)

    The branch segment of the object deposit path



25
26
27
# File 'lib/stanford/storage_repository.rb', line 25

def deposit_branch(object_id)
  object_id.split(/:/)[-1]
end

#druid_tree(object_id) ⇒ String

Returns the druid tree directory path based on the given object identifier.

Parameters:

  • object_id (String)

    The identifier of the digital object whose path is requested

Returns:

  • (String)

    the druid tree directory path based on the given object identifier.



31
32
33
34
35
36
37
38
39
# File 'lib/stanford/storage_repository.rb', line 31

def druid_tree(object_id)
  # Note: this seems an odd place to do druid validation, but leaving it here for now
  syntax_msg = "Identifier has invalid suri syntax: #{object_id}"
  raise syntax_msg + " nil or empty" if object_id.to_s.empty?
  identifier = object_id.split(':')[-1]
  raise syntax_msg if identifier.to_s.empty?
  raise syntax_msg unless DruidTools::Druid.valid?(identifier, true)
  DruidTools::Druid.new(identifier, true).tree.join(File::SEPARATOR)
end

#storage_branch(object_id) ⇒ String

Returns The branch segment of the object storage path.

Parameters:

  • object_id (String)

    The identifier of the digital object

Returns:

  • (String)

    The branch segment of the object storage path



14
15
16
17
18
19
20
21
# File 'lib/stanford/storage_repository.rb', line 14

def storage_branch(object_id)
  case Moab::Config.path_method.to_s
  when 'druid_tree'
    druid_tree(object_id)
  when 'druid'
    object_id.split(/:/)[-1]
  end
end