Sha256: d4d23fc18b329b7ff332d35a6336c5a851b72c91b8185ece0e85d6e646308773

Contents?: true

Size: 984 Bytes

Versions: 7

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

7 entries across 7 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-5.0.4 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-5.0.3 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-5.0.2 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-5.0.1 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-5.0.0 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb
hyrax-5.0.0.rc3 app/services/hyrax/listeners/active_fedora_acl_index_listener.rb