Class AssetsUpdateActionUtils
- java.lang.Object
-
- com.commercetools.sync.commons.utils.AssetsUpdateActionUtils
-
public final class AssetsUpdateActionUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ASSET_KEY_NOT_SET
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends io.sphere.sdk.models.Resource,D>
java.util.List<io.sphere.sdk.commands.UpdateAction<T>>buildAssetsUpdateActions(D newResource, java.util.List<io.sphere.sdk.models.Asset> oldAssets, java.util.List<io.sphere.sdk.models.AssetDraft> newAssetDrafts, AssetActionFactory<T,D> assetActionFactory, BaseSyncOptions syncOptions)
Compares a list ofAsset
s with a list ofAssetDraft
s.
-
-
-
Field Detail
-
ASSET_KEY_NOT_SET
public static final java.lang.String ASSET_KEY_NOT_SET
- See Also:
- Constant Field Values
-
-
Method Detail
-
buildAssetsUpdateActions
@Nonnull public static <T extends io.sphere.sdk.models.Resource,D> java.util.List<io.sphere.sdk.commands.UpdateAction<T>> buildAssetsUpdateActions(@Nonnull D newResource, @Nonnull java.util.List<io.sphere.sdk.models.Asset> oldAssets, @Nullable java.util.List<io.sphere.sdk.models.AssetDraft> newAssetDrafts, @Nonnull AssetActionFactory<T,D> assetActionFactory, @Nonnull BaseSyncOptions syncOptions) throws BuildUpdateActionException
Compares a list ofAsset
s with a list ofAssetDraft
s. The method serves as a generic implementation for assets syncing. The method takes in functions for building the required update actions ( AddAsset, RemoveAsset, ChangeAssetOrder and 1-1 update actions on assets (e.g. changeAssetName, setAssetDescription, etc..) for the required resource.If the list of new
AssetDraft
s isnull
, then remove actions are built for every existing asset in theoldAssets
list.- Type Parameters:
T
- the type of the resource the asset update actions are built for.D
- the type of the draft, which contains the changes the asset update actions are built for.- Parameters:
newResource
- resource draft from a source project, which contains the asset to update.oldAssets
- the old list of assets.newAssetDrafts
- the new list of asset drafts.assetActionFactory
- factory responsible for building asset update actions.syncOptions
- responsible for supplying the sync options to the sync utility method. It is used for triggering the warn callback within the utility- Returns:
- a list of asset update actions on the resource of type T if the list of assets is not identical. Otherwise, if the assets are identical, an empty list is returned.
- Throws:
BuildUpdateActionException
- in case there are asset drafts with duplicate keys.
-
-