use of com.commercetools.sync.commons.exceptions.SyncException in project commercetools-project-sync by commercetools.
the class TypeSyncer method of.
@Nonnull
public static TypeSyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
final QuadConsumer<SyncException, Optional<TypeDraft>, Optional<Type>, List<UpdateAction<Type>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "type", exception, oldResource, updateActions);
final TriConsumer<SyncException, Optional<TypeDraft>, Optional<Type>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "type", exception, oldResource);
final TypeSyncOptions syncOptions = TypeSyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
final TypeSync typeSync = new TypeSync(syncOptions);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
return new TypeSyncer(typeSync, sourceClient, targetClient, customObjectService, clock);
}
use of com.commercetools.sync.commons.exceptions.SyncException in project commercetools-project-sync by commercetools.
the class CategorySyncer method of.
@Nonnull
public static CategorySyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
final QuadConsumer<SyncException, Optional<CategoryDraft>, Optional<Category>, List<UpdateAction<Category>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "category", exception, oldResource, updateActions);
final TriConsumer<SyncException, Optional<CategoryDraft>, Optional<Category>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "category", exception, oldResource);
final CategorySyncOptions syncOptions = CategorySyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
final CategorySync categorySync = new CategorySync(syncOptions);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
return new CategorySyncer(categorySync, sourceClient, targetClient, customObjectService, clock);
}
use of com.commercetools.sync.commons.exceptions.SyncException in project commercetools-project-sync by commercetools.
the class CustomerSyncer method of.
public static CustomerSyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
final QuadConsumer<SyncException, Optional<CustomerDraft>, Optional<Customer>, List<UpdateAction<Customer>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "customer", exception, oldResource, updateActions);
final TriConsumer<SyncException, Optional<CustomerDraft>, Optional<Customer>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "customer", exception, oldResource);
final CustomerSyncOptions customerSyncOptions = CustomerSyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
final CustomerSync customerSync = new CustomerSync(customerSyncOptions);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
return new CustomerSyncer(customerSync, sourceClient, targetClient, customObjectService, clock);
}
use of com.commercetools.sync.commons.exceptions.SyncException in project commercetools-project-sync by commercetools.
the class CustomObjectSyncer method of.
@Nonnull
public static CustomObjectSyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock, @Nullable final String runnerName, final boolean isSyncProjectSyncCustomObjects) {
final QuadConsumer<SyncException, Optional<CustomObjectDraft<JsonNode>>, Optional<CustomObject<JsonNode>>, List<UpdateAction<CustomObject<JsonNode>>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> {
final String resourceIdentifier = getCustomObjectResourceIdentifier(oldResource);
updateActions = updateActions == null ? Collections.emptyList() : updateActions;
logErrorCallback(LOGGER, "customObject", exception, resourceIdentifier, updateActions);
};
final TriConsumer<SyncException, Optional<CustomObjectDraft<JsonNode>>, Optional<CustomObject<JsonNode>>> logWarningCallback = (exception, newResourceDraft, oldResource) -> {
final String resourceIdentifier = getCustomObjectResourceIdentifier(oldResource);
logWarningCallback(LOGGER, "customObject", exception, resourceIdentifier);
};
final CustomObjectSyncOptions syncOptions = CustomObjectSyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
final CustomObjectSync customObjectSyncer = new CustomObjectSync(syncOptions);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
return new CustomObjectSyncer(customObjectSyncer, sourceClient, targetClient, customObjectService, clock, runnerName, isSyncProjectSyncCustomObjects);
}
use of com.commercetools.sync.commons.exceptions.SyncException in project commercetools-project-sync by commercetools.
the class InventoryEntrySyncer method of.
public static InventoryEntrySyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
final QuadConsumer<SyncException, Optional<InventoryEntryDraft>, Optional<InventoryEntry>, List<UpdateAction<InventoryEntry>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "inventory entry", exception, oldResource.map(InventoryEntry::getSku).orElse(IDENTIFIER_NOT_PRESENT), updateActions);
final TriConsumer<SyncException, Optional<InventoryEntryDraft>, Optional<InventoryEntry>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "inventory entry", exception, oldResource.map(InventoryEntry::getSku).orElse(IDENTIFIER_NOT_PRESENT));
final InventorySyncOptions syncOptions = InventorySyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
final InventorySync inventorySync = new InventorySync(syncOptions);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
return new InventoryEntrySyncer(inventorySync, sourceClient, targetClient, customObjectService, clock);
}
Aggregations