#514 - Prepare upgrade to Spring Data release train Moore.
Upgrade to latest versions of Spring HATOEAS and Spring Plugin.
This commit is contained in:
committed by
Oliver Drotbohm
parent
e1a739a3d6
commit
fb8dccd9d4
@@ -16,7 +16,7 @@
|
||||
package example.springdata.rest.uris;
|
||||
|
||||
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
|
||||
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter;
|
||||
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -25,16 +25,16 @@ import org.springframework.stereotype.Component;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Component
|
||||
public class SpringDataRestCustomization extends RepositoryRestConfigurerAdapter {
|
||||
public class SpringDataRestCustomization implements RepositoryRestConfigurer {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter#configureRepositoryRestConfiguration(org.springframework.data.rest.core.config.RepositoryRestConfiguration)
|
||||
* @see org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer#configureRepositoryRestConfiguration(org.springframework.data.rest.core.config.RepositoryRestConfiguration)
|
||||
*/
|
||||
@Override
|
||||
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
|
||||
|
||||
config.withEntityLookup().//
|
||||
forRepository(UserRepository.class, User::getUsername, UserRepository::findByUsername);
|
||||
config.withEntityLookup() //
|
||||
.forRepository(UserRepository.class, User::getUsername, UserRepository::findByUsername);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package example.springdata.rest.uris;
|
||||
|
||||
import lombok.Value;
|
||||
import lombok.experimental.NonFinal;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -26,6 +27,7 @@ import org.springframework.data.annotation.Id;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@NonFinal
|
||||
@Value
|
||||
public class User {
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.data.rest.core.support.EntityLookupSupport;
|
||||
/**
|
||||
* Custom {@link EntityLookup} to replace the usage of the database identifier in item resource URIs with the username
|
||||
* property of the {@link User}. This one is not really used out of the box as it's not a Spring bean. It's just a
|
||||
* sample of how to deploy a customization in non-Java 8 environments which can't use the fluent API in use in
|
||||
* sample of how to deploy a customization in pre-Java 8 environments which can't use the fluent API in use in
|
||||
* {@link SpringDataRestCustomization}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
@@ -54,4 +54,13 @@ public class UserEntityLookup extends EntityLookupSupport<User> {
|
||||
public Optional<User> lookupEntity(Object id) {
|
||||
return repository.findByUsername(id.toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.rest.core.support.EntityLookup#getLookupProperty()
|
||||
*/
|
||||
@Override
|
||||
public Optional<String> getLookupProperty() {
|
||||
return Optional.of("username");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user