Class TemplatedBodyBuilder

    • Field Detail

      • log

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

        @NonnullAfterInit
        private String cacheKeyTemplateText
        Text of cache key template to be evaluated.
      • engine

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

        @Nullable
        private String charset
        Character set.
      • contentType

        @NonnullAfterInit
        private org.apache.http.entity.ContentType contentType
        Content type.
      • 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.
      • xmlAttributeEscaper

        @Nonnull
        private final Escaper xmlAttributeEscaper
        Escaper for XML Attributes.
      • xmlContentEscaper

        @Nonnull
        private final Escaper xmlContentEscaper
        Escaper for XML content.
      • customObject

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

      • TemplatedBodyBuilder

        public TemplatedBodyBuilder()
        Constructor.
    • Method Detail

      • getURLTemplate

        @NonnullAfterInit
        public Template getURLTemplate()
        Get the URL template to be evaluated.
        Returns:
        template
      • getBodyTemplate

        @NonnullAfterInit
        public Template getBodyTemplate()
        Get the body template to be evaluated.
        Returns:
        template
      • getCacheKeyTemplate

        @Nullable
        public Template getCacheKeyTemplate()
        Get the cache key template to be evaluated.
        Returns:
        template
      • getURLTemplateText

        @NonnullAfterInit
        public String getURLTemplateText()
        Get the URL template text to be evaluated.
        Returns:
        template text
      • setURLTemplateText

        public void setURLTemplateText​(@Nullable
                                       String text)
        Set the URL template to be evaluated.
        Parameters:
        text - template to be evaluated
      • getBodyTemplateText

        @NonnullAfterInit
        public String getBodyTemplateText()
        Get the body template text to be evaluated.
        Returns:
        template text
      • setBodyTemplateText

        public void setBodyTemplateText​(@Nullable
                                        String text)
        Set the body template to be evaluated.
        Parameters:
        text - template to be evaluated
      • getCacheKeyTemplateText

        @Nullable
        public String getCacheKeyTemplateText()
        Get the cache key template text to be evaluated.
        Returns:
        template text
      • setCacheKeyTemplateText

        public void setCacheKeyTemplateText​(@Nullable
                                            String text)
        Set the cache key 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
      • setMethod

        public void setMethod​(@Nonnull @NotEmpty
                              String m)
        Set the HTTP method.

        Defaults to "POST".

        Parameters:
        m - method
      • setMIMEType

        public void setMIMEType​(@Nonnull @NotEmpty
                                String type)
        Set the MIME type.

        Defaults to "text/plain".

        Parameters:
        type - MIME type
      • setCharacterSet

        public void setCharacterSet​(@Nullable
                                    String c)
        Set the character set.
        Parameters:
        c - character set
      • setCustomObject

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

        @Nonnull
        @NotEmpty
        protected String getResultCacheKey​(@Nonnull
                                           org.apache.http.client.methods.HttpUriRequest request,
                                           @Nonnull
                                           AttributeResolutionContext resolutionContext,
                                           @Nonnull
                                           Map<String,​List<IdPAttributeValue>> dependencyAttributes)
        Default implementation just allows caching of GET requests and returns the URI itself.
        Overrides:
        getResultCacheKey in class AbstractHTTPSearchBuilder
        Parameters:
        request - the HTTP request about to be executed
        resolutionContext - the attribute resolution context
        dependencyAttributes - dependencies
        Returns:
        the cache key