From 4dc6f41ee17671421836d888a53b58d336d192e7 Mon Sep 17 00:00:00 2001 From: Andrii Kovalenko Date: Wed, 27 Sep 2017 14:53:18 +0200 Subject: [PATCH] #98: fix "Tag @link: reference not found" for generic links --- .../integration/commons/utils/SphereClientUtils.java | 2 +- .../java/com/commercetools/sync/commons/BaseSync.java | 10 +++++----- .../sync/commons/helpers/CustomReferenceResolver.java | 2 +- .../commons/helpers/GenericCustomActionBuilder.java | 10 +++++----- .../sync/commons/utils/CustomUpdateActionUtils.java | 4 ++-- .../sync/commons/utils/GenericUpdateActionUtils.java | 10 +++++----- .../helpers/InventoryCustomActionBuilder.java | 4 ++++ 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/integration-test/java/com/commercetools/sync/integration/commons/utils/SphereClientUtils.java b/src/integration-test/java/com/commercetools/sync/integration/commons/utils/SphereClientUtils.java index c99a2c0f64..c9a79a121e 100644 --- a/src/integration-test/java/com/commercetools/sync/integration/commons/utils/SphereClientUtils.java +++ b/src/integration-test/java/com/commercetools/sync/integration/commons/utils/SphereClientUtils.java @@ -33,7 +33,7 @@ public class SphereClientUtils { public static final Long QUERY_MAX_LIMIT = 500L; /** - * Fetches resources of {@link T} using a {@code query}. The {@code ctpRequest} is applied on each resultant + * Fetches resources of {@code T} using a {@code query}. The {@code ctpRequest} is applied on each resultant * resource from fetching, to make a {@link SphereRequest}. Then each request is executed by {@code client}. * Method blocks until above operations were done. * diff --git a/src/main/java/com/commercetools/sync/commons/BaseSync.java b/src/main/java/com/commercetools/sync/commons/BaseSync.java index 8daed68da1..667a6b0b57 100644 --- a/src/main/java/com/commercetools/sync/commons/BaseSync.java +++ b/src/main/java/com/commercetools/sync/commons/BaseSync.java @@ -22,8 +22,8 @@ protected BaseSync(@Nonnull final U statistics, @Nonnull final V syncOptions) { * actions on the existing resource if it exists or create it if it doesn't. * * @param resourceDrafts the list of new resources as drafts. - * @return an instance of {@link CompletionStage}<{@link U}> which contains as a result an instance of - * {@link U} which is a subclass of {@link BaseSyncStatistics} representing the {@code statistics} instance + * @return an instance of {@link CompletionStage}<{@code U}> which contains as a result an instance of + * {@code U} which is a subclass of {@link BaseSyncStatistics} representing the {@code statistics} instance * attribute of {@code this} {@link BaseSync}. */ protected abstract CompletionStage process(@Nonnull final List resourceDrafts); @@ -38,8 +38,8 @@ protected BaseSync(@Nonnull final U statistics, @Nonnull final V syncOptions) { * container so that the total processing time is computed in the statistics. * * @param resourceDrafts the list of new resources as drafts. - * @return an instance of {@link CompletionStage}<{@link U}> which contains as a result an instance of - * {@link U} which is a subclass of {@link BaseSyncStatistics} representing the {@code statistics} instance + * @return an instance of {@link CompletionStage}<{@code U}> which contains as a result an instance of + * {@code U} which is a subclass of {@link BaseSyncStatistics} representing the {@code statistics} instance * attribute of {@code this} {@link BaseSync}. */ public CompletionStage sync(@Nonnull final List resourceDrafts) { @@ -73,7 +73,7 @@ public U getStatistics() { * @param result in the first call of this recursive method, this result is normally a completed future, it * used from within the method to recursively sync each batch once the previous batch has * finished syncing. - * @return an instance of {@link CompletionStage}<{@link U}> which contains as a result an instance of + * @return an instance of {@link CompletionStage}<{@code U}> which contains as a result an instance of * {@link BaseSyncStatistics} representing the {@code statistics} of the sync process executed on the * given list of batches. */ diff --git a/src/main/java/com/commercetools/sync/commons/helpers/CustomReferenceResolver.java b/src/main/java/com/commercetools/sync/commons/helpers/CustomReferenceResolver.java index da2cf240bd..b6d4551ce6 100644 --- a/src/main/java/com/commercetools/sync/commons/helpers/CustomReferenceResolver.java +++ b/src/main/java/com/commercetools/sync/commons/helpers/CustomReferenceResolver.java @@ -34,7 +34,7 @@ protected CustomReferenceResolver(@Nonnull final S options, @Nonnull final TypeS } /** - * Given a draft of {@link T} (e.g. {@link CategoryDraft}) this method attempts to resolve it's custom type + * Given a draft of {@code T} (e.g. {@link CategoryDraft}) this method attempts to resolve it's custom type * reference to return {@link CompletionStage} which contains a new instance of the draft with the resolved * custom type reference. The key of the custom type is taken from the from the id field of the reference. * diff --git a/src/main/java/com/commercetools/sync/commons/helpers/GenericCustomActionBuilder.java b/src/main/java/com/commercetools/sync/commons/helpers/GenericCustomActionBuilder.java index f57f8286f2..847c86c963 100644 --- a/src/main/java/com/commercetools/sync/commons/helpers/GenericCustomActionBuilder.java +++ b/src/main/java/com/commercetools/sync/commons/helpers/GenericCustomActionBuilder.java @@ -22,8 +22,8 @@ */ public abstract class GenericCustomActionBuilder> { /** - * Creates a CTP "setCustomType" update action on the given resource {@link T} that removes the custom type set on - * the given resource {@link T} (which currently could either be a {@link Category} or a {@link Channel}). + * Creates a CTP "setCustomType" update action on the given resource {@code T} that removes the custom type set on + * the given resource {@code T} (which currently could either be a {@link Category} or a {@link Channel}). * * @return a setCustomType update action that removes the custom type from the resource it's requested on. */ @@ -31,7 +31,7 @@ public abstract class GenericCustomActionBuilder> public abstract UpdateAction buildRemoveCustomTypeAction(); /** - * Creates a CTP "setCustomType" update action on the given resource {@link T} (which currently could either + * Creates a CTP "setCustomType" update action on the given resource {@code T} (which currently could either * be a {@link Category} or a {@link Channel}). * * @param customTypeId the id of the new custom type. @@ -43,9 +43,9 @@ public abstract UpdateAction buildSetCustomTypeAction(@Nullable final String @Nullable final Map customFieldsJsonMap); /** - * Creates a CTP "setCustomField" update action on the given resource {@link T} that updates a custom field with + * Creates a CTP "setCustomField" update action on the given resource {@code T} that updates a custom field with * {@code customFieldName} and a {@code customFieldValue} on the given - * resource {@link T} (which currently could either be a {@link Category} or a {@link Channel}). + * resource {@code T} (which currently could either be a {@link Category} or a {@link Channel}). * * @param customFieldName the name of the custom field to update. * @param customFieldValue the new JSON value of the custom field. diff --git a/src/main/java/com/commercetools/sync/commons/utils/CustomUpdateActionUtils.java b/src/main/java/com/commercetools/sync/commons/utils/CustomUpdateActionUtils.java index f29ca64985..c1ed96aeba 100644 --- a/src/main/java/com/commercetools/sync/commons/utils/CustomUpdateActionUtils.java +++ b/src/main/java/com/commercetools/sync/commons/utils/CustomUpdateActionUtils.java @@ -34,9 +34,9 @@ public final class CustomUpdateActionUtils { private static final String CUSTOM_TYPE_ID_IS_BLANK = "New resource's custom type id is blank (empty/null)."; /** - * Compares the {@link CustomFields} of an old resource {@link T} (for example {@link Category}, + * Compares the {@link CustomFields} of an old resource {@code T} (for example {@link Category}, * {@link io.sphere.sdk.products.Product}, etc..), to the {@link CustomFieldsDraft}, of a new - * resource draft {@link S} (for example {@link CategoryDraft}, {@link io.sphere.sdk.products.ProductVariantDraft}, + * resource draft {@code S} (for example {@link CategoryDraft}, {@link io.sphere.sdk.products.ProductVariantDraft}, * etc..), and returns a {@link List}<{@link UpdateAction}> as a result. If no update action is needed, * for example in the case where both the {@link CustomFields} and the {@link CustomFieldsDraft} are null, an empty * {@link List}<{@link UpdateAction}> is returned. A {@link BaseSyncOptions} instance is injected into the diff --git a/src/main/java/com/commercetools/sync/commons/utils/GenericUpdateActionUtils.java b/src/main/java/com/commercetools/sync/commons/utils/GenericUpdateActionUtils.java index 76c28d7c07..f002d41006 100644 --- a/src/main/java/com/commercetools/sync/commons/utils/GenericUpdateActionUtils.java +++ b/src/main/java/com/commercetools/sync/commons/utils/GenericUpdateActionUtils.java @@ -28,7 +28,7 @@ final class GenericUpdateActionUtils { + "remove the custom type on the %s with id '%s'. Reason: %s"; /** - * Creates a CTP "setCustomType" update action on the given resource {@link T} (which currently could either + * Creates a CTP "setCustomType" update action on the given resource {@code T} (which currently could either * be a {@link Category} or a {@link Channel}). * * @param customTypeId the id of the new custom type. @@ -56,8 +56,8 @@ static > Optional> buildTypedSetC } /** - * Creates a CTP "setCustomType" update action on the given resource {@link T} that removes the custom type set on - * the given resource {@link T} (which currently could either be a {@link Category} or a {@link Channel}). + * Creates a CTP "setCustomType" update action on the given resource {@code T} that removes the custom type set on + * the given resource {@code T} (which currently could either be a {@link Category} or a {@link Channel}). * * @param resource the resource to do the update action on. * @param the type of the resource to do the update action on. @@ -77,9 +77,9 @@ static > Optional> buildTypedRemo } /** - * Creates a CTP "setCustomField" update action on the given resource {@link T} that updates a custom field with + * Creates a CTP "setCustomField" update action on the given resource {@code T} that updates a custom field with * {@code customFieldName} and a {@code customFieldValue} on the given - * resource {@link T} (which currently could either be a {@link Category} or a {@link Channel}). + * resource {@code T} (which currently could either be a {@link Category} or a {@link Channel}). * * @param customFieldName the name of the custom field to update. * @param customFieldValue the new JSON value of the custom field. diff --git a/src/main/java/com/commercetools/sync/inventories/helpers/InventoryCustomActionBuilder.java b/src/main/java/com/commercetools/sync/inventories/helpers/InventoryCustomActionBuilder.java index dc3865f16e..cc2b2e3fa8 100644 --- a/src/main/java/com/commercetools/sync/inventories/helpers/InventoryCustomActionBuilder.java +++ b/src/main/java/com/commercetools/sync/inventories/helpers/InventoryCustomActionBuilder.java @@ -7,16 +7,19 @@ import io.sphere.sdk.inventory.commands.updateactions.SetCustomField; import io.sphere.sdk.inventory.commands.updateactions.SetCustomType; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Map; public class InventoryCustomActionBuilder extends GenericCustomActionBuilder { + @Nonnull @Override public UpdateAction buildRemoveCustomTypeAction() { return SetCustomType.ofRemoveType(); } + @Nonnull @Override public UpdateAction buildSetCustomTypeAction(@Nullable final String customTypeId, @Nullable final Map @@ -24,6 +27,7 @@ public UpdateAction buildSetCustomTypeAction(@Nullable final Str return SetCustomType.ofTypeIdAndJson(customTypeId, customFieldsJsonMap); } + @Nonnull @Override public UpdateAction buildSetCustomFieldAction(@Nullable final String customFieldName, @Nullable final JsonNode customFieldValue) {