Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
Merge f2e95c1 into 0c498db
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Apr 18, 2019
2 parents 0c498db + f2e95c1 commit 0cd9eff
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
15 changes: 14 additions & 1 deletion lib/dor/datastreams/rights_metadata_ds.rb
Expand Up @@ -216,5 +216,18 @@ def use_license
def prefix
''
end
end # class

def rights
xml = ng_xml
if xml.search('//rightsMetadata/access[@type=\'read\']/machine/group').length == 1
'Stanford'
elsif xml.search('//rightsMetadata/access[@type=\'read\']/machine/world').length == 1
'World'
elsif xml.search('//rightsMetadata/access[@type=\'discover\']/machine/none').length == 1
'Dark'
else
'None'
end
end
end
end
2 changes: 2 additions & 0 deletions lib/dor/models/abstract.rb
Expand Up @@ -45,5 +45,7 @@ def allows_modification?
client.active_lifecycle('dor', pid, 'opened') ||
client.workflow_status('dor', pid, 'accessionWF', 'sdr-ingest-transfer') == 'hold'
end

delegate :rights, to: :rightsMetadata
end
end
18 changes: 0 additions & 18 deletions lib/dor/models/concerns/governable.rb
Expand Up @@ -61,23 +61,5 @@ def remove_collection(collection_or_druid)
def reapplyAdminPolicyObjectDefaults
rightsMetadata.content = admin_policy_object.datastreams['defaultObjectRights'].content
end

def rights
return nil unless respond_to? :rightsMetadata
return nil if rightsMetadata.nil?

xml = rightsMetadata.ng_xml
return nil if xml.search('//rightsMetadata').length != 1 # ORLY?

if xml.search('//rightsMetadata/access[@type=\'read\']/machine/group').length == 1
'Stanford'
elsif xml.search('//rightsMetadata/access[@type=\'read\']/machine/world').length == 1
'World'
elsif xml.search('//rightsMetadata/access[@type=\'discover\']/machine/none').length == 1
'Dark'
else
'None'
end
end
end
end
2 changes: 1 addition & 1 deletion spec/indexers/processable_indexer_spec.rb
Expand Up @@ -39,7 +39,7 @@
end

it 'does not error if there is nothing in the datastream' do
allow(obj).to receive(:rightsMetadata).and_return(ActiveFedora::OmDatastream.new)
allow(obj).to receive(:rightsMetadata).and_return(Dor::RightsMetadataDS.new)
expect { solr_doc }.not_to raise_error
end
end
Expand Down

0 comments on commit 0cd9eff

Please sign in to comment.