Merge branch '1.5.x'

This commit is contained in:
Stephane Nicoll 2016-10-07 10:35:59 +02:00
commit 5a2eae5628
3 changed files with 24 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (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;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy.RepositoryDetectionStrategies;
import org.springframework.http.MediaType;
/**
@ -61,6 +62,12 @@ public class RepositoryRestProperties {
*/
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.
*/
@ -130,6 +137,14 @@ public class RepositoryRestProperties {
this.sortParamName = sortParamName;
}
public RepositoryDetectionStrategies getDetectionStrategy() {
return this.detectionStrategy;
}
public void setDetectionStrategy(RepositoryDetectionStrategies detectionStrategy) {
this.detectionStrategy = detectionStrategy;
}
public MediaType getDefaultMediaType() {
return this.defaultMediaType;
}
@ -181,6 +196,9 @@ public class RepositoryRestProperties {
if (this.sortParamName != null) {
configuration.setSortParamName(this.sortParamName);
}
if (this.detectionStrategy != null) {
configuration.setRepositoryDetectionStrategy(this.detectionStrategy);
}
if (this.defaultMediaType != null) {
configuration.setDefaultMediaType(this.defaultMediaType);
}

View File

@ -38,6 +38,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
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.config.RepositoryRestMvcConfiguration;
import org.springframework.http.MediaType;
@ -94,6 +95,7 @@ public class RepositoryRestMvcAutoConfigurationTests {
"spring.data.rest.page-param-name:_page",
"spring.data.rest.limit-param-name:_limit",
"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.return-body-on-create:false",
"spring.data.rest.return-body-on-update:false",
@ -107,6 +109,8 @@ public class RepositoryRestMvcAutoConfigurationTests {
assertThat(bean.getPageParamName()).isEqualTo("_page");
assertThat(bean.getLimitParamName()).isEqualTo("_limit");
assertThat(bean.getSortParamName()).isEqualTo("_sort");
assertThat(bean.getRepositoryDetectionStrategy())
.isEqualTo(RepositoryDetectionStrategies.VISIBILITY);
assertThat(bean.getDefaultMediaType())
.isEqualTo(MediaType.parseMediaType("application/my-json"));
assertThat(bean.returnBodyOnCreate(null)).isFalse();

View File

@ -575,6 +575,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])
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.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.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.