DATAREST-553 - Removed RepositoryRestConfiguration.setBaseUri(…).
Updated existing unit tests to use setBasePath. Added extra assertion to setBasePath to guard against sending in a URI with a protocol. Original pull request: #178.
This commit is contained in:
committed by
Oliver Gierke
parent
018fa22593
commit
07986acc54
@@ -33,6 +33,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Jon Brisbin
|
||||
* @author Oliver Gierke
|
||||
* @author Jeremy Rickard
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RepositoryRestConfiguration {
|
||||
@@ -98,40 +99,6 @@ public class RepositoryRestConfiguration {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base URI against which the exporter should calculate its links.
|
||||
*
|
||||
* @param baseUri must not be {@literal null}.
|
||||
* @deprecated use {@link #setBasePath(String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public RepositoryRestConfiguration setBaseUri(URI baseUri) {
|
||||
|
||||
Assert.notNull(baseUri, "The base URI cannot be null.");
|
||||
|
||||
LOGGER.warn("Configuring a base URI has been deprecated. Use basePath property instead!");
|
||||
|
||||
if (baseUri.isAbsolute()) {
|
||||
LOGGER
|
||||
.warn("Using absolute base URIs will not be supported as of Spring Data REST 2.3! Be sure to switch to configuring a base path!");
|
||||
}
|
||||
|
||||
this.baseUri = baseUri;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base URI against which the exporter should calculate its links.
|
||||
*
|
||||
* @param baseUri must not be {@literal null}.
|
||||
* @deprecated use {@link #setBasePath(String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public RepositoryRestConfiguration setBaseUri(String baseUri) {
|
||||
Assert.notNull(baseUri, "The base URI cannot be null.");
|
||||
return setBaseUri(URI.create(baseUri));
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the base path to be used by Spring Data REST to expose repository resources.
|
||||
*
|
||||
@@ -139,6 +106,7 @@ public class RepositoryRestConfiguration {
|
||||
*/
|
||||
public void setBasePath(String basePath) {
|
||||
|
||||
Assert.isTrue(!basePath.startsWith("http"), "Use a path not a URI");
|
||||
basePath = StringUtils.trimTrailingCharacter(basePath, '/');
|
||||
this.basePath = URI.create(basePath.startsWith("/") ? basePath : "/".concat(basePath));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user