fedora-migrate 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +6 -8
  4. data/README.md +3 -1
  5. data/fedora-migrate.gemspec +2 -2
  6. data/lib/fedora_migrate/file_configurator.rb +1 -1
  7. data/lib/fedora_migrate/migration_options.rb +5 -0
  8. data/lib/fedora_migrate/migration_report.rb +32 -6
  9. data/lib/fedora_migrate/repository_migrator.rb +53 -30
  10. data/lib/fedora_migrate/version.rb +1 -1
  11. data/spec/fixtures/reports/failed/sufia_5m60qr94g.json +7 -0
  12. data/spec/fixtures/reports/failed/sufia_5m60qr95r.json +58 -0
  13. data/spec/fixtures/reports/failed/sufia_5m60qr961.json +58 -0
  14. data/spec/fixtures/reports/failed/sufia_5m60qr979.json +34 -0
  15. data/spec/fixtures/reports/failed/sufia_rb68xc089.json +7 -0
  16. data/spec/fixtures/reports/failed/sufia_rb68xc09k.json +21 -0
  17. data/spec/fixtures/reports/failed/sufia_rb68xc10b.json +49 -0
  18. data/spec/fixtures/reports/failed/sufia_rb68xc11m.json +49 -0
  19. data/spec/fixtures/reports/failed/sufia_xp68km39w.json +54 -0
  20. data/spec/fixtures/reports/sample/scholarsphere_000000000.json +26 -0
  21. data/spec/fixtures/reports/sample/scholarsphere_000000018.json +102 -0
  22. data/spec/fixtures/reports/sample/scholarsphere_05741r698.json +26 -0
  23. data/spec/fixtures/reports/sample/scholarsphere_6395wb555.json +5 -0
  24. data/spec/fixtures/reports/sample/scholarsphere_x346dm27k.json +5 -0
  25. data/spec/integration/repository_migration_spec.rb +21 -10
  26. data/spec/integration/versions_spec.rb +1 -0
  27. data/spec/spec_helper.rb +1 -0
  28. data/spec/support/example_model.rb +8 -1
  29. data/spec/unit/migration_options_spec.rb +18 -0
  30. data/spec/unit/migration_report_spec.rb +16 -13
  31. data/spec/unit/repository_migrator_spec.rb +2 -8
  32. metadata +35 -11
  33. data/spec/fixtures/failed-report.json +0 -339
  34. data/spec/fixtures/sample-report.json +0 -166
