public interface CustomObjectService
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>> |
cacheKeysToIds(java.util.Set<CustomObjectCompositeIdentifier> identifiers)
Filters out the custom object identifiers which are already cached and fetches only the not-cached custom object
identifiers from the CTP project defined in an injected
SphereClient and stores a mapping for every
custom object to id in the cached map of keys -> ids and returns this cached map. |
java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>> |
fetchCachedCustomObjectId(CustomObjectCompositeIdentifier identifier)
Given an
identifier, this method first checks if identifier#toString()
is contained in a cached map of CustomObjectCompositeIdentifier.toString() -> ids . |
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.customobjects.CustomObject<com.fasterxml.jackson.databind.JsonNode>>> |
fetchCustomObject(CustomObjectCompositeIdentifier identifier)
Given a CustomObjectCompositeIdentifier identify which includes key and container of CustomObject, this method
fetches a CustomObject that matches this given identifier in the CTP project defined in an
injected
SphereClient. |
java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.customobjects.CustomObject<com.fasterxml.jackson.databind.JsonNode>>> |
fetchMatchingCustomObjects(java.util.Set<CustomObjectCompositeIdentifier> identifiers)
Given a
Set of CustomObjectCompositeIdentifier, this method fetches a set of all the CustomObjects,
matching this given set of CustomObjectCompositeIdentifiers in the CTP project defined in an injected
SphereClient. |
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.customobjects.CustomObject<com.fasterxml.jackson.databind.JsonNode>>> |
upsertCustomObject(io.sphere.sdk.customobjects.CustomObjectDraft<com.fasterxml.jackson.databind.JsonNode> customObjectDraft)
Given a resource draft of CustomObject
CustomObjectDraft, this method attempts to create or update
a resource CustomObject based on it in the CTP project defined by the sync options. |
@Nonnull
java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>> cacheKeysToIds(@Nonnull
java.util.Set<CustomObjectCompositeIdentifier> identifiers)
SphereClient and stores a mapping for every
custom object to id in the cached map of keys -> ids and returns this cached map.identifiers - - a set custom object identifiers to fetch and cache the ids forCompletionStage<Map> in which the result of it's completion contains a map of
requested custom object identifiers -> ids@Nonnull
java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>> fetchCachedCustomObjectId(@Nonnull
CustomObjectCompositeIdentifier identifier)
identifier, this method first checks if identifier#toString()
is contained in a cached map of CustomObjectCompositeIdentifier.toString() -> ids .
If it contains, it returns a CompletionStage<Optional<String>>
in which String is what this identifier maps to in the cache. If the cache doesn't contain the identifier,
this method attempts to fetch the id of the identifier from the CTP project, caches it and returns
a CompletionStage<Optional<String>>
in which the Optional could contain the id inside of it.identifier - the identifier object containing CustomObject key and container, by which a
CustomObject id should be fetched from the CTP project.CompletionStage<Optional<String>> in which the result of its
completion could contain an Optional with the id inside of it or an empty Optional if no
CustomObject was found in the CTP project with this identifier.@Nonnull
java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.customobjects.CustomObject<com.fasterxml.jackson.databind.JsonNode>>> fetchMatchingCustomObjects(@Nonnull
java.util.Set<CustomObjectCompositeIdentifier> identifiers)
Set of CustomObjectCompositeIdentifier, this method fetches a set of all the CustomObjects,
matching this given set of CustomObjectCompositeIdentifiers in the CTP project defined in an injected
SphereClient. A mapping of the CustomObjectCompositeIdentifier to the id of the
fetched CustomObject is persisted in an in-memory map.identifiers - set of CustomObjectCompositeIdentifiers. Each identifier includes key and container to fetch
matching CustomObject.CompletionStage<Map> in which the result of its completion contains a Set
of all matching CustomObjects.@Nonnull
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.customobjects.CustomObject<com.fasterxml.jackson.databind.JsonNode>>> fetchCustomObject(@Nonnull
CustomObjectCompositeIdentifier identifier)
SphereClient. If there is no matching CustomObject an empty Optional will be
returned in the returned future.identifier - the identifier of the CustomObject to fetch.CompletionStage<Optional> in which the result of its completion contains an
Optional that contains the matching CustomObject if exists, otherwise empty.@Nonnull
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.customobjects.CustomObject<com.fasterxml.jackson.databind.JsonNode>>> upsertCustomObject(@Nonnull
io.sphere.sdk.customobjects.CustomObjectDraft<com.fasterxml.jackson.databind.JsonNode> customObjectDraft)
CustomObjectDraft, this method attempts to create or update
a resource CustomObject based on it in the CTP project defined by the sync options.
A completion stage containing an empty optional and the error callback will be triggered in those cases:
On the other hand, if the resource gets created or updated successfully on CTP, then the created resource's
id and key/container wrapped by CustomObjectCompositeIdentifier are cached and the method returns a
CompletionStage in which the result of its completion contains an instance Optional of the
resource which was created or updated.
If an object with the given container/key exists on CTP, the object will be replaced with the new value and the version is incremente.
customObjectDraft - the resource draft to create or update a resource based off of.CompletionStage containing an optional with the created/updated resource if successful
otherwise an empty optional.