Sha256: 9bdce329479bdf2df2c46d78fa89519bd9cd86bfd19820102b743802d4a64b52

Contents?: true

Size: 984 Bytes

Versions: 14

Compression:

Stored size: 984 Bytes

Contents

# frozen_string_literal: true

module Hyrax
  module Listeners
    ##
    # Reindexes resources when their ACLs are updated
    #
    # Hyrax's `Ability` behavior depends on the index being up-to-date as
    # concerns-their read/write users/groups, and visibility.
    class ActiveFedoraAclIndexListener
      ##
      # Re-index the resource for the updated ACL.
      #
      # Called when 'object.acl.updated' event is published
      # @param [Dry::Events::Event] event
      # @return [void]
      def on_object_acl_updated(event)
        return if Hyrax.config.disable_wings
        return unless event[:result] == :success # do nothing on failure

        if Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter)
          Wings::ActiveFedoraConverter.convert(resource: event[:acl].resource).update_index
        else
          Hyrax.logger.info('Skipping ActiveFedora object reindex because the Wings adapter is not in use.')
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
hyrax-5.0.0.rc2 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-5.0.0.rc1 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-3.6.0 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-4.0.0 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-4.0.0.rc3 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-4.0.0.rc2 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-4.0.0.rc1 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-3.5.0 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-4.0.0.beta2 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-3.4.2 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-4.0.0.beta1 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-3.4.1 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-3.4.0 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-3.3.0 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb