dor-rights-auth 1.0.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 40f40de949255d9644bb67069e570735acfa4b5b
4
- data.tar.gz: 7691335eecd9d5cf68b6fa70609c782c7114f566
2
+ SHA256:
3
+ metadata.gz: f3461a34cc8edcf7b4362d1c6c58304bbe43a82fbd9edd16452ec02cf8a40204
4
+ data.tar.gz: 826e6ef53e3fec66cb97b1ab385793b9727ddc82bd81be1add9c46d285183303
5
5
  SHA512:
6
- metadata.gz: f71d100e9c23464dc50014d8749589f8c69ca46137eb60cfb82cbf5b3caa9cad0c5b99130a5bad2133c5e45d735c54ff3b6203f092105ecf1335c8da6960a770
7
- data.tar.gz: 9278835bc26a8774acfccc5e41f8cb9cfc58750832db255f84444e1f3180fa31fb0401775dab9f57ecbbead7ec1798b58eda873f694d98384b52f2123c2a44b7
6
+ metadata.gz: 196996c12540e5e17907865aabdff51c36afca65d59781d6cf08660d7c422b8bd26fefd699bc211c02ffc51e97ada62331fc19a701f5b39c5a9e15b90a1248f0
7
+ data.tar.gz: 9dd9fa090720a1f4cdf5f9673513153ae3d41a63b57aaac99385353f26c9e4d3e1fa0e8309d863d1c0f01ab29302a4b4def2ee0730336ee72ace62f920ab9477
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dor/rights_auth'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'nokogiri'
2
4
  require 'time'
3
5
 
@@ -8,7 +10,7 @@ module Dor
8
10
  Rights = Struct.new(:value, :rule)
9
11
 
10
12
  # Rights for an object or File
11
- EntityRights = Struct.new(:world, :group, :agent)
13
+ EntityRights = Struct.new(:world, :group, :agent, :location, :controlled_digital_lending)
12
14
  # class EntityRights
13
15
  # @world = #Rights
14
16
  # @group {
@@ -18,6 +20,7 @@ module Dor
18
20
  # 'app1' => #Rights,
19
21
  # 'app2' => #Rights
20
22
  # }
23
+ # @controlled_digital_lending = false
21
24
  # end
22
25
 
23
26
  # class Dor::RightsAuth
@@ -28,9 +31,11 @@ module Dor
28
31
  # }
29
32
  # end
30
33
 
34
+ # read rights_xml only once and create query-able methods for rights info
31
35
  class RightsAuth
32
36
 
33
37
  CONTAINS_STANFORD_XPATH = "contains(translate(text(), 'STANFORD', 'stanford'), 'stanford')"
38
+ NO_DOWNLOAD_RULE = 'no-download'
34
39
 
35
40
  attr_accessor :obj_lvl, :file, :embargoed, :index_elements
36
41
 
@@ -43,20 +48,59 @@ module Dor
43
48
 
44
49
  # Returns true if the object is under embargo.
45
50
  # @return [Boolean]
46
- def embargoed? # rubocop:disable Style/TrivialAccessors
51
+ def embargoed?
47
52
  @embargoed
48
53
  end
49
54
 
55
+ # summary level rights info is mostly used for object-level indexing/faceting.
56
+ # thus, we currently only calculate it when parsing object rights for indexing.
57
+ # to keep from having to refactor or duplicate code right now, we'll just leverage
58
+ # what we've got, checking whether index_elements is populated, and raising an error
59
+ # if the object wasn't instantiated in a way that makes those calculations.
60
+ def check_index_elements_calculated!
61
+ unless index_elements.size > 0
62
+ raise "primary access rights not calculated. instantiate by calling '.parse(xml, forindex = true)'."
63
+ end
64
+ end
65
+
66
+ # this is just a convenience method for asking whether an object's rights would
67
+ # classify it as 'dark'.
68
+ def dark?
69
+ check_index_elements_calculated!
70
+ index_elements[:primary] == 'dark'
71
+ end
72
+
73
+ # this is just a convenience method for asking whether an object's rights would
74
+ # classify it as 'citation only'.
75
+ def citation_only?
76
+ check_index_elements_calculated!
77
+ index_elements[:primary] == 'citation'
78
+ end
79
+
50
80
  # Returns true if the object is world readable AND has no rule attribute
51
81
  # @return [Boolean]
52
82
  def world_unrestricted?
53
83
  @obj_lvl.world.value && @obj_lvl.world.rule.nil?
54
84
  end
55
-
56
85
  alias_method :public_unrestricted?, :world_unrestricted?
57
86
 
58
87
  def readable?
59
- public_unrestricted? || stanford_only_unrestricted? # TODO: stanford_only or public with rule, figure out if this is still a legit method
88
+ # TODO: stanford_only or public with rule, figure out if this is still a legit method
89
+ public_unrestricted? || stanford_only_unrestricted?
90
+ end
91
+
92
+ # Returns true if the object is readable AND allows download
93
+ # @return [Boolean]
94
+ def world_downloadable?
95
+ world_rule = @obj_lvl.world.rule
96
+ @obj_lvl.world.value && (world_rule.nil? || world_rule != NO_DOWNLOAD_RULE)
97
+ end
98
+ alias_method :public_downloadable?, :world_downloadable?
99
+
100
+ # Returns true if the object is enabled for controlled digital lending
101
+ # @return [Boolean]
102
+ def controlled_digital_lending?
103
+ @obj_lvl.controlled_digital_lending
60
104
  end
61
105
 
62
106
  # Returns true if the object is stanford-only readable AND has no rule attribute
@@ -65,14 +109,21 @@ module Dor
65
109
  @obj_lvl.group[:stanford].value && @obj_lvl.group[:stanford].rule.nil?
66
110
  end
67
111
 
112
+ # Returns true if the object is stanford-only readable AND allows download
113
+ # @return [Boolean]
114
+ def stanford_only_downloadable?
115
+ stanford_rule = @obj_lvl.group[:stanford].rule
116
+ @obj_lvl.group[:stanford].value && (stanford_rule.nil? || stanford_rule != NO_DOWNLOAD_RULE)
117
+ end
118
+
68
119
  # Returns true if the passed in agent (usually an application) is allowed access to the object without a rule
69
120
  # @param [String] agent_name Name of the agent that wants to access this object
70
121
  # @return [Boolean]
71
122
  def agent_unrestricted?(agent_name)
72
123
  return false unless @obj_lvl.agent.key? agent_name
124
+
73
125
  @obj_lvl.agent[agent_name].value && @obj_lvl.agent[agent_name].rule.nil?
74
126
  end
75
-
76
127
  alias_method :allowed_read_agent?, :agent_unrestricted?
77
128
 
78
129
  # Returns true if the file is stanford-only readable AND has no rule attribute
@@ -96,18 +147,38 @@ module Dor
96
147
 
97
148
  @file[file_name].world.value && @file[file_name].world.rule.nil?
98
149
  end
99
-
100
150
  alias_method :public_unrestricted_file?, :world_unrestricted_file?
101
151
 
152
+ # Returns true if the file is world readable AND either has no rule attribute or
153
+ # the rule attribute is not 'no-download'
154
+ # If world rights do not exist for this file, then object level rights are returned
155
+ # @see #world_downloadable?
156
+ # @param [String] file_name name of the file being tested
157
+ # @return (see #world_rights)
158
+ def world_downloadable_file?(file_name)
159
+ return world_downloadable? if @file[file_name].nil? || @file[file_name].world.nil?
160
+
161
+ world_rule = @file[file_name].world.rule
162
+ @file[file_name].world.value && (world_rule.nil? || world_rule != NO_DOWNLOAD_RULE)
163
+ end
164
+ alias_method :public_downloadable_file?, :world_downloadable_file?
165
+
166
+ def stanford_only_downloadable_file?(file_name)
167
+ return stanford_only_downloadable? if @file[file_name].nil? || @file[file_name].group[:stanford].nil?
168
+
169
+ stanford_rule = @file[file_name].group[:stanford].rule
170
+ @file[file_name].group[:stanford].value && (stanford_rule.nil? || stanford_rule != NO_DOWNLOAD_RULE)
171
+ end
172
+
102
173
  # Returns whether an object-level world node exists, and the value of its rule attribute
