static ReviewDeleteCommand ofKey(final String key, final Long version) { final Versioned<Review> versioned = Versioned.of("key=" + key, version);//hack for simple reuse return of(versioned); } }
private CustomerPasswordResetCommand(final Versioned<Customer> customer, final String tokenValue, final String newPassword) { this.id = customer != null ? customer.getId() : null; this.version = customer != null ? customer.getVersion() : null; this.tokenValue = tokenValue; this.newPassword = newPassword; }
/** * Creates a versioned that only contains the id and the version. * @param versioned the template object to use its ID and version * @param <T> The type which has an ID and version. * @return versioned */ static <T> Versioned<T> of(final Versioned<T> versioned) { return of(versioned.getId(), versioned.getVersion()); }
/** * Creates a command object to create a token to verify a customer's email. * No optimistic version control is used. * @param customer customer * @param timeToLiveInMinutes the time in minutes the token is valid, platform limitation apply * @return command */ public static CustomerCreateEmailTokenCommand of(final Identifiable<Customer> customer, final Integer timeToLiveInMinutes) { final Long version = customer != null && customer instanceof Versioned ? ((Versioned<Customer>)customer).getVersion() :null; return new CustomerCreateEmailTokenCommand(customer.getId(), version, timeToLiveInMinutes); }
private static void deleteWithRetry(final BlockingSphereClient client, final Versioned<Product> unPublishedProduct, final int ttl) { if (ttl > 0) { try { client.executeBlocking(ProductDeleteCommand.of(unPublishedProduct)); } catch(final ConcurrentModificationException e) { final Versioned<Product> versioned = Versioned.of(unPublishedProduct.getId(), e.getCurrentVersion()); deleteWithRetry(client, versioned, ttl - 1); } } else { throw new RuntimeException("cannot delete product due to too much concurrent updates, product: " + unPublishedProduct); } }
/** * Creates a command object to create a token to verify a customer's email. * No optimistic version control is used. * @param customer customer * @param timeToLiveInMinutes the time in minutes the token is valid, platform limitation apply * @return command */ public static CustomerCreateEmailTokenCommand of(final Identifiable<Customer> customer, final Integer timeToLiveInMinutes) { final Long version = customer != null && customer instanceof Versioned ? ((Versioned<Customer>)customer).getVersion() :null; return new CustomerCreateEmailTokenCommand(customer.getId(), version, timeToLiveInMinutes); }
private CustomerPasswordResetCommand(final Versioned<Customer> customer, final String tokenValue, final String newPassword) { this.id = customer.getId(); this.version = customer.getVersion(); this.tokenValue = tokenValue; this.newPassword = newPassword; }
static ProductTypeDeleteCommand ofKey(final String key, final Long version) { final Versioned<ProductType> versioned = Versioned.of("key=" + key, version);//hack for simple reuse return of(versioned); } }
private static Product unpublishWithRetry(final BlockingSphereClient client, final Versioned<Product> product, final int ttl) { if (ttl > 0) { try { return client.executeBlocking(ProductUpdateCommand.of(product, Unpublish.of())); } catch(final ConcurrentModificationException e) { final Versioned<Product> versioned = Versioned.of(product.getId(), e.getCurrentVersion()); return unpublishWithRetry(client, versioned, ttl - 1); } } else { throw new RuntimeException("cannot unpublish product due to too much concurrent updates, product: " + product); } }
private CustomerPasswordResetCommand(final Versioned<Customer> customer, final String tokenValue, final String newPassword) { this.id = customer != null ? customer.getId() : null; this.version = customer != null ? customer.getVersion() : null; this.tokenValue = tokenValue; this.newPassword = newPassword; }
static ReviewUpdateCommand ofKey(final String key, final Long version, final List<? extends UpdateAction<Review>> updateActions) { final Versioned<Review> versioned = Versioned.of("key=" + key, version);//hack for simple reuse return new ReviewUpdateCommandImpl(versioned, updateActions); }
private CustomerPasswordResetCommand(final Versioned<Customer> customer, final String tokenValue, final String newPassword) { this.id = customer.getId(); this.version = customer.getVersion(); this.tokenValue = tokenValue; this.newPassword = newPassword; }
static ProductUpdateCommand ofKey(final String key, final Long version, final List<? extends UpdateAction<Product>> updateActions) { final Versioned<Product> versioned = Versioned.of("key=" + key, version);//hack for simple reuse return of(versioned, updateActions); }
static OrderFromCartDraft of(final Versioned<Cart> cart) { return OrderFromCartDraftDsl.of(cart.getId(), cart.getVersion(), null, null); } }
static ProductUpdateCommand ofKey(final String key, final Long version, final List<? extends UpdateAction<Product>> updateActions) { final Versioned<Product> versioned = Versioned.of("key=" + key, version);//hack for simple reuse return of(versioned, updateActions); }
static OrderFromCartDraft of(final Versioned<Cart> cart) { return OrderFromCartDraftDsl.of(cart.getId(), cart.getVersion(), null, null); } }
static ProductTypeUpdateCommand ofKey(final String key, final Long version, final List<? extends UpdateAction<ProductType>> updateActions) { final Versioned<ProductType> versioned = Versioned.of("key=" + key, version);//hack for simple reuse return new ProductTypeUpdateCommandImpl(versioned, updateActions); }
public static CustomerChangePasswordCommand of(final Versioned<Customer> customer, final String currentPassword, final String newPassword) { return new CustomerChangePasswordCommand(customer.getId(), customer.getVersion(), currentPassword, newPassword); }
/** Creates a command object to delete a {@link Subscription} by its key. @param key the key of the Subscription to delete, see {@link Subscription#getKey()} @param version `the current version of the Subscription, see {@link Subscription#getVersion()} @return delete command */ static SubscriptionDeleteCommand ofKey(final String key, final Long version) { final Versioned<Subscription> versioned = Versioned.of("key=" + urlEncode(key), version);//hack for simple reuse return of(versioned); }