diff --git a/pom.xml b/pom.xml
index 527776d30..8cc9817ea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,7 +35,6 @@
4.1.0.BUILD-SNAPSHOT
2.2.0.BUILD-SNAPSHOT
2.2.0.BUILD-SNAPSHOT
- 0.25.0.RELEASE
5.2.17.Final
1.1.0
diff --git a/spring-data-rest-core/pom.xml b/spring-data-rest-core/pom.xml
index ff3116b07..5ab0ad2b2 100644
--- a/spring-data-rest-core/pom.xml
+++ b/spring-data-rest-core/pom.xml
@@ -16,7 +16,7 @@
- 1.2.0.RELEASE
+ 2.0.0.BUILD-SNAPSHOT
1.2.2
spring.data.rest.core
${basedir}/..
diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/util/Java8PluginRegistry.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/util/Java8PluginRegistry.java
index 42ca48117..0b134bfa8 100644
--- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/util/Java8PluginRegistry.java
+++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/util/Java8PluginRegistry.java
@@ -46,7 +46,7 @@ public class Java8PluginRegistry, S> {
}
public Optional getPluginFor(S delimiter) {
- return Optional.ofNullable(registry.getPluginFor(delimiter));
+ return registry.getPluginFor(delimiter);
}
public T getPluginOrDefaultFor(S delimiter, T fallback) {
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 64e4c3bf7..2af3fc50c 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
@@ -83,7 +83,7 @@ public class ResourceTester {
private final Link assertHasLinkMatching(String rel, Matcher hrefMatcher) {
- Link link = resource.getLink(rel);
+ Link link = resource.getRequiredLink(rel);
assertThat("Expected link with rel '" + rel + "' but didn't find it in " + resource.getLinks(), link,
is(notNullValue()));
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 85e8ee387..a76043ae7 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
@@ -99,7 +99,7 @@ public class RepositoryEntityLinksIntegrationTests extends AbstractControllerInt
assertThat(links.hasLink("firstname")).isTrue();
- Link firstnameLink = links.getLink("firstname");
+ Link firstnameLink = links.getLink("firstname").orElse(null);
assertThat(firstnameLink.isTemplated()).isTrue();
assertThat(firstnameLink.getVariableNames()).contains("page", "size");
}
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 cb55fa5e8..fa8c77633 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
@@ -68,7 +68,7 @@ public class PersistentEntityResourceAssemblerIntegrationTests extends AbstractC
Links links = new Links(resource.getLinks());
assertThat(links).hasSize(2);
- assertThat(links.getLink("self").getVariables()).isEmpty();
- assertThat(links.getLink("user").getVariableNames()).contains("projection");
+ assertThat(links.getLink("self").orElseThrow(() -> new RuntimeException("Unable to find 'self' link")).getVariables()).isEmpty();
+ assertThat(links.getLink("user").orElseThrow(() -> new RuntimeException("Unable to find 'user' link")).getVariableNames()).contains("projection");
}
}
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 56972f4fa..0e7924ec8 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
@@ -63,7 +63,7 @@ class AbstractRepositoryRestController {
ResourceMetadata repoMapping = resourceLink.getResourceMetadata();
- Link selfLink = resource.getLink("self");
+ Link selfLink = resource.getRequiredLink(Link.REL_SELF);
String rel = repoMapping.getItemResourceRel();
return new Link(selfLink.getHref(), rel);
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 3e1b8038f..b58a8808f 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
@@ -73,7 +73,7 @@ public class PersistentEntityResourceAssembler implements ResourceAssembler(resource, HttpStatus.OK);
+ return new ResponseEntity<>(resource, HttpStatus.OK);
}
}
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 5bb64c83a..e2893de61 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
@@ -499,7 +499,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem
*/
private void addLocationHeader(HttpHeaders headers, PersistentEntityResourceAssembler assembler, Object source) {
- String selfLink = assembler.getSelfLinkFor(source).getHref();
+ String selfLink = assembler.getExpandedSelfLink(source).getHref();
headers.setLocation(new UriTemplate(selfLink).expand());
}
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 fc46199d6..f7bd9b9ed 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
@@ -134,11 +134,11 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro
} else {
PersistentEntityResource resource = assembler.toResource(it);
- headers.set("Content-Location", resource.getId().getHref());
+ headers.set("Content-Location", resource.getRequiredLink(Link.REL_SELF).getHref());
return resource;
}
- }).orElseThrow(() -> new ResourceNotFoundException());
+ }).orElseThrow(ResourceNotFoundException::new);
return ControllerUtils.toResponseEntity(HttpStatus.OK, headers, //
doWithReferencedProperty(repoRequest, id, property, handler, HttpMethod.GET));
@@ -187,7 +187,7 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro
if (propertyId.equals(accessor1.getIdentifier().toString())) {
PersistentEntityResource resource1 = assembler.toResource(obj);
- headers.set("Content-Location", resource1.getId().getHref());
+ headers.set("Content-Location", resource1.getRequiredLink(Link.REL_SELF).getHref());
return resource1;
}
}
@@ -200,18 +200,18 @@ class RepositoryPropertyReferenceController extends AbstractRepositoryRestContro
if (propertyId.equals(accessor2.getIdentifier().toString())) {
PersistentEntityResource resource2 = assembler.toResource(entry.getValue());
- headers.set("Content-Location", resource2.getId().getHref());
+ headers.set("Content-Location", resource2.getRequiredLink(Link.REL_SELF).getHref());
return resource2;
}
}
} else {
- return new Resource