103
- # @return [Array<(Boolean, String)>] First value: existance of node. Second Value: rule attribute, nil otherwise
174
+ # @return [Array<(Boolean, String)>] First value: existence of node. Second Value: rule attribute, nil otherwise
104
175
  # @example Using multiple variable assignment to read both array elements
105
176
  # world_exists, world_rule = rights.world_rights
106
177
  def world_rights
107
178
  [@obj_lvl.world.value, @obj_lvl.world.rule]
108
179
  end
109
180
 
110
- # Returns whether and object-level group/stanford node exists, and the value of its rule attribute
181
+ # Returns whether an object-level group/stanford node exists, and the value of its rule attribute
111
182
  # @return (see #world_rights)
112
183
  # @example Using multiple variable assignment to read both array elements
113
184
  # su_only_exists, su_only_rule = rights.stanford_only_rights
@@ -115,6 +186,30 @@ module Dor
115
186
  [@obj_lvl.group[:stanford].value, @obj_lvl.group[:stanford].rule]
116
187
  end
117
188
 
189
+ # Returns whether an object-level location node exists for the passed in location, and the
190
+ # value of its rule attribute
191
+ # @param [String] location_name name of the location that is tested for access
192
+ # @return (see #world_rights)
193
+ # @example Using multiple variable assignment to read both array elements
194
+ # location_exists, location_rule = rights.location_rights('spec_coll_reading_room')
195
+ def location_rights(location_name)
196
+ return [false, nil] if @obj_lvl.location[location_name].nil?
197
+
198
+ [@obj_lvl.location[location_name].value, @obj_lvl.location[location_name].rule]
199
+ end
200
+
201
+ # Returns whether a given file has any location restrictions and falls back to
202
+ # the object behavior in the absence of the file.
203
+ # @param [String] file_name name of the file being tested
204
+ # @return [Boolean] whether any location restrictions exist on the file or the
205
+ # object itself (in the absence of file-level rights)
206
+ def restricted_by_location?(file_name = nil)
207
+ any_file_location = @file[file_name]&.location&.any?
208
+ any_object_location = @obj_lvl.location&.any?
209
+
210
+ any_file_location || any_object_location
211
+ end
212
+
118
213
  # Returns whether an object-level agent node exists for the passed in agent, and the value of its rule attribute
119
214
  # @param [String] agent_name name of the app or thing that is tested for access
120
215
  # @return (see #world_rights)
@@ -123,6 +218,7 @@ module Dor
123
218
  # @note should be called after doing a check for world_unrestricted?
124
219
  def agent_rights(agent_name)
125
220
  return [false, nil] if @obj_lvl.agent[agent_name].nil?
221
+
126
222
  [@obj_lvl.agent[agent_name].value, @obj_lvl.agent[agent_name].rule]
127
223
  end
128
224
 
@@ -142,7 +238,7 @@ module Dor
142
238
  # Returns whether a file-level group/stanford node exists, and the value of its rule attribute
143
239
  # If a group/stanford node does not exist for this file, then object-level group/stanford rights are returned
144
240
  # @see #stanford_only_rights
145
- # @param (see #world_rights_for_file)
241
+ # @param [String] file_name name of the file being tested
146
242
  # @return (see #world_rights)
147
243
  # @example Using multiple variable assignment to read both array elements
148
244
  # su_only_exists, su_only_rule = rights.stanford_only_rights_for_file('somefile')
@@ -152,6 +248,22 @@ module Dor
152
248
  [@file[file_name].group[:stanford].value, @file[file_name].group[:stanford].rule]
153
249
  end
154
250
 
251
+ # Returns whether a file-level location-node exists, and the value of its rule attribute
252
+ # If a location-node does not exist for this file, then object-level location rights are returned
253
+ # @param [String] file_name name of the file being tested
254
+ # @param [String] location_name name of the location being tested
255
+ # @return (see #world_rights)
256
+ # @example Using multiple variable assignment to read both array elements
257
+ # location_exists, location_rule = rightslocation_rights_for_file('filex', 'spec_coll_reading_room')
258
+ def location_rights_for_file(file_name, location_name)
259
+ file_rights = @file[file_name]
260
+ return location_rights(location_name) if file_rights.nil?
261
+
262
+ return [false, nil] if file_rights.location[location_name].nil?
263
+
264
+ [file_rights.location[location_name].value, file_rights.location[location_name].rule]
265
+ end
266
+
155
267
  # Returns whether a file-level agent-node exists, and the value of its rule attribute
156
268
  # If an agent-node does not exist for this file, then object-level agent rights are returned
157
269
  # @param [String] file_name name of the file being tested
@@ -160,7 +272,8 @@ module Dor
160
272
  # @example Using multiple variable assignment to read both array elements
161
273
  # agent_exists, agent_rule = rights.agent_rights_for_file('filex', 'someapp')
162
274
  def agent_rights_for_file(file_name, agent_name)
163
- return agent_rights(agent_name) if @file[file_name].nil? # look at object level agent rights if the file-name is not stored
275
+ # look at object level agent rights if the file-name is not stored
276
+ return agent_rights(agent_name) if @file[file_name].nil?
164
277
 
165
278
  return [false, nil] if @file[file_name].agent[agent_name].nil? # file rules exist, but not for this agent
166
279
 
@@ -172,6 +285,7 @@ module Dor
172
285
  # @return [Array] list of things that are wrong with it
173
286
  def self.validate_lite(doc)
174
287
  return ['no_rightsMetadata'] if doc.nil? || doc.at_xpath('//rightsMetadata').nil?
288
+
175
289
  errors = []
176
290
  maindiscover = doc.at_xpath("//rightsMetadata/access[@type='discover' and not(file)]")
177
291
  mainread = doc.at_xpath("//rightsMetadata/access[@type='read' and not(file)]")
@@ -200,7 +314,10 @@ module Dor
200
314
  def self.extract_index_terms(doc)
201
315
  terms = []
202
316
  machine = doc.at_xpath("//rightsMetadata/access[@type='read' and not(file)]/machine")
203
- terms.push 'none_discover' if doc.at_xpath("//rightsMetadata/access[@type='discover']/machine/none")
317
+ if doc.at_xpath("//rightsMetadata/access[@type='discover']/machine/none") ||
318
+ doc.at_xpath("//rightsMetadata/access[@type='discover']/machine[not(*)]")
319
+ terms.push 'none_discover'
320
+ end
204
321
  terms.push 'world_discover' if doc.at_xpath("//rightsMetadata/access[@type='discover']/machine/world[not(@rule)]")
205
322
  return terms if machine.nil?
206
323
 
@@ -214,11 +331,22 @@ module Dor
214
331
  terms.push "group|#{machine.at_xpath('./group').value.downcase}"
215
332
  end
216
333
 
334
+ ['location', 'agent'].each do |access_type|
335
+ if machine.at_xpath("./#{access_type}")
336
+ terms.push access_type
337
+ terms.push "#{access_type}_with_rule" if machine.at_xpath("./#{access_type}")
338
+ end
339
+ end
340
+
341
+ terms.push 'none_read_file' if doc.at_xpath("//rightsMetadata/access[@type='read' and file]/machine/none")
342
+
217
343
  if machine.at_xpath('./none')
218
344
  terms.push 'none_read'
219
345
  elsif machine.at_xpath('./world')
220
346
  terms.push 'world_read'
221
347
  terms.push "world|#{machine.at_xpath('./world/@rule').value.downcase}" if machine.at_xpath('./world/@rule')
348
+ elsif machine.at_xpath('./cdl')
349
+ terms.push 'cdl_none'
222
350
  end
223
351
 
224
352
  # now some statistical generation
@@ -250,12 +378,26 @@ module Dor
250
378
  # :errors => [...], # known error cases
251
379
  # :terms => [...] # array of non-error characterizations and stats strings
252
380
  # }
253
- def self.extract_access_rights(doc)
381
+ def self.init_index_elements(doc)
254
382
  errors = validate_lite(doc)
255
383
  stuff = {
256
384
  :primary => nil,
257
- :errors => errors,
258
- :terms => []
385
+ :errors => errors,
386
+ :terms => [],
387
+ :obj_groups => [],
388
+ :obj_locations => [],
389
+ :obj_agents => [],
390
+ :file_groups => [],
391
+ :file_locations => [],
392
+ :file_agents => [],
393
+ :obj_world_qualified => [],
394
+ :obj_groups_qualified => [],
395
+ :obj_locations_qualified => [],
396
+ :obj_agents_qualified => [],
397
+ :file_world_qualified => [],
398
+ :file_groups_qualified => [],
399
+ :file_locations_qualified => [],
400
+ :file_agents_qualified => []
259
401
  }
260
402
 
261
403
  if errors.include? 'no_rightsMetadata'
@@ -264,22 +406,33 @@ module Dor
264
406
  end
265
407
 
266
408
  stuff[:terms] = extract_index_terms(doc)
267
- has_rule = stuff[:terms].include? 'has_rule'
409
+ stuff[:primary] = primary_access_rights stuff[:terms], errors
268
410
 
269
- if stuff[:terms].include?('none_discover')
270
- stuff[:primary] = 'dark'
411
+ stuff
412
+ end
413
+
414
+ # "primary" access is a somewhat crude way of summarizing a whole
415
+ # object (possibly with many disparate interacting rights types)
416
+ # using one rights label. but it should still do a good job of capturing
417
+ # rights that make more sense at the object level (e.g. 'dark').
418
+ def self.primary_access_rights(index_terms, errors)
419
+ has_rule = index_terms.include? 'has_rule'
420
+ if index_terms.include?('none_discover')
421
+ 'dark'
422
+ elsif index_terms.include?('cdl_none')
423
+ 'controlled digital lending'
271
424
  elsif errors.include?('no_discover_access') || errors.include?('no_discover_machine')
272
- stuff[:primary] = 'dark'
273
- elsif errors.include?('no_read_machine') || stuff[:terms].include?('none_read')
274
- stuff[:primary] = 'citation'
275
- elsif stuff[:terms].include? 'world_read'
276
- stuff[:primary] = has_rule ? 'world_qualified' : 'world'
277
- elsif stuff[:terms].include? 'group|stanford'
278
- stuff[:primary] = has_rule ? 'stanford_qualified' : 'stanford'
425
+ 'dark'
426
+ elsif errors.include?('no_read_machine') || index_terms.include?('none_read')
427
+ 'citation'
428
+ elsif index_terms.include? 'world_read'
429
+ has_rule ? 'world_qualified' : 'world'
430
+ elsif index_terms.include?('has_group_rights') ||
431
+ index_terms.include?('location') || index_terms.include?('agent')
432
+ has_rule ? 'access_restricted_qualified' : 'access_restricted'
279
433
  else # should never happen, but we might as well note it if it does
280
- stuff[:primary] = has_rule ? 'UNKNOWN_qualified' : 'UNKNOWN'
434
+ has_rule ? 'UNKNOWN_qualified' : 'UNKNOWN'
281
435
  end
282
- stuff
283
436
  end
284
437
 
285
438
  # Create a Dor::RightsAuth object from xml
@@ -292,31 +445,61 @@ module Dor
292
445
  rights.obj_lvl.world = Rights.new
293
446
 
294
447
  doc = xml.is_a?(Nokogiri::XML::Document) ? xml.clone : Nokogiri::XML(xml)
448
+
449
+ rights.index_elements = init_index_elements(doc) if forindex
450
+
295
451
  if doc.at_xpath("//rightsMetadata/access[@type='read' and not(file)]/machine/world")
296
452
  rights.obj_lvl.world.value = true
297
453
  rule = doc.at_xpath("//rightsMetadata/access[@type='read' and not(file)]/machine/world/@rule")
298
454
  rights.obj_lvl.world.rule = rule.value if rule
455
+ rights.index_elements[:obj_world_qualified] << { :rule => (rule ? rule.value : nil) } if forindex
299
456
  else
300
457
  rights.obj_lvl.world.value = false
301
458
  end
302
459
 
303
- rights.obj_lvl.group = { :stanford => Rights.new }
304
- rights.index_elements = extract_access_rights(doc) if forindex
460
+ # TODO: we should also look for the <group rule="no-download">stanford</group> node and parse as needed
461
+ if doc.at_xpath("//rightsMetadata/access[@type='read' and not(file)]/machine/cdl")
462
+ rights.obj_lvl.controlled_digital_lending = true
463
+ else
464
+ rights.obj_lvl.controlled_digital_lending = false
465
+ end
305
466
 
306
- if doc.at_xpath("//rightsMetadata/access[@type='read' and not(file)]/machine/group[#{CONTAINS_STANFORD_XPATH}]")
467
+ rights.obj_lvl.group = { :stanford => Rights.new }
468
+ xpath = "//rightsMetadata/access[@type='read' and not(file)]/machine/group[#{CONTAINS_STANFORD_XPATH}]"
469
+ if doc.at_xpath(xpath)
307
470
  rights.obj_lvl.group[:stanford].value = true
308
- rule = doc.at_xpath("//rightsMetadata/access[@type='read' and not(file)]/machine/group[#{CONTAINS_STANFORD_XPATH}]/@rule")
471
+ rule = doc.at_xpath("#{xpath}/@rule")
309
472
  rights.obj_lvl.group[:stanford].rule = rule.value if rule
473
+ if forindex
474
+ rights.index_elements[:obj_groups_qualified] << { :group => 'stanford', :rule => (rule ? rule.value : nil) }
475
+ rights.index_elements[:obj_groups] << 'stanford'
476
+ end
310
477
  else
311
478
  rights.obj_lvl.group[:stanford].value = false
312
479
  end
313
480
 
481
+ rights.obj_lvl.location = {}
482
+ doc.xpath("//rightsMetadata/access[@type='read' and not(file)]/machine/location").each do |node|
483
+ r = Rights.new
484
+ r.value = true
485
+ r.rule = node['rule']
486
+ rights.obj_lvl.location[node.content] = r
487
+ if forindex
488
+ rights.index_elements[:obj_locations_qualified] << { :location => node.content, :rule => node['rule'] }
489
+ rights.index_elements[:obj_locations] << node.content
490
+ end
491
+ end
492
+
314
493
  rights.obj_lvl.agent = {}
315
494
  doc.xpath("//rightsMetadata/access[@type='read' and not(file)]/machine/agent").each do |node|
316
495
  r = Rights.new
317
496
  r.value = true
318
497
  r.rule = node['rule']
319
498
  rights.obj_lvl.agent[node.content] = r
499
+ if forindex
500
+ rights.index_elements[:obj_agents_qualified] << { :agent => node.content, :rule => node['rule'] }
501
+ rights.index_elements[:obj_agents] << node.content
502
+ end
320
503
  end
321
504
 
322
505
  # Initialze embargo_status to false
@@ -335,6 +518,11 @@ module Dor
335
518
  stanford_access.value = true
336
519
  rule = access_node.at_xpath("machine/group[#{CONTAINS_STANFORD_XPATH}]/@rule")
337
520
  stanford_access.rule = rule.value if rule
521
+ if forindex
522
+ rights.index_elements[:file_groups_qualified] <<
523
+ { :group => 'stanford', :rule => (rule ? rule.value : nil) }
524
+ rights.index_elements[:file_groups] << 'stanford'
525
+ end
338
526
  else
339
527
  stanford_access.value = false
340
528
  end
@@ -343,16 +531,33 @@ module Dor
343
531
  world_access.value = true
344
532
  rule = access_node.at_xpath('machine/world/@rule')
345
533
  world_access.rule = rule.value if rule
534
+ rights.index_elements[:file_world_qualified] << { :rule => (rule ? rule.value : nil) } if forindex
346
535
  else
347
536
  world_access.value = false
348
537
  end
349
538
 
539
+ file_locations = {}
540
+ access_node.xpath('machine/location').each do |node|
541
+ r = Rights.new
542
+ r.value = true
543
+ r.rule = node['rule']
544
+ file_locations[node.content] = r
545
+ if forindex
546
+ rights.index_elements[:file_locations_qualified] << { :location => node.content, :rule => node['rule'] }
547
+ rights.index_elements[:file_locations] << node.content
548
+ end
549
+ end
550
+
350
551
  file_agents = {}
351
552
  access_node.xpath('machine/agent').each do |node|
352
553
  r = Rights.new
353
554
  r.value = true
354
555
  r.rule = node['rule']
355
556
  file_agents[node.content] = r
557
+ if forindex
558
+ rights.index_elements[:file_agents_qualified] << { :agent => node.content, :rule => node['rule'] }
559
+ rights.index_elements[:file_agents] << node.content
560
+ end
356
561
  end
357
562
 
358
563
  access_node.xpath('file').each do |f|
@@ -360,11 +565,29 @@ module Dor
360
565
  file_rights.world = world_access
361
566
  file_rights.group = { :stanford => stanford_access }
362
567
  file_rights.agent = file_agents
568
+ file_rights.location = file_locations
363
569
 
364
570
  rights.file[f.content] = file_rights
365
571
  end
366
572
  end
367
573
 
574
+ if forindex
575
+ %i[obj_groups
576
+ obj_locations
577
+ obj_agents
578
+ file_groups
579
+ file_locations
580
+ file_agents
581
+ obj_world_qualified
582
+ obj_groups_qualified
583
+ obj_locations_qualified
584
+ obj_agents_qualified
585
+ file_world_qualified
586
+ file_groups_qualified
587
+ file_locations_qualified
588
+ file_agents_qualified].each { |index_elt| rights.index_elements[index_elt].uniq! }
589
+ end
590
+
368
591
  rights
369
592
  end
370
593
 
metadata CHANGED
@@ -1,15 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-rights-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willy Mene
8
8
  - Joe Atzberger
9
+ - Johnathan Martin
10
+ - Naomi Dushay
9
11
  autorequire:
10
12
  bindir: bin
11
13
  cert_chain: []
12
- date: 2015-12-11 00:00:00.000000000 Z
14
+ date: 2020-08-26 00:00:00.000000000 Z
13
15
  dependencies:
14
16
  - !ruby/object:Gem::Dependency
15
17
  name: nokogiri
@@ -25,6 +27,34 @@ dependencies:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
27
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: codeclimate-test-reporter
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: coveralls
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
28
58
  - !ruby/object:Gem::Dependency
29
59
  name: rake
30
60
  requirement: !ruby/object:Gem::Requirement
@@ -53,6 +83,34 @@ dependencies:
53
83
  - - "~>"
54
84
  - !ruby/object:Gem::Version
55
85
  version: '3.0'
86
+ - !ruby/object:Gem::Dependency
87
+ name: rubocop
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ - !ruby/object:Gem::Dependency
101
+ name: rubocop-rspec
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
56
114
  - !ruby/object:Gem::Dependency
57
115
  name: yard
58
116
  requirement: !ruby/object:Gem::Requirement
@@ -69,8 +127,7 @@ dependencies:
69
127
  version: '0'
70
128
  description: Parses rightsMetadata xml into a useable object
71
129
  email:
72
- - wmene@stanford.edu
73
- - atz@stanford.edu
130
+ - dlss-infrastructure-team@lists.stanford.edu
74
131
  executables: []
75
132
  extensions: []
76
133
  extra_rdoc_files: []
@@ -93,19 +150,17 @@ require_paths:
93
150
  - lib
94
151
  required_ruby_version: !ruby/object:Gem::Requirement
95
152
  requirements:
96
- - - ">="
153
+ - - "~>"
97
154
  - !ruby/object:Gem::Version
98
- version: '0'
155
+ version: '2.5'
99
156
  required_rubygems_version: !ruby/object:Gem::Requirement
100
157
  requirements:
101
158
  - - ">="
102
159
  - !ruby/object:Gem::Version
103
160
  version: 1.3.6
104
161
  requirements: []
105
- rubyforge_project:
106
- rubygems_version: 2.4.6
162
+ rubygems_version: 3.1.2
107
163
  signing_key:
108
164
  specification_version: 4
109
165
  summary: Parses rightsMetadata xml into a useable object
110
166
  test_files: []
111
- has_rdoc: