fedora-migrate 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +1 -0
  4. data/LICENSE +14 -0
  5. data/README.md +201 -6
  6. data/config/jetty.yml +2 -2
  7. data/fedora-migrate.gemspec +7 -6
  8. data/lib/fedora-migrate.rb +7 -24
  9. data/lib/fedora_migrate/content_mover.rb +49 -0
  10. data/lib/fedora_migrate/datastream_mover.rb +19 -34
  11. data/lib/fedora_migrate/datastream_verification.rb +36 -0
  12. data/lib/fedora_migrate/dates_mover.rb +14 -0
  13. data/lib/fedora_migrate/hooks.rb +23 -0
  14. data/lib/fedora_migrate/migration_options.rb +18 -0
  15. data/lib/fedora_migrate/mover.rb +12 -0
  16. data/lib/fedora_migrate/object_mover.rb +20 -9
  17. data/lib/fedora_migrate/rdf_datastream_mover.rb +31 -14
  18. data/lib/fedora_migrate/rels_ext_datastream_mover.rb +28 -62
  19. data/lib/fedora_migrate/repository_migrator.rb +30 -25
  20. data/lib/fedora_migrate/rubydora_connection.rb +0 -2
  21. data/lib/fedora_migrate/target_constructor.rb +39 -0
  22. data/lib/fedora_migrate/version.rb +1 -1
  23. data/spec/fixtures/objects/scholarsphere_5712mc568.xml +7284 -0
  24. data/spec/fixtures/objects/scholarsphere_7d279232g.xml +20120 -0
  25. data/spec/fixtures/objects/scholarsphere_sf2686078.xml +8823 -0
  26. data/spec/fixtures/objects/scholarsphere_x346dj04v.xml +188 -0
  27. data/spec/fixtures/objects/scholarsphere_x346dj06d.xml +255 -0
  28. data/spec/fixtures/objects/scholarsphere_x346dj08z.xml +1242 -0
  29. data/spec/fixtures/objects/sufia_5m60qr94g.xml +68 -0
  30. data/spec/fixtures/objects/sufia_5m60qr95r.xml +133 -0
  31. data/spec/fixtures/objects/sufia_5m60qr961.xml +133 -0
  32. data/spec/fixtures/objects/sufia_5m60qr979.xml +118 -0
  33. data/spec/integration/content_versions_spec.rb +24 -1
  34. data/spec/integration/missing_relationships_spec.rb +30 -0
  35. data/spec/integration/object_migration_spec.rb +49 -5
  36. data/spec/integration/rdf_migration_spec.rb +38 -13
  37. data/spec/integration/relationship_migration_spec.rb +10 -9
  38. data/spec/integration/repository_migration_spec.rb +46 -19
  39. data/spec/integration/versions_spec.rb +32 -0
  40. data/spec/spec_helper.rb +8 -1
  41. data/spec/support/example_model.rb +56 -0
  42. data/spec/unit/content_mover_spec.rb +78 -0
  43. data/spec/unit/datastream_verification_spec.rb +60 -0
  44. data/spec/unit/dates_mover_spec.rb +33 -0
  45. data/spec/unit/migration_options_spec.rb +61 -0
  46. data/spec/unit/mover_spec.rb +35 -1
  47. data/spec/unit/object_mover_spec.rb +1 -3
  48. data/spec/unit/rels_ext_datastream_mover_spec.rb +28 -18
  49. data/spec/unit/repository_migrator_spec.rb +16 -5
  50. data/spec/unit/target_constructor_spec.rb +34 -0
  51. data/tasks/dev.rake +1 -1
  52. metadata +80 -38
  53. data/LICENSE.txt +0 -22
  54. data/lib/fedora_migrate/rdf_datastream_parser.rb +0 -29
  55. data/lib/fedora_migrate/triple_converter.rb +0 -39
  56. data/spec/fixtures/datastreams/rdf_ntriples_datastream.txt +0 -2
  57. data/spec/unit/rdf_datastream_mover_spec.rb +0 -8
  58. data/spec/unit/rdf_datastream_parser_spec.rb +0 -38
  59. data/spec/unit/triple_converter_spec.rb +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1cd495240ef6ef07dafbfa15720b1c5eca3a4146
