Commit Graph

839 Commits

Author SHA1 Message Date
Oliver Gierke
29153b6aae DATAREST-765 - Upgraded Solr dependency to 5.3.1. 2016-02-09 20:55:13 +01:00
Oliver Gierke
16306f6826 DATAREST-756 - Fix Querydsl test class generation.
We now configure a proper output directory for Querydsl generated test classes. Previously we used the folder that's automatically picked up by the main compilation step which breaks subsequent compile runs if they're not run with a previous clean.
2016-01-29 19:16:51 +01:00
Oliver Gierke
46df1279bf DATAREST-757 - Upgraded to Spring Data Solr 2.0.
Tweaked test configuration to use SolrClientFactory instead of SolrServerFactory.
2016-01-29 18:51:52 +01:00
Oliver Gierke
b25df0bcf1 DATAREST-756 - Reorganize dependencies to make sure they get pulled in in release profile. 2016-01-28 15:41:58 +01:00
Oliver Gierke
b866af762d DATAREST-754 - Polishing.
Upgraded to Groovy 2.4.4. Polished sample domain types and repositories. Removed obsolete format registration in test cases for schema creation. Keep inlined null checks to make sure the IDE doesn't create unnecessary can-be-null warnings.

Original pull request: #206.
2016-01-25 17:50:48 +01:00
Greg Turnquist
9fd62b5dbf DATAREST-753 - Added support for Groovy-based domain objects.
Groovy-based objects inherit from GroovyObject. This brings along attributes that Spring Data REST may try to parse when generating metadata like JSON Schema. Also verify ALPS is supported.

We now exclude those artificial properties from being exposed in the schema as well as causing issues.

Original pull request: #206.
2016-01-25 17:50:48 +01:00
Oliver Gierke
88c97a600d DATAREST-743 - Made ProjectionResourceContentSerializer immutable.
ProjectionResourceContentSerializer.unwrappingSerializer(…) now returns a new unwrapping instance instead of mutating the current instance to prevent the source one from answering subsequent calls to isUnwrappingSerializer() with true.

This allows the source instance to be reused and produce reliable results on multiple serialization attempts.

Related tickets: DATAREST-716.
2016-01-07 21:46:26 +01:00
Oliver Gierke
3ce10774d8 DATAREST-741 - UriToEntityDeserializer now uses RepositoryInvoker directly.
UriToEntityDeserializer now uses the RepositoryInvokerFactory to resolve entity instances directly to make sure potentially registered EntityLookup instances are considered for the lookup.
2016-01-06 14:17:42 +01:00
Oliver Gierke
000f645543 DATAREST-740 - Removed Cassandra integration tests. 2016-01-05 12:47:48 +01:00
Oliver Gierke
482c78c925 DATAREST-724 - Fixed invocation of DELETE on item resource with entity lookup present.
Tweaked the RepositoryEntityController to lookup the identifier of the entity to be deleted from the entity obtained rather than forwarding the given id directly. This makes sure we use the real entity identifier on calls to delete in case the one to be used in URIs is customized via an EntityLookup.
2016-01-05 12:47:47 +01:00
Oliver Gierke
1b99111634 DATAREST-730 - Temporarily remove integration tests for Neo4j. 2015-12-16 16:45:41 +01:00
Oliver Gierke
e08dff846e DATAREST-702 - Tweaked ResourceProcessorHandlerMethodReturnValueHandler to handle potentially proxied ResourceProcessors. 2015-12-11 19:02:19 +01:00
Oliver Gierke
0757253846 DATAREST-726 - Moved ResourceProcessorHandlerMethodReturnValueHandler to ResolvableType.
Removed all usages of TypeInformation from ResourceProcessorHandlerMethodReturnValueHandler so that it's not tied to Spring Data (REST) APIs anymore.
2015-12-10 18:50:17 +01:00
Oliver Gierke
6709d1fd92 DATAREST-697 - Fixed unwrapping mode in ProjectionSerializer.
Projection serializer now only creates a nested JSON document if it's not in unwrapping mode. Switched to a completely immutable implementation as we were previously mutating state in the request for an unwrapping instance as we were assuming the instances not being reused.
2015-12-10 13:20:47 +01:00
Oliver Gierke
3a66bc75e2 DATAREST-724 - Added configuration API for entity lookup customizations.
RepositoryRestConfiguration now exposes a withCustomEntityLookup() returning an EntityLookupRegistrar that allows to define customizations as follows on Java 8:

