public class ProductServiceImpl extends java.lang.Object implements ProductService
| Constructor and Description |
|---|
ProductServiceImpl(ProductSyncOptions syncOptions) |
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>> |
cacheKeysToIds()
If not already done once before, it fetches all the product keys from the CTP project defined in a potentially
injected
SphereClient and stores a mapping for every product to id in Map
and returns this cached map. |
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.products.Product>> |
createProduct(io.sphere.sdk.products.ProductDraft productDraft)
Given a
ProductDraft, this method creates a Product based on it in the CTP project defined in
a potentially injected SphereClient. |
java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.products.Product>> |
createProducts(java.util.Set<io.sphere.sdk.products.ProductDraft> productsDrafts)
Given a
Set of productsDrafts, this method creates Products corresponding to them in the CTP project
defined in a potentially injected SphereClient. |
java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>> |
fetchCachedProductId(java.lang.String key)
Given a
key, this method first checks if cached map of product keys -> ids is not empty. |
java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.products.Product>> |
fetchMatchingProductsByKeys(java.util.Set<java.lang.String> productKeys)
Given a
Set of product keys, this method fetches a set of all the products matching this given set of
keys in the CTP project defined in a potentially injected SphereClient. |
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.products.Product>> |
fetchProduct(java.lang.String key)
Given a product key, this method fetches a product that matches this given key in the CTP project defined in a
potentially injected
SphereClient. |
java.util.concurrent.CompletionStage<io.sphere.sdk.products.Product> |
publishProduct(io.sphere.sdk.products.Product product)
Given a
Product, this method issues an update request to publish this Product in the CTP project
defined in a potentially injected SphereClient. |
java.util.concurrent.CompletionStage<io.sphere.sdk.products.Product> |
revertProduct(io.sphere.sdk.products.Product product)
Given a
Product, this method issues an update request to revert the staged changes of this
Product in the CTP project defined in a potentially injected SphereClient. |
java.util.concurrent.CompletionStage<io.sphere.sdk.products.Product> |
updateProduct(io.sphere.sdk.products.Product product,
java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> updateActions)
Given a
Product and a List<UpdateAction<Product>>, this method
issues an update request with these update actions on this Product in the CTP project defined in a
potentially injected SphereClient. |
public ProductServiceImpl(@Nonnull
ProductSyncOptions syncOptions)
@Nonnull
public java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>> fetchCachedProductId(@Nullable
java.lang.String key)
ProductServicekey, this method first checks if cached map of product 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 products' keys
to ids in the CTP project. After that, the method returns a
CompletionStage<Optional<String>> in which the result of it's completion
could contain an Optional with the id inside of it or an empty Optional if no Product
was found in the CTP project with this key.
Note: If the supplied key is null, this method will return an empty optional as a result of the CompletionStage.
fetchCachedProductId in interface ProductServicekey - the key by which a Product id should be fetched from the CTP project.CompletionStage<Optional<String>> in which the result of it's
completion could contain an Optional with the id inside of it or an empty Optional if no
Product was found in the CTP project with this key.@Nonnull public java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>> cacheKeysToIds()
ProductServiceSphereClient and stores a mapping for every product to id in Map
and returns this cached map.cacheKeysToIds in interface ProductServiceCompletionStage<Map> in which the result of it's completion contains a map of all
product keys -> ids@Nonnull
public java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.products.Product>> fetchMatchingProductsByKeys(@Nonnull
java.util.Set<java.lang.String> productKeys)
ProductServiceSet of product keys, this method fetches a set of all the products matching this given set of
keys in the CTP project defined in a potentially injected SphereClient.fetchMatchingProductsByKeys in interface ProductServiceproductKeys - set of product keys to fetch matching products by.CompletionStage<Map> in which the result of it's completion contains a Set
of all matching products.@Nonnull
public java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.products.Product>> fetchProduct(@Nullable
java.lang.String key)
ProductServiceSphereClient. If there is no matching product an empty Optional will be
returned in the returned future.fetchProduct in interface ProductServicekey - the key of the product to fetch.CompletionStage<Optional> in which the result of it's completion contains an
Optional that contains the matching Product if exists, otherwise empty.@Nonnull
public java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.products.Product>> createProducts(@Nonnull
java.util.Set<io.sphere.sdk.products.ProductDraft> productsDrafts)
ProductServiceSet of productsDrafts, this method creates Products corresponding to them in the CTP project
defined in a potentially injected SphereClient.createProducts in interface ProductServiceproductsDrafts - set of productsDrafts to create on the CTP project.CompletionStage<Map> in which the result of it's completion contains a Set
of all created products.@Nonnull
public java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.products.Product>> createProduct(@Nonnull
io.sphere.sdk.products.ProductDraft productDraft)
ProductServiceProductDraft, this method creates a Product based on it in the CTP project defined in
a potentially injected SphereClient. The created product's id and key are also
cached. This method returns CompletionStage<Product> in which the result of it's
completion contains an instance of the Product which was created in the CTP project.createProduct in interface ProductServiceproductDraft - the ProductDraft to create a Product based off of.CompletionStage<Product> containing as a result of it's completion an instance of
the Product which was created in the CTP project or a
SphereException.@Nonnull
public java.util.concurrent.CompletionStage<io.sphere.sdk.products.Product> updateProduct(@Nonnull
io.sphere.sdk.products.Product product,
@Nonnull
java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> updateActions)
ProductServiceProduct and a List<UpdateAction<Product>>, this method
issues an update request with these update actions on this Product in the CTP project defined in a
potentially injected SphereClient. This method returns
CompletionStage<Product> in which the result of it's completion contains an instance of
the Product which was updated in the CTP project.updateProduct in interface ProductServiceproduct - the Product to update.updateActions - the update actions to update the Product with.CompletionStage<Product> containing as a result of it's completion an instance of
the Product which was updated in the CTP project or a
SphereException.@Nonnull
public java.util.concurrent.CompletionStage<io.sphere.sdk.products.Product> publishProduct(@Nonnull
io.sphere.sdk.products.Product product)
ProductServiceProduct, this method issues an update request to publish this Product in the CTP project
defined in a potentially injected SphereClient. This method returns
CompletionStage<Product> in which the result of it's completion contains an instance of
the Product which was published in the CTP project.publishProduct in interface ProductServiceproduct - the Product to publish.CompletionStage<Product> containing as a result of it's completion an instance of
the Product which was published in the CTP project or a
SphereException.@Nonnull
public java.util.concurrent.CompletionStage<io.sphere.sdk.products.Product> revertProduct(@Nonnull
io.sphere.sdk.products.Product product)
ProductServiceProduct, this method issues an update request to revert the staged changes of this
Product in the CTP project defined in a potentially injected SphereClient.
This method returns CompletionStage<Product> in which the result of it's completion
contains an instance of the Product which had its staged changes reverted in the CTP project.revertProduct in interface ProductServiceproduct - the Product to revert the staged changes for.CompletionStage<Product> containing as a result of it's completion an instance of
the Product which was published in the CTP project or a
SphereException.