Sha256: 88ac3c628648995cc983c0038a9a4ecf9fb30a4d53880c3e5a6f93bec8cf60d5
Contents?: true
Size: 1.69 KB
Versions: 3
Compression:
Stored size: 1.69 KB
Contents
module ActiveFedora class FixityService extend ActiveSupport::Concern attr_accessor :target, :response # @param [String, RDF::URI] target url for a Fedora resource def initialize(target) raise ArgumentError, 'You must provide a uri' unless target @target = target.to_s end # Executes a fixity check on Fedora and saves the Faraday::Response. # @return true or false def check @response = fixity_response_from_fedora status.include?(success) end def status fixity_graph.query(predicate: premis_status_predicate).map(&:object) + fixity_graph.query(predicate: fedora_status_predicate).map(&:object) end private def premis_status_predicate ::RDF::Vocab::PREMIS.hasEventOutcome end # Fcrepo4.status was used by Fedora < 4.3, but it was removed # from the 2015-07-24 version of the fedora 4 ontology # http://fedora.info/definitions/v4/2015/07/24/repository and # from rdf-vocab in version 0.8.5 def fedora_status_predicate ::RDF::URI("http://fedora.info/definitions/v4/repository#status") end def success ::RDF::Literal.new("SUCCESS") end def fixity_response_from_fedora uri = target + "/fcr:fixity" ActiveFedora.fedora.connection.get(encoded_url(uri)) end def fixity_graph ::RDF::Graph.new << ::RDF::Reader.for(:ttl).new(response.body) end # See https://jira.duraspace.org/browse/FCREPO-1247 # @param [String] uri def encoded_url(uri) if uri.match("fcr:versions") uri.gsub(/fcr:versions/, "fcr%3aversions") else uri end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
active-fedora-9.7.0 | lib/active_fedora/fixity_service.rb |
active-fedora-9.6.2 | lib/active_fedora/fixity_service.rb |
active-fedora-9.6.1 | lib/active_fedora/fixity_service.rb |