/** * Returns the entity as JSON. * * @return the entity as JSON. */ default Optional<JsonValue> getEntity() { return getEntity(JsonSchemaVersion.LATEST); }
/** * Returns the entity as JSON. * * @return the entity as JSON. */ default Optional<JsonValue> getEntity() { return getEntity(JsonSchemaVersion.LATEST); }
private static WithDittoHeaders checkForHarmfulEntity(final WithDittoHeaders withDittoHeaders) { if (withDittoHeaders instanceof Command && withDittoHeaders instanceof WithOptionalEntity) { final Optional<JsonValue> optionalEntity = ((WithOptionalEntity) withDittoHeaders).getEntity(); if (optionalEntity.isPresent() && isJsonValueIllegal(optionalEntity.get())) { throw buildError(withDittoHeaders); } } return withDittoHeaders; }
private static Function<HttpResponse, HttpResponse> createBodyAddingResponseMapper( final CommandResponse commandResponse, final WithOptionalEntity withOptionalEntity) { return response -> { if (StatusCodes.NO_CONTENT.equals(response.status())) { return response; } else { return withOptionalEntity.getEntity(commandResponse.getImplementedSchemaVersion()) .map(entity -> addEntityAccordingToContentType(response, entity, commandResponse.getDittoHeaders())) .orElse(response); } }; }