config.withCustomEntityLookup()
  .forRepository(UserRepository.class)
  .withIdMapping(User::getUsername)
  .withLookup(UserRepository::findByUsername);

or even abbreviated to:

config.withCustomEntityLookup()
  .forRepository(UserRepository.class, User::getUsername, UserRepository::findByUsername);

The API basically takes two lambdas or method references to define the id mapping (User::getUsername in this case) as well as the lookup call based on the repository type with which the customization builder was set up in the first place (UserRepository::findByUsername in this case).
2015-12-09 16:00:32 +01:00
Oliver Gierke
44ab756873 DATAREST-724 - Added support for customizing the property to be used for URI generation.
Spring Data REST now exposes an EntityLookup interface that allows to customize the property of an entity that shall be used to create item resource URIs. By default this mechanism uses the backend identifier and uses the repository's findOne(…) method.

The EntityLookup now exposes one method to return the property value to be used for URI generation as well as one method to obtain the entity instance from the very same raw identifier value. The EntityLookups are registered with both the SelfLinkProvider (for link creation) and the RepositoryInvoker (to obtain the entity instance).
2015-12-09 12:42:15 +01:00
Oliver Gierke
dc36dfb67a DATAREST-473 - Introduced configuration option to control default exposure of repositories.
RepositoryRestConfiguration now exposes a setRepositoryDetectionStrategy(…) to define which repositories should be detected for exposure by default. The default value for that will consider the repository interfaces visibility but also take the exported flag of @(Repository)RestResource into account. See all other options in RepositoryDetectionStrategies.

Tweaked the auto-registration of excerpt projections to avoid a circular dependency between configuration and resource mappings and moved it onto a BeanPostProcessor implementation.
2015-11-25 13:40:26 +01:00
Oliver Gierke
b663b5ff73 DATAREST-712 - Fixed application of Querydsl bindings to only kick in for collection resources.
The Querydsl integration in RootResourceInformationHandlerMethodArgumentResolver now only kicks in if the controller method parameter is annotated with @QuerydslPredicate. This allows us to apply the QuerydslBindings for collection resources but make sure they aren't accidentally applied during executions of query methods etc.

Improved the type lookup for query method execution to make sure the correct mapping is looked up for collection parameters.
2015-11-24 15:35:39 +01:00
Oliver Gierke
8329fcf8f6 DATAREST-705 - DomainObjectReader now doesn't wipe identifier and version properties.
Identifier and version properties are handled in a special way by Spring Data REST (ids are derived from and exposed via the URI, versions make it into the ETag header) and are not contained in the response representation. That requires handling PUT request having to explicitly exclude them from being wiped to null so that the server side values are still preserved.
2015-11-20 16:53:18 +01:00
Oliver Gierke
3e98496333 DATAREST-708 - Upgrade to Querydsl 4. 2015-11-17 13:32:02 +01:00
Oliver Gierke
5911874b52 DATAREST-706 - Added unit test for fixed functionality.
Original pull request: #200.
2015-11-13 17:34:54 +01:00
Artur M
0f6ca1c028 DATAREST-706 - RepositoryExceptionHandler.handleMiscFailures(…) now passes exception instead of null.
Original pull request: #200.
2015-11-13 17:34:33 +01:00
Oliver Gierke
238e8b8462 DATAREST-701 - Fixed potential NullPointerException in DomainObjectReader.
We now skip nested Map handling in case the Map value is not a managed entity. Also added a more strict guard against the PersistentEntity lookup to make sure users see a more descriptive error in case of failures.
2015-11-10 11:58:02 +01:00
Oliver Gierke
a173986fb7 DATAREST-690 - Fixed JSON schema handling for collection associations.
We now make sure not to render an items nor an uniqueItems clause for collection associations as they are exposed as URIs for which JSON schema doesn't allow these attributes.
2015-11-09 08:36:14 +01:00
Oliver Gierke
1f133fbcd4 DATAREST-683 - Enum values are now correctly i18ned in ALPS.
If enum translation is enabled, ALPS descriptors now expose the translated values correctly.
2015-11-06 16:32:07 +01:00
Oliver Gierke
75f1143fa3 DATAREST-683 - ALPS documents are now correctly nested.
We now wrap the ALPS descriptors into a root ALPS JSON node.
2015-11-06 16:32:03 +01:00
Oliver Gierke
43366a327c DATAREST-686 - Set default encoding for resource description message source to UTF-8. 2015-11-02 11:58:02 +01:00
Oliver Gierke
76380eb650 DATAREST-674 - Defensively handle potential double slashes in lookup
path.

We now defensively replace all double slashes contained in the lookup
path as Spring 4.2 might return such paths due to a regression in
UrlPathHelper. This might occur if the original URL contains
intermediate matrix parameters (e.g. /books/;test/1) whose removal now
results in double slashes and thus the downstream repository metadata
lookup to fail.

Related tickets: SPR-13455.
2015-09-10 09:17:11 +02:00
Oliver Gierke
25aee4be1c DATAREST-665 - Prevent non-serializable properties from making it into the schema.
We now explicitly skip non-Jackson-serializable properties from being rendered in the schema. This prevents exceptions in rare cases where the Jackson BeanPropertyDefinition is only backed by a setter.

The issue occurred with current Spring Data Gemfire as it considers a BigDecimal a PersistentEntity and then failed to produce a proper ResolvableProperty for setScale(…) as it's a setter-only property.

Related tickets: SGF-429.
2015-09-08 15:14:28 +02:00
Oliver Gierke
7daca726c0 DATAREST-668 - Added test case to verify search links are created correctly.
Added a test case that explictly verifies the projection template variable being added to search links for domain types with projections registered.

Related tickets: DATAREST-467, DATAREST-519.
2015-09-03 17:56:14 +02:00
Oliver Gierke
b4bbc1d79c DATAREST-665 - Switched to a more consistent scheme for I18N of JsonSchema.
We now use the following keys in the resource bundle to determine values for the title attribute of JSON schema property (in descending order of preference):

$fullyQualifiedClassName.$property._title
$simpleClassName.$property._title
$property._title

Also tweaked JsonProperty.format to make sure it always serializes as its toString() value.
2015-09-02 10:10:50 +02:00
Spring Buildmaster
123b7a01c2 DATAREST-663 - Prepare next development iteration. 2015-09-01 02:46:04 -07:00
Spring Buildmaster
1a38f96602 DATAREST-663 - Release version 2.4.0.RELEASE (Gosling GA). 2015-09-01 02:46:01 -07:00
Oliver Gierke
71cfe235ad DATAREST-662 - Polishing.
Simplified test case. Added author tags.
2015-08-29 15:32:42 +02:00
Valentin Rentschler
b7e650af5e DATAREST-662 - Tweaked UriStringDeserializer to work for polymorphic references. 2015-08-29 15:32:07 +02:00
Oliver Gierke
e7374697f1 DATAREST-363 - Fixed Resources setup for embedded values in PersistentEntityResource.
We're now creating a dedicated Resources inner class to be able to explicitly ignore the links of the embeds as they would cause the link attribute to be rendered when the unwrapping is applied in the custom JSON serializer.

Polished test case. Foxed Javadoc in PersistentEntityResource.Builder. Tweaked the TestDataPopulator to always reinitialize the data set to make sure the test cases see the expected data.
2015-08-29 14:50:43 +02:00
Greg Turnquist
22bbc6d305 DATAREST-363 - Added test cases exposing legacy format issue.
Added integration test to show the "links" attribute rendered twice in the legacy JSON format.
2015-08-28 18:29:38 +02:00
Oliver Gierke
a5ed63050f DATAREST-661 - Fixed non-existant resource detection for PATCH requests.
PATCH requests to non existing resource now correctly return 404 Not Found as PersistentEntityResourceHandlerMethodArgumentResolver.read(…) now correctly throws the ResourceNotFoundException.
2015-08-28 10:51:27 +02:00
Oliver Gierke
1c1766ba12 DATAREST-658 - HEAD requests now return resource links.
HEAD requests to both item and collection resource now return the top-level links as a Link header. Fixed HEAD requests to the item resource now use the raw domain object instead of the projected resource to calculate ETag and Last-Modified headers.
2015-08-22 20:10:51 +02:00
Oliver Gierke
8ed188cbc2 DATAREST-654 - Additional tweaks and tests for enum deserialization.
Made the EnumTranslatingDeserializer contextual to make sure we get access to the BeanProperty and thus the actual enum target type.
2015-08-21 17:03:27 +02:00
Oliver Gierke
06b6b266db DATAREST-654 - Added suport for internationalization of enum values.
RepositoryRestConfiguration now exposes an option to enable enum value serialization and a nested configuration object to tweak the details.

If enabled, a Jackson serializer and deserializer is registered trying to resolve the enum values from the Spring Data REST resource bundle using the fully-qualified enum value name as key. If no explicitly configured value is configured a default translation is triggered that capitalizes the lowercased value name replacing the underscores with spaces (e.g. PAYMENT_EXPECTED -> Payment expected). This can be opted out of, of course.

On the parsing side the deserializer will also consult the resourcebundle and default translation but also accepting the enum name as is (also opt-outable).

Deprecated non-bean-style accessors for projection and metadata configuration on RepositoryRestConfiguration to make these options tweakable via Spring Boot application properties by default.
2015-08-21 15:22:27 +02:00
Oliver Gierke
39eb338025 DATAREST-651 - Upgraded to Spring HATEOAS 0.19.
Upgraded to snapshots of Spring HATEOAS to use the now extended constructor of HalHandlerInstantiator to be able to render title attributes for links.
2015-08-19 19:13:03 +02:00
Oliver Gierke
52a8d837f0 DATAREST-638 - Polishing.
Removed unnecessary dependencies from AlpsController. Minor formatting issues. Copyright years.

Original pull request: #196.
2015-08-19 11:44:49 +02:00
Greg Turnquist
345c198a75 DATAREST-638 - Consolidated metadata under a single profile link.
Moved /alps into a separate link underneath /profile, so that /schema can ALSO be served there as well. Also added a profile link to the collection resources, linking to collection-specific metadata. We now use strict content negotiation for each form of metadata so clients don't have to navigate a labyrinth of links. To preserve backwards compatibility, make ALPS the default metadata type.

Original pull request: #196.
2015-08-19 11:25:17 +02:00
Oliver Gierke
5f7f912e69 DATAREST-647 - Removed unnecessary lookup of the entity to update.
RepositoryEntityController.patchItemResource(…) triggered an additional, unnecessary lookup of the original entity to be updated. However the resolution algorithm for PersistentEntityResource already checks the presence and rejects an invalid identifier with a ResourceNotFoundException.

PersistentEntityResource now carries a boolean flag to expose whether the entity is about to be created. That allows us to avoid the additional lookup in the method handling PUT requests, too.

Related tickets: DATAREST-441.
2015-08-18 18:14:24 +02:00
Oliver Gierke
d4dbeb93a0 DATAREST-644 - Improvements to JSON Schema output.
Fixed JSON Schema output use "definitions" keyword instead of the previously used wrong "descriptors".

We now also include the title attribute for properties, using rest.description.$type.$property._title as i18n key. Titles are now also defaulted to the camel-case property name split up, lowercased and capitalized, e.g. "orderDate" will become "Order date".

JacksonMetadata now allows obtaining the Jackson serializer being used for a given type and exposes whether a property is considered read-only for Jackson.

Introduced JsonSchemaPropertyCustomizer to potentially tweak the JSON schema property definition. This is helpful in case custom JsonSerializers are implemented to also reflect the change in representation in the schema.
2015-08-14 19:13:23 +02:00
Spring Buildmaster
1d7e7f4ea4 DATAREST-634 - Prepare next development iteration. 2015-08-04 05:06:47 -07:00
Spring Buildmaster
402d7c9382 DATAREST-634 - Release version 2.4.0.RC1 (Gosling RC1). 2015-08-04 05:06:44 -07:00
Oliver Gierke
f17bd13c73 DATAREST-616 - Initial support to execute Querydsl predicates.
If Querydsl is on the classpath and the repository exposed implements QuerydslPredicateExecutor, we now register a component that customizes the RepositoryInvoker to route repository interactions for collection resource calls to the QuerydslPredicateExecutor.

The invocation gets enriched with a Predicate obtained from the request data. Bindings can be customized through the QuerydslBinderCustomizer interface implemented in a default method on the repository.

Tweaked the build to generate Querydsl meta-model classes for the MongoDB domain types.
2015-08-04 10:19:07 +02:00
Greg Turnquist
2244a2c588 DATAREST-632 - Fixed gap in JSON Schema unit tests.
Consolidated constraint tests for JSON Schema test for User and Profile.

Original pull request: #192.
2015-08-04 02:02:25 +02:00