From 4d8ba0bdaeafb62a9839c30ed51267ea8aa46a71 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 21 Jul 2015 11:42:14 +0200 Subject: [PATCH] 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. --- pom.xml | 1 - .../data/rest/webmvc/PersistentEntityResource.java | 12 ++++-------- .../webmvc/json/PersistentEntityJackson2Module.java | 3 +-- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 2c7c2a677..d2a1325c3 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,6 @@ org.springframework.data.build spring-data-parent 1.6.2.BUILD-SNAPSHOT - ../spring-data-build/parent/pom.xml diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/PersistentEntityResource.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/PersistentEntityResource.java index 45569df50..583dff808 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/PersistentEntityResource.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/PersistentEntityResource.java @@ -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 { - private static final Resources NO_EMBEDDEDS = new Resources( - Collections. emptyList()); + private static final Iterable NO_EMBEDDEDS = Collections.emptyList(); private final PersistentEntity entity; - private final Resources embeddeds; + private final Iterable embeddeds; private final boolean enforceAssociationLinks; /** @@ -56,7 +53,7 @@ public class PersistentEntityResource extends Resource { * @param embeddeds can be {@literal null}. */ private PersistentEntityResource(PersistentEntity entity, Object content, Iterable links, - boolean renderAllAssociations, Resources embeddeds) { + boolean renderAllAssociations, Iterable embeddeds) { super(content, links); @@ -90,8 +87,7 @@ public class PersistentEntityResource extends Resource { * * @return the embeddeds */ - @JsonUnwrapped - public Resources getEmbeddeds() { + public Iterable getEmbeddeds() { return embeddeds; } diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2Module.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2Module.java index 21945ee96..4f29fd838 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2Module.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2Module.java @@ -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 resourceToRender = new Resource(resource.getContent(), links) { @JsonUnwrapped - public Resources getEmbedded() { + public Iterable getEmbedded() { return resource.getEmbeddeds(); } };