Class TemplatedURLBuilder

All Implemented Interfaces:
ExecutableSearchBuilder<HTTPSearch>, Component, DestructableComponent, InitializableComponent

public class TemplatedURLBuilder extends AbstractHTTPSearchBuilder
An ExecutableSearchBuilder that generates the URL to request by evaluating a Template against the currently resolved attributes within an AttributeResolutionContext.
  • Field Details

    • log

      @Nonnull private final org.slf4j.Logger log
      Class logger.
    • template

      @NonnullAfterInit private Template template
      Template to be evaluated.
    • templateText

      @NonnullAfterInit private String templateText
      Text of template to be evaluated.
    • engine

      @NonnullAfterInit private org.apache.velocity.app.VelocityEngine engine
      VelocityEngine.
    • paramEscaper

      @Nonnull private final Escaper paramEscaper
      Escaper for form parameters.
    • fragmentEscaper

      @Nonnull private final Escaper fragmentEscaper
      Escaper for fragments.
    • pathEscaper

      @Nonnull private final Escaper pathEscaper
      Escaper for path segments.
    • customObject

      @Nullable private Object customObject
      A custom object to inject into the template.
  • Constructor Details

    • TemplatedURLBuilder

      public TemplatedURLBuilder()
      Constructor.
  • Method Details

    • getTemplate

      @NonnullAfterInit public Template getTemplate()
      Get the template to be evaluated.
      Returns:
      template
    • getTemplateText

      @NonnullAfterInit public String getTemplateText()
      Get the template text to be evaluated.
      Returns:
      template text
    • setTemplateText

      public void setTemplateText(@Nullable String text)
      Set the template to be evaluated.
      Parameters:
      text - template to be evaluated
    • getVelocityEngine

      @NonnullAfterInit public org.apache.velocity.app.VelocityEngine getVelocityEngine()
      Get the VelocityEngine to be used.
      Returns:
      template engine
    • setVelocityEngine

      public void setVelocityEngine(@Nonnull org.apache.velocity.app.VelocityEngine velocityEngine)
      Set the VelocityEngine to be used.
      Parameters:
      velocityEngine - engine to be used
    • setCustomObject

      public void setCustomObject(@Nullable Object object)
      Set the custom (externally provided) object.
      Parameters:
      object - the custom object
    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class AbstractInitializableComponent
      Throws:
      ComponentInitializationException
    • merge

      @Nonnull @NotEmpty protected String merge(@Nonnull org.apache.velocity.VelocityContext context)
      Parameters:
      context - to merge
      Returns:
      result of the merge operation
    • getURL

      @Nonnull protected String getURL(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String,List<IdPAttributeValue>> dependencyAttributes) throws ResolutionException
      Method to return the URL to access via GET.

      Subclasses may override this method to support simple GET requests.

      Overrides:
      getURL in class AbstractHTTPSearchBuilder
      Parameters:
      resolutionContext - the context of the resolution
      dependencyAttributes - made available to the request
      Returns:
      the URL to GET
      Throws:
      ResolutionException - if an error occurs