4
- data.tar.gz: 4d59a16932745f6082133cf3a5492a024e499f84
3
+ metadata.gz: a1c6f75dc48d80e784199985d948420c2c449de4
4
+ data.tar.gz: 0002dcb8c3e0508510359bc427c70cd2cf0b1f76
5
5
  SHA512:
6
- metadata.gz: 3a906945035f3966d5c5ecb24668081da701e52a5cec8f881b0b75d3e938ee72a53354008315911e1dd3914793311f9efb79991aeb78199ef210f659e6b9c111
7
- data.tar.gz: 18a47d1a58619bd9a57f4489537f79a35655f184eac5f3a47e2424f5feef646946e407d1bdc6c52504cd529d42f7f61bfa98935dab8f8e98c83e881178660ff6
6
+ metadata.gz: cc62419d71580ecda28950eea55ada46b397d517730eff12f3d3bdbfb3b184565a1499f8ec2e219d24f61395b7be42ea2f357b18ec772d4887b6706786a97301
7
+ data.tar.gz: e2adbf133dc201a4176958a53b83fe9dfc32351dfd59a72651e73ac527b4be01adf8ee762e76ac6233bb118b88daca67af1091ac4e09291fb2b888d28a56d4f6
data/.gitignore CHANGED
@@ -14,3 +14,4 @@
14
14
  mkmf.log
15
15
  jetty
16
16
  .ruby-version
17
+ .rvmrc
data/Gemfile CHANGED
@@ -5,3 +5,4 @@ gemspec
5
5
 
6
6
  gem 'byebug'
7
7
  gem 'pry'
8
+ gem 'http_logger'
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ Copyright © 2015 The Pennsylvania State University
2
+ Additional copyright may be held by others, as reflected in the commit history.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
data/README.md CHANGED
@@ -1,22 +1,211 @@
1
- # FedoraMigrate
1
+ # FedoraMigrate [![Version](https://badge.fury.io/gh/projecthydra-labs%2Ffedora-migrate.png)](http://badge.fury.io/gh/projecthydra-labs%2Ffedora-migrate) [![Build Status](https://travis-ci.org/projecthydra-labs/fedora-migrate.png?branch=master)](https://travis-ci.org/projecthydra-labs/fedora-migrate)
2
2
 
3
3
  Migrates content from a Fedora3 repository to a Fedora4 one.
4
4
 
5
5
  ## Status
6
6
 
7
- Very alpha. This has been tested against Penn State's existing Scholarsohere applications, as well
8
- as generic Sufia applications.
7
+ This has been tested against Penn State's existing Scholarsphere applications, as well as generic Sufia applications.
8
+ Other uses are presently unknown.
9
9
 
10
- ## TODOs
10
+ ## Overview
11
11
 
