diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/RepositoryRestConfiguration.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/RepositoryRestConfiguration.java index 987e52089..ceb5696e1 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/RepositoryRestConfiguration.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/RepositoryRestConfiguration.java @@ -32,8 +32,8 @@ import org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy; import org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy.RepositoryDetectionStrategies; import org.springframework.data.rest.core.support.EntityLookup; import org.springframework.hateoas.MediaTypes; -import org.springframework.hateoas.RelProvider; -import org.springframework.hateoas.core.EvoInflectorRelProvider; +import org.springframework.hateoas.server.RelProvider; +import org.springframework.hateoas.server.core.EvoInflectorRelProvider; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.util.StringUtils; diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/CrudMethodsSupportedHttpMethods.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/CrudMethodsSupportedHttpMethods.java index 702fb8ae6..e6e03e667 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/CrudMethodsSupportedHttpMethods.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/CrudMethodsSupportedHttpMethods.java @@ -62,7 +62,7 @@ public class CrudMethodsSupportedHttpMethods implements SupportedHttpMethods { @Override public HttpMethods getMethodsFor(ResourceType resourceType) { - Assert.notNull(resourceType, "Resource type must not be null!"); + Assert.notNull(resourceType, "EntityRepresentationModel type must not be null!"); Set methods = new HashSet(); methods.add(OPTIONS); diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/EvoInflectorTypeBasedCollectionResourceMapping.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/EvoInflectorTypeBasedCollectionResourceMapping.java index 2a6565dae..80f04cdb9 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/EvoInflectorTypeBasedCollectionResourceMapping.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/EvoInflectorTypeBasedCollectionResourceMapping.java @@ -16,7 +16,7 @@ package org.springframework.data.rest.core.mapping; import org.atteo.evo.inflector.English; -import org.springframework.hateoas.RelProvider; +import org.springframework.hateoas.server.RelProvider; /** * {@link TypeBasedCollectionResourceMapping} extension to use Evo Inflector to pluralize the simple class name by as diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryCollectionResourceMapping.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryCollectionResourceMapping.java index 5537420fe..4c7a39391 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryCollectionResourceMapping.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryCollectionResourceMapping.java @@ -23,8 +23,8 @@ import org.springframework.data.rest.core.Path; import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RestResource; import org.springframework.hateoas.LinkRelation; -import org.springframework.hateoas.RelProvider; -import org.springframework.hateoas.core.EvoInflectorRelProvider; +import org.springframework.hateoas.server.RelProvider; +import org.springframework.hateoas.server.core.EvoInflectorRelProvider; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryMethodResourceMapping.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryMethodResourceMapping.java index c0f75a0ba..a5833910a 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryMethodResourceMapping.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryMethodResourceMapping.java @@ -31,8 +31,8 @@ import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.Path; import org.springframework.data.rest.core.annotation.RestResource; import org.springframework.hateoas.LinkRelation; -import org.springframework.hateoas.core.AnnotationAttribute; -import org.springframework.hateoas.core.MethodParameters; +import org.springframework.hateoas.server.core.AnnotationAttribute; +import org.springframework.hateoas.server.core.MethodParameters; import org.springframework.util.Assert; import org.springframework.util.StringUtils; diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappings.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappings.java index 11998401a..066bf0174 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappings.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappings.java @@ -28,7 +28,7 @@ import org.springframework.data.repository.core.RepositoryInformation; import org.springframework.data.repository.support.Repositories; import org.springframework.data.rest.core.annotation.RestResource; import org.springframework.data.rest.core.config.RepositoryRestConfiguration; -import org.springframework.hateoas.RelProvider; +import org.springframework.hateoas.server.RelProvider; import org.springframework.util.Assert; /** diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/TypeBasedCollectionResourceMapping.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/TypeBasedCollectionResourceMapping.java index 28fdfb79f..20b9946f7 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/TypeBasedCollectionResourceMapping.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/TypeBasedCollectionResourceMapping.java @@ -22,8 +22,8 @@ import org.springframework.data.rest.core.Path; import org.springframework.data.rest.core.annotation.Description; import org.springframework.data.rest.core.annotation.RestResource; import org.springframework.hateoas.LinkRelation; -import org.springframework.hateoas.RelProvider; -import org.springframework.hateoas.core.EvoInflectorRelProvider; +import org.springframework.hateoas.server.RelProvider; +import org.springframework.hateoas.server.core.EvoInflectorRelProvider; import org.springframework.util.Assert; import org.springframework.util.StringUtils; diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/DefaultSelfLinkProvider.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/DefaultSelfLinkProvider.java index bc449e4ae..2884ffa6c 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/DefaultSelfLinkProvider.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/DefaultSelfLinkProvider.java @@ -18,8 +18,8 @@ package org.springframework.data.rest.core.support; import java.util.List; import org.springframework.data.mapping.context.PersistentEntities; -import org.springframework.hateoas.EntityLinks; import org.springframework.hateoas.Link; +import org.springframework.hateoas.server.EntityLinks; import org.springframework.plugin.core.PluginRegistry; import org.springframework.util.Assert; @@ -65,7 +65,7 @@ public class DefaultSelfLinkProvider implements SelfLinkProvider { Assert.notNull(instance, "Domain object must not be null!"); - return entityLinks.linkToSingleResource(instance.getClass(), getResourceId(instance)); + return entityLinks.linkToItemResource(instance.getClass(), getResourceId(instance)); } /** @@ -81,7 +81,7 @@ public class DefaultSelfLinkProvider implements SelfLinkProvider { return lookups.getPluginFor(instanceType)// .map(it -> it.getClass().cast(it))// - .map(it -> (Object) it.getResourceIdentifier(instance))// + .map(it -> it.getResourceIdentifier(instance))// .orElseGet(() -> identifierOrNull(instance)); } diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/RepositoryRelProvider.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/RepositoryRelProvider.java index 5129fdc65..ccb2d3e23 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/RepositoryRelProvider.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/RepositoryRelProvider.java @@ -20,7 +20,7 @@ import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.data.rest.core.mapping.ResourceMappings; import org.springframework.hateoas.LinkRelation; -import org.springframework.hateoas.RelProvider; +import org.springframework.hateoas.server.RelProvider; import org.springframework.util.Assert; /** @@ -46,7 +46,7 @@ public class RepositoryRelProvider implements RelProvider { /* * (non-Javadoc) - * @see org.springframework.hateoas.RelProvider#getCollectionResourceRelFor(java.lang.Class) + * @see org.springframework.hateoas.server.RelProvider#getCollectionResourceRelFor(java.lang.Class) */ @Override public LinkRelation getCollectionResourceRelFor(Class type) { @@ -55,7 +55,7 @@ public class RepositoryRelProvider implements RelProvider { /* * (non-Javadoc) - * @see org.springframework.hateoas.RelProvider#getItemResourceRelFor(java.lang.Class) + * @see org.springframework.hateoas.server.RelProvider#getItemResourceRelFor(java.lang.Class) */ @Override public LinkRelation getItemResourceRelFor(Class type) { diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/SimpleRelProvider.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/SimpleRelProvider.java index 2ecfdeeab..77d6200b6 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/SimpleRelProvider.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/SimpleRelProvider.java @@ -16,7 +16,7 @@ package org.springframework.data.rest.core.support; import org.springframework.hateoas.LinkRelation; -import org.springframework.hateoas.RelProvider; +import org.springframework.hateoas.server.RelProvider; import org.springframework.util.StringUtils; /** @@ -35,7 +35,7 @@ public class SimpleRelProvider implements RelProvider { /* * (non-Javadoc) - * @see org.springframework.hateoas.RelProvider#getItemResourceRelFor(java.lang.Class) + * @see org.springframework.hateoas.server.RelProvider#getItemResourceRelFor(java.lang.Class) */ @Override public LinkRelation getItemResourceRelFor(Class type) { @@ -46,7 +46,7 @@ public class SimpleRelProvider implements RelProvider { /* * (non-Javadoc) - * @see org.springframework.hateoas.RelProvider#getCollectionResourceRelFor(java.lang.Class) + * @see org.springframework.hateoas.server.RelProvider#getCollectionResourceRelFor(java.lang.Class) */ @Override public LinkRelation getCollectionResourceRelFor(Class type) { diff --git a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/config/ResourceMappingUnitTests.java b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/config/ResourceMappingUnitTests.java index 97bd698e9..a0d615745 100755 --- a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/config/ResourceMappingUnitTests.java +++ b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/config/ResourceMappingUnitTests.java @@ -27,8 +27,8 @@ import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RestResource; import org.springframework.data.rest.core.domain.Person; import org.springframework.data.rest.core.mapping.ResourceMapping; -import org.springframework.hateoas.RelProvider; -import org.springframework.hateoas.core.EvoInflectorRelProvider; +import org.springframework.hateoas.server.RelProvider; +import org.springframework.hateoas.server.core.EvoInflectorRelProvider; /** * Ensure the {@link ResourceMapping} components convey the correct information. diff --git a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DefaultSelfLinkProviderUnitTests.java b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DefaultSelfLinkProviderUnitTests.java index 82679e4df..c17157bf3 100755 --- a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DefaultSelfLinkProviderUnitTests.java +++ b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DefaultSelfLinkProviderUnitTests.java @@ -35,7 +35,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.springframework.data.keyvalue.core.mapping.context.KeyValueMappingContext; import org.springframework.data.mapping.context.PersistentEntities; import org.springframework.data.rest.core.domain.Profile; -import org.springframework.hateoas.EntityLinks; +import org.springframework.hateoas.server.EntityLinks; import org.springframework.hateoas.Link; /** @@ -58,7 +58,7 @@ public class DefaultSelfLinkProviderUnitTests { @Before public void setUp() { - when(entityLinks.linkToSingleResource((Class) any(), any())).then(invocation -> { + when(entityLinks.linkToItemResource((Class) any(), any())).then(invocation -> { Class type = invocation.getArgument(0); Serializable id = invocation.getArgument(1); diff --git a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java index f957e968b..7149121a4 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/AbstractWebIntegrationTests.java @@ -31,7 +31,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; import org.springframework.hateoas.Link; -import org.springframework.hateoas.LinkDiscoverers; +import org.springframework.hateoas.client.LinkDiscoverers; import org.springframework.hateoas.LinkRelation; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; diff --git a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/RepositoryTestsConfig.java b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/RepositoryTestsConfig.java index 98e6c3f69..bf796af86 100644 --- a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/RepositoryTestsConfig.java +++ b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/RepositoryTestsConfig.java @@ -49,12 +49,12 @@ import org.springframework.data.rest.webmvc.support.PagingAndSortingTemplateVari import org.springframework.data.rest.webmvc.support.RepositoryEntityLinks; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.format.support.FormattingConversionService; -import org.springframework.hateoas.EntityLinks; -import org.springframework.hateoas.RelProvider; -import org.springframework.hateoas.ResourceProcessor; -import org.springframework.hateoas.core.EvoInflectorRelProvider; -import org.springframework.hateoas.hal.Jackson2HalModule; -import org.springframework.hateoas.mvc.ResourceProcessorInvoker; +import org.springframework.hateoas.server.EntityLinks; +import org.springframework.hateoas.server.RelProvider; +import org.springframework.hateoas.server.RepresentationModelProcessor; +import org.springframework.hateoas.server.core.EvoInflectorRelProvider; +import org.springframework.hateoas.mediatype.hal.Jackson2HalModule; +import org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvoker; import org.springframework.plugin.core.PluginRegistry; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -121,7 +121,7 @@ public class RepositoryTestsConfig { return new PersistentEntityJackson2Module(associations, persistentEntities(), uriToEntityConverter, collector, invokerFactory, mock(LookupObjectSerializer.class), - new ResourceProcessorInvoker(Collections.> emptyList()), + new RepresentationModelProcessorInvoker(Collections.> emptyList()), new EmbeddedResourcesAssembler(persistentEntities(), associations, mock(ExcerptProjector.class))); } diff --git a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/ResourceTester.java b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/ResourceTester.java index d5665b905..dbd370b01 100644 --- a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/ResourceTester.java +++ b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/ResourceTester.java @@ -22,10 +22,10 @@ import static org.junit.Assert.assertThat; import org.hamcrest.Matcher; import org.springframework.data.rest.core.Path; import org.springframework.hateoas.Link; -import org.springframework.hateoas.PagedResources; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.ResourceSupport; -import org.springframework.hateoas.Resources; +import org.springframework.hateoas.PagedModel; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.RepresentationModel; +import org.springframework.hateoas.CollectionModel; import org.springframework.util.Assert; import org.springframework.web.util.UriTemplate; @@ -36,11 +36,11 @@ import org.springframework.web.util.UriTemplate; */ public class ResourceTester { - private final ResourceSupport resource; + private final RepresentationModel resource; public static ResourceTester of(Object object) { - assertThat(object, is(instanceOf(ResourceSupport.class))); - return new ResourceTester((ResourceSupport) object); + assertThat(object, is(instanceOf(RepresentationModel.class))); + return new ResourceTester((RepresentationModel) object); } /** @@ -48,8 +48,8 @@ public class ResourceTester { * * @param resource must not be {@literal null}. */ - private ResourceTester(ResourceSupport resource) { - Assert.notNull(resource, "Resource must not be null!"); + private ResourceTester(RepresentationModel resource) { + Assert.notNull(resource, "EntityRepresentationModel must not be null!"); this.resource = resource; } @@ -96,27 +96,27 @@ public class ResourceTester { } @SuppressWarnings("unchecked") - public PagedResources assertIsPage() { + public PagedModel assertIsPage() { - assertThat(resource, is(instanceOf(PagedResources.class))); - return (PagedResources) resource; + assertThat(resource, is(instanceOf(PagedModel.class))); + return (PagedModel) resource; } public ResourceTester getContentResource() { - assertThat(resource, is(instanceOf(Resources.class))); - Object next = ((Resources) resource).getContent().iterator().next(); + assertThat(resource, is(instanceOf(CollectionModel.class))); + Object next = ((CollectionModel) resource).getContent().iterator().next(); - assertThat(next, is(instanceOf(ResourceSupport.class))); - return new ResourceTester((ResourceSupport) next); + assertThat(next, is(instanceOf(RepresentationModel.class))); + return new ResourceTester((RepresentationModel) next); } public void withContentResource(ContentResourceHandler handler) { - assertThat(resource, is(instanceOf(Resources.class))); + assertThat(resource, is(instanceOf(CollectionModel.class))); - for (Object element : ((Resources) resource).getContent()) { - assertThat(element, is(instanceOf(ResourceSupport.class))); + for (Object element : ((CollectionModel) resource).getContent()) { + assertThat(element, is(instanceOf(RepresentationModel.class))); handler.doWith(of(element)); } } diff --git a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/TestMvcClient.java b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/TestMvcClient.java index 3e2b3a681..7e7bac018 100644 --- a/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/TestMvcClient.java +++ b/spring-data-rest-tests/spring-data-rest-tests-core/src/test/java/org/springframework/data/rest/tests/TestMvcClient.java @@ -26,8 +26,8 @@ import java.util.Iterator; import java.util.Optional; import org.springframework.hateoas.Link; -import org.springframework.hateoas.LinkDiscoverer; -import org.springframework.hateoas.LinkDiscoverers; +import org.springframework.hateoas.client.LinkDiscoverer; +import org.springframework.hateoas.client.LinkDiscoverers; import org.springframework.hateoas.LinkRelation; import org.springframework.hateoas.Links; import org.springframework.http.HttpEntity; @@ -365,7 +365,7 @@ public class TestMvcClient { * Using the servlet response's content type, find the corresponding link discoverer. * * @param response - * @return {@link org.springframework.hateoas.LinkDiscoverer} + * @return {@link org.springframework.hateoas.client.LinkDiscoverer} */ public LinkDiscoverer getDiscoverer(MockHttpServletResponse response) { diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryEntityControllerIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryEntityControllerIntegrationTests.java index e09765ab3..1a051191e 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryEntityControllerIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositoryEntityControllerIntegrationTests.java @@ -48,7 +48,7 @@ import org.springframework.data.rest.webmvc.jpa.Order; import org.springframework.data.rest.webmvc.jpa.Person; import org.springframework.data.rest.webmvc.support.DefaultedPageable; import org.springframework.data.rest.webmvc.support.ETag; -import org.springframework.hateoas.Resource; +import org.springframework.hateoas.EntityModel; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -243,7 +243,7 @@ public class RepositoryEntityControllerIntegrationTests extends AbstractControll Mockito.when(assembler.toFullResource(Mockito.any(Object.class))).thenReturn(resource); - ResponseEntity> entity = controller.getItemResource(getResourceInformation(Address.class), address.id, + ResponseEntity> entity = controller.getItemResource(getResourceInformation(Address.class), address.id, assembler, new HttpHeaders()); assertThat(entity.getHeaders().getETag()).isNotNull(); diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositorySearchControllerIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositorySearchControllerIntegrationTests.java index 2e7242b95..67740b1f9 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositorySearchControllerIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RepositorySearchControllerIntegrationTests.java @@ -35,9 +35,9 @@ import org.springframework.data.rest.webmvc.jpa.JpaRepositoryConfig; import org.springframework.data.rest.webmvc.jpa.Person; import org.springframework.data.rest.webmvc.jpa.TestDataPopulator; import org.springframework.data.rest.webmvc.support.DefaultedPageable; -import org.springframework.hateoas.PagedResources; -import org.springframework.hateoas.ResourceSupport; -import org.springframework.hateoas.Resources; +import org.springframework.hateoas.PagedModel; +import org.springframework.hateoas.RepresentationModel; +import org.springframework.hateoas.CollectionModel; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -72,7 +72,7 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll public void rendersCorrectSearchLinksForPersons() throws Exception { RootResourceInformation request = getResourceInformation(Person.class); - ResourceSupport resource = controller.listSearches(request); + RepresentationModel resource = controller.listSearches(request); ResourceTester tester = ResourceTester.of(resource); tester.assertNumberOfLinks(7); // Self link included @@ -107,7 +107,7 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll Sort.unsorted(), assembler, new HttpHeaders()); ResourceTester tester = ResourceTester.of(response.getBody()); - PagedResources pagedResources = tester.assertIsPage(); + PagedModel pagedResources = tester.assertIsPage(); assertThat(pagedResources.getContent()).hasSize(1); ResourceMetadata metadata = getMetadata(Person.class); @@ -169,7 +169,7 @@ public class RepositorySearchControllerIntegrationTests extends AbstractControll ResponseEntity result = controller.executeSearch(resourceInformation, parameters, "findByAuthorsContains", PAGEABLE, Sort.unsorted(), assembler, new HttpHeaders()); - assertThat(result.getBody()).isInstanceOf(Resources.class); + assertThat(result.getBody()).isInstanceOf(CollectionModel.class); } @Test // DATAREST-515 diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/alps/AlpsControllerIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/alps/AlpsControllerIntegrationTests.java index d432da53b..3e4f8f1a8 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/alps/AlpsControllerIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/alps/AlpsControllerIntegrationTests.java @@ -38,9 +38,9 @@ import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; import org.springframework.data.rest.webmvc.jpa.Item; import org.springframework.data.rest.webmvc.jpa.JpaRepositoryConfig; import org.springframework.hateoas.Link; -import org.springframework.hateoas.LinkDiscoverer; -import org.springframework.hateoas.LinkDiscoverers; -import org.springframework.hateoas.core.JsonPathLinkDiscoverer; +import org.springframework.hateoas.client.LinkDiscoverer; +import org.springframework.hateoas.client.LinkDiscoverers; +import org.springframework.hateoas.client.JsonPathLinkDiscoverer; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.web.WebAppConfiguration; diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest262Tests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest262Tests.java index 035b61413..4ba89e7ad 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest262Tests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest262Tests.java @@ -40,7 +40,7 @@ import org.springframework.data.rest.webmvc.PersistentEntityResource; import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; import org.springframework.hateoas.Link; import org.springframework.hateoas.MediaTypes; -import org.springframework.hateoas.Resource; +import org.springframework.hateoas.EntityModel; import org.springframework.http.HttpHeaders; import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter; import org.springframework.mock.web.MockHttpServletRequest; @@ -122,7 +122,7 @@ public class DataRest262Tests { JpaPersistentEntity persistentEntity = mappingContext.getRequiredPersistentEntity(AircraftMovement.class); - Resource resource = PersistentEntityResource.build(movement, persistentEntity).// + EntityModel resource = PersistentEntityResource.build(movement, persistentEntity).// withLink(new Link("/api/airports/" + movement.id)).// build(); diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest363Tests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest363Tests.java index 6efa9bb87..72f4eca92 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest363Tests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/DataRest363Tests.java @@ -28,9 +28,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.rest.tests.TestMvcClient; import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; -import org.springframework.hateoas.LinkDiscoverer; -import org.springframework.hateoas.LinkDiscoverers; -import org.springframework.hateoas.core.JsonPathLinkDiscoverer; +import org.springframework.hateoas.client.LinkDiscoverer; +import org.springframework.hateoas.client.LinkDiscoverers; +import org.springframework.hateoas.client.JsonPathLinkDiscoverer; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaWebTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaWebTests.java index b6d3a687e..9314af7a0 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaWebTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/JpaWebTests.java @@ -41,7 +41,7 @@ import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.Link; import org.springframework.hateoas.LinkRelation; import org.springframework.hateoas.Links; -import org.springframework.hateoas.RelProvider; +import org.springframework.hateoas.server.RelProvider; import org.springframework.http.MediaType; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/ProfileIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/ProfileIntegrationTests.java index 3ba43a828..107d6e175 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/ProfileIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/ProfileIntegrationTests.java @@ -31,7 +31,7 @@ import org.springframework.data.rest.webmvc.ProfileResourceProcessor; import org.springframework.data.rest.webmvc.RestMediaTypes; import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; import org.springframework.hateoas.Link; -import org.springframework.hateoas.LinkDiscoverers; +import org.springframework.hateoas.client.LinkDiscoverers; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.web.WebAppConfiguration; diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java index 1e1af6a47..ddcc6570d 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java @@ -41,14 +41,14 @@ import org.springframework.data.rest.webmvc.PersistentEntityResource; import org.springframework.data.rest.webmvc.jpa.*; import org.springframework.data.rest.webmvc.util.TestUtils; import org.springframework.hateoas.Link; -import org.springframework.hateoas.LinkDiscoverer; +import org.springframework.hateoas.client.LinkDiscoverer; import org.springframework.hateoas.LinkRelation; -import org.springframework.hateoas.PagedResources; -import org.springframework.hateoas.PagedResources.PageMetadata; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.core.EmbeddedWrapper; -import org.springframework.hateoas.core.EmbeddedWrappers; -import org.springframework.hateoas.hal.HalLinkDiscoverer; +import org.springframework.hateoas.PagedModel; +import org.springframework.hateoas.PagedModel.PageMetadata; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.server.core.EmbeddedWrapper; +import org.springframework.hateoas.server.core.EmbeddedWrappers; +import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -204,7 +204,7 @@ public class PersistentEntitySerializationTests { withLink(new Link("/orders/1")).// build(); - PagedResources persistentEntityResource = new PagedResources( + PagedModel persistentEntityResource = new PagedModel( Arrays.asList(orderResource), new PageMetadata(1, 0, 10)); String result = mapper.writeValueAsString(persistentEntityResource); @@ -260,7 +260,7 @@ public class PersistentEntitySerializationTests { ProjectionFactory factory = new SpelAwareProxyProjectionFactory(); PersonSummary projection = factory.createProjection(PersonSummary.class, person); - String result = mapper.writeValueAsString(new Resource(projection)); + String result = mapper.writeValueAsString(new EntityModel(projection)); assertThat(JsonPath. read(result, "$._links.self")).isNotNull(); } diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/RepositoryTestsConfig.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/RepositoryTestsConfig.java index 5c13354d7..1f0757202 100644 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/RepositoryTestsConfig.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/json/RepositoryTestsConfig.java @@ -50,12 +50,12 @@ import org.springframework.data.rest.webmvc.support.PagingAndSortingTemplateVari import org.springframework.data.rest.webmvc.support.RepositoryEntityLinks; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.format.support.FormattingConversionService; -import org.springframework.hateoas.EntityLinks; -import org.springframework.hateoas.RelProvider; -import org.springframework.hateoas.ResourceProcessor; -import org.springframework.hateoas.core.EvoInflectorRelProvider; -import org.springframework.hateoas.hal.Jackson2HalModule; -import org.springframework.hateoas.mvc.ResourceProcessorInvoker; +import org.springframework.hateoas.server.EntityLinks; +import org.springframework.hateoas.server.RelProvider; +import org.springframework.hateoas.server.RepresentationModelProcessor; +import org.springframework.hateoas.server.core.EvoInflectorRelProvider; +import org.springframework.hateoas.mediatype.hal.Jackson2HalModule; +import org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvoker; import org.springframework.plugin.core.PluginRegistry; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -129,7 +129,7 @@ public class RepositoryTestsConfig { return new PersistentEntityJackson2Module(associations, persistentEntities(), uriToEntityConverter, collector, invokerFactory, mock(LookupObjectSerializer.class), - new ResourceProcessorInvoker(Collections.> emptyList()), + new RepresentationModelProcessorInvoker(Collections.> emptyList()), new EmbeddedResourcesAssembler(persistentEntities(), associations, mock(ExcerptProjector.class))); } diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinksIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinksIntegrationTests.java index bd9937be5..143de70e2 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinksIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinksIntegrationTests.java @@ -51,7 +51,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt @Test public void returnsLinkToSingleResource() { - Link link = entityLinks.linkToSingleResource(Person.class, 1); + Link link = entityLinks.linkToItemResource(Person.class, 1); assertThat(link.getHref(), endsWith("/people/1{?projection}")); assertThat(link.getRel()).isEqualTo(LinkRelation.of("person")); @@ -70,7 +70,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt @Test // DATAREST-221 public void returnsLinkWithProjectionTemplateVariableIfProjectionIsDefined() { - Link link = entityLinks.linkToSingleResource(Order.class, 1); + Link link = entityLinks.linkToItemResource(Order.class, 1); assertThat(link.isTemplated()).isTrue(); assertThat(link.getVariableNames()).contains(configuration.getProjectionConfiguration().getParameterName()); @@ -79,7 +79,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt @Test // DATAREST-155 public void usesCustomGeneratedBackendId() { - Link link = entityLinks.linkToSingleResource(Book.class, 7L); + Link link = entityLinks.linkToItemResource(Book.class, 7L); assertThat(link.expand().getHref(), endsWith("/7-7-7-7-7-7-7")); } diff --git a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/tests/mongodb/MongoWebTests.java b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/tests/mongodb/MongoWebTests.java index 5a20dbab0..6303435cc 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/tests/mongodb/MongoWebTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/tests/mongodb/MongoWebTests.java @@ -313,7 +313,7 @@ public class MongoWebTests extends CommonWebTests { Link link = client.discoverUnique("users", "search", "findByColleaguesContains"); User thomas = userRepository.findAll(QUser.user.firstname.eq("Thomas")).iterator().next(); - Link thomasUri = entityLinks.linkToSingleResource(User.class, thomas.id).expand(); + Link thomasUri = entityLinks.linkToItemResource(User.class, thomas.id).expand(); String href = link.expand(thomasUri.getHref()).getHref(); diff --git a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/PersistentEntityResourceAssemblerIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/PersistentEntityResourceAssemblerIntegrationTests.java index 5b6b34adb..3798ab7c0 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/PersistentEntityResourceAssemblerIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/PersistentEntityResourceAssemblerIntegrationTests.java @@ -33,7 +33,7 @@ import org.springframework.data.rest.tests.mongodb.MongoDbRepositoryConfig; import org.springframework.data.rest.tests.mongodb.User; import org.springframework.data.rest.webmvc.mapping.Associations; import org.springframework.data.rest.webmvc.support.Projector; -import org.springframework.hateoas.EntityLinks; +import org.springframework.hateoas.server.EntityLinks; import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.Links; import org.springframework.test.context.ContextConfiguration; @@ -63,7 +63,7 @@ public class PersistentEntityResourceAssemblerIntegrationTests extends AbstractC User user = new User(); user.id = BigInteger.valueOf(4711); - PersistentEntityResource resource = assembler.toResource(user); + PersistentEntityResource resource = assembler.toModel(user); Links links = resource.getLinks(); diff --git a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java index 898071513..ce812fe82 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntitySerializationTests.java @@ -42,10 +42,10 @@ import org.springframework.data.rest.tests.mongodb.User.Nested; import org.springframework.data.rest.tests.mongodb.UserRepository; import org.springframework.data.rest.webmvc.PersistentEntityResource; import org.springframework.hateoas.Link; -import org.springframework.hateoas.LinkDiscoverer; -import org.springframework.hateoas.PagedResources; -import org.springframework.hateoas.PagedResources.PageMetadata; -import org.springframework.hateoas.hal.HalLinkDiscoverer; +import org.springframework.hateoas.client.LinkDiscoverer; +import org.springframework.hateoas.PagedModel; +import org.springframework.hateoas.PagedModel.PageMetadata; +import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -109,7 +109,7 @@ public class PersistentEntitySerializationTests { withLink(new Link("/users/1")).// build(); - PagedResources persistentEntityResource = new PagedResources( + PagedModel persistentEntityResource = new PagedModel( Arrays.asList(userResource), new PageMetadata(1, 0, 10)); String result = mapper.writeValueAsString(persistentEntityResource); diff --git a/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopConfiguration.java b/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopConfiguration.java index c460b94d3..2d20b4232 100644 --- a/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopConfiguration.java +++ b/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopConfiguration.java @@ -28,8 +28,8 @@ import org.springframework.data.rest.tests.shop.Customer.Gender; import org.springframework.data.rest.tests.shop.Product.ProductNameOnlyProjection; import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter; import org.springframework.hateoas.Link; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.ResourceProcessor; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.server.RepresentationModelProcessor; /** * @author Oliver Gierke @@ -44,15 +44,15 @@ public class ShopConfiguration { @Autowired LineItemTypeRepository lineItemTypes; @Bean - public ResourceProcessor> lineItemResourceProcessor() { - return new ResourceProcessor>() { + public RepresentationModelProcessor> lineItemResourceProcessor() { + return new RepresentationModelProcessor>() { /* * (non-Javadoc) - * @see org.springframework.hateoas.ResourceProcessor#process(org.springframework.hateoas.ResourceSupport) + * @see org.springframework.hateoas.server.RepresentationModelProcessor#process(org.springframework.hateoas.RepresentationModel) */ @Override - public Resource process(Resource resource) { + public EntityModel process(EntityModel resource) { resource.add(new Link("foo", "bar")); return resource; } @@ -60,16 +60,16 @@ public class ShopConfiguration { } @Bean - public ResourceProcessor> productNameOnlyProjectionResourceProcessor() { + public RepresentationModelProcessor> productNameOnlyProjectionResourceProcessor() { - return new ResourceProcessor>() { + return new RepresentationModelProcessor>() { /* * (non-Javadoc) - * @see org.springframework.hateoas.ResourceProcessor#process(org.springframework.hateoas.ResourceSupport) + * @see org.springframework.hateoas.server.RepresentationModelProcessor#process(org.springframework.hateoas.RepresentationModel) */ @Override - public Resource process(Resource resource) { + public EntityModel process(EntityModel resource) { resource.add(new Link("alpha", "beta")); return resource; } diff --git a/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopIntegrationTests.java index 3c1871617..6c4edf2f5 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-shop/src/test/java/org/springframework/data/rest/tests/shop/ShopIntegrationTests.java @@ -51,7 +51,7 @@ public class ShopIntegrationTests extends AbstractWebIntegrationTests { ResultActions actions = client.follow(selfLink) // Lookup type is rendered as String .andExpect(jsonPath("items[0].type", is("good")))// - // Invokes ResourceProcessor for nested Resource + // Invokes RepresentationModelProcessor for nested Resource .andExpect(jsonPath("items[0]._links.bar").exists());// // Adds excerpt projection for related product diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/AbstractRepositoryRestController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/AbstractRepositoryRestController.java index 8ec52f64f..2eb54d6c9 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/AbstractRepositoryRestController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/AbstractRepositoryRestController.java @@ -26,13 +26,13 @@ import org.springframework.data.auditing.AuditableBeanWrapperFactory; import org.springframework.data.domain.Page; import org.springframework.data.rest.core.mapping.ResourceMetadata; import org.springframework.data.web.PagedResourcesAssembler; +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.Link; import org.springframework.hateoas.LinkRelation; -import org.springframework.hateoas.PagedResources; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.Resources; -import org.springframework.hateoas.core.EmbeddedWrappers; +import org.springframework.hateoas.PagedModel; +import org.springframework.hateoas.server.core.EmbeddedWrappers; import org.springframework.util.Assert; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; @@ -61,7 +61,7 @@ class AbstractRepositoryRestController { this.pagedResourcesAssembler = pagedResourcesAssembler; } - protected Link resourceLink(RootResourceInformation resourceLink, Resource resource) { + protected Link resourceLink(RootResourceInformation resourceLink, EntityModel resource) { ResourceMetadata repoMapping = resourceLink.getResourceMetadata(); @@ -72,7 +72,7 @@ class AbstractRepositoryRestController { } @SuppressWarnings({ "unchecked" }) - protected Resources toResources(Iterable source, PersistentEntityResourceAssembler assembler, + protected CollectionModel toCollectionModel(Iterable source, PersistentEntityResourceAssembler assembler, Class domainType, Optional baseLink) { if (source instanceof Page) { @@ -81,38 +81,38 @@ class AbstractRepositoryRestController { } else if (source instanceof Iterable) { return entitiesToResources((Iterable) source, assembler, domainType); } else { - return new Resources(EMPTY_RESOURCE_LIST); + return new CollectionModel(EMPTY_RESOURCE_LIST); } } - protected Resources entitiesToResources(Page page, PersistentEntityResourceAssembler assembler, + protected CollectionModel entitiesToResources(Page page, PersistentEntityResourceAssembler assembler, Class domainType, Optional baseLink) { if (page.getContent().isEmpty()) { - return baseLink.> map(it -> pagedResourcesAssembler.toEmptyResource(page, domainType, it))// - .orElseGet(() -> pagedResourcesAssembler.toEmptyResource(page, domainType)); + return baseLink.> map(it -> pagedResourcesAssembler.toEmptyModel(page, domainType, it))// + .orElseGet(() -> pagedResourcesAssembler.toEmptyModel(page, domainType)); } - return baseLink.map(it -> pagedResourcesAssembler.toResource(page, assembler, it))// - .orElseGet(() -> pagedResourcesAssembler.toResource(page, assembler)); + return baseLink.map(it -> pagedResourcesAssembler.toModel(page, assembler, it))// + .orElseGet(() -> pagedResourcesAssembler.toModel(page, assembler)); } - protected Resources entitiesToResources(Iterable entities, PersistentEntityResourceAssembler assembler, - Class domainType) { + protected CollectionModel entitiesToResources(Iterable entities, + PersistentEntityResourceAssembler assembler, Class domainType) { if (!entities.iterator().hasNext()) { List content = Arrays. asList(WRAPPERS.emptyCollectionOf(domainType)); - return new Resources(content, getDefaultSelfLink()); + return new CollectionModel(content, getDefaultSelfLink()); } - List> resources = new ArrayList>(); + List> resources = new ArrayList>(); for (Object obj : entities) { - resources.add(obj == null ? null : assembler.toResource(obj)); + resources.add(obj == null ? null : assembler.toModel(obj)); } - return new Resources>(resources, getDefaultSelfLink()); + return new CollectionModel>(resources, getDefaultSelfLink()); } protected Link getDefaultSelfLink() { diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java index 984106fa4..95159f2e0 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java @@ -18,8 +18,8 @@ package org.springframework.data.rest.webmvc; import java.util.Collections; import java.util.Optional; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.RepresentationModel; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -31,10 +31,10 @@ import org.springframework.util.Assert; */ public class ControllerUtils { - public static final Iterable> EMPTY_RESOURCE_LIST = Collections.emptyList(); + public static final Iterable> EMPTY_RESOURCE_LIST = Collections.emptyList(); - public static ResponseEntity toResponseEntity(HttpStatus status, - HttpHeaders headers, Optional resource) { + public static > ResponseEntity> toResponseEntity( + HttpStatus status, HttpHeaders headers, Optional resource) { HttpHeaders hdrs = new HttpHeaders(); @@ -42,7 +42,7 @@ public class ControllerUtils { hdrs.putAll(headers); } - return new ResponseEntity(resource.orElse(null), hdrs, status); + return new ResponseEntity>(resource.orElse(null), hdrs, status); } /** @@ -54,8 +54,8 @@ public class ControllerUtils { * @param * @return */ - public static ResponseEntity toResponseEntity(HttpStatus status, - HttpHeaders headers, R resource) { + public static > ResponseEntity> toResponseEntity( + HttpStatus status, HttpHeaders headers, R resource) { Assert.notNull(status, "Http status must not be null!"); Assert.notNull(headers, "Http headers must not be null!"); @@ -70,7 +70,7 @@ public class ControllerUtils { * @param status * @return */ - public static ResponseEntity toEmptyResponse(HttpStatus status) { + public static ResponseEntity> toEmptyResponse(HttpStatus status) { return toEmptyResponse(status, new HttpHeaders()); } @@ -81,7 +81,7 @@ public class ControllerUtils { * @param headers * @return */ - public static ResponseEntity toEmptyResponse(HttpStatus status, HttpHeaders headers) { + public static ResponseEntity> toEmptyResponse(HttpStatus status, HttpHeaders headers) { return toResponseEntity(status, headers, Optional.empty()); } } diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/EmbeddedResourcesAssembler.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/EmbeddedResourcesAssembler.java index c6b35088f..4ba13d2f1 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/EmbeddedResourcesAssembler.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/EmbeddedResourcesAssembler.java @@ -31,8 +31,8 @@ import org.springframework.data.rest.core.mapping.ResourceMetadata; import org.springframework.data.rest.webmvc.mapping.Associations; import org.springframework.data.rest.webmvc.support.ExcerptProjector; import org.springframework.hateoas.LinkRelation; -import org.springframework.hateoas.core.EmbeddedWrapper; -import org.springframework.hateoas.core.EmbeddedWrappers; +import org.springframework.hateoas.server.core.EmbeddedWrapper; +import org.springframework.hateoas.server.core.EmbeddedWrappers; import org.springframework.util.Assert; /** 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 1cb1046d6..724760b6f 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 @@ -26,9 +26,9 @@ import org.springframework.data.mapping.PersistentProperty; import org.springframework.data.mapping.PersistentPropertyAccessor; import org.springframework.hateoas.Link; import org.springframework.hateoas.Links; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.Resources; -import org.springframework.hateoas.core.EmbeddedWrapper; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.server.core.EmbeddedWrapper; import org.springframework.util.Assert; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -39,7 +39,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; * @author Jon Brisbin * @author Oliver Gierke */ -public class PersistentEntityResource extends Resource { +public class PersistentEntityResource extends EntityModel { private static final Iterable NO_EMBEDDEDS = new NoLinksResources( Collections. emptyList()); @@ -203,7 +203,7 @@ public class PersistentEntityResource extends Resource { } } - private static class NoLinksResources extends Resources { + private static class NoLinksResources extends CollectionModel { public NoLinksResources(Iterable content) { super(content); @@ -211,7 +211,7 @@ public class PersistentEntityResource extends Resource { /* * (non-Javadoc) - * @see org.springframework.hateoas.ResourceSupport#getLinks() + * @see org.springframework.hateoas.RepresentationModel#getLinks() */ @Override @JsonIgnore diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/PersistentEntityResourceAssembler.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/PersistentEntityResourceAssembler.java index b58a8808f..ec157d154 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/PersistentEntityResourceAssembler.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/PersistentEntityResourceAssembler.java @@ -25,9 +25,9 @@ import org.springframework.data.rest.webmvc.PersistentEntityResource.Builder; import org.springframework.data.rest.webmvc.mapping.Associations; import org.springframework.data.rest.webmvc.support.Projector; import org.springframework.hateoas.Link; -import org.springframework.hateoas.ResourceAssembler; -import org.springframework.hateoas.core.EmbeddedWrapper; -import org.springframework.hateoas.core.EmbeddedWrappers; +import org.springframework.hateoas.server.RepresentationModelAssembler; +import org.springframework.hateoas.server.core.EmbeddedWrapper; +import org.springframework.hateoas.server.core.EmbeddedWrappers; import org.springframework.util.Assert; /** @@ -36,7 +36,7 @@ import org.springframework.util.Assert; * @author Oliver Gierke */ @RequiredArgsConstructor -public class PersistentEntityResourceAssembler implements ResourceAssembler { +public class PersistentEntityResourceAssembler implements RepresentationModelAssembler { private final @NonNull PersistentEntities entities; private final @NonNull Projector projector; @@ -46,10 +46,10 @@ public class PersistentEntityResourceAssembler implements ResourceAssembler(headers, HttpStatus.OK); + return ResponseEntity.ok().headers(headers).build(); } /** @@ -93,9 +92,9 @@ public class ProfileController { * @return */ @RequestMapping(value = PROFILE_ROOT_MAPPING, method = GET) - HttpEntity listAllFormsOfMetadata() { + HttpEntity> listAllFormsOfMetadata() { - ResourceSupport profile = new ResourceSupport(); + RepresentationModel profile = new RepresentationModel<>(); profile.add(new Link(getRootPath(this.configuration)).withSelfRel()); @@ -108,7 +107,7 @@ public class ProfileController { } } - return new ResponseEntity(profile, HttpStatus.OK); + return ResponseEntity.ok(profile); } /** diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ProfileResourceProcessor.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ProfileResourceProcessor.java index 53e1d0897..c63f4d9e2 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ProfileResourceProcessor.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ProfileResourceProcessor.java @@ -18,7 +18,7 @@ package org.springframework.data.rest.webmvc; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.rest.core.config.RepositoryRestConfiguration; import org.springframework.hateoas.Link; -import org.springframework.hateoas.ResourceProcessor; +import org.springframework.hateoas.server.RepresentationModelProcessor; import org.springframework.util.Assert; /** @@ -28,7 +28,7 @@ import org.springframework.util.Assert; * @author Greg Turnquist * @since 2.4 */ -public class ProfileResourceProcessor implements ResourceProcessor { +public class ProfileResourceProcessor implements RepresentationModelProcessor { public static final String PROFILE_REL = "profile"; diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryController.java index 1b96759b5..d90b2ea6b 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryController.java @@ -22,7 +22,7 @@ import org.springframework.data.repository.support.Repositories; import org.springframework.data.rest.core.mapping.ResourceMappings; import org.springframework.data.rest.core.mapping.ResourceMetadata; import org.springframework.data.web.PagedResourcesAssembler; -import org.springframework.hateoas.EntityLinks; +import org.springframework.hateoas.server.EntityLinks; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java index 0a68d4d2b..748b6a81c 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java @@ -50,12 +50,12 @@ import org.springframework.data.rest.webmvc.support.ETag; import org.springframework.data.rest.webmvc.support.ETagDoesntMatchException; import org.springframework.data.rest.webmvc.support.RepositoryEntityLinks; import org.springframework.data.web.PagedResourcesAssembler; +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.Link; import org.springframework.hateoas.Links; -import org.springframework.hateoas.PagedResources; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.ResourceSupport; -import org.springframework.hateoas.Resources; +import org.springframework.hateoas.PagedModel; +import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.UriTemplate; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -186,7 +186,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem */ @ResponseBody @RequestMapping(value = BASE_MAPPING, method = RequestMethod.GET) - public Resources getCollectionResource(@QuerydslPredicate RootResourceInformation resourceInformation, + public CollectionModel getCollectionResource(@QuerydslPredicate RootResourceInformation resourceInformation, DefaultedPageable pageable, Sort sort, PersistentEntityResourceAssembler assembler) throws ResourceNotFoundException, HttpRequestMethodNotSupportedException { @@ -205,7 +205,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem Optional baseLink = Optional.of(entityLinks.linkToPagedResource(resourceInformation.getDomainType(), pageable.isDefault() ? null : pageable.getPageable())); - Resources result = toResources(results, assembler, metadata.getDomainType(), baseLink); + CollectionModel result = toCollectionModel(results, assembler, metadata.getDomainType(), baseLink); result.add(getCollectionResourceLinks(resourceInformation, pageable)); return result; } @@ -228,22 +228,22 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem @SuppressWarnings({ "unchecked" }) @RequestMapping(value = BASE_MAPPING, method = RequestMethod.GET, produces = { "application/x-spring-data-compact+json", "text/uri-list" }) - public Resources getCollectionResourceCompact(@QuerydslPredicate RootResourceInformation resourceinformation, + public CollectionModel getCollectionResourceCompact(@QuerydslPredicate RootResourceInformation resourceinformation, DefaultedPageable pageable, Sort sort, PersistentEntityResourceAssembler assembler) throws ResourceNotFoundException, HttpRequestMethodNotSupportedException { - Resources resources = getCollectionResource(resourceinformation, pageable, sort, assembler); + CollectionModel resources = getCollectionResource(resourceinformation, pageable, sort, assembler); Links links = resources.getLinks(); - for (Resource resource : ((Resources>) resources).getContent()) { + for (EntityModel resource : ((CollectionModel>) resources).getContent()) { PersistentEntityResource persistentEntityResource = (PersistentEntityResource) resource; links = links.and(resourceLink(resourceinformation, persistentEntityResource)); } - if (resources instanceof PagedResources) { - return new PagedResources(Collections.emptyList(), ((PagedResources) resources).getMetadata(), links); + if (resources instanceof PagedModel) { + return new PagedModel(Collections.emptyList(), ((PagedModel) resources).getMetadata(), links); } else { - return new Resources(Collections.emptyList(), links); + return new CollectionModel(Collections.emptyList(), links); } } @@ -259,7 +259,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem */ @ResponseBody @RequestMapping(value = BASE_MAPPING, method = RequestMethod.POST) - public ResponseEntity postCollectionResource(RootResourceInformation resourceInformation, + public ResponseEntity> postCollectionResource(RootResourceInformation resourceInformation, PersistentEntityResource payload, PersistentEntityResourceAssembler assembler, @RequestHeader(value = ACCEPT_HEADER, required = false) String acceptHeader) throws HttpRequestMethodNotSupportedException { @@ -304,7 +304,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem return getItemResource(resourceInformation, id).map(it -> { - Links links = assembler.toResource(it).getLinks(); + Links links = assembler.toModel(it).getLinks(); HttpHeaders headers = headersPreparer.prepareHeaders(resourceInformation.getPersistentEntity(), it); headers.add(LINK_HEADER, links.toString()); @@ -323,7 +323,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem * @throws HttpRequestMethodNotSupportedException */ @RequestMapping(value = BASE_MAPPING + "/{id}", method = RequestMethod.GET) - public ResponseEntity> getItemResource(RootResourceInformation resourceInformation, + public ResponseEntity> getItemResource(RootResourceInformation resourceInformation, @BackendId Serializable id, final PersistentEntityResourceAssembler assembler, @RequestHeader HttpHeaders headers) throws HttpRequestMethodNotSupportedException { @@ -334,7 +334,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem return resourceStatus.getStatusAndHeaders(headers, it, entity).toResponseEntity(// () -> assembler.toFullResource(it)); - }).orElseGet(() -> new ResponseEntity>(HttpStatus.NOT_FOUND)); + }).orElseGet(() -> new ResponseEntity>(HttpStatus.NOT_FOUND)); } /** @@ -350,7 +350,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem * @throws HttpRequestMethodNotSupportedException */ @RequestMapping(value = BASE_MAPPING + "/{id}", method = RequestMethod.PUT) - public ResponseEntity putItemResource(RootResourceInformation resourceInformation, + public ResponseEntity> putItemResource(RootResourceInformation resourceInformation, PersistentEntityResource payload, @BackendId Serializable id, PersistentEntityResourceAssembler assembler, ETag eTag, @RequestHeader(value = ACCEPT_HEADER, required = false) String acceptHeader) throws HttpRequestMethodNotSupportedException { @@ -384,7 +384,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem * @throws ETagDoesntMatchException */ @RequestMapping(value = BASE_MAPPING + "/{id}", method = RequestMethod.PATCH) - public ResponseEntity patchItemResource(RootResourceInformation resourceInformation, + public ResponseEntity> patchItemResource(RootResourceInformation resourceInformation, PersistentEntityResource payload, @BackendId Serializable id, PersistentEntityResourceAssembler assembler, ETag eTag, @RequestHeader(value = ACCEPT_HEADER, required = false) String acceptHeader) throws HttpRequestMethodNotSupportedException, ResourceNotFoundException { @@ -442,7 +442,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem * @param httpMethod * @return */ - private ResponseEntity saveAndReturn(Object domainObject, RepositoryInvoker invoker, + private ResponseEntity> saveAndReturn(Object domainObject, RepositoryInvoker invoker, HttpMethod httpMethod, PersistentEntityResourceAssembler assembler, boolean returnBody) { publisher.publishEvent(new BeforeSaveEvent(domainObject)); @@ -470,7 +470,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem * @param invoker * @return */ - private ResponseEntity createAndReturn(Object domainObject, RepositoryInvoker invoker, + private ResponseEntity> createAndReturn(Object domainObject, RepositoryInvoker invoker, PersistentEntityResourceAssembler assembler, boolean returnBody) { publisher.publishEvent(new BeforeCreateEvent(domainObject)); diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryLinksResource.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryLinksResource.java index 60fc5e086..409d27369 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryLinksResource.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryLinksResource.java @@ -15,7 +15,7 @@ */ package org.springframework.data.rest.webmvc; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.RepresentationModel; /** * Dedicated resource type to represent the links pointing to collection resources exposed for repositories. @@ -23,4 +23,4 @@ import org.springframework.hateoas.ResourceSupport; * @author Jon Brisbin * @author Oliver Gierke */ -public class RepositoryLinksResource extends ResourceSupport {} +public class RepositoryLinksResource extends RepresentationModel {} diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceController.java index 86298a787..e322e10f0 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceController.java @@ -17,7 +17,7 @@ package org.springframework.data.rest.webmvc; import static org.springframework.data.rest.webmvc.ControllerUtils.*; import static org.springframework.data.rest.webmvc.RestMediaTypes.*; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*; import static org.springframework.web.bind.annotation.RequestMethod.*; import lombok.AccessLevel; @@ -56,12 +56,13 @@ import org.springframework.data.rest.core.mapping.ResourceMapping; import org.springframework.data.rest.core.mapping.ResourceMetadata; import org.springframework.data.rest.webmvc.support.BackendId; import org.springframework.data.web.PagedResourcesAssembler; +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.Link; import org.springframework.hateoas.LinkRelation; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.ResourceSupport; -import org.springframework.hateoas.Resources; -import org.springframework.hateoas.mvc.ControllerLinkBuilder; +import org.springframework.hateoas.RepresentationModel; +import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; @@ -110,32 +111,32 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro } @RequestMapping(value = BASE_MAPPING, method = GET) - public ResponseEntity followPropertyReference(final RootResourceInformation repoRequest, + public ResponseEntity> followPropertyReference(final RootResourceInformation repoRequest, @BackendId Serializable id, final @PathVariable String property, final PersistentEntityResourceAssembler assembler) throws Exception { HttpHeaders headers = new HttpHeaders(); - Function handler = prop -> prop.mapValue(it -> { + Function> handler = prop -> prop.mapValue(it -> { if (prop.property.isCollectionLike()) { - return toResources((Iterable) it, assembler, prop.propertyType, Optional.empty()); + return toCollectionModel((Iterable) it, assembler, prop.propertyType, Optional.empty()); } else if (prop.property.isMap()) { - Map> resources = new HashMap>(); + Map> resources = new HashMap>(); for (Map.Entry entry : ((Map) it).entrySet()) { - resources.put(entry.getKey(), assembler.toResource(entry.getValue())); + resources.put(entry.getKey(), assembler.toModel(entry.getValue())); } - return new Resource(resources); + return new EntityModel(resources); } else { - PersistentEntityResource resource = assembler.toResource(it); - headers.set("Content-Location", resource.getRequiredLink(Link.REL_SELF).getHref()); + PersistentEntityResource resource = assembler.toModel(it); + headers.set("Content-Location", resource.getRequiredLink(IanaLinkRelations.SELF).getHref()); return resource; } @@ -146,10 +147,10 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro } @RequestMapping(value = BASE_MAPPING, method = DELETE) - public ResponseEntity deletePropertyReference(RootResourceInformation repoRequest, + public ResponseEntity> deletePropertyReference(RootResourceInformation repoRequest, @BackendId Serializable id, @PathVariable String property) throws Exception { - Function handler = prop -> prop.mapValue(it -> { + Function> handler = prop -> prop.mapValue(it -> { if (prop.property.isCollectionLike() || prop.property.isMap()) { throw HttpRequestMethodNotSupportedException.forRejectedMethod(HttpMethod.DELETE) @@ -162,7 +163,7 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro Object result = repoRequest.getInvoker().invokeSave(prop.accessor.getBean()); publisher.publishEvent(new AfterLinkDeleteEvent(result, prop.propertyValue)); - return (ResourceSupport) null; + return (RepresentationModel) null; }).orElse(null); @@ -172,13 +173,13 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro } @RequestMapping(value = BASE_MAPPING + "/{propertyId}", method = GET) - public ResponseEntity followPropertyReference(RootResourceInformation repoRequest, + public ResponseEntity> followPropertyReference(RootResourceInformation repoRequest, @BackendId Serializable id, @PathVariable String property, @PathVariable String propertyId, PersistentEntityResourceAssembler assembler) throws Exception { HttpHeaders headers = new HttpHeaders(); - Function handler = prop -> prop.mapValue(it -> { + Function> handler = prop -> prop.mapValue(it -> { if (prop.property.isCollectionLike()) { @@ -187,8 +188,8 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro IdentifierAccessor accessor1 = prop.entity.getIdentifierAccessor(obj); if (propertyId.equals(accessor1.getIdentifier().toString())) { - PersistentEntityResource resource1 = assembler.toResource(obj); - headers.set("Content-Location", resource1.getRequiredLink(Link.REL_SELF).getHref()); + PersistentEntityResource resource1 = assembler.toModel(obj); + headers.set("Content-Location", resource1.getRequiredLink(IanaLinkRelations.SELF).getHref()); return resource1; } } @@ -200,14 +201,14 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro IdentifierAccessor accessor2 = prop.entity.getIdentifierAccessor(entry.getValue()); if (propertyId.equals(accessor2.getIdentifier().toString())) { - PersistentEntityResource resource2 = assembler.toResource(entry.getValue()); - headers.set("Content-Location", resource2.getRequiredLink(Link.REL_SELF).getHref()); + PersistentEntityResource resource2 = assembler.toModel(entry.getValue()); + headers.set("Content-Location", resource2.getRequiredLink(IanaLinkRelations.SELF).getHref()); return resource2; } } } else { - return new Resource<>(prop.propertyValue); + return new EntityModel<>(prop.propertyValue); } throw new ResourceNotFoundException(); @@ -220,11 +221,11 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro @RequestMapping(value = BASE_MAPPING, method = GET, produces = { SPRING_DATA_COMPACT_JSON_VALUE, TEXT_URI_LIST_VALUE }) - public ResponseEntity followPropertyReferenceCompact(RootResourceInformation repoRequest, + public ResponseEntity> followPropertyReferenceCompact(RootResourceInformation repoRequest, @BackendId Serializable id, @PathVariable String property, PersistentEntityResourceAssembler assembler) throws Exception { - ResponseEntity response = followPropertyReference(repoRequest, id, property, assembler); + ResponseEntity> response = followPropertyReference(repoRequest, id, property, assembler); if (response.getStatusCode() != HttpStatus.OK) { return response; @@ -234,28 +235,29 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro PersistentProperty persistentProp = repoRequest.getPersistentEntity().getRequiredPersistentProperty(property); ResourceMapping propertyMapping = repoMapping.getMappingFor(persistentProp); - ResourceSupport resource = response.getBody(); + RepresentationModel resource = response.getBody(); List links = new ArrayList(); - ControllerLinkBuilder linkBuilder = linkTo(methodOn(RepositoryPropertyReferenceController.class) + WebMvcLinkBuilder linkBuilder = linkTo(methodOn(RepositoryPropertyReferenceController.class) .followPropertyReference(repoRequest, id, property, assembler)); - if (resource instanceof Resource) { + if (resource instanceof EntityModel) { - Object content = ((Resource) resource).getContent(); + Object content = ((EntityModel) resource).getContent(); if (content instanceof Iterable) { - for (Resource res : (Iterable>) content) { + for (EntityModel res : (Iterable>) content) { links.add(linkBuilder.withRel(propertyMapping.getRel())); } } else if (content instanceof Map) { - Map> map = (Map>) content; + Map> map = (Map>) content; - for (Entry> entry : map.entrySet()) { - Link l = new Link(entry.getValue().getRequiredLink(Link.REL_SELF).getHref(), entry.getKey().toString()); + for (Entry> entry : map.entrySet()) { + Link l = new Link(entry.getValue().getRequiredLink(IanaLinkRelations.SELF).getHref(), + entry.getKey().toString()); links.add(l); } } @@ -264,19 +266,20 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro links.add(linkBuilder.withRel(propertyMapping.getRel())); } - return ControllerUtils.toResponseEntity(HttpStatus.OK, null, new Resource(EMPTY_RESOURCE_LIST, links)); + return ControllerUtils.toResponseEntity(HttpStatus.OK, null, new EntityModel(EMPTY_RESOURCE_LIST, links)); } @RequestMapping(value = BASE_MAPPING, method = { PATCH, PUT, POST }, // consumes = { MediaType.APPLICATION_JSON_VALUE, SPRING_DATA_COMPACT_JSON_VALUE, TEXT_URI_LIST_VALUE }) - public ResponseEntity createPropertyReference(RootResourceInformation resourceInformation, - HttpMethod requestMethod, @RequestBody(required = false) Resources incoming, @BackendId Serializable id, + public ResponseEntity> createPropertyReference( + RootResourceInformation resourceInformation, HttpMethod requestMethod, + @RequestBody(required = false) CollectionModel incoming, @BackendId Serializable id, @PathVariable String property) throws Exception { - Resources source = incoming == null ? new Resources(Collections.emptyList()) : incoming; + CollectionModel source = incoming == null ? new CollectionModel(Collections.emptyList()) : incoming; RepositoryInvoker invoker = resourceInformation.getInvoker(); - Function handler = prop -> { + Function> handler = prop -> { Class propertyType = prop.property.getType(); @@ -337,11 +340,11 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro } @RequestMapping(value = BASE_MAPPING + "/{propertyId}", method = DELETE) - public ResponseEntity deletePropertyReferenceId(RootResourceInformation repoRequest, + public ResponseEntity> deletePropertyReferenceId(RootResourceInformation repoRequest, @BackendId Serializable backendId, @PathVariable String property, @PathVariable String propertyId) throws Exception { - Function handler = prop -> prop.mapValue(it -> { + Function> handler = prop -> prop.mapValue(it -> { if (prop.property.isCollectionLike()) { @@ -381,7 +384,7 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro Object result = repoRequest.getInvoker().invokeSave(prop.accessor.getBean()); publisher.publishEvent(new AfterLinkDeleteEvent(result, it)); - return (ResourceSupport) null; + return (RepresentationModel) null; }).orElse(null); @@ -400,9 +403,9 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro return invoker.invokeFindById(id).orElse(null); } - private Optional doWithReferencedProperty(RootResourceInformation resourceInformation, - Serializable id, String propertyPath, Function handler, HttpMethod method) - throws Exception { + private Optional> doWithReferencedProperty(RootResourceInformation resourceInformation, + Serializable id, String propertyPath, Function> handler, + HttpMethod method) throws Exception { ResourceMetadata metadata = resourceInformation.getResourceMetadata(); PropertyAwareResourceMapping mapping = metadata.getProperty(propertyPath); @@ -421,7 +424,7 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro return domainObj.map(it -> { - PersistentPropertyAccessor accessor = property.getOwner().getPropertyAccessor(it); + PersistentPropertyAccessor accessor = property.getOwner().getPropertyAccessor(it); return handler.apply(new ReferencedProperty(property, accessor.getProperty(property), accessor)); }); } @@ -432,14 +435,14 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro final PersistentProperty property; final Class propertyType; final Object propertyValue; - final PersistentPropertyAccessor accessor; + final PersistentPropertyAccessor accessor; private ReferencedProperty(PersistentProperty property, Object propertyValue, - PersistentPropertyAccessor wrapper) { + PersistentPropertyAccessor accessor) { this.property = property; this.propertyValue = propertyValue; - this.accessor = wrapper; + this.accessor = accessor; this.propertyType = property.getActualType(); this.entity = repositories.getPersistentEntity(propertyType); } diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerAdapter.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerAdapter.java index b1b6cbbd8..816fde872 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerAdapter.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestHandlerAdapter.java @@ -33,19 +33,19 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl * @author Oliver Gierke */ public class RepositoryRestHandlerAdapter - extends org.springframework.hateoas.mvc.ResourceProcessorInvokingHandlerAdapter { + extends org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvokingHandlerAdapter { private final List argumentResolvers; /** * Creates a new {@link RepositoryRestHandlerAdapter} using the given {@link HandlerMethodArgumentResolver} and - * {@link org.springframework.hateoas.mvc.ResourceProcessorInvoker}. + * {@link org.springframework.hateoas.server.mvc.ResourceProcessorInvoker}. * * @param argumentResolvers must not be {@literal null}. * @param invoker must not be {@literal null}. */ public RepositoryRestHandlerAdapter(List argumentResolvers, - org.springframework.hateoas.mvc.ResourceProcessorInvoker invoker) { + org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvoker invoker) { super(invoker); this.argumentResolvers = argumentResolvers; @@ -53,7 +53,7 @@ public class RepositoryRestHandlerAdapter /* * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.ResourceProcessorInvokingHandlerAdapter#afterPropertiesSet() + * @see org.springframework.data.rest.webmvc.RepresentationModelProcessorInvokingHandlerAdapter#afterPropertiesSet() */ @Override public void afterPropertiesSet() { diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java index 08f73fd7c..e7fa38395 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java @@ -23,7 +23,6 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map.Entry; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; @@ -41,14 +40,14 @@ import org.springframework.data.rest.webmvc.support.RepositoryEntityLinks; import org.springframework.data.util.ClassTypeInformation; import org.springframework.data.util.TypeInformation; import org.springframework.data.web.PagedResourcesAssembler; -import org.springframework.hateoas.EntityLinks; +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.Link; import org.springframework.hateoas.Links; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.ResourceSupport; -import org.springframework.hateoas.Resources; -import org.springframework.hateoas.core.AnnotationAttribute; -import org.springframework.hateoas.core.MethodParameters; +import org.springframework.hateoas.RepresentationModel; +import org.springframework.hateoas.server.EntityLinks; +import org.springframework.hateoas.server.core.AnnotationAttribute; +import org.springframework.hateoas.server.core.MethodParameters; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -154,11 +153,9 @@ class RepositorySearchController extends AbstractRepositoryRestController { throw new ResourceNotFoundException(); } - RepositorySearchesResource result = new RepositorySearchesResource(resourceInformation.getDomainType()); - result.add(queryMethodLinks); - result.add(getDefaultSelfLink()); - - return result; + return new RepositorySearchesResource(resourceInformation.getDomainType()) // + .add(queryMethodLinks) // + .add(getDefaultSelfLink()); } /** @@ -187,7 +184,7 @@ class RepositorySearchController extends AbstractRepositoryRestController { MethodResourceMapping methodMapping = searchMappings.getExportedMethodMappingForPath(search); Class domainType = methodMapping.getReturnedDomainType(); - return toResource(result, assembler, domainType, Optional.empty(), headers, resourceInformation); + return toModel(result, assembler, domainType, Optional.empty(), headers, resourceInformation); } /** @@ -200,13 +197,13 @@ class RepositorySearchController extends AbstractRepositoryRestController { * @param baseLink can be {@literal null}. * @return */ - protected ResponseEntity toResource(Optional source, final PersistentEntityResourceAssembler assembler, + protected ResponseEntity toModel(Optional source, final PersistentEntityResourceAssembler assembler, Class domainType, Optional baseLink, HttpHeaders headers, RootResourceInformation information) { return source.map(it -> { if (it instanceof Iterable) { - return ResponseEntity.ok(toResources((Iterable) it, assembler, domainType, baseLink)); + return ResponseEntity.ok(toCollectionModel((Iterable) it, assembler, domainType, baseLink)); } else if (ClassUtils.isPrimitiveOrWrapper(it.getClass())) { return ResponseEntity.ok(it); } @@ -239,7 +236,7 @@ class RepositorySearchController extends AbstractRepositoryRestController { @ResponseBody @RequestMapping(value = BASE_MAPPING + "/{search}", method = RequestMethod.GET, // produces = { "application/x-spring-data-compact+json" }) - public ResourceSupport executeSearchCompact(RootResourceInformation resourceInformation, + public RepresentationModel executeSearchCompact(RootResourceInformation resourceInformation, @RequestHeader HttpHeaders headers, @RequestParam MultiValueMap parameters, @PathVariable String repository, @PathVariable String search, DefaultedPageable pageable, Sort sort, PersistentEntityResourceAssembler assembler) { @@ -248,28 +245,28 @@ class RepositorySearchController extends AbstractRepositoryRestController { Optional result = executeQueryMethod(resourceInformation.getInvoker(), parameters, method, pageable, sort, assembler); ResourceMetadata metadata = resourceInformation.getResourceMetadata(); - ResponseEntity entity = toResource(result, assembler, metadata.getDomainType(), Optional.empty(), headers, + ResponseEntity entity = toModel(result, assembler, metadata.getDomainType(), Optional.empty(), headers, resourceInformation); Object resource = entity.getBody(); List links = new ArrayList(); - if (resource instanceof Resources && ((Resources) resource).getContent() != null) { + if (resource instanceof CollectionModel && ((CollectionModel) resource).getContent() != null) { - for (Object obj : ((Resources) resource).getContent()) { - if (null != obj && obj instanceof Resource) { - Resource res = (Resource) obj; + for (Object obj : ((CollectionModel) resource).getContent()) { + if (null != obj && obj instanceof EntityModel) { + EntityModel res = (EntityModel) obj; links.add(resourceLink(resourceInformation, res)); } } - } else if (resource instanceof Resource) { + } else if (resource instanceof EntityModel) { - Resource res = (Resource) resource; + EntityModel res = (EntityModel) resource; links.add(resourceLink(resourceInformation, res)); } - return new Resources>(EMPTY_RESOURCE_LIST, links); + return new CollectionModel>(EMPTY_RESOURCE_LIST, links); } /** @@ -346,18 +343,17 @@ class RepositorySearchController extends AbstractRepositoryRestController { parameters.entrySet().forEach(entry -> - methodParameters.getParameter(entry.getKey()).ifPresent(parameter -> { + methodParameters.getParameter(entry.getKey()).ifPresent(parameter -> { - int parameterIndex = parameterList.indexOf(parameter); - TypeInformation domainType = parameterTypeInformations.get(parameterIndex).getActualType(); + int parameterIndex = parameterList.indexOf(parameter); + TypeInformation domainType = parameterTypeInformations.get(parameterIndex).getActualType(); - ResourceMetadata metadata = mappings.getMetadataFor(domainType.getType()); + ResourceMetadata metadata = mappings.getMetadataFor(domainType.getType()); - if (metadata != null && metadata.isExported()) { - result.put(parameter.getParameterName(), prepareUris(entry.getValue())); - } + if (metadata != null && metadata.isExported()) { + result.put(parameter.getParameterName(), prepareUris(entry.getValue())); } - )); + })); return invoker.invokeQueryMethod(method, result, pageable.getPageable(), sort); } diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchesResource.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchesResource.java index a7762ea8d..13c0be6a2 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchesResource.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchesResource.java @@ -15,8 +15,7 @@ */ package org.springframework.data.rest.webmvc; -import org.springframework.hateoas.ResourceProcessor; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.RepresentationModel; import org.springframework.util.Assert; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -27,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; * * @author Oliver Gierke */ -public class RepositorySearchesResource extends ResourceSupport { +public class RepositorySearchesResource extends RepresentationModel { private final Class domainType; diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceNotFoundException.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceNotFoundException.java index 860bcd72c..d5473abe6 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceNotFoundException.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceNotFoundException.java @@ -30,7 +30,7 @@ public class ResourceNotFoundException extends RuntimeException { private static final long serialVersionUID = 7992904489502842099L; public ResourceNotFoundException() { - this("Resource not found!"); + this("EntityRepresentationModel not found!"); } public ResourceNotFoundException(String message) { diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorHandlerMethodReturnValueHandler.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorHandlerMethodReturnValueHandler.java deleted file mode 100644 index a5f6ab5ee..000000000 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorHandlerMethodReturnValueHandler.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.webmvc; - -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - -import java.lang.reflect.Field; - -import org.springframework.core.MethodParameter; -import org.springframework.core.ResolvableType; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.ResourceProcessor; -import org.springframework.hateoas.ResourceSupport; -import org.springframework.hateoas.Resources; -import org.springframework.hateoas.mvc.HeaderLinksResponseEntity; -import org.springframework.http.HttpEntity; -import org.springframework.http.ResponseEntity; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.method.support.HandlerMethodReturnValueHandler; -import org.springframework.web.method.support.ModelAndViewContainer; - -/** - * {@link HandlerMethodReturnValueHandler} to post-process the objects returned from controller methods using the - * configured {@link ResourceProcessor}s. - * - * @author Oliver Gierke - * @deprecated use the same type from Spring HATEOAS, will be removed in 2.7. - */ -@Deprecated -@RequiredArgsConstructor -public class ResourceProcessorHandlerMethodReturnValueHandler implements HandlerMethodReturnValueHandler { - - static final ResolvableType RESOURCE_TYPE = ResolvableType.forClass(Resource.class); - static final ResolvableType RESOURCES_TYPE = ResolvableType.forClass(Resources.class); - private static final ResolvableType HTTP_ENTITY_TYPE = ResolvableType.forClass(HttpEntity.class); - - static final Field CONTENT_FIELD = ReflectionUtils.findField(Resources.class, "content"); - - static { - ReflectionUtils.makeAccessible(CONTENT_FIELD); - } - - private final @NonNull HandlerMethodReturnValueHandler delegate; - private final @NonNull ResourceProcessorInvoker invoker; - - private boolean rootLinksAsHeaders = false; - - /** - * @param rootLinksAsHeaders the rootLinksAsHeaders to set - */ - public void setRootLinksAsHeaders(boolean rootLinksAsHeaders) { - this.rootLinksAsHeaders = rootLinksAsHeaders; - } - - /* - * (non-Javadoc) - * @see org.springframework.web.method.support.HandlerMethodReturnValueHandler#supportsReturnType(org.springframework.core.MethodParameter) - */ - @Override - public boolean supportsReturnType(MethodParameter returnType) { - return delegate.supportsReturnType(returnType); - } - - /* - * (non-Javadoc) - * @see org.springframework.web.method.support.HandlerMethodReturnValueHandler#handleReturnValue(java.lang.Object, org.springframework.core.MethodParameter, org.springframework.web.method.support.ModelAndViewContainer, org.springframework.web.context.request.NativeWebRequest) - */ - @Override - public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, - NativeWebRequest webRequest) throws Exception { - - Object value = returnValue; - - if (returnValue instanceof HttpEntity) { - value = ((HttpEntity) returnValue).getBody(); - } - - // No post-processable type found - proceed with delegate - if (!ResourceSupport.class.isInstance(value)) { - delegate.handleReturnValue(returnValue, returnType, mavContainer, webRequest); - return; - } - - // We have a Resource or Resources - find suitable processors - ResolvableType targetType = ResolvableType.forMethodReturnType(returnType.getMethod()); - - // Unbox HttpEntity - if (HTTP_ENTITY_TYPE.isAssignableFrom(targetType)) { - targetType = targetType.getGeneric(0); - } - - ResolvableType returnValueType = ResolvableType.forClass(value.getClass()); - - // Returned value is actually of a more specific type, use this type information - if (!getRawType(targetType).equals(getRawType(returnValueType))) { - targetType = returnValueType; - } - - ResourceSupport result = invoker.invokeProcessorsFor((ResourceSupport) value, targetType); - delegate.handleReturnValue(rewrapResult(result, returnValue), returnType, mavContainer, webRequest); - } - - /** - * Re-wraps the result of the post-processing work into an {@link HttpEntity} or {@link ResponseEntity} if the - * original value was one of those two types. Copies headers and status code from the original value but uses the new - * body. - * - * @param newBody the post-processed value. - * @param originalValue the original input value. - * @return - */ - Object rewrapResult(ResourceSupport newBody, Object originalValue) { - - if (!(originalValue instanceof HttpEntity)) { - return newBody; - } - - HttpEntity entity = null; - - if (originalValue instanceof ResponseEntity) { - ResponseEntity source = (ResponseEntity) originalValue; - entity = new ResponseEntity(newBody, source.getHeaders(), source.getStatusCode()); - } else { - HttpEntity source = (HttpEntity) originalValue; - entity = new HttpEntity(newBody, source.getHeaders()); - } - - return addLinksToHeaderWrapper(entity); - } - - private HttpEntity addLinksToHeaderWrapper(HttpEntity entity) { - return rootLinksAsHeaders ? HeaderLinksResponseEntity.wrap(entity) : entity; - } - - private static Class getRawType(ResolvableType type) { - - Class rawType = type.getRawClass(); - return rawType == null ? Object.class : rawType; - } -} diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvoker.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvoker.java deleted file mode 100644 index 991f4445a..000000000 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvoker.java +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Copyright 2016-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.webmvc; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.springframework.core.Ordered; -import org.springframework.core.ResolvableType; -import org.springframework.core.annotation.AnnotationAwareOrderComparator; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.ResourceProcessor; -import org.springframework.hateoas.ResourceSupport; -import org.springframework.hateoas.Resources; -import org.springframework.hateoas.core.EmbeddedWrapper; -import org.springframework.util.Assert; -import org.springframework.util.ReflectionUtils; - -/** - * Component to easily invoke all {@link ResourceProcessor} instances registered for values of type - * {@link ResourceSupport}. - * - * @author Oliver Gierke - * @author Mark Paluch - * @since 2.5 - * @deprecated use the same type from Spring HATEOAS, will be removed in 2.7. - */ -@Deprecated -public class ResourceProcessorInvoker { - - private final List processors; - - /** - * Creates a new {@link ResourceProcessorInvoker} to consider the given {@link ResourceProcessor} to post-process the - * controller methods return value to before invoking the delegate. - * - * @param processors the {@link ResourceProcessor}s to be considered, must not be {@literal null}. - */ - public ResourceProcessorInvoker(Collection> processors) { - - Assert.notNull(processors, "ResourceProcessors must not be null!"); - - this.processors = new ArrayList(); - - for (ResourceProcessor processor : processors) { - - ResolvableType processorType = ResolvableType.forClass(ResourceProcessor.class, processor.getClass()); - Class rawType = processorType.getGeneric(0).resolve(); - - if (Resource.class.isAssignableFrom(rawType)) { - this.processors.add(new ResourceProcessorWrapper(processor)); - } else if (Resources.class.isAssignableFrom(rawType)) { - this.processors.add(new ResourcesProcessorWrapper(processor)); - } else { - this.processors.add(new DefaultProcessorWrapper(processor)); - } - } - - Collections.sort(this.processors, AnnotationAwareOrderComparator.INSTANCE); - } - - /** - * Invokes all {@link ResourceProcessor} instances registered for the type of the given value. - * - * @param value must not be {@literal null}. - * @return - */ - public T invokeProcessorsFor(T value) { - - Assert.notNull(value, "Value must not be null!"); - - return invokeProcessorsFor(value, ResolvableType.forClass(value.getClass())); - } - - /** - * Invokes all {@link ResourceProcessor} instances registered for the type of the given value and reference type. - * - * @param value must not be {@literal null}. - * @param referenceType must not be {@literal null}. - * @return - */ - @SuppressWarnings("unchecked") - public T invokeProcessorsFor(T value, ResolvableType referenceType) { - - Assert.notNull(value, "Value must not be null!"); - Assert.notNull(referenceType, "Reference type must not be null!"); - - // For Resources implementations, process elements first - if (ResourceProcessorHandlerMethodReturnValueHandler.RESOURCES_TYPE.isAssignableFrom(referenceType)) { - - Resources resources = (Resources) value; - ResolvableType elementTargetType = ResolvableType.forClass(Resources.class, referenceType.getRawClass()) - .getGeneric(0); - List result = new ArrayList(resources.getContent().size()); - - for (Object element : resources) { - - ResolvableType elementType = ResolvableType.forClass(element.getClass()); - - if (!getRawType(elementTargetType).equals(elementType.getRawClass())) { - elementTargetType = elementType; - } - - result.add(invokeProcessorsFor(element, elementTargetType)); - } - - ReflectionUtils.setField(ResourceProcessorHandlerMethodReturnValueHandler.CONTENT_FIELD, resources, result); - } - - return (T) invokeProcessorsFor((Object) value, referenceType); - } - - /** - * Invokes all registered {@link ResourceProcessor}s registered for the given {@link ResolvableType}. - * - * @param value the object to process - * @param type - * @return - */ - private Object invokeProcessorsFor(Object value, ResolvableType type) { - - Object currentValue = value; - - // Process actual value - for (ResourceProcessorInvoker.ProcessorWrapper wrapper : this.processors) { - if (wrapper.supports(type, currentValue)) { - currentValue = wrapper.invokeProcessor(currentValue); - } - } - - return currentValue; - } - - private static boolean isRawTypeAssignable(ResolvableType left, Class right) { - return getRawType(left).isAssignableFrom(right); - } - - private static Class getRawType(ResolvableType type) { - - Class rawType = type.getRawClass(); - return rawType == null ? Object.class : rawType; - } - - /** - * Interface to unify interaction with {@link ResourceProcessor}s. The {@link Ordered} rank should be determined by - * the underlying processor. - * - * @author Oliver Gierke - */ - private interface ProcessorWrapper extends Ordered { - - /** - * Returns whether the underlying processor supports the given {@link ResolvableType}. It might also additionally - * inspect the object that would eventually be handed to the processor. - * - * @param type the type of object to be post processed, will never be {@literal null}. - * @param value the object that would be passed into the processor eventually, can be {@literal null}. - * @return - */ - boolean supports(ResolvableType type, Object value); - - /** - * Performs the actual invocation of the processor. Implementations can be sure - * {@link #supports(ResolvableType, Object)} has been called before and returned {@literal true}. - * - * @param object - */ - Object invokeProcessor(Object object); - } - - /** - * Default implementation of {@link ProcessorWrapper} to generically deal with {@link ResourceSupport} types. - * - * @author Oliver Gierke - */ - private static class DefaultProcessorWrapper implements ResourceProcessorInvoker.ProcessorWrapper { - - private final ResourceProcessor processor; - private final ResolvableType targetType; - - /** - * Creates a new {@link DefaultProcessorWrapper} with the given {@link ResourceProcessor}. - * - * @param processor must not be {@literal null}. - */ - public DefaultProcessorWrapper(ResourceProcessor processor) { - - Assert.notNull(processor, "ResourceProcessor must not be null!"); - - this.processor = processor; - this.targetType = ResolvableType.forClass(ResourceProcessor.class, processor.getClass()).getGeneric(0); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.ResourceProcessorHandlerMethodReturnValueHandler.ProcessorWrapper#supports(org.springframework.core.ResolvableType, java.lang.Object) - */ - @Override - public boolean supports(ResolvableType type, Object value) { - return isRawTypeAssignable(targetType, getRawType(type)); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.ResourceProcessorHandlerMethodReturnValueHandler.PostProcessorWrapper#invokeProcessor(java.lang.Object) - */ - @Override - @SuppressWarnings("unchecked") - public Object invokeProcessor(Object object) { - return ((ResourceProcessor) processor).process((ResourceSupport) object); - } - - /* - * (non-Javadoc) - * @see org.springframework.core.Ordered#getOrder() - */ - @Override - public int getOrder() { - return CustomOrderAwareComparator.INSTANCE.getOrder(processor); - } - - /** - * Returns the target type the underlying {@link ResourceProcessor} wants to get invoked for. - * - * @return the targetType - */ - public ResolvableType getTargetType() { - return targetType; - } - } - - /** - * {@link ProcessorWrapper} to deal with {@link ResourceProcessor}s for {@link Resource}s. Will fall back to peeking - * into the {@link Resource}'s content for type resolution. - * - * @author Oliver Gierke - */ - private static class ResourceProcessorWrapper extends ResourceProcessorInvoker.DefaultProcessorWrapper { - - /** - * Creates a new {@link ResourceProcessorWrapper} for the given {@link ResourceProcessor}. - * - * @param processor must not be {@literal null}. - */ - public ResourceProcessorWrapper(ResourceProcessor processor) { - super(processor); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.ResourceProcessorHandlerMethodReturnValueHandler.DefaultProcessorWrapper#supports(org.springframework.core.ResolvableType, java.lang.Object) - */ - @Override - public boolean supports(ResolvableType type, Object value) { - - if (!ResourceProcessorHandlerMethodReturnValueHandler.RESOURCE_TYPE.isAssignableFrom(type)) { - return false; - } - - return super.supports(type, value) && isValueTypeMatch((Resource) value, getTargetType()); - } - - /** - * Returns whether the given {@link Resource} matches the given target {@link ResolvableType}. We inspect the - * {@link Resource}'s value to determine the match. - * - * @param resource - * @param target must not be {@literal null}. - * @return whether the given {@link Resource} can be assigned to the given target {@link ResolvableType} - */ - private static boolean isValueTypeMatch(Resource resource, ResolvableType target) { - - if (resource == null || !isRawTypeAssignable(target, resource.getClass())) { - return false; - } - - Object content = resource.getContent(); - - if (content == null) { - return false; - } - - ResolvableType type = findGenericType(target, Resource.class); - return type != null && type.getGeneric(0).isAssignableFrom(ResolvableType.forClass(content.getClass())); - } - - private static ResolvableType findGenericType(ResolvableType source, Class type) { - - Class rawType = getRawType(source); - - if (Object.class.equals(rawType)) { - return null; - } - - if (rawType.equals(type)) { - return source; - } - - return findGenericType(source.getSuperType(), type); - } - } - - /** - * {@link ProcessorWrapper} for {@link ResourceProcessor}s targeting {@link Resources}. Will peek into the content of - * the {@link Resources} for type matching decisions if needed. - * - * @author Oliver Gierke - */ - static class ResourcesProcessorWrapper extends ResourceProcessorInvoker.DefaultProcessorWrapper { - - /** - * Creates a new {@link ResourcesProcessorWrapper} for the given {@link ResourceProcessor}. - * - * @param processor must not be {@literal null}. - */ - public ResourcesProcessorWrapper(ResourceProcessor processor) { - super(processor); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.ResourceProcessorHandlerMethodReturnValueHandler.DefaultProcessorWrapper#supports(org.springframework.core.ResolvableType, java.lang.Object) - */ - @Override - public boolean supports(ResolvableType type, Object value) { - - if (!ResourceProcessorHandlerMethodReturnValueHandler.RESOURCES_TYPE.isAssignableFrom(type)) { - return false; - } - - return super.supports(type, value) && isValueTypeMatch((Resources) value, getTargetType()); - } - - /** - * Returns whether the given {@link Resources} instance matches the given {@link ResolvableType}. We predict this by - * inspecting the first element of the content of the {@link Resources}. - * - * @param resources the {@link Resources} to inspect. - * @param target that target {@link ResolvableType}. - * @return - */ - static boolean isValueTypeMatch(Resources resources, ResolvableType target) { - - if (resources == null) { - return false; - } - - Collection content = resources.getContent(); - - if (content.isEmpty()) { - return false; - } - - ResolvableType superType = null; - - for (Class resourcesType : Arrays.> asList(resources.getClass(), Resources.class)) { - - superType = ResolvableType.forClass(resourcesType, getRawType(target)); - - if (superType != null) { - break; - } - } - - if (superType == null) { - return false; - } - - Object element = content.iterator().next(); - ResolvableType resourceType = superType.getGeneric(0); - - if (element instanceof Resource) { - return ResourceProcessorWrapper.isValueTypeMatch((Resource) element, resourceType); - } else if (element instanceof EmbeddedWrapper) { - return isRawTypeAssignable(resourceType, ((EmbeddedWrapper) element).getRelTargetType()); - } - - return false; - } - } - - /** - * Helper extension of {@link AnnotationAwareOrderComparator} to make {@link #getOrder(Object)} public to allow it - * being used in a standalone fashion. - * - * @author Oliver Gierke - */ - private static class CustomOrderAwareComparator extends AnnotationAwareOrderComparator { - - public static ResourceProcessorInvoker.CustomOrderAwareComparator INSTANCE = new CustomOrderAwareComparator(); - - @Override - protected int getOrder(Object obj) { - return super.getOrder(obj); - } - } -} diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvokingHandlerAdapter.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvokingHandlerAdapter.java deleted file mode 100644 index 29c47e03a..000000000 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceProcessorInvokingHandlerAdapter.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.webmvc; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.hateoas.ResourceProcessor; -import org.springframework.util.Assert; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.method.support.HandlerMethodReturnValueHandler; -import org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite; -import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; - -/** - * Special {@link RequestMappingHandlerAdapter} that tweaks the {@link HandlerMethodReturnValueHandlerComposite} to be - * proxied by a {@link ResourceProcessorHandlerMethodReturnValueHandler} which will invoke the {@link ResourceProcessor} - * s found in the application context and eventually delegate to the originally configured - * {@link HandlerMethodReturnValueHandler}. - *

- * This is a separate component as it might make sense to deploy it in a standalone SpringMVC application to enable post - * processing. It would actually make most sense in Spring HATEOAS project. - * - * @author Oliver Gierke - * @author Phil Webb - * @author Mark Paluch - * @deprecated use the same type from Spring HATEOAS, will be removed in 2.7. - */ -@Deprecated -public class ResourceProcessorInvokingHandlerAdapter extends RequestMappingHandlerAdapter { - - private static final Method RETURN_VALUE_HANDLER_METHOD = ReflectionUtils - .findMethod(ResourceProcessorInvokingHandlerAdapter.class, "getReturnValueHandlers"); - - private final ResourceProcessorInvoker invoker; - - /** - * Creates a new {@link ResourceProcessorInvokingHandlerAdapter} with the given {@link ResourceProcessorInvoker}. - * - * @param invoker must not be {@literal null}. - */ - @Autowired(required = false) - public ResourceProcessorInvokingHandlerAdapter(ResourceProcessorInvoker invoker) { - - Assert.notNull(invoker, "ResourceProcessorInvoker must not be null!"); - this.invoker = invoker; - } - - /* - * (non-Javadoc) - * @see org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#afterPropertiesSet() - */ - @Override - public void afterPropertiesSet() { - - super.afterPropertiesSet(); - - // Retrieve actual handlers to use as delegate - HandlerMethodReturnValueHandlerComposite oldHandlers = getReturnValueHandlersComposite(); - - // Set up ResourceProcessingHandlerMethodResolver to delegate to originally configured ones - List newHandlers = new ArrayList(); - newHandlers.add(new ResourceProcessorHandlerMethodReturnValueHandler(oldHandlers, invoker)); - - // Configure the new handler to be used - this.setReturnValueHandlers(newHandlers); - } - - /** - * Gets a {@link HandlerMethodReturnValueHandlerComposite} for return handlers, dealing with API changes introduced in - * Spring 4.0. - * - * @return a HandlerMethodReturnValueHandlerComposite - */ - @SuppressWarnings("unchecked") - private HandlerMethodReturnValueHandlerComposite getReturnValueHandlersComposite() { - - Object handlers = ReflectionUtils.invokeMethod(RETURN_VALUE_HANDLER_METHOD, this); - - if (handlers instanceof HandlerMethodReturnValueHandlerComposite) { - return (HandlerMethodReturnValueHandlerComposite) handlers; - } - - return new HandlerMethodReturnValueHandlerComposite() - .addHandlers((List) handlers); - } -} diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceStatus.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceStatus.java index d437b4c12..d3b0477e5 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceStatus.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceStatus.java @@ -25,7 +25,7 @@ import java.util.function.Supplier; import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.rest.webmvc.support.ETag; -import org.springframework.hateoas.Resource; +import org.springframework.hateoas.EntityModel; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -98,9 +98,9 @@ class ResourceStatus { * {@literal null}. * @return */ - public ResponseEntity> toResponseEntity(Supplier supplier) { - return modified ? new ResponseEntity>(supplier.get(), headers, HttpStatus.OK) - : new ResponseEntity>(headers, HttpStatus.NOT_MODIFIED); + public ResponseEntity> toResponseEntity(Supplier supplier) { + return modified ? new ResponseEntity>(supplier.get(), headers, HttpStatus.OK) + : new ResponseEntity>(headers, HttpStatus.NOT_MODIFIED); } } } diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RootResourceInformation.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RootResourceInformation.java index 761aa69ac..9431d535e 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RootResourceInformation.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RootResourceInformation.java @@ -94,7 +94,7 @@ public class RootResourceInformation { throws HttpRequestMethodNotSupportedException, ResourceNotFoundException { Assert.notNull(httpMethod, "HTTP method must not be null!"); - Assert.notNull(resourceType, "Resource type must not be null!"); + Assert.notNull(resourceType, "EntityRepresentationModel type must not be null!"); if (!resourceMetadata.isExported()) { throw new ResourceNotFoundException(); @@ -121,7 +121,7 @@ public class RootResourceInformation { throws HttpRequestMethodNotSupportedException { Assert.notNull(httpMethod, "HTTP method must not be null!"); - Assert.notNull(property, "Resource type must not be null!"); + Assert.notNull(property, "EntityRepresentationModel type must not be null!"); if (!resourceMetadata.isExported()) { throw new ResourceNotFoundException(); diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/AlpsJsonHttpMessageConverter.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/AlpsJsonHttpMessageConverter.java index 17ce09738..eaa93cd0d 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/AlpsJsonHttpMessageConverter.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/AlpsJsonHttpMessageConverter.java @@ -23,7 +23,7 @@ import org.springframework.core.MethodParameter; import org.springframework.core.convert.converter.Converter; import org.springframework.data.rest.webmvc.RestMediaTypes; import org.springframework.data.rest.webmvc.RootResourceInformation; -import org.springframework.hateoas.alps.Alps; +import org.springframework.hateoas.mediatype.alps.Alps; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/RootResourceInformationToAlpsDescriptorConverter.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/RootResourceInformationToAlpsDescriptorConverter.java index 07d22d545..8cb31ee23 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/RootResourceInformationToAlpsDescriptorConverter.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/alps/RootResourceInformationToAlpsDescriptorConverter.java @@ -15,7 +15,7 @@ */ package org.springframework.data.rest.webmvc.alps; -import static org.springframework.hateoas.alps.Alps.*; +import static org.springframework.hateoas.mediatype.alps.Alps.*; import lombok.NonNull; import lombok.RequiredArgsConstructor; @@ -55,16 +55,16 @@ import org.springframework.data.rest.webmvc.RootResourceInformation; import org.springframework.data.rest.webmvc.json.EnumTranslator; import org.springframework.data.rest.webmvc.json.JacksonMetadata; import org.springframework.data.rest.webmvc.mapping.Associations; -import org.springframework.hateoas.EntityLinks; +import org.springframework.hateoas.server.EntityLinks; import org.springframework.hateoas.Link; import org.springframework.hateoas.LinkRelation; import org.springframework.hateoas.TemplateVariable; -import org.springframework.hateoas.alps.Alps; -import org.springframework.hateoas.alps.Descriptor; -import org.springframework.hateoas.alps.Descriptor.DescriptorBuilder; -import org.springframework.hateoas.alps.Doc; -import org.springframework.hateoas.alps.Format; -import org.springframework.hateoas.alps.Type; +import org.springframework.hateoas.mediatype.alps.Alps; +import org.springframework.hateoas.mediatype.alps.Descriptor; +import org.springframework.hateoas.mediatype.alps.Descriptor.DescriptorBuilder; +import org.springframework.hateoas.mediatype.alps.Doc; +import org.springframework.hateoas.mediatype.alps.Format; +import org.springframework.hateoas.mediatype.alps.Type; import org.springframework.http.HttpMethod; import org.springframework.util.StringUtils; diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/ArgumentResolverPagingAndSortingTemplateVariables.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/ArgumentResolverPagingAndSortingTemplateVariables.java index 0749c34a1..edf05f795 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/ArgumentResolverPagingAndSortingTemplateVariables.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/ArgumentResolverPagingAndSortingTemplateVariables.java @@ -84,7 +84,7 @@ class ArgumentResolverPagingAndSortingTemplateVariables implements PagingAndSort /* * (non-Javadoc) - * @see org.springframework.hateoas.mvc.UriComponentsContributor#enhance(org.springframework.web.util.UriComponentsBuilder, org.springframework.core.MethodParameter, java.lang.Object) + * @see org.springframework.hateoas.server.mvc.UriComponentsContributor#enhance(org.springframework.web.util.UriComponentsBuilder, org.springframework.core.MethodParameter, java.lang.Object) */ @Override public void enhance(UriComponentsBuilder builder, MethodParameter parameter, Object value) { @@ -98,7 +98,7 @@ class ArgumentResolverPagingAndSortingTemplateVariables implements PagingAndSort /* * (non-Javadoc) - * @see org.springframework.hateoas.mvc.UriComponentsContributor#supportsParameter(org.springframework.core.MethodParameter) + * @see org.springframework.hateoas.server.mvc.UriComponentsContributor#supportsParameter(org.springframework.core.MethodParameter) */ @Override public boolean supportsParameter(MethodParameter parameter) { diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java index 64c730a8e..7d1632421 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java @@ -97,18 +97,18 @@ import org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguratio import org.springframework.data.web.config.SpringDataJacksonConfiguration; import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.hateoas.MediaTypes; -import org.springframework.hateoas.RelProvider; -import org.springframework.hateoas.ResourceProcessor; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.server.RelProvider; +import org.springframework.hateoas.server.RepresentationModelProcessor; +import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.config.EnableHypermediaSupport; import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; -import org.springframework.hateoas.core.EvoInflectorRelProvider; -import org.springframework.hateoas.hal.CurieProvider; -import org.springframework.hateoas.hal.HalConfiguration; -import org.springframework.hateoas.hal.Jackson2HalModule; -import org.springframework.hateoas.hal.Jackson2HalModule.HalHandlerInstantiator; -import org.springframework.hateoas.mvc.ResourceProcessorInvoker; -import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; +import org.springframework.hateoas.server.core.EvoInflectorRelProvider; +import org.springframework.hateoas.mediatype.hal.CurieProvider; +import org.springframework.hateoas.mediatype.hal.HalConfiguration; +import org.springframework.hateoas.mediatype.hal.Jackson2HalModule; +import org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalHandlerInstantiator; +import org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvoker; +import org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; @@ -365,7 +365,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon } /** - * A special {@link org.springframework.hateoas.EntityLinks} implementation that takes repository and current + * A special {@link org.springframework.hateoas.server.EntityLinks} implementation that takes repository and current * configuration into account when generating links. * * @return @@ -525,17 +525,17 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon @Bean @SuppressWarnings("rawtypes") - public ResourceProcessorInvoker resourceProcessorInvoker() { + public RepresentationModelProcessorInvoker resourceProcessorInvoker() { - Collection beans = applicationContext.getBeansOfType(ResourceProcessor.class, false, false) + Collection beans = applicationContext.getBeansOfType(RepresentationModelProcessor.class, false, false) .values(); - List> processors = new ArrayList>(beans.size()); + List> processors = new ArrayList>(beans.size()); - for (ResourceProcessor bean : beans) { + for (RepresentationModelProcessor bean : beans) { processors.add(bean); } - return new ResourceProcessorInvoker(processors); + return new RepresentationModelProcessorInvoker(processors); } /** @@ -903,7 +903,7 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon * @param order the order for the {@link HttpMessageConverter}. */ public ResourceSupportHttpMessageConverter(int order) { - super(ResourceSupport.class); + super(RepresentationModel.class); this.order = order; } diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/convert/UriListHttpMessageConverter.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/convert/UriListHttpMessageConverter.java index fe5478be6..6fba82113 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/convert/UriListHttpMessageConverter.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/convert/UriListHttpMessageConverter.java @@ -25,8 +25,8 @@ import java.util.Scanner; import org.springframework.core.convert.converter.Converter; import org.springframework.hateoas.Link; -import org.springframework.hateoas.ResourceSupport; -import org.springframework.hateoas.Resources; +import org.springframework.hateoas.RepresentationModel; +import org.springframework.hateoas.CollectionModel; import org.springframework.http.HttpInputMessage; import org.springframework.http.HttpOutputMessage; import org.springframework.http.MediaType; @@ -43,7 +43,7 @@ import org.springframework.util.StringUtils; * @author Greg Turnquist * @author Oliver Gierke */ -public class UriListHttpMessageConverter implements HttpMessageConverter { +public class UriListHttpMessageConverter implements HttpMessageConverter { private static final List MEDIA_TYPES = new ArrayList(); @@ -60,7 +60,7 @@ public class UriListHttpMessageConverter implements HttpMessageConverter clazz, HttpInputMessage inputMessage) + public RepresentationModel read(Class clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { List links = new ArrayList(); @@ -107,7 +107,7 @@ public class UriListHttpMessageConverter implements HttpMessageConverter(Collections.emptyList(), links); + return new CollectionModel(Collections.emptyList(), links); } /* @@ -115,7 +115,7 @@ public class UriListHttpMessageConverter implements HttpMessageConverter resourceToRender = new Resource(resource.getContent(), links) { + EntityModel resourceToRender = new EntityModel(resource.getContent(), links) { @JsonUnwrapped public Iterable getEmbedded() { @@ -326,10 +326,10 @@ public class PersistentEntityJackson2Module extends SimpleModule { private final PersistentEntities entities; private final EmbeddedResourcesAssembler assembler; - private final ResourceProcessorInvoker invoker; + private final RepresentationModelProcessorInvoker invoker; public NestedEntitySerializer(PersistentEntities entities, EmbeddedResourcesAssembler assembler, - ResourceProcessorInvoker invoker) { + RepresentationModelProcessorInvoker invoker) { super(Object.class); this.entities = entities; @@ -350,7 +350,7 @@ public class PersistentEntityJackson2Module extends SimpleModule { List resources = new ArrayList(); for (Object element : source) { - resources.add(toResource(element)); + resources.add(toModel(element)); } provider.defaultSerializeValue(resources, gen); @@ -361,13 +361,13 @@ public class PersistentEntityJackson2Module extends SimpleModule { Map resources = CollectionFactory.createApproximateMap(value.getClass(), source.size()); for (Entry entry : source.entrySet()) { - resources.put(entry.getKey(), toResource(entry.getValue())); + resources.put(entry.getKey(), toModel(entry.getValue())); } provider.defaultSerializeValue(resources, gen); } else { - provider.defaultSerializeValue(toResource(value), gen); + provider.defaultSerializeValue(toModel(value), gen); } } @@ -381,7 +381,7 @@ public class PersistentEntityJackson2Module extends SimpleModule { serialize(value, gen, provider); } - private Resource toResource(Object value) { + private EntityModel toModel(Object value) { PersistentEntity entity = entities.getRequiredPersistentEntity(value.getClass()); @@ -540,7 +540,7 @@ public class PersistentEntityJackson2Module extends SimpleModule { private final LinkCollector collector; private final Associations associations; - private final ResourceProcessorInvoker invoker; + private final RepresentationModelProcessorInvoker invoker; private final boolean unwrapping; /** @@ -552,7 +552,7 @@ public class PersistentEntityJackson2Module extends SimpleModule { * @param invoker must not be {@literal null}. * @param unwrapping */ - private ProjectionSerializer(LinkCollector collector, Associations mappings, ResourceProcessorInvoker invoker, + private ProjectionSerializer(LinkCollector collector, Associations mappings, RepresentationModelProcessorInvoker invoker, boolean unwrapping) { super(TargetAware.class); @@ -578,7 +578,7 @@ public class PersistentEntityJackson2Module extends SimpleModule { provider.// findValueSerializer(ProjectionResource.class, null).// unwrappingSerializer(null).// - serialize(toResource(value), jgen, provider); + serialize(toModel(value), jgen, provider); if (!unwrapping) { jgen.writeEndObject(); @@ -609,19 +609,19 @@ public class PersistentEntityJackson2Module extends SimpleModule { * @param value must not be {@literal null}. * @return */ - private ProjectionResource toResource(TargetAware value) { + private ProjectionResource toModel(TargetAware value) { Object target = value.getTarget(); ResourceMetadata metadata = associations.getMetadataFor(value.getTargetClass()); Links links = metadata.isExported() ? collector.getLinksFor(target) : Links.NONE; - Resource resource = invoker.invokeProcessorsFor(new Resource(value, links)); + EntityModel resource = invoker.invokeProcessorsFor(new EntityModel(value, links)); return new ProjectionResource(resource.getContent(), resource.getLinks()); } } - static class ProjectionResource extends Resource { + static class ProjectionResource extends EntityModel { ProjectionResource(TargetAware projection, Iterable links) { super(new ProjectionResourceContent(projection, projection.getClass().getInterfaces()[0]), links); diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/mapping/NestedLinkCollectingAssociationHandler.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/mapping/NestedLinkCollectingAssociationHandler.java index 3f22cca58..9fe3d2157 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/mapping/NestedLinkCollectingAssociationHandler.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/mapping/NestedLinkCollectingAssociationHandler.java @@ -32,7 +32,7 @@ import org.springframework.data.mapping.context.PersistentEntities; import org.springframework.data.rest.core.mapping.ResourceMapping; import org.springframework.data.rest.core.mapping.ResourceMappings; import org.springframework.data.rest.core.mapping.ResourceMetadata; -import org.springframework.hateoas.EntityLinks; +import org.springframework.hateoas.server.EntityLinks; import org.springframework.hateoas.Link; /** @@ -68,7 +68,7 @@ public class NestedLinkCollectingAssociationHandler implements SimpleAssociation PersistentEntity entity = entities.getRequiredPersistentEntity(element.getClass()); IdentifierAccessor identifierAccessor = entity.getIdentifierAccessor(element); - links.add(entityLinks.linkForSingleResource(element.getClass(), identifierAccessor.getIdentifier()) + links.add(entityLinks.linkForItemResource(element.getClass(), identifierAccessor.getIdentifier()) .withRel(propertyMapping.getRel())); } @@ -77,7 +77,7 @@ public class NestedLinkCollectingAssociationHandler implements SimpleAssociation PersistentEntity entity = entities.getRequiredPersistentEntity(propertyValue.getClass()); IdentifierAccessor identifierAccessor = entity.getIdentifierAccessor(propertyValue); - links.add(entityLinks.linkForSingleResource(propertyValue.getClass(), identifierAccessor.getIdentifier()) + links.add(entityLinks.linkForItemResource(propertyValue.getClass(), identifierAccessor.getIdentifier()) .withRel(propertyMapping.getRel())); } } diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/PagingAndSortingTemplateVariables.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/PagingAndSortingTemplateVariables.java index 1aac9a98b..7884e26ff 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/PagingAndSortingTemplateVariables.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/PagingAndSortingTemplateVariables.java @@ -17,7 +17,7 @@ package org.springframework.data.rest.webmvc.support; import org.springframework.core.MethodParameter; import org.springframework.hateoas.TemplateVariables; -import org.springframework.hateoas.mvc.UriComponentsContributor; +import org.springframework.hateoas.server.mvc.UriComponentsContributor; import org.springframework.web.util.UriComponents; /** diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/PersistentEntityResourceProcessor.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/PersistentEntityResourceProcessor.java index 88d32ec2e..ea13f601a 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/PersistentEntityResourceProcessor.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/PersistentEntityResourceProcessor.java @@ -10,21 +10,21 @@ import org.springframework.data.repository.support.Repositories; import org.springframework.data.rest.webmvc.PersistentEntityResource; import org.springframework.data.util.ClassTypeInformation; import org.springframework.data.util.TypeInformation; -import org.springframework.hateoas.Resource; -import org.springframework.hateoas.ResourceProcessor; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.server.RepresentationModelProcessor; /** * @author Jon Brisbin */ -public class PersistentEntityResourceProcessor implements ResourceProcessor { +public class PersistentEntityResourceProcessor implements RepresentationModelProcessor { private final List resourceProcessors = new ArrayList(); @Autowired public PersistentEntityResourceProcessor(Repositories repositories, - List>> resourceProcessors) { + List>> resourceProcessors) { if (null != resourceProcessors) { - for (ResourceProcessor> rp : resourceProcessors) { + for (RepresentationModelProcessor> rp : resourceProcessors) { TypeInformation typeInfo = ClassTypeInformation.from(rp.getClass()); TypeInformation domainType = typeInfo.getTypeArguments().get(0); if (null != repositories.getPersistentEntity(domainType.getType())) { @@ -55,9 +55,9 @@ public class PersistentEntityResourceProcessor implements ResourceProcessor domainType; - final ResourceProcessor> resourceProcessor; + final RepresentationModelProcessor> resourceProcessor; - private DomainTypeResourceProcessor(Class domainType, ResourceProcessor> resourceProcessor) { + private DomainTypeResourceProcessor(Class domainType, RepresentationModelProcessor> resourceProcessor) { this.domainType = domainType; this.resourceProcessor = resourceProcessor; } diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinks.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinks.java index 05fa6cc48..8fd0d629c 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinks.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/RepositoryEntityLinks.java @@ -38,16 +38,16 @@ import org.springframework.data.rest.core.mapping.SearchResourceMappings; import org.springframework.data.rest.webmvc.BaseUri; import org.springframework.data.rest.webmvc.spi.BackendIdConverter; import org.springframework.data.rest.webmvc.spi.BackendIdConverter.DefaultIdConverter; -import org.springframework.hateoas.EntityLinks; +import org.springframework.hateoas.server.EntityLinks; import org.springframework.hateoas.Link; -import org.springframework.hateoas.LinkBuilder; +import org.springframework.hateoas.server.LinkBuilder; import org.springframework.hateoas.LinkRelation; import org.springframework.hateoas.Links; import org.springframework.hateoas.TemplateVariable; import org.springframework.hateoas.TemplateVariable.VariableType; import org.springframework.hateoas.TemplateVariables; import org.springframework.hateoas.UriTemplate; -import org.springframework.hateoas.core.AbstractEntityLinks; +import org.springframework.hateoas.server.core.AbstractEntityLinks; import org.springframework.plugin.core.PluginRegistry; import org.springframework.util.Assert; import org.springframework.web.util.UriComponents; @@ -80,7 +80,7 @@ public class RepositoryEntityLinks extends AbstractEntityLinks { /* * (non-Javadoc) - * @see org.springframework.hateoas.EntityLinks#linkFor(java.lang.Class) + * @see org.springframework.hateoas.server.EntityLinks#linkFor(java.lang.Class) */ @Override public LinkBuilder linkFor(Class type) { @@ -91,7 +91,7 @@ public class RepositoryEntityLinks extends AbstractEntityLinks { /* * (non-Javadoc) - * @see org.springframework.hateoas.EntityLinks#linkFor(java.lang.Class, java.lang.Object[]) + * @see org.springframework.hateoas.server.EntityLinks#linkFor(java.lang.Class, java.lang.Object[]) */ @Override public LinkBuilder linkFor(Class type, Object... parameters) { @@ -119,7 +119,7 @@ public class RepositoryEntityLinks extends AbstractEntityLinks { /* * (non-Javadoc) - * @see org.springframework.hateoas.EntityLinks#linkToCollectionResource(java.lang.Class) + * @see org.springframework.hateoas.server.EntityLinks#linkToCollectionResource(java.lang.Class) */ @Override public Link linkToCollectionResource(Class type) { @@ -128,10 +128,10 @@ public class RepositoryEntityLinks extends AbstractEntityLinks { /* * (non-Javadoc) - * @see org.springframework.hateoas.EntityLinks#linkToSingleResource(java.lang.Class, java.lang.Object) + * @see org.springframework.hateoas.server.EntityLinks#linkToItemResource(java.lang.Class, java.lang.Object) */ @Override - public Link linkToSingleResource(Class type, Object id) { + public Link linkToItemResource(Class type, Object id) { Assert.isInstanceOf(Serializable.class, id, "Id must be assignable to Serializable!"); diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/RepositoryLinkBuilder.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/RepositoryLinkBuilder.java index b59ef9433..2343d56bd 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/RepositoryLinkBuilder.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/RepositoryLinkBuilder.java @@ -24,8 +24,8 @@ import org.springframework.data.rest.core.mapping.ResourceMetadata; import org.springframework.data.rest.webmvc.BaseUri; import org.springframework.hateoas.Affordance; import org.springframework.hateoas.Link; -import org.springframework.hateoas.LinkBuilder; -import org.springframework.hateoas.core.LinkBuilderSupport; +import org.springframework.hateoas.server.LinkBuilder; +import org.springframework.hateoas.server.core.LinkBuilderSupport; import org.springframework.util.Assert; import org.springframework.web.util.UriComponentsBuilder; @@ -66,7 +66,7 @@ public class RepositoryLinkBuilder extends LinkBuilderSupport affordances) { @@ -95,7 +95,7 @@ public class RepositoryLinkBuilder extends LinkBuilderSupport entity; - Resources resources; + CollectionModel resources; Link link = new Link("http://localhost", "foo"); @Before @@ -50,7 +50,7 @@ public class PersistentEntityResourceUnitTests { EmbeddedWrappers wrappers = new EmbeddedWrappers(false); EmbeddedWrapper wrapper = wrappers.wrap("Embedded", LinkRelation.of("foo")); - this.resources = new Resources(Collections.singleton(wrapper)); + this.resources = new CollectionModel(Collections.singleton(wrapper)); } @Test(expected = IllegalArgumentException.class) // DATAREST-317 diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceControllerUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceControllerUnitTests.java index a021f8c30..5fafbcd71 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceControllerUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositoryPropertyReferenceControllerUnitTests.java @@ -45,7 +45,7 @@ import org.springframework.data.rest.core.mapping.ResourceType; import org.springframework.data.rest.core.mapping.SupportedHttpMethods; import org.springframework.data.web.PagedResourcesAssembler; import org.springframework.hateoas.Link; -import org.springframework.hateoas.Resources; +import org.springframework.hateoas.CollectionModel; import org.springframework.http.HttpMethod; /** @@ -84,7 +84,7 @@ public class RepositoryPropertyReferenceControllerUnitTests { doReturn(new Sample()).when(invoker).invokeSave(any(Object.class)); RootResourceInformation information = new RootResourceInformation(metadata, entity, invoker); - Resources request = new Resources(Collections.emptySet(), new Link("/reference/some-id")); + CollectionModel request = new CollectionModel(Collections.emptySet(), new Link("/reference/some-id")); controller.createPropertyReference(information, HttpMethod.POST, request, 4711, "references"); diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/ArgumentResolverPagingAndSortingTemplateVariablesUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/ArgumentResolverPagingAndSortingTemplateVariablesUnitTests.java index 00fc2724a..eb1a7d626 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/ArgumentResolverPagingAndSortingTemplateVariablesUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/ArgumentResolverPagingAndSortingTemplateVariablesUnitTests.java @@ -31,7 +31,7 @@ import org.springframework.data.domain.Sort; import org.springframework.data.rest.webmvc.support.PagingAndSortingTemplateVariables; import org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver; import org.springframework.data.web.HateoasSortHandlerMethodArgumentResolver; -import org.springframework.hateoas.mvc.UriComponentsContributor; +import org.springframework.hateoas.server.mvc.UriComponentsContributor; import org.springframework.web.util.UriComponentsBuilder; /** diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvConfigurationIntegrationTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvConfigurationIntegrationTests.java index ae45acd5e..5217fdf8a 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvConfigurationIntegrationTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvConfigurationIntegrationTests.java @@ -49,10 +49,10 @@ import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module; import org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver; import org.springframework.data.web.PageableHandlerMethodArgumentResolver; import org.springframework.format.datetime.DateFormatter; -import org.springframework.hateoas.LinkDiscoverers; +import org.springframework.hateoas.client.LinkDiscoverers; import org.springframework.hateoas.MediaTypes; -import org.springframework.hateoas.core.DefaultRelProvider; -import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; +import org.springframework.hateoas.server.core.DefaultRelProvider; +import org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2ModuleUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2ModuleUnitTests.java index c1c4e4d25..1d6b378ed 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2ModuleUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2ModuleUnitTests.java @@ -49,10 +49,10 @@ import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module. import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module.NestedEntitySerializer; import org.springframework.data.rest.webmvc.mapping.Associations; import org.springframework.data.rest.webmvc.support.ExcerptProjector; -import org.springframework.hateoas.EntityLinks; -import org.springframework.hateoas.ResourceProcessor; +import org.springframework.hateoas.server.EntityLinks; +import org.springframework.hateoas.server.RepresentationModelProcessor; import org.springframework.hateoas.UriTemplate; -import org.springframework.hateoas.mvc.ResourceProcessorInvoker; +import org.springframework.hateoas.server.mvc.RepresentationModelProcessorInvoker; import org.springframework.plugin.core.PluginRegistry; import com.fasterxml.jackson.annotation.JsonInclude; @@ -92,7 +92,7 @@ public class PersistentEntityJackson2ModuleUnitTests { this.persistentEntities = new PersistentEntities(Arrays.asList(mappingContext)); - ResourceProcessorInvoker invoker = new ResourceProcessorInvoker(Collections.> emptyList()); + RepresentationModelProcessorInvoker invoker = new RepresentationModelProcessorInvoker(Collections.> emptyList()); NestedEntitySerializer nestedEntitySerializer = new NestedEntitySerializer(persistentEntities, new EmbeddedResourcesAssembler(persistentEntities, associations, mock(ExcerptProjector.class)), invoker); diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/ProjectionJacksonIntegrationTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/ProjectionJacksonIntegrationTests.java index 2a18274a3..d96b50012 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/ProjectionJacksonIntegrationTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/ProjectionJacksonIntegrationTests.java @@ -23,10 +23,10 @@ import org.junit.Before; import org.junit.Test; import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.projection.SpelAwareProxyProjectionFactory; -import org.springframework.hateoas.Resources; -import org.springframework.hateoas.core.EvoInflectorRelProvider; -import org.springframework.hateoas.hal.Jackson2HalModule; -import org.springframework.hateoas.hal.Jackson2HalModule.HalHandlerInstantiator; +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.server.core.EvoInflectorRelProvider; +import org.springframework.hateoas.mediatype.hal.Jackson2HalModule; +import org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalHandlerInstantiator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.ObjectMapper; @@ -78,7 +78,7 @@ public class ProjectionJacksonIntegrationTests { customer.address = new Address(); CustomerProjection projection = factory.createProjection(CustomerProjection.class, customer); - Resources resources = new Resources(Arrays.asList(projection)); + CollectionModel resources = new CollectionModel(Arrays.asList(projection)); String result = mapper.writeValueAsString(resources);