Class 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 com.commercetools.api.models.ResourceUpdateAction<T>,​D>
      java.util.List<T>
      buildAssetsUpdateActions​(D newResource, java.util.List<com.commercetools.api.models.common.Asset> oldAssets, java.util.List<com.commercetools.api.models.common.AssetDraft> newAssetDrafts, AssetActionFactory<T,​D> assetActionFactory, BaseSyncOptions syncOptions)
      Compares a list of Assets with a list of AssetDrafts.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 com.commercetools.api.models.ResourceUpdateAction<T>,​D> java.util.List<T> buildAssetsUpdateActions​(@Nonnull
                                                                                                                                          D newResource,
                                                                                                                                          @Nonnull
                                                                                                                                          java.util.List<com.commercetools.api.models.common.Asset> oldAssets,
                                                                                                                                          @Nullable
                                                                                                                                          java.util.List<com.commercetools.api.models.common.AssetDraft> newAssetDrafts,
                                                                                                                                          @Nonnull
                                                                                                                                          AssetActionFactory<T,​D> assetActionFactory,
                                                                                                                                          @Nonnull
                                                                                                                                          BaseSyncOptions syncOptions)
                                                                                                                                   throws BuildUpdateActionException
        Compares a list of Assets with a list of AssetDrafts. 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 AssetDrafts is null, then remove actions are built for every existing asset in the oldAssets 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.