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



27
28
29
# File 'lib/stanford/storage_repository.rb', line 27

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.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/stanford/storage_repository.rb', line 33

def druid_tree(object_id)
  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?
  # The object identifier must be in the SURI format, otherwise an exception is raised:
  # e.g. druid:aannnaannnn or aannnaannnn
  # where 'a' is an alphabetic character
  # where 'n' is a numeric character
  if identifier =~ /^([a-z]{2})(\d{3})([a-z]{2})(\d{4})$/
    return File.join( $1, $2, $3, $4, identifier)
  else
    raise syntax_msg
  end
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



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

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