Skip to content

Commit 3838214

Browse files
committed
Consistent anchor names for headings in documentation.
1 parent 8a1d147 commit 3838214

15 files changed

+61
-22
lines changed

src/main/asciidoc/adding-sdr-to-spring-mvc-app.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ The following example shows the corresponding XML configuration:
3333

3434
When your ApplicationContext comes across this bean definition, it bootstraps the necessary Spring MVC resources to fully configure the controller for exporting the repositories it finds in that `ApplicationContext` and any parent contexts.
3535

36+
[[customizing-sdr.adding-sdr-to-spring-mvc-app.required-config]]
3637
== More on Required Configuration
3738

3839
Spring Data REST depends on a couple Spring MVC resources that must be configured correctly for it to work inside an existing Spring MVC application. We tried to isolate those resources from whatever similar resources already exist within your application, but it may be that you want to customize some of the behavior of Spring Data REST by modifying these MVC components.
3940

4041
You should pay special attention to configuring `RepositoryRestHandlerMapping`, covered in the next section.
4142

43+
[[customizing-sdr.adding-sdr-to-spring-mvc-app.required-config.mapping]]
4244
=== `RepositoryRestHandlerMapping`
4345

4446
We register a custom `HandlerMapping` instance that responds only to the `RepositoryRestController` and only if a path is meant to be handled by Spring Data REST. In order to keep paths that are meant to be handled by your application separate from those handled by Spring Data REST, this custom `HandlerMapping` class inspects the URL path and checks to see if a repository has been exported under that name. If it has, the custom `HandlerMapping` class lets the request be handled by Spring Data REST. If there is no Repository exported under that name, it returns `null`, which means "`let other `HandlerMapping` instances try to service this request`".

src/main/asciidoc/configuring-cors.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ For security reasons, browsers prohibit AJAX calls to resources residing outside
55

66
Spring Data REST, as of 2.6, supports https://en.wikipedia.org/wiki/Cross-origin_resource_sharing[Cross-Origin Resource Sharing] (CORS) through https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/web.html#mvc-cors[Spring's CORS] support.
77

8-
8+
[[customizing-sdr.configuring-cors.config]]
99
== Repository Interface CORS Configuration
1010

1111
You can add a `@CrossOrigin` annotation to your repository interfaces to enable CORS for the whole repository. By default, `@CrossOrigin` allows all origins and HTTP methods. The following example shows a cross-origin repository interface definition:
@@ -32,6 +32,7 @@ interface PersonRepository extends CrudRepository<Person, Long> {}
3232

3333
The preceding example enables CORS support for the whole `PersonRepository` by providing one origin, restricted to the `GET`, `POST`, and `DELETE` methods and with a max age of 3600 seconds.
3434

35+
[[customizing-sdr.configuring-cors.controller-config]]
3536
== Repository REST Controller Method CORS Configuration
3637

3738
Spring Data REST fully supports https://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/web.html#controller-method-cors-configuration[Spring Web MVC's controller method configuration] on custom REST controllers that share repository base paths, as the following example shows:
@@ -53,6 +54,7 @@ public class PersonController {
5354

5455
NOTE: Controllers annotated with `@RepositoryRestController` inherit `@CrossOrigin` configuration from their associated repositories.
5556

57+
[[customizing-sdr.configuring-cors.global-config]]
5658
== Global CORS Configuration
5759

5860
In addition to fine-grained, annotation-based configuration, you probably want to define some global CORS configuration as well. This is similar to Spring Web MVC'S CORS configuration but can be declared within Spring Data REST and combined with fine-grained `@CrossOrigin` configuration. By default, all origins and `GET`, `HEAD`, and `POST` methods are allowed.

src/main/asciidoc/configuring-the-rest-url-path.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ interface PersonRepository extends CrudRepository<Person, Long> {
5858

5959
Now the query method in the preceding example is exposed at `http://localhost:8080/people/search/names`.
6060

61+
[[customizing-sdr.configuring-the-rest-url-path.rels]]
6162
== Handling `rel` Attributes
6263

6364
Since these resources are all discoverable, you can also affect how the `rel` attribute is displayed in the links sent out by the exporter.

src/main/asciidoc/custom-jackson-deserialization.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Sometimes, the behavior of the Spring Data REST `ObjectMapper` (which has been s
55

66
To accommodate the largest percentage of the use cases, Spring Data REST tries to render your object graph correctly. It tries to serialize unmanaged beans as normal POJOs, and tries to create links to managed beans where necessary. However, if your domain model does not easily lend itself to reading or writing plain JSON, you may want to configure Jackson's `ObjectMapper` with your own custom type mappings and (de)serializers.
77

8+
[[customizing-sdr.custom-jackson-deserialization.abstract-classes]]
89
== Abstract Class Registration
910

1011
One key configuration point you might need to hook into is when you use an abstract class (or an interface) in your domain model. Jackson does not, by default, know what implementation to create for an interface. Consider the following example:
@@ -46,6 +47,7 @@ public class MyCustomModule extends SimpleModule {
4647

4748
Once you have access to the `SetupContext` object in your `Module`, you can do all sorts of cool things to configure Jackon's JSON mapping. You can read more about how https://wiki.fasterxml.com/JacksonFeatureModules[Modules work on Jackson's wiki].
4849

50+
[[customizing-sdr.custom-jackson-deserialization.custom-serializers]]
4951
== Adding Custom Serializers for Domain Types
5052

5153
If you want to serialize or deserialize a domain type in a special way, you can register your own implementations with Jackson's `ObjectMapper`. Then the Spring Data REST exporter transparently handles those domain objects correctly.

src/main/asciidoc/customizing-json-output.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
Sometimes in your application, you need to provide links to other resources from a particular entity. For example, a `Customer` response might be enriched with links to a current shopping cart or links to manage resources related to that entity. Spring Data REST provides integration with https://github.com/SpringSource/spring-hateoas[Spring HATEOAS] and provides an extension hook that lets you alter the representation of resources that go out to the client.
55

6+
[[customizing-sdr.customizing-json-output.representation-model-processor]]
67
== The `RepresentationModelProcessor` Interface
78

89
Spring HATEOAS defines a `RepresentationModelProcessor<>` interface for processing entities. All beans of type `RepresentationModelProcessor&lt;EntityModel&lt;T&gt;&gt;` are automatically picked up by the Spring Data REST exporter and triggered when serializing an entity of type `T`.
@@ -29,11 +30,12 @@ public RepresentationModelProcessor<EntityModel<Person>> personProcessor() {
2930
====
3031

3132
IMPORTANT: The preceding example hard codes a link to `http://localhost:8080/people`. If you have a Spring MVC endpoint inside your app to which you wish to link, consider using Spring HATEOAS's https://github.com/spring-projects/spring-hateoas#building-links-pointing-to-methods[`linkTo(...)`] method to avoid managing the URL.
32-
33+
[[customizing-sdr.customizing-json-output.adding-links]]
3334
== Adding Links
3435

3536
You can add links to the default representation of an entity by calling `model.add(Link)`, as the preceding example shows. Any links you add to the `EntityModel` are added to the final output.
3637

38+
[[customizing-sdr.customizing-json-output.customizing-representation]]
3739
== Customizing the Representation
3840

3941
The Spring Data REST exporter executes any discovered `RepresentationModelProcessor` instances before it creates the output representation. It does so by registering a `Converter<Entity, EntityModel>` instance with an internal `ConversionService`. This is the component responsible for creating the links to referenced entities (such as those objects under the `_links` property in the object's JSON representation). It takes an `@Entity` and iterates over its properties, creating links for those properties that are managed by a `Repository` and copying across any embedded or simple properties.

src/main/asciidoc/customizing-sdr.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
There are many options to tailor Spring Data REST. These subsections show how.
55

6+
[[customizing-sdr.item-resource-uris]]
67
== Customizing Item Resource URIs
78

89
By default, the URI for item resources are comprised of the path segment used for the collection resource with the database identifier appended.

src/main/asciidoc/events.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class BeforeSaveEventListener extends AbstractRepositoryEventListener {
3737

3838
One thing to note with this approach, however, is that it makes no distinction based on the type of the entity. You have to inspect that yourself.
3939

40+
[[events.annotated-handler]]
4041
== Writing an Annotated Handler
4142

4243
Another approach is to use an annotated handler, which filters events based on domain type.

src/main/asciidoc/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[spring-data-rest-reference]]
22
= Spring Data REST Reference Guide
3-
Jon Brisbin, Oliver Gierke, Greg Turnquist, Jay Bryant
3+
Jon Brisbin, Oliver Drotbohm, Greg Turnquist, Jay Bryant
44
:revnumber: {version}
55
:revdate: {localdate}
66
ifdef::backend-epub3[:front-cover-image: image:epub-cover.png[Front Cover,1050,1600]]

src/main/asciidoc/integration.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
This section details various ways to integrate with Spring Data REST components, whether from a Spring application that is using Spring Data REST or from other means.
66

7+
[[integration.programmatic-links]]
78
== Programmatic Links
89

910
Sometimes you need to add links to exported resources in your own custom-built Spring MVC controllers. There are three basic levels of linking available:

src/main/asciidoc/metadata.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ If you navigate to `/profile/persons` and look at the profile data for a `Person
118118
} ]
119119
}
120120
----
121-
122121
<1> A detailed listing of the attributes of a `Person` resource, identified as `#person-representation`, lists the names
123122
of the attributes.
124123
<2> The supported operations. This one indicates how to create a new `Person`.

src/main/asciidoc/paging-and-sorting.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
This section documents Spring Data REST's usage of the Spring Data Repository paging and sorting abstractions. To familiarize yourself with those features, see the Spring Data documentation for the repository implementation you use (such as Spring Data JPA).
55

6+
[[paging-and-sorting.paging]]
67
== Paging
78

89
Rather than return everything from a large result set, Spring Data REST recognizes some URL parameters that influence the page size and the starting page number.
@@ -29,7 +30,7 @@ public Page findByNameStartsWith(@Param("name") String name, Pageable p);
2930

3031
The Spring Data REST exporter recognizes the returned `Page` and gives you the results in the body of the response, just as it would with a non-paged response, but additional links are added to the resource to represent the previous and next pages of data.
3132

32-
[[paging-and-sorting.prev-and-next-links]]
33+
[[paging-and-sorting.paging.prev-and-next-links]]
3334
=== Previous and Next Links
3435

3536
Each paged response returns links to the previous and next pages of results based on the current page by using the IANA-defined link relations https://www.w3.org/TR/html5/links.html#link-type-prev[`prev`] and https://www.w3.org/TR/html5/links.html#link-type-next[`next`]. If you are currently at the first page of results, however, no `prev` link is rendered. For the last page of results, no `next` link is rendered.
@@ -57,7 +58,7 @@ curl localhost:8080/people?size=5
5758
}
5859
},
5960
"_embedded" : {
60-
... data ...
61+
data
6162
},
6263
"page" : { <3>
6364
"size" : 5,

src/main/asciidoc/repository-resources.adoc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ NOTE: For more details about the `profile` link, see <<metadata.alps>>.
7777

7878
Spring Data REST exposes a collection resource named after the uncapitalized, pluralized version of the domain class the exported repository is handling. Both the name of the resource and the path can be customized by using `@RepositoryRestResource` on the repository interface.
7979

80+
[[repository-resources.collection-resource.supported-methods]]
8081
=== Supported HTTP Methods
8182

8283
Collections resources support both `GET` and `POST`. All other HTTP methods cause a `405 Method Not Allowed`.
8384

85+
[[repository-resources.collection-resource.supported-methods.get]]
8486
==== `GET`
8587

8688
Returns all entities the repository servers through its `findAll(…)` method.
@@ -123,6 +125,7 @@ The `GET` method supports a single link for discovering related resources:
123125

124126
* `search`: A <<repository-resources.search-resource,search resource>> is exposed if the backing repository exposes query methods.
125127

128+
[[repository-resources.collection-resource.supported-methods.head]]
126129
==== `HEAD`
127130

128131
The `HEAD` method returns whether the collection resource is available. It has no status codes, media types, or related resources.
@@ -137,6 +140,7 @@ The following methods are used if present (decending order):
137140

138141
For more information on the default exposure of methods, see <<repository-resources.methods>>.
139142

143+
[[repository-resources.collection-resource.supported-methods.post]]
140144
==== `POST`
141145

142146
The `POST` method creates a new entity from the given request body.
@@ -167,10 +171,12 @@ The `POST` method supports the following media types:
167171

168172
Spring Data REST exposes a resource for individual collection items as sub-resources of the collection resource.
169173

174+
[[repository-resources.item-resource.supported-methods]]
170175
=== Supported HTTP Methods
171176

172177
Item resources generally support `GET`, `PUT`, `PATCH`, and `DELETE`, unless explicit configuration prevents that (see "`<<repository-resources.association-resource>>`" for details).
173178

179+
[[repository-resources.item-resource.supported-methods.get]]
174180
==== GET
175181

176182
The `GET` method returns a single entity.
@@ -200,6 +206,7 @@ The `GET` method supports the following media types:
200206

201207
For every association of the domain type, we expose links named after the association property. You can customize this behavior by using `@RestResource` on the property. The related resources are of the <<repository-resources.association-resource,association resource>> type.
202208

209+
[[repository-resources.item-resource.supported-methods.head]]
203210
==== `HEAD`
204211

205212
The `HEAD` method returns whether the item resource is available. It has no status codes, media types, or related resources.
@@ -212,6 +219,7 @@ The following methods are used if present (decending order):
212219

213220
For more information on the default exposure of methods, see <<repository-resources.methods>>.
214221

222+
[[repository-resources.item-resource.supported-methods.put]]
215223
==== `PUT`
216224

217225
The `PUT` method replaces the state of the target resource with the supplied request body.
@@ -237,6 +245,7 @@ The `PUT` method supports the following media types:
237245
* application/hal+json
238246
* application/json
239247

248+
[[repository-resources.item-resource.supported-methods-patch]]
240249
==== `PATCH`
241250

242251
The `PATCH` method is similar to the `PUT` method but partially updates the resources state.
@@ -264,13 +273,14 @@ The `PATCH` method supports the following media types:
264273
* https://tools.ietf.org/html/rfc6902[application/patch+json]
265274
* https://tools.ietf.org/html/rfc7386[application/merge-patch+json]
266275

276+
[[repository-resources.item-resource.supported-methods.delete]]
267277
==== `DELETE`
268278

269279
The `DELETE` method deletes the resource exposed.
270280

271281
===== Methods used for invocation
272282

273-
The following methods are used if present (decending order):
283+
The following methods are used if present (descending order):
274284

275285
- `delete(T)`
276286
- `delete(ID)`
@@ -289,6 +299,7 @@ The `DELETE` method has only one custom status code:
289299

290300
Spring Data REST exposes sub-resources of every item resource for each of the associations the item resource has. The name and path of the resource defaults to the name of the association property and can be customized by using `@RestResource` on the association property.
291301

302+
[[repository-resources.association-resource.supported-methods]]
292303
=== Supported HTTP Methods
293304

294305
The association resource supports the following media types:
@@ -298,6 +309,7 @@ The association resource supports the following media types:
298309
* POST
299310
* DELETE
300311

312+
[[repository-resources.association-resource.supported-methods.get]]
301313
==== `GET`
302314

303315
The `GET` method returns the state of the association resource.
@@ -309,6 +321,7 @@ The `GET` method supports the following media types:
309321
* application/hal+json
310322
* application/json
311323

324+
[[repository-resources.association-resource.supported-methods.put]]
312325
==== `PUT`
313326

314327
The `PUT` method binds the resource pointed to by the given URI(s) to the resource. This
@@ -325,6 +338,7 @@ The `PUT` method supports only one media type:
325338

326339
* text/uri-list: URIs pointing to the resource to bind to the association.
327340

341+
[[repository-resources.association-resource.supported-methods.post]]
328342
==== `POST`
329343

330344
The `POST` method is supported only for collection associations. It adds a new element to the collection.
@@ -335,6 +349,7 @@ The `POST` method supports only one media type:
335349

336350
* text/uri-list: URIs pointing to the resource to add to the association.
337351

352+
[[repository-resources.association-resource.supported-methods.delete]]
338353
==== `DELETE`
339354

340355
The `DELETE` method unbinds the association.
@@ -350,10 +365,12 @@ The `POST` method has only one custom status code:
350365

351366
The search resource returns links for all query methods exposed by a repository. The path and name of the query method resources can be modified using `@RestResource` on the method declaration.
352367

368+
[[repository-resources.search-resource.supported-methods]]
353369
=== Supported HTTP Methods
354370

355371
As the search resource is a read-only resource, it supports only the `GET` method.
356372

373+
[[repository-resources.search-resource.supported-methods.get]]
357374
==== `GET`
358375

359376
The `GET` method returns a list of links pointing to the individual query method resources.
@@ -369,6 +386,7 @@ The `GET` method supports the following media types:
369386

370387
For every query method declared in the repository, we expose a <<repository-resources.query-method-resource,query method resource>>. If the resource supports pagination, the URI pointing to it is a URI template containing the pagination parameters.
371388

389+
[[repository-resources.search-resource.supported-methods.head]]
372390
==== `HEAD`
373391

374392
The `HEAD` method returns whether the search resource is available. A 404 return code indicates no query method resources are available.
@@ -378,10 +396,12 @@ The `HEAD` method returns whether the search resource is available. A 404 return
378396

379397
The query method resource runs the exposed query through an individual query method on the repository interface.
380398

399+
[[repository-resources.query-resource.supported-method]]
381400
=== Supported HTTP Methods
382401

383402
As the search resource is a read-only resource, it supports `GET` only.
384403

404+
[[repository-resources.query-resource.supported-method.get]]
385405
==== `GET`
386406

387407
The `GET` method returns the result of the query execution.
@@ -401,6 +421,7 @@ The `GET` method supports the following media types:
401421
* `application/hal+json`
402422
* `application/json`
403423

424+
[[repository-resources.query-resource.supported-method.head]]
404425
==== `HEAD`
405426

406427
The `HEAD` method returns whether a query method resource is available.

0 commit comments

Comments
 (0)