Commit Graph

207 Commits

Author SHA1 Message Date
Oliver Gierke
9c9d125d78 DATAREST-1177 - DefaultExposureAwareCrudMethods now caches results. 2018-01-24 11:06:25 +01:00
Oliver Gierke
a10aa934b7 DATAREST-1176 - Repository method exposure can now be controlled via RepositoryRestConfiguration.
The default exposure of repository methods is now controlled via RepositoryRestConfiguration.setExposeRepositoryMethodsByDefault(…). That allows us to remove the additional API from RepositoryDetectionStrategy as the mere detection is an orthogonal topic.

Also added RepositoryRestConfiguration.disableDefaultExposure() to set the RepositoryDetectionStategy to ANNOTATED and disables default method exposure in one go. That can be exposed via a Spring Boot configuration property downstream.
2018-01-18 18:41:07 +01:00
Oliver Gierke
6b61d2b026 DATAREST-1176 - Polishing.
Moved the flag to decide whether to expose repository methods by default to the RepositoryDetectionStrategy interface, so that it can be directly accessed and the test on the particular enum value is not needed anymore and thus also not duplicated into different parts of the codebase.

Added more tests to actually verify behavior on CrudMethodsSupportedHttpMethods. DefaultExposureAwareCrudMethods uses @RequiredArgumentConstructor again.
2018-01-18 18:41:07 +01:00
Tobias Weiß
5172f89281 DATAREST-1176 - Add explicitly method annotated detection strategy 2018-01-18 18:41:07 +01:00
Mark Paluch
5d9dbf1823 DATAREST-1170 - Update copyright years to 2018. 2018-01-09 08:44:14 +01:00
Oliver Gierke
1ebdeb9589 DATAREST-1163 - ValidationErrors now properly looks up null values.
The field value lookup in ValidationErrors previously threw a NotReadablePropertyException in case a property value was null as we incorrectly piped the null value into an Optional in turn. We now eagerly reject the property if we can't find a PersistentProperty in the metamodel to avoid this.
2017-11-29 10:28:26 +01:00
Mark Paluch
127640dd14 DATAREST-1129 - Prepare next development iteration. 2017-10-02 11:37:22 +02:00
Mark Paluch
ac2cbfcbc5 DATAREST-1129 - Release version 3.0 GA (Kay). 2017-10-02 11:10:23 +02:00
Mark Paluch
a315e054ba DATAREST-1135 - Added explicit automatic module name for JDK 9. 2017-09-21 14:11:02 +02:00
Oliver Gierke
8e16a9553f DATAREST-1112 - Prepare next development iteration. 2017-09-11 17:40:19 +02:00
Oliver Gierke
c3dc9ebfaf DATAREST-1112 - Release version 3.0 RC3 (Kay). 2017-09-11 17:24:45 +02:00
Oliver Gierke
2a8eb44cc9 DATAREST-1111 - Prepare next development iteration. 2017-07-25 16:10:35 +02:00
Oliver Gierke
ccc5b228cd DATAREST-1111 - Release version 3.0 RC2 (Kay). 2017-07-25 15:34:24 +02:00
Oliver Gierke
59a9d4d7df DATAREST-1093 - Prepare next development iteration. 2017-07-25 10:00:06 +02:00
Oliver Gierke
e54f908218 DATAREST-1093 - Release version 3.0 RC1 (Kay). 2017-07-25 09:48:49 +02:00
Oliver Gierke
182d32b715 DATAREST-1075 - AnnotatedEventHandlerInvoker skips methods introduced by proxy.
Removed now unused Methods deprecated in Ingalls / Hopper.
2017-07-06 13:28:46 +02:00
Oliver Gierke
2ad963074c DATAREST-1104 - Adapt to API changes in mapping subsystem. 2017-07-04 15:27:54 +02:00
Mark Paluch
b62c950b4a DATAREST-1071 - Prepare next development iteration. 2017-06-14 17:14:07 +02:00
Mark Paluch
1c5d3b4c76 DATAREST-1071 - Release version 3.0 M4 (Kay). 2017-06-14 17:03:48 +02:00
Oliver Gierke
87790ccb18 DATAREST-1079 - Upgraded to EvoInflector 1.2.2. 2017-05-18 14:52:20 +02:00
Oliver Gierke
e4f34aaa67 DATAREST-1076 - Expose constructor that takes RelProvider of RepositoryResourceMappings.
We now expose the constructor that takes a RelProvider in RepositoryResourceMappings so that clients can tweak the default relation names. Changed the order of constructor parameters of (previously) non-public constructors for consistency.

The RelProvider to be used with the mappings can now be configured via RepositoryRestConfiguration and defaults to the EvoInflector based one.
2017-05-18 14:49:44 +02:00
Mark Paluch
793c09270d DATAREST-1052 - Prepare next development iteration. 2017-05-09 11:34:41 +02:00
Mark Paluch
edaf6197e2 DATAREST-1052 - Release version 3.0 M3 (Kay). 2017-05-09 11:23:00 +02:00
Oliver Gierke
3b0c73f109 DATAREST-1067 - EntityLookup.lookupEntity(…) now returns Optional<T>. 2017-05-04 23:56:40 +02:00
Oliver Gierke
f906695e7a DATAREST-1064 - Adapt to API changes in repository interfaces.
Additional cleanups in QuerydslAwareRootResourceInformationHandlerMethodArgumentResolver to make sure a QuerydslRepositoryInvokerAdapter is only applied if the QuerydslPredicateBuilder actually exposes a predicate. Extracted a couple of methods to make sure the mapping pipeline reads nicely.
2017-05-03 18:10:27 +02:00
Oliver Gierke
680d84fe4e DATAREST-946 - Prepare next development iteration. 2017-04-04 22:08:15 +02:00
Oliver Gierke
fceb36ff71 DATAREST-946 - Release version 3.0 M2 (Kay). 2017-04-04 21:12:35 +02:00
Oliver Gierke
b9957d1a6c DATAREST-1008 - Adapt to API changes in Spring Data Commons, Java 8 upgrades and Mockito 2.7. 2017-03-24 11:02:54 +01:00
Oliver Gierke
7295535d16 DATAREST-1018 - Prevent NullPointerException in UriToEntityConverter.
In case PersistentEntities exposes a managed type whose raw type currently doesn't have a PersistentEntity registered, the constructor of UriToEntityConverter ran into a NullPointerException.

We now explicitly check for null and skip those types.

Filed DATAREST-1021 for further improvements in the 3.0 time frame.
2017-03-07 14:50:44 +01:00
Mark Paluch
b06f8664f1 DATAREST-992 - Remove references to Assert single-arg methods.
Replace references to Assert single-arg methods with references to methods accepting the test object and message.

Related ticket: SPR-15196.
2017-02-01 13:25:13 +01:00
Oliver Gierke
74cc5551a5 DATAREST-983 - AnnotatedEventHandlerInvoker now resolves generic handler method argument.
We now resolve the handler method argument type of an annotated repository event handler against the concrete handler type to make sure generics are resolved properly.
2017-01-24 16:57:53 +01:00
Oliver Gierke
2b9c7847b4 DATAREST-970 - AnnotationEventHandlerInvoker now considers order of event handler methods.
We now make sure that an @Order annotation on annotated event handler methods are considered and the methods are invoked in the defined order.

Non-annotation-based event handlers don't suffer from the same problem as they're ApplicationListener instances directly so that the container will enforce the correct ordering in case @Order is used or Ordered is implemented.

Some cleanup in EventHandlerMethod.

Original pull request: #248.
2017-01-19 15:09:56 +01:00
Mark Paluch
6bb989018c DATAREST-978 - Migrate ticket references in test code to Spring Framework style. 2017-01-13 10:09:53 +01:00
Oliver Gierke
83899bb42a DATAREST-793 - RepositoryRestConfiguration's setters return this consistently.
Adapted the return type of setter methods in RepositoryRestConfiguration to consistently return the current instance to allow call chaining.
2016-12-12 17:00:05 +01:00
Oliver Gierke
aa7eec4683 DATAREST-835 - Search resources returning a single resource now get and consider ETag and Last-Modified headers.
We now interpret If-None-Match and If-Modified-Since headers on requests to resources backed by query methods returning a single instance only. This allows clients to optimize GET requests to those resources to save bandwidth.
2016-12-08 21:35:37 +01:00
Oliver Gierke
42378ab34d DATAREST-957 - Polish most critical Sonar warnings.
Fixed broken equals(…) in ProjectionDefinition. Switched to iterating over Map's entry set instead of the keys. Made UriAwareHttpServletRequest static.
2016-12-08 10:12:31 +01:00
Oliver Gierke
03aa65890e DATAREST-934 - Prepare next development iteration. 2016-11-23 10:59:09 +01:00
Oliver Gierke
4e8771eee8 DATAREST-934 - Release version 3.0 M1 (Kay). 2016-11-23 10:35:48 +01:00
Oliver Gierke
8327b6f4ab DATAREST-935 - Prepare 3.0 development.
Upgraded version numbers and dependencies to Spring Data build parent, Commons and store modules. Fixed a compiler issue in DomainObjectReader.
2016-11-18 16:13:54 +01:00
Oliver Gierke
40bb8e8e6c DATAREST-573 - Polishing.
Removed RepositoryRestConfiguration.addCorsMapping(…) as we currently don't have any other shortcut methods for configuration like this.

Tweaked the setup of (now Repository)CorsConfigurationAccessor to be created earlier so that we avoid recreation for every lookup. Introduced a NoOpStringValueResolver to be used by default so that we don't need to deal with the case of the resolver being null at the end of the call chain. Replaced constructor of RepositoryCorsConfigurationAccessor with corresponding Lombok annotation.

Updated reference documentation accordingly.

Original pull request: #233.
2016-10-28 14:19:26 +02:00
Mark Paluch
a3870ca528 DATAREST-573 - Add support for new CORS configuration mechanisms introduced in Spring 4.2.
We now support CORS configuration mechanisms introduced in Spring 4.2. CORS can be configured on multiple levels: Repository interface, Repository REST controller and global level. Spring Data REST CORS configuration is isolated so Spring Web MVC'S CORS configuration does not apply to Spring Data REST resources.

 Multiple configuration sources are merged so different aspects of CORS can be configured in separate locations.

@CrossOrigin
interface PersonRepository extends CrudRepository<Person, Long> {}

@RepositoryRestController
@RequestMapping("/person")
public class PersonController {

	@CrossOrigin(maxAge = 3600)
	@RequestMapping(method = RequestMethod.GET, "/xml/{id}", produces = MediaType.APPLICATION_XML_VALUE)
	public Person retrieve(@PathVariable Long id) {
		// ...
	}
}

@Component
public class SpringDataRestCustomization extends RepositoryRestConfigurerAdapter {

  @Override
  public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {

    config.addCorsMapping("/person/**")
        .allowedOrigins("http://domain2.com")
        .allowedMethods("PUT", "DELETE")
        .allowedHeaders("header1", "header2", "header3")
        .exposedHeaders("header1", "header2")
        .allowCredentials(false).maxAge(3600);
  }
}
2016-10-28 14:19:26 +02:00
Oliver Trosien
d6caac122e DATAREST-898 - Fix typo in EntityLookupConfiguration assertion message.
Original pull request: #228.
2016-09-19 15:40:56 +02:00
Oliver Gierke
eb630ef273 DATAREST-803 - Prepare next development iteration. 2016-07-27 14:32:36 +02:00
Oliver Gierke
eaca77051a DATAREST-803 - Release version 2.6 M1 (Ingalls). 2016-07-27 13:52:12 +02:00
Oliver Gierke
f2f9564882 DATAREST-825 - Fixed exposure of DELETE HTTP method if findOne(…) is not exposed.
Previously our support for the HTTP DELETE method on item resources was requiring a repository's findOne(…) method to be available and exposed. However, the latter might not be desirable as the support of GET and HEAD requests for item resources depends on that.

We now changed that to only checking that a findOne(…) method is declared on the repository as the implementation of RepositoryEntityController.deleteItemResource(…) requires it to be present to be able to trigger the events that intercept deletes for a particular type.
2016-05-18 13:43:17 +02:00
Oliver Gierke
127f1a846f DATAREST-801 - Improved nested value handling in ValidationErrors.
We now correctly handle nested values by manually traversing the potentially nested property path, creating a PropertyAccessor for each nesting step considering the property access settings defined in the mapping metadata.
2016-04-14 21:34:37 +02:00
Oliver Gierke
e18fe00ea6 DATAREST-790 - Prepare next development iteration. 2016-04-06 16:36:59 +02:00
Oliver Gierke
c49a29a247 DATAREST-790 - Release version 2.5 GA (Hopper). 2016-04-06 16:35:59 +02:00
Oliver Gierke
b530cbe471 DATAREST-798 - Fixed invalid implementation of ValidationErrors.
Changed the implementation of ValidationErrors to be based on AbstractBeanPropertyBindingResult to consider the nesting implemented in superclasses and using a PersistentPropertyAccessor to lookup the property values.

ValidatingRepositoryEventListener now uses this implementation if a PersistentEntity can be obtained for the type under consideration, falling back to a DirectFieldBindingResult otherwise.
2016-04-04 15:12:33 +02:00
Oliver Gierke
05c723fe50 DATAREST-782 - Prepare next development iteration. 2016-03-18 11:15:51 +01:00