DATAREST-622 - Removed unnecessary wrapping of embeddeds.
We now use a plain collection of EmbeddedWrapper instead of a Resources to avoid the links contained in the Resources to potentially cause issues on rendering.
This commit is contained in:
1
pom.xml
1
pom.xml
@@ -14,7 +14,6 @@
|
||||
<groupId>org.springframework.data.build</groupId>
|
||||
<artifactId>spring-data-parent</artifactId>
|
||||
<version>1.6.2.BUILD-SNAPSHOT</version>
|
||||
<relativePath>../spring-data-build/parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -28,8 +28,6 @@ import org.springframework.hateoas.Resources;
|
||||
import org.springframework.hateoas.core.EmbeddedWrapper;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
|
||||
/**
|
||||
* A Spring HATEOAS {@link Resource} subclass that holds a reference to the entity's {@link PersistentEntity} metadata.
|
||||
*
|
||||
@@ -38,11 +36,10 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
*/
|
||||
public class PersistentEntityResource extends Resource<Object> {
|
||||
|
||||
private static final Resources<EmbeddedWrapper> NO_EMBEDDEDS = new Resources<EmbeddedWrapper>(
|
||||
Collections.<EmbeddedWrapper> emptyList());
|
||||
private static final Iterable<EmbeddedWrapper> NO_EMBEDDEDS = Collections.emptyList();
|
||||
|
||||
private final PersistentEntity<?, ?> entity;
|
||||
private final Resources<EmbeddedWrapper> embeddeds;
|
||||
private final Iterable<EmbeddedWrapper> embeddeds;
|
||||
private final boolean enforceAssociationLinks;
|
||||
|
||||
/**
|
||||
@@ -56,7 +53,7 @@ public class PersistentEntityResource extends Resource<Object> {
|
||||
* @param embeddeds can be {@literal null}.
|
||||
*/
|
||||
private PersistentEntityResource(PersistentEntity<?, ?> entity, Object content, Iterable<Link> links,
|
||||
boolean renderAllAssociations, Resources<EmbeddedWrapper> embeddeds) {
|
||||
boolean renderAllAssociations, Iterable<EmbeddedWrapper> embeddeds) {
|
||||
|
||||
super(content, links);
|
||||
|
||||
@@ -90,8 +87,7 @@ public class PersistentEntityResource extends Resource<Object> {
|
||||
*
|
||||
* @return the embeddeds
|
||||
*/
|
||||
@JsonUnwrapped
|
||||
public Resources<EmbeddedWrapper> getEmbeddeds() {
|
||||
public Iterable<EmbeddedWrapper> getEmbeddeds() {
|
||||
return embeddeds;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.springframework.data.rest.webmvc.mapping.AssociationLinks;
|
||||
import org.springframework.data.rest.webmvc.mapping.LinkCollectingAssociationHandler;
|
||||
import org.springframework.hateoas.Link;
|
||||
import org.springframework.hateoas.Resource;
|
||||
import org.springframework.hateoas.Resources;
|
||||
import org.springframework.hateoas.UriTemplate;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -172,7 +171,7 @@ public class PersistentEntityJackson2Module extends SimpleModule {
|
||||
Resource<Object> resourceToRender = new Resource<Object>(resource.getContent(), links) {
|
||||
|
||||
@JsonUnwrapped
|
||||
public Resources<?> getEmbedded() {
|
||||
public Iterable<?> getEmbedded() {
|
||||
return resource.getEmbeddeds();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user