diff --git a/spring-content-rest/src/main/asciidoc/rest-index.adoc b/spring-content-rest/src/main/asciidoc/rest-index.adoc index fcbeedb9c..79e478e27 100644 --- a/spring-content-rest/src/main/asciidoc/rest-index.adoc +++ b/spring-content-rest/src/main/asciidoc/rest-index.adoc @@ -38,15 +38,4 @@ include::rest-cors.adoc[leveloffset=+1] include::rest-baseuri.adoc[leveloffset=+1] include::rest-linkrel.adoc[leveloffset=+1] include::rest-fullyqualifiedlinks.adoc[leveloffset=+1] -//[[appendix]] -//= Appendix - -//:numbered!: -// :leveloffset: +1 -// include::{spring-data-commons-docs}/repository-namespace-reference.adoc[] -// include::{spring-data-commons-docs}/repository-populator-namespace-reference.adoc[] -// include::{spring-data-commons-docs}/repository-query-keywords-reference.adoc[] -// include::{spring-data-commons-docs}/repository-query-return-types-reference.adoc[] -// include::faq.adoc[] -// include::glossary.adoc[] -// :leveloffset: -1 +include::rest-storeresolver.adoc[leveloffset=+1] diff --git a/spring-content-rest/src/main/asciidoc/rest-storeresolver.adoc b/spring-content-rest/src/main/asciidoc/rest-storeresolver.adoc new file mode 100644 index 000000000..6843077e3 --- /dev/null +++ b/spring-content-rest/src/main/asciidoc/rest-storeresolver.adoc @@ -0,0 +1,33 @@ +== Store Resolver +Every REST request must map to one store and one store only. However, it is entirely possible to define an application +with multiple stores that make this impossible. + +For these situations you need to provide a `StoreResolver` that, based on runtime context, can resolve these conflicts. + +.Configuring a StoreResolver +==== +[source, java] +---- +@Configuration +@EnableS3Stores +public static class ApplicationConfig { + + @Bean + public ContentRestConfigurer contentRestConfigurer() { + return new ContentRestConfigurer() { + @Override + public void configure(RestConfiguration config) { + config.addStoreResolver("examples", new StoreResolver() { <1> + @Override + public StoreInfo resolve(StoreInfo... stores) { + /* your resolver implementation */ + } + }); + } + }; + } +} +---- +<1> This store resolver resolves conflicts for stores exported through the path "examples" +==== + diff --git a/spring-content-rest/src/test/java/internal/org/springframework/content/rest/storeresolver/Application.java b/spring-content-rest/src/test/java/internal/org/springframework/content/rest/storeresolver/Application.java index 2d4d95d2c..dbbaf0cf5 100644 --- a/spring-content-rest/src/test/java/internal/org/springframework/content/rest/storeresolver/Application.java +++ b/spring-content-rest/src/test/java/internal/org/springframework/content/rest/storeresolver/Application.java @@ -115,8 +115,8 @@ public FileSystemResourceLoader fileSystemResourceLoader() throws IOException { return new FileSystemResourceLoader(Files.createTempDirectory("").toFile().getAbsolutePath()); } - @Bean - public ContentRestConfigurer contentRestConfigurer() { + @Bean + public ContentRestConfigurer contentRestConfigurer() { return new ContentRestConfigurer() { @Override public void configure(RestConfiguration config) { diff --git a/spring-content-rest/src/test/java/internal/org/springframework/content/rest/storeresolver/StoreResolverRestConfigurationIT.java b/spring-content-rest/src/test/java/internal/org/springframework/content/rest/storeresolver/StoreResolverRestConfigurationIT.java index 96f20e042..71360718d 100644 --- a/spring-content-rest/src/test/java/internal/org/springframework/content/rest/storeresolver/StoreResolverRestConfigurationIT.java +++ b/spring-content-rest/src/test/java/internal/org/springframework/content/rest/storeresolver/StoreResolverRestConfigurationIT.java @@ -53,7 +53,7 @@ public class StoreResolverRestConfigurationIT { tEntity = new Application.TEntity(); tEntity = repo.save(tEntity); }); - It("should return the content with 200 OK", () -> { + It("should return the content from the correct store", () -> { assertThat(jpaStore, is(not(nullValue()))); assertThat(fsStore, is(not(nullValue())));