Commit Graph

716 Commits

Author SHA1 Message Date
Jon Brisbin
d526e073ba Fix NPE. 2012-10-12 08:32:28 -05:00
Jon Brisbin
babf3b0104 Added custom FieldError arguments to the message formatting arguments. Now passes type name, property name, value, then user-supplied arguments. 2012-10-12 08:29:14 -05:00
Jon Brisbin
96a37b490f Merge branch 'master' of github.com:SpringSource/spring-data-rest 2012-10-11 10:38:39 -05:00
Jon Brisbin
72691f2d16 Merge pull request #40 from jotomo/bean-default
Declare all @Autowired uses of RepositoryRestConfiguration as optional.
2012-10-11 08:38:00 -07:00
Jon Brisbin
4b6a408b5a Forgot to add the test error message file. 2012-10-10 09:27:20 -05:00
Jon Brisbin
aff62b7cd7 Added specific message key for testing @NotNull handling. 2012-10-10 08:56:29 -05:00
Johannes Mockenhaupt
470ccf1308 Declare all @Autowired uses of RepositoryRestConfiguration as optional. 2012-10-10 01:53:42 +02:00
Jon Brisbin
d97c14ebb2 Integrated standard Spring MessageSource components for resolving error messages in validators. 2012-10-09 16:55:14 -05:00
Jon Brisbin
e8be1c1ded Added timestamp to Person for testing Date conversion. 2012-10-09 09:15:39 -05:00
Jon Brisbin
3fa13a60a7 Make RepositoryRestConfiguration bean optional by defaulting. 2012-10-09 09:13:49 -05:00
Jon Brisbin
39a53f6841 Fix bug in URI-generation for links. 2012-10-02 10:37:26 -05:00
Jon Brisbin
1100693c53 Fixed a bug introduced by a change in how the validators were looked up. Not sure why I made the original change to begin with but the functionality has been been reverted to its previous behavior. 2012-10-02 10:06:53 -05:00
Jon Brisbin
ce466d00ab Changed ApplicationRestConfig to just import RepositoryRestMvcConfiguration rather than extend it. It works the same either way. It's easier to override the default behavior by extending it, but if you're just defining validators and additional components, you can just use the @Import. 2012-10-02 09:58:52 -05:00
Jon Brisbin
dbfd43c1a0 Changes to the order in which ApplicationContexts are loaded, changed package that JavaConfig classes are in to keep them from being picked up by the repository component scanning, split single JavaConfig into separate JPA Repository config and Spring Data REST config classes. 2012-10-02 09:05:21 -05:00
Jon Brisbin
df3b60ba41 Changed the way baseUri is calculated. Changed tests to accommodate new method signatures, fix failing tests.
* Added a configuration property to `RepositoryRestConfiguration` for deployments behind a proxy which do not know the external URL to use as the baseUri for links.
* Changed the way the baseUri is injected into the controller by introducing a `BaseUriMethodArgumentResolver` to inject the proper baseUri (either the one from the configuration, or the one from the request if that's not specified).
2012-10-01 09:52:46 -05:00
Jon Brisbin
697f39d5b0 Tweak to accommodate some weird situation in the Gradle build where the HSQL session stays open a lot longer than it does when the tests are run in the IDE, which causes all kinds of stupid situations that have to be adjusted for in the tests. 2012-09-27 16:53:13 -05:00
Jon Brisbin
a3d0c548c5 Tests were failing for some reason. Various errors from the Gradle command line that don't happen when the tests are run in the IDE. Had to comment out the delete/clear of entities because that was causing a foreign key error and had to comment out a non-optional relationship test because I had to remove a back reference in a bi-directional relationship (I think it's an HSQL problem or a Gradle test environment problem because these things don't happen when run in the IDE). 2012-09-27 16:48:38 -05:00
Jon Brisbin
c856d50a7c Previous Jackson Module configuration was causing serializers to be set to none (probably because it was the last module to be registered). 2012-09-27 16:15:02 -05:00
Jon Brisbin
2b187c91ed Already picking up the necessary Jackson modules. No need to register the internal one twice. 2012-09-27 16:14:20 -05:00
Jon Brisbin
28f4936d97 Added JsonSchemaController for generating JSON schema for managed entities. 2012-09-27 15:53:32 -05:00
Jon Brisbin
50dc81954b Added JSON serializers to format timestamps into human-readable strings. 2012-09-27 15:52:51 -05:00
Jon Brisbin
3ffae1a1ec Added default servlet enabling in the test app to be able to serve static resources from the webapp. 2012-09-27 15:51:36 -05:00
Jon Brisbin
cff8065d8d Fixed misspelling. 2012-09-27 15:50:41 -05:00
Jon Brisbin
967e6572ff Removed obsolete reference. 2012-09-27 15:50:24 -05:00
Jon Brisbin
1ac4ab6c17 Added simple assert to ensure RepositoryMetadata is non-null. 2012-09-27 15:49:50 -05:00
Jon Brisbin
4fc50526a3 Fixed problem with infinite recursion on entities by adding @JsonBackReference et al 2012-09-27 15:49:11 -05:00
Jon Brisbin
2ddf788350 DATAREST-48 Fix a bug with compact content-type not displaying links properly when executing query methods. 2012-09-13 08:22:57 -05:00
Jon Brisbin
749218445a Updating source to reflect latest changes in Spring HATEOAS snapshots. 2012-09-12 10:49:17 -05:00
Jon Brisbin
143ae89c6d DATAREST-47 Skip links property when value is null, not just an empty list. 2012-09-11 08:30:05 -05:00
Mark Hellkamp
8c24c641b4 Fixed issue with deserializing empty collections and sets. 2012-09-07 15:03:42 -07:00
Mark Hellkamp
16af522def Fixed issue with deserializing collections and sets. 2012-09-07 14:37:34 -07:00
Jon Brisbin
217e840678 Adjusted test for new repositories. 2012-09-06 09:28:36 -05:00
Jon Brisbin
4ece75b625 Tests added looking into #35 2012-09-06 09:27:20 -05:00
Jon Brisbin
079f07b3fe Tweak comment wording. 2012-09-05 14:51:11 -05:00
Jon Brisbin
e3dde1a2cd DATAREST-39 Introduced new property on AttributeMetadata to encapsulate the decision of whether or not a property is nullable. Removed references to JPA-specific classes from everything but the JpaAttributeMetadata class. 2012-09-05 08:57:43 -05:00
Jon Brisbin
a2288b7242 DATAREST-41 Slight tweak to fix to ensure that a links property is never specified as anything other than an array on incoming JSON. 2012-09-04 10:34:14 -05:00
Jon Brisbin
ae8d7d9326 DATAREST-41 Fix bug in JSON reading that wasn't advancing JSON parser past the value of "links" on incoming JSON, causing the entity properties to not be read correctly which prevents the update from succeeding correctly. 2012-09-04 10:17:40 -05:00
Jon Brisbin
18616d9c89 DATAREST-45 Using the wrong base URI to build links to the "self" and properties of entities. Needed to add two lines of code to generate a proper self link and use that as the base URI for generating property links. 2012-08-31 09:39:41 -05:00
Jon Brisbin
e4d43278f7 Tweaking representations and return values to get the right nesting of resources. 2012-08-31 09:26:28 -05:00
Jon Brisbin
1fdde3531e DATAREST-43 Using the correct method now. 2012-08-30 10:24:46 -05:00
Jon Brisbin
0f925cc5ff Re-organized how entities are serialized. Broke out the Jackson Module into its own class and incorporated the code from EntityResource.wrap into the serializer so that entities are properly serialized wherever they are encountered. Also implemented a Converter and use the ConversionService to turn an Entity into a Resource. Right now that's done in two separate places since the propertyOfEntity method needs to turn entities into resources as well as the Jackson serializer. Also threw in a fix for DATAREST-43. 2012-08-30 09:38:28 -05:00
Jon Brisbin
40645673bf Integrated Spring HATEOAS. 2012-08-27 15:16:02 -05:00
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
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