ddr-models 2.0.0.pre.1 → 2.0.0.pre.2
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 +4 -4
- data/app/models/collection.rb +0 -10
- data/app/models/item.rb +1 -12
- data/lib/ddr/auth.rb +8 -2
- data/lib/ddr/auth/legacy/abstract_legacy_permissions.rb +17 -0
- data/lib/ddr/auth/legacy/legacy_authorization.rb +44 -0
- data/lib/ddr/auth/legacy/legacy_default_permissions.rb +33 -0
- data/lib/ddr/auth/legacy/legacy_permissions.rb +33 -0
- data/lib/ddr/auth/legacy/legacy_roles.rb +25 -0
- data/lib/ddr/auth/roles/role_set.rb +1 -1
- data/lib/ddr/datastreams/administrative_metadata_datastream.rb +2 -0
- data/lib/ddr/datastreams/structural_metadata_datastream.rb +3 -16
- data/lib/ddr/index_fields.rb +1 -0
- data/lib/ddr/jobs.rb +1 -0
- data/lib/ddr/jobs/migrate_legacy_authorization.rb +23 -0
- data/lib/ddr/models.rb +2 -0
- data/lib/ddr/models/access_controllable.rb +0 -1
- data/lib/ddr/models/base.rb +4 -0
- data/lib/ddr/models/has_admin_metadata.rb +2 -7
- data/lib/ddr/models/has_struct_metadata.rb +34 -31
- data/lib/ddr/models/indexing.rb +1 -0
- data/lib/ddr/models/solr_document.rb +4 -0
- data/lib/ddr/models/struct_div.rb +45 -0
- data/lib/ddr/models/structure.rb +52 -0
- data/lib/ddr/models/version.rb +1 -1
- data/lib/ddr/vocab.rb +1 -0
- data/lib/ddr/vocab/display.rb +11 -0
- data/spec/auth/legacy_authorization_spec.rb +94 -0
- data/spec/auth/legacy_default_permissions_spec.rb +37 -0
- data/spec/auth/legacy_permissions_spec.rb +14 -12
- data/spec/auth/legacy_roles_spec.rb +32 -0
- data/spec/factories/structure_factories.rb +27 -0
- data/spec/jobs/migrate_legacy_authorization_spec.rb +43 -0
- data/spec/models/has_admin_metadata_spec.rb +5 -0
- data/spec/models/has_struct_metadata_spec.rb +38 -0
- data/spec/models/item_spec.rb +0 -12
- data/spec/models/solr_document_spec.rb +5 -0
- data/spec/models/struct_div_spec.rb +65 -0
- data/spec/models/structure_spec.rb +20 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/structural_metadata_helper.rb +95 -0
- metadata +29 -4
- data/lib/ddr/auth/legacy_permissions.rb +0 -39
- data/lib/ddr/auth/legacy_roles.rb +0 -33
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Ddr
|
4
|
+
module Models
|
5
|
+
RSpec.describe HasStructMetadata, type: :model, structural_metadata: true do
|
6
|
+
|
7
|
+
describe "#structure" do
|
8
|
+
let(:item) { Item.new(pid: 'test:2') }
|
9
|
+
context "no existing structural metadata" do
|
10
|
+
it "should return nil" do
|
11
|
+
expect(item.structure).to eq(nil)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
context "existing structural metadata" do
|
15
|
+
before { item.datastreams[Ddr::Datastreams::STRUCT_METADATA].content = simple_structure }
|
16
|
+
it "should return the structural metadata" do
|
17
|
+
expect(item.structure.to_xml).to be_equivalent_to(simple_structure)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#build_default_structure" do
|
23
|
+
let(:item) { Item.new(pid: 'test:2') }
|
24
|
+
let(:components) { [ Component.new(pid: 'test:5', identifier: [ 'abc002' ]),
|
25
|
+
Component.new(pid: 'test:6', identifier: [ 'abc001' ]),
|
26
|
+
Component.new(pid: 'test:7', identifier: [ 'abc003' ])
|
27
|
+
] }
|
28
|
+
let(:expected) { FactoryGirl.build(:simple_structure) }
|
29
|
+
before { allow(item).to receive(:find_children) { simple_structure_query_response } }
|
30
|
+
it "should build the appropriate structural metadata" do
|
31
|
+
results = item.build_default_structure
|
32
|
+
expect(results).to be_equivalent_to(expected)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/models/item_spec.rb
CHANGED
@@ -7,16 +7,4 @@ RSpec.describe Item, type: :model do
|
|
7
7
|
it_behaves_like "it has an association", :has_many, :children, :is_part_of, "Component"
|
8
8
|
it_behaves_like "a non-collection model"
|
9
9
|
|
10
|
-
context "has structured children" do
|
11
|
-
let!(:item) { Item.create }
|
12
|
-
let!(:comp1) { Component.create(parent: item, file_use: 'master', order: 2) }
|
13
|
-
let!(:comp2) { Component.create(parent: item, file_use: 'reference', order: 1) }
|
14
|
-
let!(:comp3) { Component.create(parent: item, file_use: 'master', order: 1) }
|
15
|
-
it "should group and order the children" do
|
16
|
-
results = item.children_by_file_use
|
17
|
-
expect(results['master']).to eq([ comp3, comp1 ])
|
18
|
-
expect(results['reference']).to eq([ comp2 ])
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
10
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/structural_metadata_helper'
|
3
|
+
|
4
|
+
module Ddr
|
5
|
+
module Models
|
6
|
+
RSpec.describe StructDiv, type: :model, structural_metadata: true do
|
7
|
+
|
8
|
+
# let(:structure) { FactoryGirl.build(:simple_structure) }
|
9
|
+
# let(:structDiv) { structure.struct_div_map['default'] }
|
10
|
+
let(:structmap_node) { nested_structure_document.xpath('//xmlns:structMap').first }
|
11
|
+
let(:struct_div) { described_class.new(structmap_node) }
|
12
|
+
|
13
|
+
describe "#initialize" do
|
14
|
+
it "should create the correct object" do
|
15
|
+
expect(struct_div.divs.size).to eq(2)
|
16
|
+
expect(struct_div.divs.first.label).to eq("Front")
|
17
|
+
expect(struct_div.divs.first.divs).to be_empty
|
18
|
+
expect(struct_div.divs.first.objs).to eq([ "test:5" ])
|
19
|
+
expect(struct_div.divs.last.label).to eq("Back")
|
20
|
+
expect(struct_div.divs.last.divs.size).to eq(2)
|
21
|
+
expect(struct_div.divs.last.objs).to be_empty
|
22
|
+
expect(struct_div.divs.last.divs.first.label).to eq("Top")
|
23
|
+
expect(struct_div.divs.last.divs.first.divs).to be_empty
|
24
|
+
expect(struct_div.divs.last.divs.first.objs).to eq([ "test:7" ])
|
25
|
+
expect(struct_div.divs.last.divs.last.label).to eq("Bottom")
|
26
|
+
expect(struct_div.divs.last.divs.last.divs).to be_empty
|
27
|
+
expect(struct_div.divs.last.divs.last.objs).to eq([ "test:6" ])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#objects?" do
|
32
|
+
context "objects" do
|
33
|
+
it "should be true" do
|
34
|
+
expect(struct_div.divs[0].objects?).to be_truthy
|
35
|
+
end
|
36
|
+
end
|
37
|
+
context "no objects" do
|
38
|
+
it "should be false" do
|
39
|
+
expect(struct_div.objects?).to_not be_truthy
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#object_pids" do
|
45
|
+
it "should return the object pids in order" do
|
46
|
+
expect(struct_div.divs.last.divs.first.object_pids).to eq([ 'test:7' ])
|
47
|
+
expect(struct_div.divs.last.divs.last.object_pids).to eq([ 'test:6' ])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#objects" do
|
52
|
+
let(:repo_objects) { [ Component.new(pid: 'test:6'), Component.new(pid: 'test:7') ] }
|
53
|
+
before do
|
54
|
+
allow(ActiveFedora::Base).to receive(:find).with('test:6') { repo_objects.first }
|
55
|
+
allow(ActiveFedora::Base).to receive(:find).with('test:7') { repo_objects.last }
|
56
|
+
end
|
57
|
+
it "should return the Active Fedora objects in order" do
|
58
|
+
expect(struct_div.divs.last.divs.first.objects).to eq([ repo_objects.last ])
|
59
|
+
expect(struct_div.divs.last.divs.last.objects).to eq([ repo_objects.first ])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/structural_metadata_helper'
|
3
|
+
|
4
|
+
module Ddr
|
5
|
+
module Models
|
6
|
+
RSpec.describe Structure, type: :model, structural_metadata: true do
|
7
|
+
|
8
|
+
describe "#struct_divs" do
|
9
|
+
let(:structure) { FactoryGirl.build(:multiple_struct_maps_structure) }
|
10
|
+
let(:struct_divs) { structure.struct_divs }
|
11
|
+
it "should include struct divs for each struct map" do
|
12
|
+
expect(struct_divs.keys).to match_array([ 'default', 'reverse' ])
|
13
|
+
expect(struct_divs['default']).to be_a(Ddr::Models::StructDiv)
|
14
|
+
expect(struct_divs['reverse']).to be_a(Ddr::Models::StructDiv)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
def simple_structure_document
|
4
|
+
Nokogiri::XML(simple_structure) do |config|
|
5
|
+
config.noblanks
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def nested_structure_document
|
10
|
+
Nokogiri::XML(nested_structure) do |config|
|
11
|
+
config.noblanks
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def multiple_struct_maps_structure_document
|
16
|
+
Nokogiri::XML(multiple_struct_maps_structure) do |config|
|
17
|
+
config.noblanks
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def simple_structure
|
22
|
+
<<-eos
|
23
|
+
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
|
24
|
+
<structMap TYPE="default">
|
25
|
+
<div ORDER="1">
|
26
|
+
<fptr CONTENTIDS="info:fedora/test:6" />
|
27
|
+
</div>
|
28
|
+
<div ORDER="2">
|
29
|
+
<fptr CONTENTIDS="info:fedora/test:5" />
|
30
|
+
</div>
|
31
|
+
<div ORDER="3">
|
32
|
+
<fptr CONTENTIDS="info:fedora/test:7" />
|
33
|
+
</div>
|
34
|
+
</structMap>
|
35
|
+
</mets>
|
36
|
+
eos
|
37
|
+
end
|
38
|
+
|
39
|
+
def nested_structure
|
40
|
+
<<-eos
|
41
|
+
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
|
42
|
+
<structMap TYPE="default">
|
43
|
+
<div ORDER="1" LABEL="Front">
|
44
|
+
<fptr CONTENTIDS="info:fedora/test:5" />
|
45
|
+
</div>
|
46
|
+
<div ORDER="2" LABEL="Back">
|
47
|
+
<div ORDER="1" LABEL="Top">
|
48
|
+
<fptr CONTENTIDS="info:fedora/test:7" />
|
49
|
+
</div>
|
50
|
+
<div ORDER="2" LABEL="Bottom">
|
51
|
+
<fptr CONTENTIDS="info:fedora/test:6" />
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
</structMap>
|
55
|
+
</mets>
|
56
|
+
eos
|
57
|
+
end
|
58
|
+
|
59
|
+
def multiple_struct_maps_structure
|
60
|
+
<<-eos
|
61
|
+
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
|
62
|
+
<structMap TYPE="default">
|
63
|
+
<div ORDER="1" LABEL="Front">
|
64
|
+
<fptr CONTENTIDS="info:fedora/test:5" />
|
65
|
+
</div>
|
66
|
+
<div ORDER="2" LABEL="Back">
|
67
|
+
<div ORDER="1" LABEL="Top">
|
68
|
+
<fptr CONTENTIDS="info:fedora/test:7" />
|
69
|
+
</div>
|
70
|
+
<div ORDER="2" LABEL="Bottom">
|
71
|
+
<fptr CONTENTIDS="info:fedora/test:6" />
|
72
|
+
</div>
|
73
|
+
</div>
|
74
|
+
</structMap>
|
75
|
+
<structMap TYPE="reverse">
|
76
|
+
<div ORDER="1" LABEL="Back">
|
77
|
+
<div ORDER="1" LABEL="Bottom">
|
78
|
+
<fptr CONTENTIDS="info:fedora/test:6" />
|
79
|
+
</div>
|
80
|
+
<div ORDER="2" LABEL="Top">
|
81
|
+
<fptr CONTENTIDS="info:fedora/test:7" />
|
82
|
+
</div>
|
83
|
+
</div>
|
84
|
+
<div ORDER="2" LABEL="Front">
|
85
|
+
<fptr CONTENTIDS="info:fedora/test:5" />
|
86
|
+
</div>
|
87
|
+
</structMap>
|
88
|
+
</mets>
|
89
|
+
eos
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
def simple_structure_query_response
|
94
|
+
[{"system_create_dtsi"=>"2015-06-17T21:04:24Z", "system_modified_dtsi"=>"2015-06-17T21:04:56Z", "object_state_ssi"=>"A", "active_fedora_model_ssi"=>"Component", "id"=>"test:6", "object_profile_ssm"=>["{\"datastreams\":{\"RELS-EXT\":{\"dsLabel\":\"Fedora Object-to-Object Relationship Metadata\",\"dsVersionID\":\"RELS-EXT.1\",\"dsCreateDate\":\"2015-06-17T21:04:56Z\",\"dsState\":\"A\",\"dsMIME\":\"application/rdf+xml\",\"dsFormatURI\":null,\"dsControlGroup\":\"X\",\"dsSize\":408,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:6+RELS-EXT+RELS-EXT.1\",\"dsLocationType\":null,\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"bf84faa89d6b25924bc06357f7c33347a602e2ec8df9c1020ec98015fe571760\"},\"descMetadata\":{\"dsLabel\":\"Descriptive Metadata for this object\",\"dsVersionID\":\"descMetadata.1\",\"dsCreateDate\":\"2015-06-17T21:04:56Z\",\"dsState\":\"A\",\"dsMIME\":\"application/n-triples\",\"dsFormatURI\":null,\"dsControlGroup\":\"M\",\"dsSize\":70,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:6+descMetadata+descMetadata.1\",\"dsLocationType\":\"INTERNAL_ID\",\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"4d227bc972634ba2126eefff207fb3b35f6ff802a210ad7945d2ec60360076dd\"},\"rightsMetadata\":{},\"properties\":{},\"thumbnail\":{},\"adminMetadata\":{},\"content\":{},\"extractedText\":{},\"multiresImage\":{},\"structMetadata\":{}},\"objLabel\":null,\"objOwnerId\":\"fedoraAdmin\",\"objModels\":[\"info:fedora/fedora-system:FedoraObject-3.0\"],\"objCreateDate\":\"2015-06-17T21:04:24Z\",\"objLastModDate\":\"2015-06-17T21:04:24Z\",\"objDissIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A6/methods/fedora-system%3A3/viewMethodIndex\",\"objItemIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A6/methods/fedora-system%3A3/viewItemIndex\",\"objState\":\"A\"}"], "identifier_tesim"=>["abc001"], "is_part_of_ssim"=>["info:fedora/test:2"], "has_model_ssim"=>["info:fedora/afmodel:Component"], "title_ssi"=>"abc001", "internal_uri_ssi"=>"info:fedora/test:6", "identifier_ssi"=>"abc001", "access_role_ssi"=>"[]", "_version_"=>1504261016868880384, "timestamp"=>"2015-06-17T21:04:56.958Z"}, {"system_create_dtsi"=>"2015-06-17T21:03:58Z", "system_modified_dtsi"=>"2015-06-17T21:04:54Z", "object_state_ssi"=>"A", "active_fedora_model_ssi"=>"Component", "id"=>"test:5", "object_profile_ssm"=>["{\"datastreams\":{\"RELS-EXT\":{\"dsLabel\":\"Fedora Object-to-Object Relationship Metadata\",\"dsVersionID\":\"RELS-EXT.1\",\"dsCreateDate\":\"2015-06-17T21:04:54Z\",\"dsState\":\"A\",\"dsMIME\":\"application/rdf+xml\",\"dsFormatURI\":null,\"dsControlGroup\":\"X\",\"dsSize\":408,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:5+RELS-EXT+RELS-EXT.1\",\"dsLocationType\":null,\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"6a7f1cbe6e435991ae3bba134e52e7a275af8a232b209ac725fa54fdd81bb973\"},\"descMetadata\":{\"dsLabel\":\"Descriptive Metadata for this object\",\"dsVersionID\":\"descMetadata.1\",\"dsCreateDate\":\"2015-06-17T21:04:54Z\",\"dsState\":\"A\",\"dsMIME\":\"application/n-triples\",\"dsFormatURI\":null,\"dsControlGroup\":\"M\",\"dsSize\":70,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:5+descMetadata+descMetadata.1\",\"dsLocationType\":\"INTERNAL_ID\",\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"8b106726ca2d39d9a2e187fc9da2e58b25bd3553031012515ae31cf4fbe520e9\"},\"rightsMetadata\":{},\"properties\":{},\"thumbnail\":{},\"adminMetadata\":{},\"content\":{},\"extractedText\":{},\"multiresImage\":{},\"structMetadata\":{}},\"objLabel\":null,\"objOwnerId\":\"fedoraAdmin\",\"objModels\":[\"info:fedora/fedora-system:FedoraObject-3.0\"],\"objCreateDate\":\"2015-06-17T21:03:58Z\",\"objLastModDate\":\"2015-06-17T21:03:58Z\",\"objDissIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A5/methods/fedora-system%3A3/viewMethodIndex\",\"objItemIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A5/methods/fedora-system%3A3/viewItemIndex\",\"objState\":\"A\"}"], "identifier_tesim"=>["abc002"], "is_part_of_ssim"=>["info:fedora/test:2"], "has_model_ssim"=>["info:fedora/afmodel:Component"], "title_ssi"=>"abc002", "internal_uri_ssi"=>"info:fedora/test:5", "identifier_ssi"=>"abc002", "access_role_ssi"=>"[]", "_version_"=>1504261014501195776, "timestamp"=>"2015-06-17T21:04:54.701Z"}, {"system_create_dtsi"=>"2015-06-17T21:04:46Z", "system_modified_dtsi"=>"2015-06-17T21:04:59Z", "object_state_ssi"=>"A", "active_fedora_model_ssi"=>"Component", "id"=>"test:7", "object_profile_ssm"=>["{\"datastreams\":{\"RELS-EXT\":{\"dsLabel\":\"Fedora Object-to-Object Relationship Metadata\",\"dsVersionID\":\"RELS-EXT.1\",\"dsCreateDate\":\"2015-06-17T21:04:59Z\",\"dsState\":\"A\",\"dsMIME\":\"application/rdf+xml\",\"dsFormatURI\":null,\"dsControlGroup\":\"X\",\"dsSize\":408,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:7+RELS-EXT+RELS-EXT.1\",\"dsLocationType\":null,\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"cb385ff9a55b5fe24e8c2a8159fc928e3ee582ef312955132d34282676102a6a\"},\"descMetadata\":{\"dsLabel\":\"Descriptive Metadata for this object\",\"dsVersionID\":\"descMetadata.1\",\"dsCreateDate\":\"2015-06-17T21:04:59Z\",\"dsState\":\"A\",\"dsMIME\":\"application/n-triples\",\"dsFormatURI\":null,\"dsControlGroup\":\"M\",\"dsSize\":70,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:7+descMetadata+descMetadata.1\",\"dsLocationType\":\"INTERNAL_ID\",\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"523ee1e5d55d188bd17b2789e4c9109c8f9d0170b63af1219de8a74d4f32966a\"},\"rightsMetadata\":{},\"properties\":{},\"thumbnail\":{},\"adminMetadata\":{},\"content\":{},\"extractedText\":{},\"multiresImage\":{},\"structMetadata\":{}},\"objLabel\":null,\"objOwnerId\":\"fedoraAdmin\",\"objModels\":[\"info:fedora/fedora-system:FedoraObject-3.0\"],\"objCreateDate\":\"2015-06-17T21:04:46Z\",\"objLastModDate\":\"2015-06-17T21:04:46Z\",\"objDissIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A7/methods/fedora-system%3A3/viewMethodIndex\",\"objItemIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A7/methods/fedora-system%3A3/viewItemIndex\",\"objState\":\"A\"}"], "identifier_tesim"=>["abc003"], "is_part_of_ssim"=>["info:fedora/test:2"], "has_model_ssim"=>["info:fedora/afmodel:Component"], "title_ssi"=>"abc003", "internal_uri_ssi"=>"info:fedora/test:7", "identifier_ssi"=>"abc003", "access_role_ssi"=>"[]", "_version_"=>1504261019487174656, "timestamp"=>"2015-06-17T21:04:59.455Z"}]
|
95
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddr-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.pre.
|
4
|
+
version: 2.0.0.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Coble
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -384,8 +384,11 @@ files:
|
|
384
384
|
- lib/ddr/auth/groups.rb
|
385
385
|
- lib/ddr/auth/inherited_roles.rb
|
386
386
|
- lib/ddr/auth/ldap_gateway.rb
|
387
|
-
- lib/ddr/auth/
|
388
|
-
- lib/ddr/auth/
|
387
|
+
- lib/ddr/auth/legacy/abstract_legacy_permissions.rb
|
388
|
+
- lib/ddr/auth/legacy/legacy_authorization.rb
|
389
|
+
- lib/ddr/auth/legacy/legacy_default_permissions.rb
|
390
|
+
- lib/ddr/auth/legacy/legacy_permissions.rb
|
391
|
+
- lib/ddr/auth/legacy/legacy_roles.rb
|
389
392
|
- lib/ddr/auth/permissions.rb
|
390
393
|
- lib/ddr/auth/remote_groups.rb
|
391
394
|
- lib/ddr/auth/resource_roles.rb
|
@@ -427,6 +430,7 @@ files:
|
|
427
430
|
- lib/ddr/events/virus_check_event.rb
|
428
431
|
- lib/ddr/index_fields.rb
|
429
432
|
- lib/ddr/jobs.rb
|
433
|
+
- lib/ddr/jobs/migrate_legacy_authorization.rb
|
430
434
|
- lib/ddr/jobs/permanent_id.rb
|
431
435
|
- lib/ddr/managers.rb
|
432
436
|
- lib/ddr/managers/derivatives_manager.rb
|
@@ -456,11 +460,14 @@ files:
|
|
456
460
|
- lib/ddr/models/indexing.rb
|
457
461
|
- lib/ddr/models/licensable.rb
|
458
462
|
- lib/ddr/models/solr_document.rb
|
463
|
+
- lib/ddr/models/struct_div.rb
|
464
|
+
- lib/ddr/models/structure.rb
|
459
465
|
- lib/ddr/models/version.rb
|
460
466
|
- lib/ddr/notifications.rb
|
461
467
|
- lib/ddr/utils.rb
|
462
468
|
- lib/ddr/vocab.rb
|
463
469
|
- lib/ddr/vocab/asset.rb
|
470
|
+
- lib/ddr/vocab/display.rb
|
464
471
|
- lib/ddr/vocab/duke_terms.rb
|
465
472
|
- lib/ddr/vocab/rdf_vocabulary_parser.rb
|
466
473
|
- lib/ddr/vocab/roles.rb
|
@@ -476,7 +483,10 @@ files:
|
|
476
483
|
- spec/auth/group_spec.rb
|
477
484
|
- spec/auth/groups_spec.rb
|
478
485
|
- spec/auth/ldap_gateway_spec.rb
|
486
|
+
- spec/auth/legacy_authorization_spec.rb
|
487
|
+
- spec/auth/legacy_default_permissions_spec.rb
|
479
488
|
- spec/auth/legacy_permissions_spec.rb
|
489
|
+
- spec/auth/legacy_roles_spec.rb
|
480
490
|
- spec/auth/roles/detached_role_set_spec.rb
|
481
491
|
- spec/auth/roles/property_role_set_spec.rb
|
482
492
|
- spec/auth/roles/role_set_query_spec.rb
|
@@ -542,6 +552,7 @@ files:
|
|
542
552
|
- spec/factories/event_factories.rb
|
543
553
|
- spec/factories/item_factories.rb
|
544
554
|
- spec/factories/role_factories.rb
|
555
|
+
- spec/factories/structure_factories.rb
|
545
556
|
- spec/factories/target_factories.rb
|
546
557
|
- spec/factories/test_model_factories.rb
|
547
558
|
- spec/factories/user_factories.rb
|
@@ -554,6 +565,7 @@ files:
|
|
554
565
|
- spec/fixtures/sample.pdf
|
555
566
|
- spec/fixtures/target.png
|
556
567
|
- spec/helpers/models_helper_spec.rb
|
568
|
+
- spec/jobs/migrate_legacy_authorization_spec.rb
|
557
569
|
- spec/managers/derivatives_manager_spec.rb
|
558
570
|
- spec/models/active_fedora_base_spec.rb
|
559
571
|
- spec/models/active_fedora_datastream_spec.rb
|
@@ -565,8 +577,11 @@ files:
|
|
565
577
|
- spec/models/file_management_spec.rb
|
566
578
|
- spec/models/has_admin_metadata_spec.rb
|
567
579
|
- spec/models/has_children_spec.rb
|
580
|
+
- spec/models/has_struct_metadata_spec.rb
|
568
581
|
- spec/models/item_spec.rb
|
569
582
|
- spec/models/solr_document_spec.rb
|
583
|
+
- spec/models/struct_div_spec.rb
|
584
|
+
- spec/models/structure_spec.rb
|
570
585
|
- spec/models/target_spec.rb
|
571
586
|
- spec/routing/user_routing_spec.rb
|
572
587
|
- spec/spec_helper.rb
|
@@ -584,6 +599,7 @@ files:
|
|
584
599
|
- spec/support/shared_examples_for_licensable.rb
|
585
600
|
- spec/support/shared_examples_for_non_collection_models.rb
|
586
601
|
- spec/support/shared_examples_for_role_sets.rb
|
602
|
+
- spec/support/structural_metadata_helper.rb
|
587
603
|
- spec/utils_spec.rb
|
588
604
|
homepage: https://github.com/duke-libraries/ddr-models
|
589
605
|
licenses:
|
@@ -621,7 +637,10 @@ test_files:
|
|
621
637
|
- spec/auth/group_spec.rb
|
622
638
|
- spec/auth/groups_spec.rb
|
623
639
|
- spec/auth/ldap_gateway_spec.rb
|
640
|
+
- spec/auth/legacy_authorization_spec.rb
|
641
|
+
- spec/auth/legacy_default_permissions_spec.rb
|
624
642
|
- spec/auth/legacy_permissions_spec.rb
|
643
|
+
- spec/auth/legacy_roles_spec.rb
|
625
644
|
- spec/auth/roles/detached_role_set_spec.rb
|
626
645
|
- spec/auth/roles/property_role_set_spec.rb
|
627
646
|
- spec/auth/roles/role_set_query_spec.rb
|
@@ -687,6 +706,7 @@ test_files:
|
|
687
706
|
- spec/factories/event_factories.rb
|
688
707
|
- spec/factories/item_factories.rb
|
689
708
|
- spec/factories/role_factories.rb
|
709
|
+
- spec/factories/structure_factories.rb
|
690
710
|
- spec/factories/target_factories.rb
|
691
711
|
- spec/factories/test_model_factories.rb
|
692
712
|
- spec/factories/user_factories.rb
|
@@ -699,6 +719,7 @@ test_files:
|
|
699
719
|
- spec/fixtures/sample.pdf
|
700
720
|
- spec/fixtures/target.png
|
701
721
|
- spec/helpers/models_helper_spec.rb
|
722
|
+
- spec/jobs/migrate_legacy_authorization_spec.rb
|
702
723
|
- spec/managers/derivatives_manager_spec.rb
|
703
724
|
- spec/models/active_fedora_base_spec.rb
|
704
725
|
- spec/models/active_fedora_datastream_spec.rb
|
@@ -710,8 +731,11 @@ test_files:
|
|
710
731
|
- spec/models/file_management_spec.rb
|
711
732
|
- spec/models/has_admin_metadata_spec.rb
|
712
733
|
- spec/models/has_children_spec.rb
|
734
|
+
- spec/models/has_struct_metadata_spec.rb
|
713
735
|
- spec/models/item_spec.rb
|
714
736
|
- spec/models/solr_document_spec.rb
|
737
|
+
- spec/models/struct_div_spec.rb
|
738
|
+
- spec/models/structure_spec.rb
|
715
739
|
- spec/models/target_spec.rb
|
716
740
|
- spec/routing/user_routing_spec.rb
|
717
741
|
- spec/spec_helper.rb
|
@@ -729,4 +753,5 @@ test_files:
|
|
729
753
|
- spec/support/shared_examples_for_licensable.rb
|
730
754
|
- spec/support/shared_examples_for_non_collection_models.rb
|
731
755
|
- spec/support/shared_examples_for_role_sets.rb
|
756
|
+
- spec/support/structural_metadata_helper.rb
|
732
757
|
- spec/utils_spec.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Ddr
|
2
|
-
module Auth
|
3
|
-
class LegacyPermissions
|
4
|
-
|
5
|
-
attr_reader :permissions
|
6
|
-
|
7
|
-
LEGACY_PERMISSION_ROLE_MAP = {
|
8
|
-
"discover" => Roles::VIEWER,
|
9
|
-
"read" => Roles::VIEWER,
|
10
|
-
"edit" => Roles::EDITOR
|
11
|
-
}
|
12
|
-
|
13
|
-
def initialize(permissions)
|
14
|
-
@permissions = permissions
|
15
|
-
end
|
16
|
-
|
17
|
-
def to_resource_roles
|
18
|
-
to_roles(Roles::RESOURCE_SCOPE)
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_policy_roles
|
22
|
-
to_roles(Roles::POLICY_SCOPE)
|
23
|
-
end
|
24
|
-
|
25
|
-
# @param scope [String] the scope to assign to each role
|
26
|
-
# @return [Ddr::Auth::Roles::RoleSet]
|
27
|
-
def to_roles(scope)
|
28
|
-
roles = permissions.map do |perm|
|
29
|
-
access, agent = perm[:access], perm[:name]
|
30
|
-
Roles::Role.build type: LEGACY_PERMISSION_ROLE_MAP[access],
|
31
|
-
agent: agent,
|
32
|
-
scope: scope
|
33
|
-
end
|
34
|
-
Roles::DetachedRoleSet.new(roles)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Ddr
|
2
|
-
module Auth
|
3
|
-
module LegacyRoles
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
LEGACY_ROLES = [:administrator, :editor, :downloader, :contributor]
|
7
|
-
|
8
|
-
# @return [Ddr::Auth::Roles::RoleSet]
|
9
|
-
def legacy_downloader_to_resource_roles
|
10
|
-
roles = adminMetadata.downloader.map do |name|
|
11
|
-
Roles::Role.build type: Roles::DOWNLOADER, agent: name, scope: Roles::RESOURCE_SCOPE
|
12
|
-
end
|
13
|
-
Roles::DetachedRoleSet.new(roles)
|
14
|
-
end
|
15
|
-
|
16
|
-
def principal_has_role?(principal, role)
|
17
|
-
warn "[DEPRECATION] `principal_has_role?` is deprecated and should not be used with role-based access control."
|
18
|
-
( principals(role) & Array(principal) ).any?
|
19
|
-
end
|
20
|
-
|
21
|
-
def principals(role)
|
22
|
-
warn "[DEPRECATION] `principals(role)` is deprecated and should not be used with role-based access control." \
|
23
|
-
" If need be, access the legacy role directly on `adminMetadata` by property name."
|
24
|
-
if LEGACY_ROLES.include?(role)
|
25
|
-
adminMetadata.send(role)
|
26
|
-
else
|
27
|
-
raise ArgumentError, "#{role.inspect} is not a legacy role."
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|