Sha256: e81d0ab8bd809fd052909e6de35f358a61c65c9b589559293afb87d884f362ba
Contents?: true
Size: 1009 Bytes
Versions: 4
Compression:
Stored size: 1009 Bytes
Contents
# frozen_string_literal: true module Hyrax module Listeners ## # Listens for object deleted events and cleans up associated members class MemberCleanupListener def on_object_deleted(event) return unless event.payload.key?(:object) # legacy callback return if event[:object].is_a?(ActiveFedora::Base) # handled by legacy code Hyrax.custom_queries.find_child_filesets(resource: event[:object]).each do |file_set| begin Hyrax.persister.delete(resource: file_set) Hyrax.publisher .publish('object.deleted', object: file_set, id: file_set.id, user: user) rescue StandardError # we don't uncaught errors looping filesets Hyrax.logger.warn "Failed to delete #{file_set.class}:#{file_set.id} " \ "during cleanup for resource: #{event[:object]}. " \ 'This member may now be orphaned.' end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems