Commit Graph

116 Commits

Author SHA1 Message Date
Oliver Gierke
55fb0e86c1 DATACMNS-40 - Adapted renaming ResourceProcessor.{enrich(…)->process(…)}. 2012-08-27 19:08:50 +02:00
Oliver Gierke
a84f8f66da DATACMNS-40 - Back to ResourceProcessors.
Using ResourceProcessors again now as some kind of middle ground between the two former design ideas. We use a value returning callback now to allow manipulating the ResourceSupport instance in its entirety. This enables implementations to be either mutable or immutable. The ResourceProcessor interface is a little less flexible than in the first iteration as we require the same type to be returned.
2012-08-24 21:57:42 +02:00
Oliver Gierke
7fdeefec52 DATAREST-40 - Added copy constructor to ease setup of HandlerAdapter.
ResourceEnricherInvokingHandlerAdapter now has a copy constructor to
allow setting it up from a default RequestMappingHandlerAdapter. The
reason we introduce this is that WebMvcConfigurationSupport unfortunately
does not allow customizing the handler adapter class to be used as its
instantiations is buried in a method with more setup code. With the copy
constructor introduced one can simply take the configured instance
WebMvcConfigurationSupport provides and pipe it into the custom
ResourceEnricherInvokingHandlerAdapter.
2012-08-23 12:35:45 +02:00
Oliver Gierke
e3049fe9fb DATAREST-40 - Moved to ResourceEnricherInterface.
Dropped usage of separate interface for ResourceProcessor and
ResourcesProcessor and go with general ResourceEnricher interface. The
custom HandlerAdapter now also invokes enrichers for Resources' content
elements before invoking enrichers for the Resources instance itself.
2012-08-23 11:13:00 +02:00
Jon Brisbin
ca907e146c Merge pull request #34 from SpringSource/DATACMNS-40
DATAREST-40 - General purpose post-processing mechanism for resources.
2012-08-22 07:42:25 -07:00
Oliver Gierke
ed9bb157c7 DATAREST-40 - General purpose post-processing mechanism for resources.
This commit implements the components described in DATAREST-40. The core
of it is the ResourceProcessingHandlerMethodReturnValueHandler. It gets 
ResourceProcessor and ResourcesProcessor instances handed into its 
constructor and selects the ones that need to be invoked in the calls to
handleReturnValue(…). In this process it does a variety of generics 
checks to ensure only the correct post-processors. To do so it inspects 
the controller method's return type, the object value type as well as 
the returned value potentially.

Assume we have a specialized Resource type 
StringResource extends Resource<String>. Beyond that we have a 
ResourceProcessor<Resource<String>> registered. Here's the decision 
matrix:

Return type					Returned type		What get's used?
Resource<?>					Resource<String>	object value inspected (Resource.getContent())
Resource<String>			Resource<String>	method return type
Resource<String>			StringResource		object value type as it's more specialized
StringResource				StringResource		method return type
Resource<?>					Resource<Long>		no invocation, object value doesn't match
Resource<? extends Number>	Resource<Long>		no invocation, object value doesn't match
Resource<Long>				Resource<Long>		no invocation, object value doesn't match

This works exactly the same for Resources returned. We peek into the 
collection returned by getContent() in case return value inspection is 
needed for type matches. If the collection is empty we don't match. The 
same applies to null values returned.

The second component added is the ResourcePostProcessorInvokingHandlerAdapter 
which customizes the setup of a RequestMappingHandlerAdapter by fronting 
the current configuration with the 
ResourceProcessingHandlerMethodReturnValueHandler to let it intercept
the handling and potentially call the post-processors.

Upgraded to snapshots of Spring Data Commons until we get to the next 
release and added Mockito as dependency.
2012-08-22 16:29:26 +02:00
Jon Brisbin
9069774dc5 #32: Fix for bug triggered by including Accept: */* header. 2012-08-20 16:47:00 -05:00
Jon Brisbin
3aa8905b15 Added configuration property for domain type to repository mappings. Also improved the post-processing support, though I think there's still some room for tweaking. 2012-08-20 15:06:15 -05:00
Jon Brisbin
2000d07b32 Introduced a MethodParameterConversionService to help convert query parameters that might be annotated with specific converters. 2012-08-20 08:23:58 -05:00
Jon Brisbin
349c3b9777 Missed checking for non-optional relationship on DELETE a singular relationship. Now works as it's supposed to. 2012-08-17 15:07:45 -05:00
Jon Brisbin
023ab6b885 Fix problem with the ConversionService not being sufficiently checked for converters when reading query parameters, requiring an alternative mechanism for doing parameter conversion. 2012-08-17 14:39:34 -05:00
Jon Brisbin
b9b6a8fe92 DATAREST-39: Modified the DELETEing of links so that an attempt to delete a required relationship will result in a 405 Method Not Allowed. Had to change the entities and tests to accommodate the new required relationship on the Address entity, which pingponged into a number of changes. 2012-08-17 13:37:26 -05:00
Jon Brisbin
2dd0511f8f #28, #29: Support for nested objects as links in the JSON representation. 2012-08-17 08:46:25 -05:00
Jon Brisbin
3da1a241e0 DATAREST-38: Adding self link to related entity representation in addition to providing the Content-Location header. 2012-08-16 07:59:58 -05:00
Jon Brisbin
524eaa07fc Documentation updates. 2012-08-16 07:57:39 -05:00
Jon Brisbin
d7e2e53ce2 Implemented a new style of JSON serialization and deserialization by registering Repository-aware components with Jackson's underlying ObjectMapper. This has the benefit of allowing us to transliterate domain objects into link representations and back again, no matter where those entities appear in complex nested object graphs. 2012-08-15 14:31:57 -05:00
Jon Brisbin
d2c6ecacc5 Tweaking fluent bean utils by adding fallback to Field access. 2012-08-15 14:28:23 -05:00
Jon Brisbin
6a28da79c3 Updated to Gradle 1.1 2012-08-15 14:24:44 -05:00
Jon Brisbin
3393780e65 DATAREST-37: Display entities inline when accessing relationship links. 2012-08-13 09:32:42 -05:00
J. Brisbin
17c97eb423 Merge pull request #26 from ericbottard/patch-1
Broken link in README
2012-08-08 06:37:08 -07:00
Eric Bottard
ca1115f5fc Broken link in README 2012-08-08 11:12:51 +03:00
Jon Brisbin
4abd842a86 Added an annotation for doing parameter conversion @ConvertWith. You can now specify a Spring Core Converter class to use to convert the query parameter String[] values coming in on the query string to the type needed in the query method parameter. 2012-08-07 17:05:43 -05:00
Jon Brisbin
42c86af9a2 Fixed a couple failing tests. 2012-08-07 11:07:20 -05:00
Jon Brisbin
81b5f29c1e Adding a test scenario for @MappedSuperclass, fixed a couple bugs w.r.t. generating links to entities. 2012-08-07 11:03:02 -05:00
Jon Brisbin
e6de869935 Updated wiki docs about event handling for render events. 2012-08-07 11:02:23 -05:00
Jon Brisbin
88fc8ba7cd Added event handling machinery to intercept render events. It's now possible to write and event handler to influence the resource objects that are being sent to the client. There is an abstract helper class and there is support for annotated POJOs. 2012-08-07 10:02:16 -05:00
Jon Brisbin
f3dde0c144 Fixed failing test due to changing the key name in the root-level object, removed the serialVersionUID compile flag. 2012-08-06 14:40:32 -05:00
Jon Brisbin
7775af8be4 Changing the representation to be more consistent in key naming (breaking change). Also starting work on the ability to "enrich" a representation with e.g. more links to other resources, etc... 2012-08-06 12:25:26 -05:00
Jon Brisbin
bd24e582fd Updated wiki documentation. 2012-08-01 13:22:26 -05:00
Jon Brisbin
b73dafbb8b Adding javadoc comments. 2012-07-31 13:13:01 -05:00
Jon Brisbin
38a3ffd376 Added ConversionFailedException to the list of 400 Bad Request throwables. 2012-07-31 10:25:49 -05:00
Jon Brisbin
bf9c719950 Fixed a bug where complex query method parameters that aren't managed by repositories were causing the parameter processing to short-circuit to a 404 error. Replaced that method call with a different one that simple returns a boolean if a type is managed by a repository so the if/else chain can continue on to the ConversionService. 2012-07-31 09:22:36 -05:00
Jon Brisbin
b681844258 Added missing exception resolver configuration to turn exceptions into meaningful HTTP codes as well as provide sane serialization of exception stacktraces. 2012-07-30 15:17:37 -05:00
Jon Brisbin
3a8969e55f Trying to fix build failures due to strange transaction issues not experienced in local builds. 2012-07-30 14:30:57 -05:00
Jon Brisbin
aa8e5a123f Trying to fix build failures due to strange transaction issues not experienced in local builds. 2012-07-30 14:28:54 -05:00
Jon Brisbin
7bc2b0cb97 Added transactional awareness to the tests to ensure they pass. 2012-07-30 14:23:00 -05:00
Jon Brisbin
2f6650c846 Added before/after link delete events and fixed a bug with deleting links where the updated entity was never saved back to the DB. 2012-07-30 13:53:13 -05:00
Jon Brisbin
1cb9307b1c Added notNull assertions to the configuration class to prevent bad configurations from blowing up the exporter. 2012-07-30 08:56:12 -05:00
Jon Brisbin
300c06f640 Changed servlet 3.0 dependency to provided. 2012-07-27 14:12:28 -05:00
Jon Brisbin
f71b25b49c Previous configuration caused a WAR to be built. Had to take that out of the gradle build so it would look properly like a Java project again. 2012-07-27 10:02:04 -05:00
Jon Brisbin
6be6de34d3 Fixing and adding tests. 2012-07-27 09:40:50 -05:00
Jon Brisbin
7f8abc5aa8 Big update. Bug fixes, code re-formatting, changing tests. 2012-07-26 13:31:34 -05:00
Jon Brisbin
6867d07295 DATAREST-23 Fix NPE when result of query is null. 2012-07-24 08:26:34 -05:00
Jon Brisbin
93d40b396b Forgot to add an important file. doh! :/ 2012-07-23 17:09:30 -05:00
Jon Brisbin
f969f92acc #18, DATAREST-20, DATAREST-21, DATAREST-22 Bugfixes, re-vamp output method, JSONPE support
There were some issues with how results were being displayed in searches versus entity lists. This code changes the way all results are displayed by offereing several options for output. The default is to inline the entity in the response and page the results (defaults to 20). If the UA sends an `Accept` header of `application/x-spring-data-compact+json` or `text/uri-list`, however, SD REST will output a compact list of only links and will not inline the entities.

The method of output was completely rewritten to use HttpMessageConverters exclusively. Views and the subsequent ContentNegotiatingViewResolver machinery have been elimintated. This should make it easier to embed inside an existing Spring MVC application. This is also easily extendable so the user can plug in their own set of HttpMessageConverters for any output format they like (JAXB, Atom/XML, etc...).

Also added was JSONPE support. By setting the `jsonpParamName` property on the `RepositoryRestConfiguration` customization class, the user can change the default JSONP param name of `callback`. There's also a `jsonpOnErrParamName` property on that configuration (defaults to `null`) that will allow you to capture errors using JSONP. Normally this would not be possible using script element injection, but the REST controller changes the status code to 200 and pass your javascript function the actual response code and wraps the error as the second parameter.
2012-07-23 17:08:10 -05:00
Jon Brisbin
014271d7db Make parameter names for sorting and paging and what repositories to export configurable. 2012-07-20 16:54:35 -05:00
Jon Brisbin
7bb48e3eb9 Bumped Spring version to 3.1.2 2012-07-20 16:54:35 -05:00
Jon Brisbin
3b3814772f Bumped Spring version to 3.1.2 2012-07-20 16:54:34 -05:00
Jon Brisbin
395101497f Added documentation on how to integrate Spring Data REST with an existing Spring MVC application. Renamed a couple components to keep them consistent with the others. 2012-06-26 13:28:45 -05:00
Jon Brisbin
b3290c190c Changed how handler mappings work in Spring Data REST so that only paths that have Repositories exported on them are recognized by the controller.
This makes it easier to integrate the RepositoryRestController into an existing Spring MVC application because all you have to do is include the RepositoryRestMvcConfiguration JavaConfig bean into your existing application.

Also included some changes to the way views are resolved so that only views starting with "org.springframework.data.rest" will be recognized as our own special views.
2012-06-26 11:24:52 -05:00