12
- See the list of issues.
12
+ FedoraMigrate iterates over your existing Fedora3 application using the Rubydora gem. For each object it finds, it
13
+ creates a new object with the same id in Fedora4 and proceeds to migrate each datastream, including versions if
14
+ they are defined, and verifies the checksum of each. Permissions and relationships are migrated as well but using
15
+ different procedures due to the changes in Fedora4.
16
+
17
+ The entire migration process takes place in two steps. In the first, all objects, including datastreams and permissions,
18
+ are copied over to Fedora4; in the second, relationships are migrated.
19
+
20
+ ## Requirements
21
+
22
+ 1. A working Hydra application using Fedora4
23
+ 2. An existing Fedora3 instance
24
+ 3. All models defined in your Hydra/Fedora4 application
25
+
26
+ ## Usage
27
+
28
+ Add the fedora-migrate gem to your existing Fedora4-based Hydra head
29
+
30
+ gem 'fedora-migrate'
31
+
32
+ Then run `bundle update`
33
+
34
+ Create a `config/fedora3.yml` file and point it to your current Fedora3 repository
35
+
36
+ development:
37
+ user: fedoraAdmin
38
+ password: fedoraAdmin
39
+ url: http://localhost:8983/fedora3
40
+ test:
41
+ user: fedoraAdmin
42
+ password: fedoraAdmin
43
+ url: http://localhost:8983/fedora3
44
+ production:
45
+ user: fedoraAdmin
46
+ password: fedoraAdmin
47
+ url: http://localhost:8983/fedora3
48
+
49
+ Create a rake task to migrate your repository. You can use the following, taken from `lib/tasks/fedora-migrate.rake`,
50
+ as an example:
51
+
52
+ ``` ruby
53
+ desc "Migrate all my objects"
54
+ task migrate: :environment do
55
+ results = FedoraMigrate.migrate_repository(namespace: "mynamespace")
56
+ puts results
57
+ end
58
+ ```
59
+
60
+ Run the task
61
+
62
+ $ bundle exec rake migrate
63
+
64
+ By default, messages are logged to your Rails environment logs.
65
+
66
+ ## Configuration
67
+
68
+ FedoraMigrate uses your existing Hydra/Fedora4 application as the basis for migrating objects. For example,
69
+ given the model
70
+
71
+ ``` ruby
72
+ class MyModel < ActiveFedora::Base
73
+ contains "content", class_name: "ActiveFedora::File"
74
+ contains "thumbnail", class_name: "ActiveFedora::File"
75
+ end
76
+ ```
77
+
78
+ When the migrator finds an object in your Fedora3 repository that has the name _MyModel_ it attempts to instantiate the
79
+ object `MyModel` in the context of your Hydra application. Only the datastreams, or files, that are defined in the model will
80
+ be migrated from Fedora3. This means if your Fedora3 object has the datastream "special" but it is not in your Hydra
81
+ model, it will not be migrated. DC datastreams are not migrated by default, and RELS-EXT and rightsMetdata datastreams are treated
82
+ differently. See [FedoraMigrate::RelsExtDatastreamMover](lib/fedora_migrate/rels_ext_datastream_mover.rb) and
83
+ [FedoraMigrate::PermissionsMover](lib/fedora_migrate/permissions_mover.rb).
84
+
85
+ If your model contains a file or datastream that is versioned, then all versions of that datastream will be migrated from
86
+ Fedora3. If the model does not define something as versioned, yet the Fedora3 datastream is versioned, then only the current
87
+ version will be migrated to Fedora4.
88
+
89
+ ### RDF Conversion
90
+
91
+ If you elect to do so, FedoraMigrate will attempt to convert ActiveFedora::NtriplesRDFDatastream objects into RDF properties
92
+ defined on your object. You can configure this as an option passed to the migrator.
93
+
94
+ ``` ruby
95
+ FedoraMigrate.migrate_repository(namespace: "mynamespace", options: {convert: "descMetadata"})
96
+ ```
97
+
98
+ However, you are required to define any and all RDF properties on your object in Hydra. For example, given
99
+
100
+ ``` ruby
101
+ class RDFObject < ActiveFedora::Base
102
+ property :title, predicate: ::RDF::DC.title do |index|
103
+ index.as :stored_searchable, :facetable
104
+ end
105
+ contains "content", class_name: "ActiveFedora::File"
106
+ contains "thumbnail", class_name: "ActiveFedora::File"
107
+ end
108
+ ```
109
+
110
+ If your descMetadata RDF datastream in Fedora3 contains the triple
111
+
112
+ <info:fedora/mynamespace:xp68km39w> <http://purl.org/dc/terms/title> "My Title" .
113
+
114
+ Then FedoraMigrate will define that property on your Fedora4 object using the DC term.
115
+
116
+ ### Object Migration
117
+
118
+ By default, FedoraMigrate will use [FedoraMigrate::TargetConstructor](lib/fedora_migrate/target_constructor.rb)
119
+ to find a model in your Hydra application that matches
120
+ the Fedora3 source object. The constructor is designed to work with Hydra applications. If need be, you can override this
121
+ class by creating a new one that determines a model name based on your own criteria.
122
+
123
+ ``` ruby
124
+ module FedoraMigrate
125
+ class TargetConstructor
126
+
127
+ attr_accessor :candidates, :target
128
+
129
+ def initialize candidates
130
+ @candidates = candidates
131
+ end
132
+
133
+ def build
134
+ # set target to whichever model you need based on candidates
135
+ return self
136
+ end
137
+ end
138
+ end
139
+ ```
140
+
141
+ You can also opt to provide your own model, if you wish, by passing it as a second argument to the object mover class.
142
+
143
+ ``` ruby
144
+ source = FedoraMigrate.source.connection.find("mynamespace:rb68xc089")
145
+ mover = FedoraMigrate::ObjectMover.new source, CustomObject.new
146
+ mover.migrate
147
+ ```
148
+
149
+ ### Configuration Hooks
150
+
151
+ Because the migration process will be different for each user, overridable methods are placed before and after each step in the
152
+ migration process. These can be used if your source or target objects need additional preparation before they can be
153
+ migrated. A good example is in Sufia, where a depositor must be applied before the object can be saved.
154
+
155
+ To use the hooks, simply define them in your migration task
156
+
157
+ ``` ruby
158
+ module FedoraMigrate::Hooks
159
+
160
+ # Both @source and @target are available, as the Rubydora object and ActiveFedora model, respectively
161
+
162
+ # Apply depositor metadata before you migrate an object
163
+ def before_object_migration
164
+ xml = Nokogiri::XML(source.datastreams["properties"].content)
165
+ target.apply_depositor_metadata xml.xpath("//depositor").text
166
+ end
167
+
168
+ def after_object_migration
169
+ # additional actions as needed
170
+ end
171
+
172
+ end
173
+
174
+ desc "Migrate all my objects"
175
+ task migrate: :environment do
176
+ results = FedoraMigrate.migrate_repository(namespace: "mynamespace", options: {convert: "descMetadata"})
177
+ puts results
178
+ end
179
+ ```
180
+
181
+ ## Testing
182
+
183
+ Execute `bundle exec rake` to run the test suite.
184
+
185
+ $ bundle exec rake jetty:clean jetty:start
186
+ $ bundle exec rake fixtures:load
187
+ $ bundle exec rspec
188
+
189
+ This will run all the spec tests and leave jetty running if you wish to run specific tests.
190
+
191
+ If you have sample objects that you feel should be used as relevant testing examples, please add them to
192
+ `spec/fixtures/objects` and re-run the tests. Sample objects should be exported from existing Fedora3
193
+ repositories as foxml files using the "archive" option. This can be done via the admin web interface,
194
+ [http://localhost:8983/fedora3/admin](http://localhost:8983/fedora3/admin), or using
195
+ `FEDORA_HOME/client/bin/fedora-export.sh`.
196
+
197
+ *Note that the script option may only work under full installs of Fedora3 and not hydra-jetty.*
198
+
199
+ ## TODOs and Reporting Errors
200
+
201
+ See the list of issues for current bugs and feature needs. Add your own as needed.
13
202
 
14
203
  ## Contributing
15
204
 
16
205
  ### Hydra Developers
17
206
 
18
207
  For Hydra developers, or anyone with a signed CLA, please clone the repo and submit PRs via
19
- topic branches. If you don't have rights to projecthydra-labs and do have a signed
208
+ feature branches. If you don't have rights to projecthydra-labs and do have a signed
20
209
  CLA, please send a note to hydra-tech@googlegroups.com.
21
210
 
22
211
  1. Clone it
@@ -29,3 +218,9 @@ CLA, please send a note to hydra-tech@googlegroups.com.
29
218
 
30
219
  Anyone is welcome to use this software and report issues.
31
220
  In order to merge any work contributed, you'll need to sign a contributor license agreement.
221
+ For more information on signing a CLA, please contact `legal@projecthyra.org`
222
+ # Project Hydra
223
+ This software has been developed by and is brought to you by the Hydra community. Learn more at the
224
+ [Project Hydra website](http://projecthydra.org)
225
+
226
+ ![Project Hydra Logo](https://github.com/uvalib/libra-oa/blob/a6564a9e5c13b7873dc883367f5e307bf715d6cf/public/images/powered_by_hydra.png?raw=true)
data/config/jetty.yml CHANGED
@@ -2,5 +2,5 @@ default:
2
2
  startup_wait: 90
3
3
  jetty_port: 8983
4
4
  java_opts:
5
- - "-Xmx256m"
6
- - "-XX:MaxPermSize=128m"
5
+ - "-Xmx512m"
6
+ - "-XX:MaxPermSize=256m"
@@ -18,13 +18,14 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "rubydora", "~> 1.8"
22
- spec.add_dependency "hydra-head", "~> 9.0.0.beta1"
23
-
21
+ spec.add_dependency "hydra-head", "~> 9.0"
22
+ spec.add_dependency "rubydora", "~> 1.8"
23
+ spec.add_dependency "rchardet"
24
+
24
25
  spec.add_development_dependency "bundler", "~> 1.7"
26
+ spec.add_development_dependency "equivalent-xml"
27
+ spec.add_development_dependency "hydra-collections", "~> 4.0"
28
+ spec.add_development_dependency "jettywrapper"
25
29
  spec.add_development_dependency "rake", "~> 10.0"
26
30
  spec.add_development_dependency "rspec"
27
- spec.add_development_dependency "jettywrapper"
28
- spec.add_development_dependency "equivalent-xml"
29
- spec.add_development_dependency "sufia", "~> 6.0.0.beta1"
30
31
  end
@@ -1,36 +1,19 @@
1
1
  require "fedora_migrate/version"
2
2
  require "active_support"
3
3
  require "active_fedora"
4
- require "hydra-core"
4
+ require "hydra/head"
5
+ require "rubydora"
5
6
 
6
7
  # Loads rake tasks
7
8
  Dir[File.expand_path(File.join(File.dirname(__FILE__),"tasks/*.rake"))].each { |ext| load ext } if defined?(Rake)
8
9
 
9
- # Shenanigans because we're not in a Rails environment and we need
10
- # Hydra::AccessControls
11
- Hydra::Engine.config.autoload_paths.each { |path| $LOAD_PATH.unshift path }
12
- # in gem version 2.4, .find_by_name isn't pulling up gems given in the Gemfile
13
- # as opposed to those in the gemspec file.
14
- # This is a workaround:
15
- Gem::Specification.all.each do |g|
16
- HAC_DIR = g.gem_dir if g.name.match("hydra-access-controls")
17
- end
18
- require HAC_DIR+'/app/vocabularies/acl'
19
- require HAC_DIR+'/app/vocabularies/hydra/acl'
20
- require HAC_DIR+'/app/models/role_mapper'
21
- require HAC_DIR+'/app/models/ability'
22
- require HAC_DIR+'/app/models/hydra/access_controls/access_control_list'
23
- require HAC_DIR+'/app/models/hydra/access_controls/permission'
24
- require HAC_DIR+'/app/models/hydra/access_controls/embargo'
25
- require HAC_DIR+'/app/models/hydra/access_controls/lease'
26
- require HAC_DIR+'/app/services/hydra/lease_service'
27
- require HAC_DIR+'/app/services/hydra/embargo_service'
28
- require HAC_DIR+'/app/validators/hydra/future_date_validator'
29
-
30
10
  module FedoraMigrate
31
11
  extend ActiveSupport::Autoload
32
12
 
13
+ autoload :ContentMover
33
14
  autoload :DatastreamMover
15
+ autoload :DatastreamVerification
16
+ autoload :DatesMover
34
17
  autoload :Errors
35
18
  autoload :FileConfigurator
36
19
  autoload :Hooks
@@ -46,6 +29,7 @@ module FedoraMigrate
46
29
  autoload :RepositoryMigrator
47
30
  autoload :RightsMetadata
48
31
  autoload :RubydoraConnection
32
+ autoload :TargetConstructor
49
33
  autoload :TripleConverter
50
34
 
51
35
  class << self
@@ -62,7 +46,7 @@ module FedoraMigrate
62
46
 
63
47
  def source
64
48
  @source ||= FedoraMigrate::RubydoraConnection.new(fedora_config.credentials)
65
- end
49
+ end
66
50
 
67
51
  def find id
68
52
  FedoraMigrate.source.connection.find(id)
@@ -72,7 +56,6 @@ module FedoraMigrate
72
56
  migrator = FedoraMigrate::RepositoryMigrator.new(args[:namespace], args[:options])
73
57
  migrator.migrate_objects
74
58
  migrator.migrate_relationships
75
- migrator.results
76
59
  end
77
60
 
78
61
  end
@@ -0,0 +1,49 @@
1
+ module FedoraMigrate
2
+ class ContentMover < Mover
3
+
4
+ def migrate
5
+ return nil_content_message if source.content.nil?
6
+ move_content
7
+ insert_date_created_by_application
8
+ end
9
+
10
+ def move_content
11
+ target.content = source.content
12
+ target.original_name = source.label.try(:gsub, /"/, '\"')
13
+ target.mime_type = source.mimeType
14
+ Logger.info "#{target.inspect}"
15
+ save
16
+ end
17
+
18
+ def insert_date_created_by_application
19
+ result = perform_sparql_insert
20
+ return true if result.status == 204
21
+ raise FedoraMigrate::Errors::MigrationError, "problem with sparql #{result.status} #{result.body}"
22
+ end
23
+
24
+ def sparql_insert
25
+ <<-EOF
26
+ PREFIX premis: <http://www.loc.gov/premis/rdf/v1#>
27
+ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
28
+ DELETE WHERE { ?s premis:hasDateCreatedByApplication ?o } ;
29
+ INSERT {
30
+ <> premis:hasDateCreatedByApplication "#{source.createDate.iso8601}"^^xsd:dateTime .
31
+ }
32
+ WHERE { }
33
+ EOF
34
+ end
35
+
36
+ private
37
+
38
+ def nil_content_message
39
+ Logger.info "datastream '#{source.dsid}' is nil. It's probably defined in the target but not present in the source"
40
+ true
41
+ end
42
+
43
+ def perform_sparql_insert
44
+ ActiveFedora.fedora.connection.patch(target.metadata.metadata_uri, sparql_insert, "Content-Type" => "application/sparql-update")
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -1,6 +1,8 @@
1
1
  module FedoraMigrate
2
2
  class DatastreamMover < Mover
3
3
 
4
+ include DatastreamVerification
5
+
4
6
  attr_accessor :versionable
5
7
 
6
8
  def post_initialize
@@ -14,12 +16,20 @@ module FedoraMigrate
14
16
  def target_versionable?
15
17
  if target.respond_to?(:versionable?)
16
18
  target.versionable?
17
- else
19
+ else
18
20
  false
19
21
  end
20
22
  end
21
-
23
+
22
24
  def migrate
25
+ before_datastream_migration
26
+ migrate_datastream
27
+ after_datastream_migration
28
+ end
29
+
30
+ private
31
+
32
+ def migrate_datastream
23
33
  if versionable?
24
34
  migrate_versions
25
35
  else
@@ -27,50 +37,25 @@ module FedoraMigrate
27
37
  end
28
38
  end
29
39
 
30
- private
31
-
32
- # Reloading the target, otherwise #get_checksum is nil
40
+ # Reload the target, otherwise the checksum is nil
33
41
  def migrate_current
34
42
  migrate_content
35
43
  target.reload
36
- verify
44
+ valid?
37
45
  end
38
46
 
47
+ # Rubydora stores the versions array as the most recent first. We explicitly sort them according to createDate
39
48
  def migrate_versions
40
- source.versions.each do |version|
49
+ source.versions.sort { |a,b| a.createDate <=> b.createDate }.each do |version|
41
50
  migrate_content(version)
42
- target.create_version
43
- verify(version)
51
+ target.create_version unless application_creates_versions?
52
+ valid?(version)
44
53
  end
45
54
  end
46
55
 
47
- # TODO: lastModified isn't the right place for the original creation date (issue #1)
48
56
  def migrate_content datastream=nil
49
57
  datastream ||= source
50
- if datastream.content.nil?
51
- Logger.info "datastream '#{datastream.dsid}' is nil. It's probably defined in the target but not present in the source"
52
- return true
53
- end
54
- target.content = datastream.content
55
- target.original_name = datastream.label
56
- target.mime_type = datastream.mimeType
57
- target.last_modified = datastream.createDate
58
- Logger.info "#{target.inspect}"
59
- save
60
- end
61
-
62
- # TODO: Reporting mechanism? If there isn't a checksum it defaults to "none" (issue #4)
63
- def verify datastream=nil
64
- datastream ||= source
65
- target_checksum = get_checksum
66
- return true if datastream.checksum == "none"
67
- unless datastream.checksum == target_checksum.split(/:/).last
68
- Logger.fatal "expected #{datastream.dsid} #{datastream.checksumType} #{datastream.checksum} to match #{target_checksum}"
69
- end
70
- end
71
-
72
- def get_checksum
73
- target.digest.first.to_s
58
+ FedoraMigrate::ContentMover.new(datastream, target).migrate
74
59
  end
75
60
 
76
61
  end