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; }
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; }
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; }
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 OrderFromCartDraft of(final Versioned<Cart> cart, @Nullable final String orderNumber, @Nullable final PaymentState paymentState) { return OrderFromCartDraftDsl.of(cart.getId(), cart.getVersion(), orderNumber, paymentState); }
/** * Creates a command to verify the email of a customer. * @param customer unused * @param tokenValue the value of the token which customer email address should be confirmed * @return command * @deprecated use {@link #ofTokenValue(String)} or {@link #ofCustomerToken(CustomerToken)} */ @Deprecated//do not delete soon public static CustomerVerifyEmailCommand of(final Versioned<Customer> customer, final String tokenValue) { return new CustomerVerifyEmailCommand(customer.getId(), customer.getVersion(), tokenValue); }
/** * 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 to verify the email of a customer. * @param customer unused * @param tokenValue the value of the token which customer email address should be confirmed * @return command * @deprecated use {@link #ofTokenValue(String)} or {@link #ofCustomerToken(CustomerToken)} */ @Deprecated//do not delete soon public static CustomerVerifyEmailCommand of(final Versioned<Customer> customer, final String tokenValue) { return new CustomerVerifyEmailCommand(customer.getId(), customer.getVersion(), tokenValue); }
static OrderFromCartDraft of(final Versioned<Cart> cart) { return OrderFromCartDraftDsl.of(cart.getId(), cart.getVersion(), null, null); } }
@Override public HttpRequestIntent httpRequestIntent() { final String baseEndpointWithoutId = endpoint.endpoint(); if (!baseEndpointWithoutId.startsWith("/")) { throw new RuntimeException("By convention the paths start with a slash, see baseEndpointWithoutId()"); } return HttpRequestIntent.of(HttpMethod.DELETE, baseEndpointWithoutId + "/" + versioned.getId() + "?version=" + versioned.getVersion()); }
public static CustomerCreateEmailTokenCommand of(final Versioned<Customer> customer, final Integer timeToLiveInMinutes) { return new CustomerCreateEmailTokenCommand(customer.getId(), customer.getVersion(), timeToLiveInMinutes); }
static OrderFromCartDraft of(final Versioned<Cart> cart) { return OrderFromCartDraftDsl.of(cart.getId(), cart.getVersion(), null, null); } }
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 to verify the email of a customer. * @param customer unused * @param customerToken the token object * @return command * @deprecated use {@link #ofTokenValue(String)} or {@link #ofCustomerToken(CustomerToken)} */ @Deprecated//do not delete soon public static CustomerVerifyEmailCommand of(final Versioned<Customer> customer, final CustomerToken customerToken) { return new CustomerVerifyEmailCommand(customer.getId(), customer.getVersion(), customerToken.getValue()); }
/** * Creates a command to verify the email of a customer. * @param customer unused * @param customerToken the token object * @return command * @deprecated use {@link #ofTokenValue(String)} or {@link #ofCustomerToken(CustomerToken)} */ @Deprecated//do not delete soon public static CustomerVerifyEmailCommand of(final Versioned<Customer> customer, final CustomerToken customerToken) { return new CustomerVerifyEmailCommand(customer.getId(), customer.getVersion(), customerToken.getValue()); }
@Override public HttpRequestIntent httpRequestIntent() { final String baseEndpointWithoutId = endpoint; if (!baseEndpointWithoutId.startsWith("/")) { throw new RuntimeException("By convention the paths start with a slash"); } final UrlQueryBuilder builder = UrlQueryBuilder.of(); expansionPaths().forEach(path -> builder.add("expand", path.toSphereExpand(), true)); final String expansionPathParameters = builder.build(); return HttpRequestIntent.of(HttpMethod.DELETE, baseEndpointWithoutId + "/" + versioned.getId() + "?version=" + versioned.getVersion() + (expansionPathParameters.isEmpty() ? "" : "&" + expansionPathParameters) + (eraseData ? "&dataErasure=true" : "")); }
@Override public HttpRequestIntent httpRequestIntent() { if (!baseEndpointWithoutId.startsWith("/")) { throw new RuntimeException("By convention the paths start with a slash, see baseEndpointWithoutId()"); } final String path = baseEndpointWithoutId + "/" + getVersioned().getId(); return HttpRequestIntent.of(HttpMethod.POST, path, toJson(new UpdateCommandBody<>(getVersioned().getVersion(), getUpdateActions()))); }
@Override public HttpRequestIntent httpRequestIntent() { if (!baseEndpointWithoutId.startsWith("/")) { throw new RuntimeException("By convention the paths start with a slash, see baseEndpointWithoutId()"); } final String additions = queryParametersToString(true); final String path = baseEndpointWithoutId + "/" + getVersioned().getId() + (additions.length() > 1 ? additions : ""); return HttpRequestIntent.of(HttpMethod.POST, path, toJsonString(new UpdateCommandBody<>(getVersioned().getVersion(), getUpdateActions()))); }
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); } }
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); } }