Class HalClient
- java.lang.Object
-
- io.wcm.caravan.pipeline.extensions.hal.client.HalClient
-
@ProviderType public final class HalClient extends Object
Factory for HAL specificJsonPipelineAction
s.
-
-
Constructor Summary
Constructors Constructor Description HalClient(io.wcm.caravan.io.http.request.CaravanHttpRequest entryPointRequest, io.wcm.caravan.pipeline.cache.CacheStrategy cacheStrategy, Map<String,String> contextProperties)
HalClient(io.wcm.caravan.io.http.request.CaravanHttpRequest entryPointRequest, ServiceIdExtractor serviceIdExtractor, io.wcm.caravan.pipeline.cache.CacheStrategy cacheStrategy, Map<String,String> contextProperties)
HalClient(String serviceId, io.wcm.caravan.pipeline.cache.CacheStrategy cacheStrategy)
HalClient(String serviceId, io.wcm.caravan.pipeline.cache.CacheStrategy cacheStrategy, Map<String,String> contextProperties)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description HalClient
addExceptionHandler(io.wcm.caravan.pipeline.JsonPipelineExceptionHandler newExceptionHandler)
Adds an exception handler for the pipeline actions.BuildResource
buildResource(String selfHref, rx.functions.Func2<io.wcm.caravan.hal.resource.HalResource,io.wcm.caravan.hal.resource.util.HalBuilder,io.wcm.caravan.hal.resource.HalResource> buildFunc)
Deprecated.use createResource insteadio.wcm.caravan.pipeline.JsonPipeline
create(io.wcm.caravan.pipeline.JsonPipelineFactory factory, io.wcm.caravan.io.http.request.CaravanHttpRequest request)
Deprecated.specify the entry point in the constructor and usegetEntryPoint(JsonPipelineFactory)
insteadio.wcm.caravan.pipeline.JsonPipeline
create(io.wcm.caravan.pipeline.JsonPipelineFactory factory, String url)
Deprecated.specify the entry point in the constructor and usegetEntryPoint(JsonPipelineFactory)
insteadio.wcm.caravan.pipeline.JsonPipeline
createEntryPoint(io.wcm.caravan.pipeline.JsonPipelineFactory factory)
Deprecated.usegetEntryPoint(JsonPipelineFactory)
insteadCreateResource
createResource(String selfHref, Function<io.wcm.caravan.hal.resource.HalResource,io.wcm.caravan.hal.resource.HalResource> buildFunc)
Allows to create aCreateResource
action by specifying the output href and a lambda.DeepEmbedLinks
deepEmbed(String relation)
Fetches the content of all links with the given relation in a HAL resource and all embedded resources, and replaces the links with the corresponding embedded resources.DeepEmbedLinks
deepEmbed(String relation, Map<String,Object> parameters)
Fetches the content of all links with the given relation in a HAL resource and all embedded resources, and replaces the links with the corresponding embedded resources.EmbedLinks
embed(String relation)
Creates an embed links action for all relation specific links.EmbedLink
embed(String relation, int index)
Creates an embed link action for theindex
specified link.EmbedLinks
embed(String relation, Map<String,Object> parameters)
Creates an embed links action for all relation specific links with the given URL parameters.EmbedLink
embed(String relation, Map<String,Object> parameters, int index)
Creates an embed link action for theindex
specified link with the given URL parameters.FollowLink
follow(String relation)
Creates a follow link action for the first relation specific linkFollowLink
follow(String relation, int index)
Creates a follow link action for theindex
specified link.FollowLink
follow(String relation, Map<String,Object> parameters)
Creates a follow link action for the first relation specific link with the given URL parameters.FollowLink
follow(String relation, Map<String,Object> parameters, int index)
Creates a follow link action for theindex
specified link with the given URL parameters.FollowLink
follow(String relation, Map<String,Object> parameters, String name)
Creates a follow link action for the forst link with the given relation and nameio.wcm.caravan.pipeline.JsonPipeline
getEntryPoint(io.wcm.caravan.pipeline.JsonPipelineFactory factory)
Creates aJsonPipeline
that will fetch the entry point of the HAL serviceLoadLink
load(io.wcm.caravan.hal.resource.Link link)
Creates aLoadLink
action for the given link.LoadLink
load(io.wcm.caravan.hal.resource.Link link, Map<String,Object> parameters)
Creates aLoadLink
action for the given link and URI parameters.ModifyResource
modifyResource(String selfHref, rx.functions.Action1<io.wcm.caravan.hal.resource.HalResource> modifyFunc)
Allows to create aModifyResource
action by specifying the output href and a lambdaHalClient
setLogger(org.slf4j.Logger value)
Sets the logger for the pipeline actions.HalClient
setServiceIdExtractor(ServiceIdExtractor extractor)
Replaces the default service id extractor (that uses the same serviceId for all requests) with a custom logic
-
-
-
Constructor Detail
-
HalClient
public HalClient(String serviceId, io.wcm.caravan.pipeline.cache.CacheStrategy cacheStrategy)
- Parameters:
serviceId
- Service IDcacheStrategy
- default cache strategy to use for all actions that fetch additional resources
-
HalClient
public HalClient(String serviceId, io.wcm.caravan.pipeline.cache.CacheStrategy cacheStrategy, Map<String,String> contextProperties)
- Parameters:
serviceId
- Service IDcacheStrategy
- default cache strategy to use for all actions that fetch additional resourcescontextProperties
- a Map of properties to pass on toJsonPipelineFactory.create(CaravanHttpRequest, Map)
-
HalClient
public HalClient(io.wcm.caravan.io.http.request.CaravanHttpRequest entryPointRequest, io.wcm.caravan.pipeline.cache.CacheStrategy cacheStrategy, Map<String,String> contextProperties)
- Parameters:
entryPointRequest
- the request to be executed to fetch the HAL entry pointcacheStrategy
- default cache strategy to use for all actions that fetch additional resourcescontextProperties
- a Map of properties to pass on toJsonPipelineFactory.create(CaravanHttpRequest, Map)
-
HalClient
public HalClient(io.wcm.caravan.io.http.request.CaravanHttpRequest entryPointRequest, ServiceIdExtractor serviceIdExtractor, io.wcm.caravan.pipeline.cache.CacheStrategy cacheStrategy, Map<String,String> contextProperties)
- Parameters:
entryPointRequest
- the request to be executed to fetch the HAL entry pointserviceIdExtractor
- Service ID extractorcacheStrategy
- default cache strategy to use for all actions that fetch additional resourcescontextProperties
- a Map of properties to pass on toJsonPipelineFactory.create(CaravanHttpRequest, Map)
-
-
Method Detail
-
addExceptionHandler
public HalClient addExceptionHandler(io.wcm.caravan.pipeline.JsonPipelineExceptionHandler newExceptionHandler)
Adds an exception handler for the pipeline actions.- Parameters:
newExceptionHandler
- The exceptionHandler to set.- Returns:
- This HAL client
-
setLogger
public HalClient setLogger(org.slf4j.Logger value)
Sets the logger for the pipeline actions.- Parameters:
value
- Logger to set.- Returns:
- This HAL client
-
setServiceIdExtractor
public HalClient setServiceIdExtractor(ServiceIdExtractor extractor)
Replaces the default service id extractor (that uses the same serviceId for all requests) with a custom logic- Parameters:
extractor
- the ServiceIdExtractor to use- Returns:
- this hal client
-
getEntryPoint
public io.wcm.caravan.pipeline.JsonPipeline getEntryPoint(io.wcm.caravan.pipeline.JsonPipelineFactory factory)
Creates aJsonPipeline
that will fetch the entry point of the HAL service- Parameters:
factory
- the factory to use to create the pipeline- Returns:
- the pipeline
-
createEntryPoint
@Deprecated public io.wcm.caravan.pipeline.JsonPipeline createEntryPoint(io.wcm.caravan.pipeline.JsonPipelineFactory factory)
Deprecated.usegetEntryPoint(JsonPipelineFactory)
insteadCreates a JSON pipeline for a service entry point.- Parameters:
factory
- Pipeline factory- Returns:
- JSON pipeline
-
create
@Deprecated public io.wcm.caravan.pipeline.JsonPipeline create(io.wcm.caravan.pipeline.JsonPipelineFactory factory, String url)
Deprecated.specify the entry point in the constructor and usegetEntryPoint(JsonPipelineFactory)
insteadCreates a JSON pipeline for a service and URL.- Parameters:
factory
- Pipeline factoryurl
- URL to start- Returns:
- JSON pipeline
-
create
@Deprecated public io.wcm.caravan.pipeline.JsonPipeline create(io.wcm.caravan.pipeline.JsonPipelineFactory factory, io.wcm.caravan.io.http.request.CaravanHttpRequest request)
Deprecated.specify the entry point in the constructor and usegetEntryPoint(JsonPipelineFactory)
insteadCreates a JSON pipeline for a HTTP request.- Parameters:
factory
- Pipeline factoryrequest
- Pre-configured HTTP request- Returns:
- JSON pipeline
-
follow
public FollowLink follow(String relation)
Creates a follow link action for the first relation specific link- Parameters:
relation
- Link relation- Returns:
- Follow link action
-
follow
public FollowLink follow(String relation, Map<String,Object> parameters)
Creates a follow link action for the first relation specific link with the given URL parameters.- Parameters:
relation
- Link relationparameters
- URL parameters- Returns:
- Follow link action
-
follow
public FollowLink follow(String relation, int index)
Creates a follow link action for theindex
specified link.- Parameters:
relation
- Link relationindex
- Link index- Returns:
- Follow link action
-
follow
public FollowLink follow(String relation, Map<String,Object> parameters, int index)
Creates a follow link action for theindex
specified link with the given URL parameters.- Parameters:
relation
- Link relationparameters
- URL parametersindex
- Link index- Returns:
- Follow link action
-
follow
public FollowLink follow(String relation, Map<String,Object> parameters, String name)
Creates a follow link action for the forst link with the given relation and name- Parameters:
relation
- Link relationparameters
- URL parametersname
- of the link to follow- Returns:
- Follow link action
-
embed
public EmbedLinks embed(String relation)
Creates an embed links action for all relation specific links.- Parameters:
relation
- Link relation- Returns:
- Embed links action
-
embed
public EmbedLinks embed(String relation, Map<String,Object> parameters)
Creates an embed links action for all relation specific links with the given URL parameters.- Parameters:
relation
- Link relationparameters
- URL parameters- Returns:
- Embed links action
-
embed
public EmbedLink embed(String relation, int index)
Creates an embed link action for theindex
specified link.- Parameters:
relation
- Link relationindex
- Link index- Returns:
- Embed links action
-
embed
public EmbedLink embed(String relation, Map<String,Object> parameters, int index)
Creates an embed link action for theindex
specified link with the given URL parameters.- Parameters:
relation
- Link relationparameters
- URL parametersindex
- Link index- Returns:
- Embed links action
-
deepEmbed
public DeepEmbedLinks deepEmbed(String relation)
Fetches the content of all links with the given relation in a HAL resource and all embedded resources, and replaces the links with the corresponding embedded resources.- Parameters:
relation
- Link relation- Returns:
- Deep Embed links action
-
deepEmbed
public DeepEmbedLinks deepEmbed(String relation, Map<String,Object> parameters)
Fetches the content of all links with the given relation in a HAL resource and all embedded resources, and replaces the links with the corresponding embedded resources.- Parameters:
relation
- Link relationparameters
- URL parameters- Returns:
- Deep Embed links action
-
buildResource
@Deprecated public BuildResource buildResource(String selfHref, rx.functions.Func2<io.wcm.caravan.hal.resource.HalResource,io.wcm.caravan.hal.resource.util.HalBuilder,io.wcm.caravan.hal.resource.HalResource> buildFunc)
Deprecated.use createResource insteadAllows to create aBuildResource
action by specifying the output href and a lambda- Parameters:
selfHref
- the path of the output resource to be used for the self helfbuildFunc
- the lambda that gets the previous step's output and aHalBuilder
with the specified self-link- Returns:
- the action that executes the lambda build function
-
createResource
public CreateResource createResource(String selfHref, Function<io.wcm.caravan.hal.resource.HalResource,io.wcm.caravan.hal.resource.HalResource> buildFunc)
Allows to create aCreateResource
action by specifying the output href and a lambda. TheCreateResource
action will automatically generated a cache-key based on the given href, and also set the self-link of the resource returned by the lambda- Parameters:
selfHref
- the path of the output resource to be used for the self helfbuildFunc
- the lambda that gets the previous step's output and should return a new HalResource- Returns:
- the action that executes the lambda build function
-
modifyResource
public ModifyResource modifyResource(String selfHref, rx.functions.Action1<io.wcm.caravan.hal.resource.HalResource> modifyFunc)
Allows to create aModifyResource
action by specifying the output href and a lambda- Parameters:
selfHref
- the path of the output resource to be used for the self helfmodifyFunc
- the lambda that gets a HalResource with the previous step's output and the specified self-link- Returns:
- the action that executes the lambda build function
-
load
public LoadLink load(io.wcm.caravan.hal.resource.Link link)
Creates aLoadLink
action for the given link.- Parameters:
link
- Link to load- Returns:
- Load link action
-
-