Package com.commercetools.sync.services
Interface ChannelService
-
- All Known Implementing Classes:
ChannelServiceImpl
public interface ChannelService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>>
cacheKeysToIds(java.util.Set<java.lang.String> channelKeys)
Filters out the keys which are already cached and fetches only the not-cached channel keys from the CTP project defined in an injectedSphereClient
and stores a mapping for every channel to id in the cached map of keys -> ids and returns this cached map.java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.channels.Channel>>
createAndCacheChannel(java.lang.String key)
Creates a new channel with the suppliedkey
and puts a new mapping of it's key to id in a cache map.java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.channels.Channel>>
createChannel(java.lang.String key)
Creates a new channel with the suppliedkey
.java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>>
fetchCachedChannelId(java.lang.String key)
Given akey
, this method first checks if a cached map of channel keys -> ids is not empty.
-
-
-
Method Detail
-
cacheKeysToIds
@Nonnull java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>> cacheKeysToIds(@Nonnull java.util.Set<java.lang.String> channelKeys)
Filters out the keys which are already cached and fetches only the not-cached channel keys from the CTP project defined in an injectedSphereClient
and stores a mapping for every channel to id in the cached map of keys -> ids and returns this cached map.- Parameters:
channelKeys
- - a set of channel keys to fetch and cache the ids for- Returns:
CompletionStage
<Map
> in which the result of it's completion contains a map of requested tax channel -> ids
-
fetchCachedChannelId
@Nonnull java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>> fetchCachedChannelId(@Nonnull java.lang.String key)
Given akey
, this method first checks if a cached map of channel keys -> ids is not empty. If not, it returns a completed future that contains an optional that contains what this key maps to in the cache. If the cache is empty, the method populates the cache with the mapping of all channels' keys to ids in the CTP project, by querying the CTP project channels.After that, the method returns a
CompletionStage
<Optional
<String
>> in which the result of it's completion could contain anOptional
with the id inside of it or an emptyOptional
if noChannel
was found in the CTP project with this key.- Parameters:
key
- the key by which aChannel
id should be fetched from the CTP project.- Returns:
CompletionStage
<Optional
<String
>> in which the result of it's completion could contain anOptional
with the id inside of it or an emptyOptional
if noChannel
was found in the CTP project with this external id.
-
createChannel
@Nonnull java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.channels.Channel>> createChannel(@Nonnull java.lang.String key)
Creates a new channel with the suppliedkey
.- Parameters:
key
- key of supply channel.- Returns:
- a future containing as a result the created
Channel
or a sphere exception.
-
createAndCacheChannel
@Nonnull java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.channels.Channel>> createAndCacheChannel(@Nonnull java.lang.String key)
Creates a new channel with the suppliedkey
and puts a new mapping of it's key to id in a cache map.- Parameters:
key
- key of supply channel.- Returns:
- a future containing as a result the created
Channel
or a sphere exception.
-
-