@@ -0,0 +1,21 @@
1
+ {
2
+ "status": true,
3
+ "object": {
4
+ "id": "rb68xc09k",
5
+ "class": "Batch",
6
+ "content_datastreams": [
7
+
8
+ ],
9
+ "rdf_datastreams": [
10
+
11
+ ],
12
+ "permissions": null,
13
+ "dates": {
14
+ "uploaded": null,
15
+ "modified": null
16
+ }
17
+ },
18
+ "relationships": [
19
+
20
+ ]
21
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "status": true,
3
+ "object": {
4
+ "id": "rb68xc10b",
5
+ "class": "GenericFile",
6
+ "content_datastreams": [
7
+ {
8
+ "ds": "content",
9
+ "versions": [
10
+
11
+ ]
12
+ },
13
+ {
14
+ "ds": "thumbnail",
15
+ "versions": [
16
+ {
17
+ "error": "Nil source -- it's probably defined in the target but not present in the source"
18
+ }
19
+ ]
20
+ },
21
+ {
22
+ "ds": "characterization",
23
+ "versions": [
24
+ {
25
+ "error": "Nil source -- it's probably defined in the target but not present in the source"
26
+ }
27
+ ]
28
+ }
29
+ ],
30
+ "rdf_datastreams": [
31
+
32
+ ],
33
+ "permissions": [
34
+ "read_groups = []",
35
+ "edit_groups = []",
36
+ "discover_groups = []",
37
+ "read_users = []",
38
+ "edit_users = [\"jilluser@example.com\"]",
39
+ "discover_users = []"
40
+ ],
41
+ "dates": {
42
+ "uploaded": null,
43
+ "modified": null
44
+ }
45
+ },
46
+ "relationships": [
47
+ "http://localhost:8983/fedora/rest/test/rb68xc10b--info:fedora/fedora-system:def/relations-external#isPartOf--http://localhost:8983/fedora/rest/test/rb68xc09k"
48
+ ]
49
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "status": true,
3
+ "object": {
4
+ "id": "rb68xc11m",
5
+ "class": "GenericFile",
6
+ "content_datastreams": [
7
+ {
8
+ "ds": "content",
9
+ "versions": [
10
+
11
+ ]
12
+ },
13
+ {
14
+ "ds": "thumbnail",
15
+ "versions": [
16
+ {
17
+ "error": "Nil source -- it's probably defined in the target but not present in the source"
18
+ }
19
+ ]
20
+ },
21
+ {
22
+ "ds": "characterization",
23
+ "versions": [
24
+ {
25
+ "error": "Nil source -- it's probably defined in the target but not present in the source"
26
+ }
27
+ ]
28
+ }
29
+ ],
30
+ "rdf_datastreams": [
31
+
32
+ ],
33
+ "permissions": [
34
+ "read_groups = []",
35
+ "edit_groups = []",
36
+ "discover_groups = []",
37
+ "read_users = []",
38
+ "edit_users = [\"otherUser\"]",
39
+ "discover_users = []"
40
+ ],
41
+ "dates": {
42
+ "uploaded": null,
43
+ "modified": null
44
+ }
45
+ },
46
+ "relationships": [
47
+ "http://localhost:8983/fedora/rest/test/rb68xc11m--info:fedora/fedora-system:def/relations-external#isPartOf--http://localhost:8983/fedora/rest/test/rb68xc09k"
48
+ ]
49
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "status": true,
3
+ "object": {
4
+ "id": "xp68km39w",
5
+ "class": "GenericFile",
6
+ "content_datastreams": [
7
+ {
8
+ "ds": "content",
9
+ "versions": [
10
+
11
+ ]
12
+ },
13
+ {
14
+ "ds": "thumbnail",
15
+ "versions": [
16
+ {
17
+ "error": "Nil source -- it's probably defined in the target but not present in the source"
18
+ }
19
+ ]
20
+ },
21
+ {
22
+ "ds": "characterization",
23
+ "versions": [
24
+ {
25
+ "error": "Nil source -- it's probably defined in the target but not present in the source"
26
+ }
27
+ ]
28
+ }
29
+ ],
30
+ "rdf_datastreams": [
31
+ {
32
+ "ds": "descMetadata",
33
+ "status": [
34
+
35
+ ]
36
+ }
37
+ ],
38
+ "permissions": [
39
+ "read_groups = []",
40
+ "edit_groups = []",
41
+ "discover_groups = []",
42
+ "read_users = []",
43
+ "edit_users = [\"awead@psu.edu\"]",
44
+ "discover_users = []"
45
+ ],
46
+ "dates": {
47
+ "uploaded": null,
48
+ "modified": null
49
+ }
50
+ },
51
+ "relationships": [
52
+
53
+ ]
54
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "status": true,
3
+ "object": {
4
+ "id": "000000000",
5
+ "class": "Batch",
6
+ "content_datastreams": [
7
+
8
+ ],
9
+ "rdf_datastreams": [
10
+ {
11
+ "ds": "descMetadata",
12
+ "status": [
13
+
14
+ ]
15
+ }
16
+ ],
17
+ "permissions": null,
18
+ "dates": {
19
+ "uploaded": null,
20
+ "modified": null
21
+ }
22
+ },
23
+ "relationships": [
24
+
25
+ ]
26
+ }
@@ -0,0 +1,102 @@
1
+ {
2
+ "status": true,
3
+ "object": {
4
+ "id": "000000018",
5
+ "class": "GenericFile",
6
+ "content_datastreams": [
7
+ {
8
+ "ds": "characterization",
9
+ "versions": [
10
+ {
11
+ "name": "",
12
+ "mime_type": "text/xml",
13
+ "original_date": "2013-03-15T11:08:21Z"
14
+ }
15
+ ]
16
+ },
17
+ {
18
+ "ds": "content",
19
+ "versions": [
20
+ {
21
+ "name": "Open_Up_Your_RepositoryWith_a_SWORD_.pdf",
22
+ "mime_type": "application/pdf",
23
+ "original_date": "2012-09-26T16:09:14Z"
24
+ },
25
+ {
26
+ "name": "Open_Up_Your_RepositoryWith_a_SWORD_.pdf",
27
+ "mime_type": "application/pdf",
28
+ "original_date": "2012-11-26T03:11:55Z"
29
+ },
30
+ {
31
+ "name": "Open_Up_Your_RepositoryWith_a_SWORD_.pdf",
32
+ "mime_type": "application/pdf",
33
+ "original_date": "2012-11-26T03:12:07Z"
34
+ },
35
+ {
36
+ "name": "Open_Up_Your_RepositoryWith_a_SWORD_.pdf",
37
+ "mime_type": "application/pdf",
38
+ "original_date": "2012-11-26T03:12:10Z"
39
+ },
40
+ {
41
+ "name": "Open_Up_Your_RepositoryWith_a_SWORD_.pdf",
42
+ "mime_type": "application/pdf",
43
+ "original_date": "2012-11-26T03:12:13Z"
44
+ },
45
+ {
46
+ "name": "Open_Up_Your_RepositoryWith_a_SWORD_.pdf",
47
+ "mime_type": "application/pdf",
48
+ "original_date": "2012-11-26T03:12:17Z"
49
+ },
50
+ {
51
+ "name": "Open_Up_Your_RepositoryWith_a_SWORD_.pdf",
52
+ "mime_type": "application/pdf",
53
+ "original_date": "2012-11-26T03:13:12Z"
54
+ }
55
+ ]
56
+ },
57
+ {
58
+ "ds": "thumbnail",
59
+ "versions": [
60
+ {
61
+ "name": "",
62
+ "mime_type": "image/jpeg",
63
+ "original_date": "2014-09-10T15:12:43Z"
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "ds": "full_text",
69
+ "versions": [
70
+ {
71
+ "name": "File Datastream",
72
+ "mime_type": "application/octet-stream",
73
+ "original_date": "2013-03-14T10:03:13Z"
74
+ }
75
+ ]
76
+ }
77
+ ],
78
+ "rdf_datastreams": [
79
+ {
80
+ "ds": "descMetadata",
81
+ "status": [
82
+
83
+ ]
84
+ }
85
+ ],
86
+ "permissions": [
87
+ "read_groups = [\"public\"]",
88
+ "edit_groups = []",
89
+ "discover_groups = []",
90
+ "read_users = []",
91
+ "edit_users = [\"mjg36\"]",
92
+ "discover_users = []"
93
+ ],
94
+ "dates": {
95
+ "uploaded": "2012-09-26T16:09:13.394Z",
96
+ "modified": "2015-01-02T22:16:02.961Z"
97
+ }
98
+ },
99
+ "relationships": [
100
+ "http://ssrepo2qa.dlt.psu.edu:8080/SSqaFedora4/rest/prod/00/00/00/01/000000018--info:fedora/fedora-system:def/relations-external#isPartOf--http://ssrepo2qa.dlt.psu.edu:8080/SSqaFedora4/rest/prod/00/00/00/00/000000000"
101
+ ]
102
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "status": true,
3
+ "object": {
4
+ "id": "05741r698",
5
+ "class": "Batch",
6
+ "content_datastreams": [
7
+
8
+ ],
9
+ "rdf_datastreams": [
10
+ {
11
+ "ds": "descMetadata",
12
+ "status": [
13
+
14
+ ]
15
+ }
16
+ ],
17
+ "permissions": null,
18
+ "dates": {
19
+ "uploaded": null,
20
+ "modified": null
21
+ }
22
+ },
23
+ "relationships": [
24
+
25
+ ]
26
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "status": false,
3
+ "object": "#<Ldp::BadRequest: RDF was not parsable>",
4
+ "relationships": "#<FedoraMigrate::Errors::MigrationError: Target object was not found in Fedora 4. Did you migrate it?>"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "status": false,
3
+ "object": "#<Ldp::BadRequest: RDF was not parsable>",
4
+ "relationships": "#<FedoraMigrate::Errors::MigrationError: Target object was not found in Fedora 4. Did you migrate it?>"
5
+ }
@@ -80,26 +80,37 @@ describe "Migrating the repository" do
80
80
  end
81
81
 
82
82
  context "with an existing report" do
83
- let(:report) { "spec/fixtures/failed-report.json" }
84
- let(:new_report) { FedoraMigrate::MigrationReport.new("report.json") }
83
+ let(:sample_report) { "spec/fixtures/reports/failed" }
84
+ let(:failed_report) { "failed" }
85
+ let(:new_report) { FedoraMigrate::MigrationReport.new(failed_report) }
86
+ let(:original_report) { FedoraMigrate::MigrationReport.new(sample_report) }
87
+ let(:sample_pid) { "sufia:rb68xc089" }
85
88
  before do
86
- FileUtils.rm("report.json") if File.exists?("report.json")
87
- migrator = FedoraMigrate.migrate_repository(namespace: "sufia", options: {convert: "descMetadata", report: report})
88
- migrator.report.save
89
+ FileUtils.rm_rf(failed_report)
90
+ FileUtils.cp_r(sample_report, failed_report)
91
+ migrator = FedoraMigrate.migrate_repository(namespace: "sufia", options: {convert: "descMetadata", report: failed_report})
89
92
  end
90
- after { FileUtils.rm("report.json") }
93
+ after { FileUtils.rm_rf(failed_report) }
91
94
  it "only migrates the objects that have failed" do
92
95
  expect(GenericFile.all.count).to eql 1
93
96
  expect(Batch.all.count).to eql 1
94
97
  expect(Collection.all.count).to eql 0
95
98
  expect(new_report.total_objects).to eql 9
96
- expect(new_report.failures).to eql 0
99
+ expect(original_report.results[sample_pid]["status"]).to be false
100
+ expect(new_report.results[sample_pid]["status"]).to be true
101
+ expect(new_report.results[sample_pid]["object"]).to_not be_nil
97
102
  end
98
103
  end
99
104
 
100
- end
101
-
105
+ context "with a blacklist" do
106
+ let(:pid1) { "sufia:rb68xc089" }
107
+ let(:pid2) { "sufia:xp68km39w" }
108
+ let(:report) { FedoraMigrate::MigrationReport.new }
109
+ before { FedoraMigrate.migrate_repository(namespace: "sufia", options: {convert: "descMetadata", blacklist: [pid1, pid2]}) }
110
+ subject { report.results.keys }
111
+ it { is_expected.to_not include(pid1)}
112
+ end
102
113
 
114
+ end
103
115
 
104
116
  end
105
-
@@ -24,6 +24,7 @@ describe "Versions" do
24
24
  end
25
25
 
26
26
  it "should be migrated in the order they were created with their original creation dates" do
27
+ pending "Requires fix to Fedora 4.4; awaiting release"
27
28
  expect(desc_metadata_source_versions[0].createDate.to_i).to eql date_created_by_application("version1")
28
29
  expect(desc_metadata_source_versions[1].createDate.to_i).to eql date_created_by_application("version2")
29
30
  expect(desc_metadata_source_versions[2].createDate.to_i).to eql date_created_by_application("version3")
@@ -33,6 +33,7 @@ RSpec.configure do |config|
33
33
  config.before(:each) do
34
34
  ActiveFedora::Cleaner.clean!
35
35
  ActiveFedora::SolrService.instance.conn.delete_by_query('*:*', params: {'softCommit' => true})
36
+ FileUtils.rm_rf(FedoraMigrate::MigrationReport::DEFAULT_PATH)
36
37
  end
37
38
 
38
39
  config.order = :random
@@ -8,8 +8,13 @@ Gem::Specification.all.each do |g|
8
8
  HAC_DIR = g.gem_dir if g.name.match("hydra-access-controls")
9
9
  HCL_DIR = g.gem_dir if g.name.match("hydra-collections")
10
10
  HCR_DIR = g.gem_dir if g.name.match("hydra-core")
11
+ BKL_DIR = g.gem_dir if g.name.match("blacklight")
11
12
  end
12
13
 
14
+ # Load Rails-specific bits of blacklight
15
+ require BKL_DIR+'/app/controllers/concerns/blacklight/request_builders'
16
+ require BKL_DIR+'/app/controllers/concerns/blacklight/search_helper'
17
+
13
18
  # Load Rails-specific bits of hydra-access-controls
14
19
  require HAC_DIR+'/app/vocabularies/acl'
15
20
  require HAC_DIR+'/app/vocabularies/hydra/acl'
@@ -27,6 +32,8 @@ require HAC_DIR+'/app/validators/hydra/future_date_validator'
27
32
  # Loading hydra-collections
28
33
  require 'hydra-collections'
29
34
  require HCR_DIR+'/app/models/concerns/hydra/model_methods'
35
+ require HCL_DIR+'/app/models/concerns/hydra/collections/metadata'
36
+ require HCL_DIR+'/app/models/concerns/hydra/collections/relations'
30
37
  require HCL_DIR+'/app/models/concerns/hydra/collection'
31
38
 
32
39
  module ExampleModel
@@ -45,7 +52,7 @@ module ExampleModel
45
52
  end
46
53
 
47
54
  class VersionedDatastream < ActiveFedora::File
48
- has_many_versions
55
+ self.versionable = true
49
56
  end
50
57
 
51
58
  class VersionedContent < ActiveFedora::Base