Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATACMNS-1412: Add support for QueryDSL Predicate, Pageable, Sort and ProjectedPayload on WebFlux controllers #2667

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes in implementation
  • Loading branch information
matiasah committed Jul 29, 2022
commit 3fbd3ff84399e5125ba7c6fa6a86b3181031657a
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.springframework.data.web;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
Expand All @@ -39,13 +38,12 @@
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.math.BigDecimal;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

/**
* {@link org.springframework.http.codec.HttpMessageDecoder} implementation to enable projected JSON binding to interfaces annotated with
* {@link ProjectedPayload}.
* {@link org.springframework.http.codec.HttpMessageDecoder} implementation to enable projected JSON binding to
* interfaces annotated with {@link ProjectedPayload}.
*
* @author Matías Hermosilla
* @since 3.0
Expand Down Expand Up @@ -138,8 +136,8 @@ public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType
}

@Override
public Flux<Object> decode(Publisher<DataBuffer> input, ResolvableType elementType,
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
public Flux<Object> decode(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType,
@Nullable Map<String, Object> hints) {

ObjectMapper mapper = selectObjectMapper(elementType, mimeType);
if (mapper == null) {
Expand All @@ -150,7 +148,7 @@ public Flux<Object> decode(Publisher<DataBuffer> input, ResolvableType elementTy

return DataBufferUtils.join(processed, this.getMaxInMemorySize())
.flatMap(dataBuffer -> Mono.just(decode(dataBuffer, elementType, mimeType, hints)))
.expand(object -> {
.flatMapMany(object -> {
if (object instanceof Iterable) {
return Flux.fromIterable((Iterable) object);
}
Expand All @@ -159,8 +157,8 @@ public Flux<Object> decode(Publisher<DataBuffer> input, ResolvableType elementTy
}

@Override
public Object decode(DataBuffer dataBuffer, ResolvableType targetType,
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) throws DecodingException {
public Object decode(DataBuffer dataBuffer, ResolvableType targetType, @Nullable MimeType mimeType,
@Nullable Map<String, Object> hints) throws DecodingException {

return projectionFactory.createProjection(ResolvableType.forType(targetType.getType()).resolve(Object.class),
dataBuffer.asInputStream());
Expand Down