sdr-replication 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 477696a5ac274697dfb1f337e562a859965695e8
4
- data.tar.gz: ee4274bb597963bb1faec8783a0a41875abbd369
3
+ metadata.gz: 11801a3c77b94dd4ef2c8af7992a033f8d9856c9
4
+ data.tar.gz: d8f5d7e38d26f467d6ce3304d5ddff0b8b2aff88
5
5
  SHA512:
6
- metadata.gz: 094e30cbc6e5e8c490e5560506a34b69cff7ab463cb4215e34d269b3f9abc9754fece858ac734a56448e1e4f0bd0332f6e7b0aee6d72e9d9436f5722afa6bfed
7
- data.tar.gz: 1b1593dc47c1190a7bc1ea60b6f2bdb6635f21fc1170a7ef3cd18bb3be481d223b1b30435b72e327226ac33a81f63129a53405821cb4f7f04bbcc0c01ae64f54
6
+ metadata.gz: 44e904744f21d27d7ee036181964230b96fbcee1c3a65c21db9aac2678bf0b3e2f7c72a6b19220ba2f6411f60d0ea4a0d5f3df504c7b3b872e5095b313fc8c75
7
+ data.tar.gz: 92fe706d2524991354ef61d2b9e63580754f8dd66c33939b62eac634e83cceaae55e225f67f304ded997acfb2a783537c195b2186dbeb7ffb417268306162809
@@ -52,8 +52,36 @@ module Replication
52
52
  end
53
53
 
54
54
  # @return [Pathname] The location of the replica bag
55
- def replica_pathname
56
- @replica_pathname ||= @@replica_cache_pathname.join(home_repository,replica_id)
55
+ def bag_pathname
56
+ @@replica_cache_pathname.join(@home_repository,@replica_id)
57
+ end
58
+
59
+ # @return [Replica] Open the replica's bag and extract its properties
60
+ def get_bag_data
61
+ bag = BagitBag.open_bag(bag_pathname)
62
+ @create_date = UtcTime.output(bag_pathname.ctime)
63
+ size_hash = bag.info_payload_size
64
+ @payload_size = size_hash[:bytes]
65
+ file_fixity_hash = bag.read_manifest_files('manifest')
66
+ tarfile_fixity = file_fixity_hash.values.first
67
+ checksums = tarfile_fixity.checksums
68
+ @payload_fixity_type = checksums.keys.last.to_s
69
+ @payload_fixity = checksums[@payload_fixity_type.to_sym]
70
+ self
71
+ end
72
+
73
+ # @return [Boolean] Update the replicas table of the Archive Catalog
74
+ def update_replica_data
75
+ replica_data = {
76
+ :replica_id => @replica_id,
77
+ :home_repository => @home_repository,
78
+ :create_date => @create_date,
79
+ :payload_size => @payload_size,
80
+ :payload_fixity_type => @payload_fixity_type,
81
+ :payload_fixity => @payload_fixity
82
+ }
83
+ ArchiveCatalog.find_or_create_item(:replicas, replica_data)
84
+ true
57
85
  end
58
86
 
59
87
  end
@@ -8,18 +8,19 @@ module Replication
8
8
  # All rights reserved. See {file:LICENSE.rdoc} for details.
9
9
  class SdrObjectVersion < Moab::StorageObjectVersion
10
10
 
11
+ # @return [String] The digital object's identifier (druid)
11
12
  def digital_object_id
12
13
  storage_object.digital_object_id
13
14
  end
14
15
 
15
16
  # @return [Moab::FileInventory] The moab version manifest for the version
16
17
  def version_inventory
17
- @version_inventory ||= file_inventory('version')
18
+ file_inventory('version')
18
19
  end
19
20
 
20
21
  # @return [Moab::FileInventory] The moab version manifest for the version
21
22
  def version_additions
22
- @version_additions ||= file_inventory('additions')
23
+ file_inventory('additions')
23
24
  end
24
25
 
25
26
  # @return [Hash] The contents of the versionMetadata file
@@ -65,6 +66,7 @@ module Replication
65
66
  metadata
66
67
  end
67
68
 
69
+ # @return [Boolean] Update digital_objects and sdr_objects tables in Archive Catalog
68
70
  def update_object_data
69
71
 
70
72
  identity_metadata = parse_identity_metadata
@@ -90,10 +92,13 @@ module Replication
90
92
  ArchiveCatalog.update_item(:sdr_objects, digital_object_id, sdr_object_data)
91
93
  end
92
94
 
95
+ true
93
96
  end
94
97
 
98
+ # @return [Boolean] Update sdr_object_versions and sdr_version_stats tables in Archive Catalog
95
99
  def update_version_data
96
100
 
101
+ version_inventory = self.version_inventory
97
102
  sdr_object_version_data = {
98
103
  :sdr_object_id => digital_object_id,
99
104
  :sdr_version_id => version_id,
@@ -118,6 +123,7 @@ module Replication
118
123
  }
119
124
  ArchiveCatalog.find_or_create_item(:sdr_version_stats, sdr_version_full)
120
125
 
126
+ version_additions = self.version_additions
121
127
  content = version_additions.group('content')
122
128
  metadata = version_additions.group('metadata')
123
129
  sdr_version_delta = {
@@ -133,28 +139,24 @@ module Replication
133
139
  }
134
140
  ArchiveCatalog.find_or_create_item(:sdr_version_stats, sdr_version_delta)
135
141
 
136
- end
137
-
138
-
139
- # @return [String] The unique identifier for the digital object replica
140
- def replica_id
141
- @replica_id ||= "#{storage_object.digital_object_id.split(':').last}-#{version_name}"
142
+ true
142
143
  end
143
144
 
144
145
  # @return [Replica] The Replica of the object version that is archived to tape, etc
145
146
  def replica
146
- @replica ||= Replica.new(replica_id, 'sdr')
147
+ Replica.new(composite_key.sub(/^druid:/,''), 'sdr')
147
148
  end
148
149
 
149
- # @return [BagitBag] Copy the object version into a BagIt Bag in tarfile format
150
- def moab_to_replica_bag
151
- bag_dir = replica.replica_pathname
152
- bag = BagitBag.create_bag(bag_dir)
150
+ # @return [Replica] Copy the object version into a BagIt Bag in tarfile format
151
+ def create_replica
152
+ replica = self.replica
153
+ bag = BagitBag.create_bag(replica.bag_pathname)
153
154
  bag.bag_checksum_types = [:sha256]
154
- bag.add_payload_tarfile("#{replica_id}.tar",version_pathname, storage_object.object_pathname.parent)
155
+ bag.add_payload_tarfile("#{replica.replica_id}.tar",version_pathname, storage_object.object_pathname.parent)
155
156
  bag.write_bag_info_txt
156
157
  bag.write_manifest_checksums('tagmanifest', bag.generate_tagfile_checksums)
157
- bag
158
+ replica.bagit_bag = bag
159
+ replica
158
160
  end
159
161
 
160
162
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdr-replication
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Anderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-16 00:00:00.000000000 Z
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_pure
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  version: 2.2.1
203
203
  requirements: []
204
204
  rubyforge_project:
205
- rubygems_version: 2.3.0
205
+ rubygems_version: 2.4.1
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: Core methods for support of SDR Preservation Core replication