Class TemplatedSearchBuilder
java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
net.shibboleth.idp.attribute.resolver.dc.storage.impl.TemplatedSearchBuilder
- All Implemented Interfaces:
ExecutableSearchBuilder<StorageServiceSearch>
,Component
,DestructableComponent
,InitializableComponent
public class TemplatedSearchBuilder
extends AbstractInitializableComponent
implements ExecutableSearchBuilder<StorageServiceSearch>
An
ExecutableSearchBuilder
that generates the StorageService
context and key
using Velocity templates.- Since:
- 4.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Template
Context template to be evaluated.private String
Text of context template to be evaluated.private Object
A custom object to inject into the template.private org.apache.velocity.app.VelocityEngine
VelocityEngine.private Template
Key template to be evaluated.private String
Text of key template to be evaluated.private final org.slf4j.Logger
Class logger. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild
(AttributeResolutionContext resolutionContext, Map<String, List<IdPAttributeValue>> dependencyAttributes) Creates an executable search that can be executed against a data source in order to produce results.protected void
getContextAndKey
(AttributeResolutionContext resolutionContext, Map<String, List<IdPAttributeValue>> dependencyAttributes) Get the context template to be evaluated.Get the context template text to be evaluated.Get the key template to be evaluated.Get the key template text to be evaluated.org.apache.velocity.app.VelocityEngine
Get theVelocityEngine
to be used.void
setContextTemplateText
(String text) Set the context template to be evaluated.void
setCustomObject
(Object object) Set the custom (externally provided) object.void
setKeyTemplateText
(String text) Set the key template to be evaluated.void
setVelocityEngine
(org.apache.velocity.app.VelocityEngine velocityEngine) Set theVelocityEngine
to be used.Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
contextTemplate
Context template to be evaluated. -
keyTemplate
Key template to be evaluated. -
contextTemplateText
Text of context template to be evaluated. -
keyTemplateText
Text of key template to be evaluated. -
engine
VelocityEngine. -
customObject
A custom object to inject into the template.
-
-
Constructor Details
-
TemplatedSearchBuilder
public TemplatedSearchBuilder()
-
-
Method Details
-
getContextTemplate
Get the context template to be evaluated.- Returns:
- template
-
getKeyTemplate
Get the key template to be evaluated.- Returns:
- template
-
getContextTemplateText
Get the context template text to be evaluated.- Returns:
- template text
-
setContextTemplateText
Set the context template to be evaluated.- Parameters:
text
- template to be evaluated
-
getKeyTemplateText
Get the key template text to be evaluated.- Returns:
- template text
-
setKeyTemplateText
Set the key template to be evaluated.- Parameters:
text
- template to be evaluated
-
getVelocityEngine
Get theVelocityEngine
to be used.- Returns:
- template engine
-
setVelocityEngine
public void setVelocityEngine(@Nonnull org.apache.velocity.app.VelocityEngine velocityEngine) Set theVelocityEngine
to be used.- Parameters:
velocityEngine
- engine to be used
-
setCustomObject
Set the custom (externally provided) object.- Parameters:
object
- the custom object
-
doInitialize
- Overrides:
doInitialize
in classAbstractInitializableComponent
- Throws:
ComponentInitializationException
-
build
public StorageServiceSearch build(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String, List<IdPAttributeValue>> dependencyAttributes) throws ResolutionExceptionCreates an executable search that can be executed against a data source in order to produce results.- Specified by:
build
in interfaceExecutableSearchBuilder<StorageServiceSearch>
- Parameters:
resolutionContext
- current request contextdependencyAttributes
- made available to the executable search- Returns:
- executable search
- Throws:
ResolutionException
- throw if their is a problem creating the executable search
-
getContextAndKey
@Nonnull private Pair<String,String> getContextAndKey(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String, List<IdPAttributeValue>> dependencyAttributes) throws ResolutionException- Throws:
ResolutionException
-