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

Commit

Permalink
Allow rights metadata indexing to function again
Browse files Browse the repository at this point in the history
It currently is fundamentally broken: https://app.honeybadger.io/projects/49897/faults/67008277
  • Loading branch information
mjgiarlo committed Aug 25, 2020
1 parent 02ffd35 commit d0bb325
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/indexers/rights_metadata_datastream_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class RightsMetadataDatastreamIndexer
attr_reader :resource

def initialize(resource:)
@resource = resource
end
Expand Down
18 changes: 16 additions & 2 deletions app/models/hydrus/rights_metadata_ds.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# frozen_string_literal: true

require 'dor/rights_auth'

class Hydrus::RightsMetadataDS < ActiveFedora::OmDatastream
include Hydrus::GenericDS
include Hydrus::Accessible
Expand Down Expand Up @@ -48,10 +52,20 @@ class Hydrus::RightsMetadataDS < ActiveFedora::OmDatastream
xml.machine(type: gcode) { xml.text(code) }
end

# just a wrapper to invalidate @dra_object
def content=(xml)
@dra_object = nil
super
end

def dra_object
@dra_object ||= Dor::RightsAuth.parse(ng_xml, true)
end

# This provides the prefix for the solr fields generated by ActiveFedora.
# Since we don't want a prefix, we override this to return an empty string.
def prefix
''.freeze
''
end

# Takes a license-group code, a license code, and the corresponding license text.
Expand All @@ -72,7 +86,7 @@ def remove_license
# Dor::Editable module and moved into a datastream which Hydrus does not use.
# Stub out these methods to get the test suite running
[:default_rights, :use_license].each do |missing_method_name|
define_method(missing_method_name) {}
define_method(missing_method_name) { [] }
end

def self.xml_template
Expand Down
4 changes: 2 additions & 2 deletions spec/indexers/rights_metadata_datastream_indexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
XML
end

let(:obj) { Dor::Item.new(pid: 'druid:rt923jk342') }
let(:obj) { Hydrus::Item.new(pid: 'druid:rt923jk342') }
let(:rights_md_ds) { obj.rightsMetadata }

let(:indexer) do
Expand All @@ -47,7 +47,7 @@
expect(doc).to include(
'copyright_ssim' => ['Copyright © World Trade Organization'],
'use_statement_ssim' => ['Official WTO documents are free for public use.'],
'use_license_machine_ssi' => 'by-nc-nd',
'use_license_machine_ssi' => nil,
'rights_descriptions_ssim' => ['world']
)
end
Expand Down

0 comments on commit d0bb325

Please sign in to comment.