Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
ed333a67
Commit
ed333a67
authored
Oct 07, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose Spring Data Rest RepositoryDetectionStrategy
Closes gh-7113
parent
d57f3afd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
RepositoryRestProperties.java
...oot/autoconfigure/data/rest/RepositoryRestProperties.java
+19
-1
RepositoryRestMvcAutoConfigurationTests.java
...re/data/rest/RepositoryRestMvcAutoConfigurationTests.java
+4
-0
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestProperties.java
View file @
ed333a67
/*
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.data.rest;
...
@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.data.rest;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.data.rest.core.config.RepositoryRestConfiguration
;
import
org.springframework.data.rest.core.config.RepositoryRestConfiguration
;
import
org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy.RepositoryDetectionStrategies
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
/**
/**
...
@@ -61,6 +62,12 @@ public class RepositoryRestProperties {
...
@@ -61,6 +62,12 @@ public class RepositoryRestProperties {
*/
*/
private
String
sortParamName
;
private
String
sortParamName
;
/**
* Strategy to use to determine which repositories get exposed.
*/
private
RepositoryDetectionStrategies
detectionStrategy
=
RepositoryDetectionStrategies
.
DEFAULT
;
/**
/**
* Content type to use as a default when none is specified.
* Content type to use as a default when none is specified.
*/
*/
...
@@ -130,6 +137,14 @@ public class RepositoryRestProperties {
...
@@ -130,6 +137,14 @@ public class RepositoryRestProperties {
this
.
sortParamName
=
sortParamName
;
this
.
sortParamName
=
sortParamName
;
}
}
public
RepositoryDetectionStrategies
getDetectionStrategy
()
{
return
this
.
detectionStrategy
;
}
public
void
setDetectionStrategy
(
RepositoryDetectionStrategies
detectionStrategy
)
{
this
.
detectionStrategy
=
detectionStrategy
;
}
public
MediaType
getDefaultMediaType
()
{
public
MediaType
getDefaultMediaType
()
{
return
this
.
defaultMediaType
;
return
this
.
defaultMediaType
;
}
}
...
@@ -181,6 +196,9 @@ public class RepositoryRestProperties {
...
@@ -181,6 +196,9 @@ public class RepositoryRestProperties {
if
(
this
.
sortParamName
!=
null
)
{
if
(
this
.
sortParamName
!=
null
)
{
configuration
.
setSortParamName
(
this
.
sortParamName
);
configuration
.
setSortParamName
(
this
.
sortParamName
);
}
}
if
(
this
.
detectionStrategy
!=
null
)
{
configuration
.
setRepositoryDetectionStrategy
(
this
.
detectionStrategy
);
}
if
(
this
.
defaultMediaType
!=
null
)
{
if
(
this
.
defaultMediaType
!=
null
)
{
configuration
.
setDefaultMediaType
(
this
.
defaultMediaType
);
configuration
.
setDefaultMediaType
(
this
.
defaultMediaType
);
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java
View file @
ed333a67
...
@@ -38,6 +38,7 @@ import org.springframework.context.annotation.Bean;
...
@@ -38,6 +38,7 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.data.rest.core.config.RepositoryRestConfiguration
;
import
org.springframework.data.rest.core.config.RepositoryRestConfiguration
;
import
org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy.RepositoryDetectionStrategies
;
import
org.springframework.data.rest.webmvc.BaseUri
;
import
org.springframework.data.rest.webmvc.BaseUri
;
import
org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration
;
import
org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
...
@@ -94,6 +95,7 @@ public class RepositoryRestMvcAutoConfigurationTests {
...
@@ -94,6 +95,7 @@ public class RepositoryRestMvcAutoConfigurationTests {
"spring.data.rest.page-param-name:_page"
,
"spring.data.rest.page-param-name:_page"
,
"spring.data.rest.limit-param-name:_limit"
,
"spring.data.rest.limit-param-name:_limit"
,
"spring.data.rest.sort-param-name:_sort"
,
"spring.data.rest.sort-param-name:_sort"
,
"spring.data.rest.detection-strategy=visibility"
,
"spring.data.rest.default-media-type:application/my-json"
,
"spring.data.rest.default-media-type:application/my-json"
,
"spring.data.rest.return-body-on-create:false"
,
"spring.data.rest.return-body-on-create:false"
,
"spring.data.rest.return-body-on-update:false"
,
"spring.data.rest.return-body-on-update:false"
,
...
@@ -107,6 +109,8 @@ public class RepositoryRestMvcAutoConfigurationTests {
...
@@ -107,6 +109,8 @@ public class RepositoryRestMvcAutoConfigurationTests {
assertThat
(
bean
.
getPageParamName
()).
isEqualTo
(
"_page"
);
assertThat
(
bean
.
getPageParamName
()).
isEqualTo
(
"_page"
);
assertThat
(
bean
.
getLimitParamName
()).
isEqualTo
(
"_limit"
);
assertThat
(
bean
.
getLimitParamName
()).
isEqualTo
(
"_limit"
);
assertThat
(
bean
.
getSortParamName
()).
isEqualTo
(
"_sort"
);
assertThat
(
bean
.
getSortParamName
()).
isEqualTo
(
"_sort"
);
assertThat
(
bean
.
getRepositoryDetectionStrategy
())
.
isEqualTo
(
RepositoryDetectionStrategies
.
VISIBILITY
);
assertThat
(
bean
.
getDefaultMediaType
())
assertThat
(
bean
.
getDefaultMediaType
())
.
isEqualTo
(
MediaType
.
parseMediaType
(
"application/my-json"
));
.
isEqualTo
(
MediaType
.
parseMediaType
(
"application/my-json"
));
assertThat
(
bean
.
returnBodyOnCreate
(
null
)).
isFalse
();
assertThat
(
bean
.
returnBodyOnCreate
(
null
)).
isFalse
();
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
ed333a67
...
@@ -576,6 +576,7 @@ content into your application; rather pick only the properties that you need.
...
@@ -576,6 +576,7 @@ content into your application; rather pick only the properties that you need.
# DATA REST ({sc-spring-boot-autoconfigure}/data/rest/RepositoryRestProperties.{sc-ext}[RepositoryRestProperties])
# DATA REST ({sc-spring-boot-autoconfigure}/data/rest/RepositoryRestProperties.{sc-ext}[RepositoryRestProperties])
spring.data.rest.base-path= # Base path to be used by Spring Data REST to expose repository resources.
spring.data.rest.base-path= # Base path to be used by Spring Data REST to expose repository resources.
spring.data.rest.default-page-size= # Default size of pages.
spring.data.rest.default-page-size= # Default size of pages.
spring.data.rest.detection-strategy=default # Strategy to use to determine which repositories get exposed.
spring.data.rest.enable-enum-translation= # Enable enum value translation via the Spring Data REST default resource bundle.
spring.data.rest.enable-enum-translation= # Enable enum value translation via the Spring Data REST default resource bundle.
spring.data.rest.limit-param-name= # Name of the URL query string parameter that indicates how many results to return at once.
spring.data.rest.limit-param-name= # Name of the URL query string parameter that indicates how many results to return at once.
spring.data.rest.max-page-size= # Maximum size of pages.
spring.data.rest.max-page-size= # Maximum size of pages.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment