Class DefaultWebhookFilterService

java.lang.Object
de.hybris.platform.webhookservices.filter.impl.DefaultWebhookFilterService
All Implemented Interfaces:
WebhookFilterService

public class DefaultWebhookFilterService extends Object implements WebhookFilterService
A default implementation of the WebhookFilterService that uses the platform's scripting engine for executing the WebhookFilter logic.
  • Constructor Details

    • DefaultWebhookFilterService

      public DefaultWebhookFilterService(@NotNull @NotNull ScriptingLanguagesService scriptingLanguagesService)
      Constructs the DefaultWebhookFilterService
      Parameters:
      scriptingLanguagesService - Service to run scripts
  • Method Details

    • filter

      public <T extends ItemModel> Optional<T> filter(T item, String scriptUri)
      Evaluates the item and filters out, if item does not match the filtering logic criteria.

      It's important that the script referenced by the scriptUri would implement WebhookFilter interface. Otherwise, the filtering won't work, i.e. all items should be filtered out by the implementations.

      Any exception thrown by the filter script eliminates the item from being sent to the webhook.

      If the script returns an ItemModel type that differs from the input item type, the item will be filtered out. However, if the returned ItemModel type is a subtype of the input item type, the item will be sent.

      Specified by:
      filter in interface WebhookFilterService
      Type Parameters:
      T - The type of the ItemModel
      Parameters:
      item - an item being sent to a webhook.
      scriptUri - a URI for the item filter logic (script) location. See Scripting Engine documentation
      Returns:
      an Optional containing the item to send to the webhook, if the item passes the filter; or an Optional.empty(), if the item is filtered out from the webhook notification.