public class RepositoryRestConfiguration extends Object
| Constructor and Description |
|---|
RepositoryRestConfiguration(ProjectionDefinitionConfiguration projectionConfiguration,
MetadataConfiguration metadataConfiguration,
EnumTranslationConfiguration enumTranslationConfiguration)
Creates a new
RepositoryRestConfiguration with the given ProjectionDefinitionConfiguration. |
| Modifier and Type | Method and Description |
|---|---|
void |
disableDefaultExposure()
Disables the default exposure of repositories entirely.
|
RepositoryRestConfiguration |
exposeIdsFor(Class<?>... domainTypes)
Set the list of domain types for which we will expose the ID value as a normal property.
|
boolean |
exposeRepositoryMethodsByDefault()
Returns whether to expose repository methods by default.
|
ResourceMapping |
findRepositoryMappingForPath(String path)
Deprecated.
for removal in 3.5
|
URI |
getBasePath()
The base path to expose repository resources under.
|
URI |
getBaseUri()
Deprecated.
use
getBasePath() instead. |
MediaType |
getDefaultMediaType()
Get the
MediaType to use as a default when none is specified. |
int |
getDefaultPageSize()
Get the default size of
Pageables. |
ResourceMappingConfiguration |
getDomainTypesResourceMappingConfiguration()
Deprecated.
for removal in 3.5
|
List<EntityLookup<?>> |
getEntityLookups(Repositories repositories)
Returns all
EntityLookups considering the customizations made to the configuration. |
EnumTranslationConfiguration |
getEnumTranslationConfiguration()
Returns the
EnumTranslationConfiguration to be used. |
ExposureConfiguration |
getExposureConfiguration() |
String |
getLimitParamName()
Get the name of the URL query string parameter that indicates how many results to return at once.
|
org.springframework.hateoas.server.LinkRelationProvider |
getLinkRelationProvider()
Returns the
LinkRelationProvider configured to calculate the link relation defaults for repositories. |
int |
getMaxPageSize()
Get the maximum size of pages.
|
MetadataConfiguration |
getMetadataConfiguration()
Returns the
MetadataConfiguration to customize metadata exposure. |
String |
getPageParamName()
Get the name of the URL query string parameter that indicates what page to return.
|
ProjectionDefinitionConfiguration |
getProjectionConfiguration()
Returns the
ProjectionDefinitionConfiguration to register addition projections. |
org.springframework.hateoas.server.LinkRelationProvider |
getRelProvider()
Deprecated.
since 3.5, use
getLinkRelationProvider() instead. |
RepositoryDetectionStrategy |
getRepositoryDetectionStrategy()
Returns the
RepositoryDetectionStrategy to be used to decide which repositories get exposed. |
ResourceMapping |
getResourceMappingForDomainType(Class<?> domainType)
Deprecated.
for removal in 3.5
|
ResourceMapping |
getResourceMappingForRepository(Class<?> repositoryInterface)
Deprecated.
for removal in 3.5
|
String |
getSortParamName()
Get the name of the URL query string parameter that indicates what direction to sort results.
|
boolean |
hasResourceMappingForDomainType(Class<?> domainType)
Deprecated.
for removal in 3.5
|
boolean |
hasResourceMappingForRepository(Class<?> repositoryInterface)
Deprecated.
for removal in 3.5
|
boolean |
isEnableEnumTranslation()
Returns whether enum value translation is enabled.
|
boolean |
isIdExposedFor(Class<?> domainType)
Should we expose the ID property for this domain type?
|
boolean |
isLookupType(Class<?> type) |
Boolean |
isReturnBodyOnCreate()
Deprecated.
|
Boolean |
isReturnBodyOnUpdate()
Deprecated.
|
MetadataConfiguration |
metadataConfiguration()
Deprecated.
since 2.4, use
getMetadataConfiguration() instead. |
ProjectionDefinitionConfiguration |
projectionConfiguration()
Deprecated.
since 2.4, use
getProjectionConfiguration() instead. |
boolean |
returnBodyOnCreate(String acceptHeader)
Whether to return a response body after creating an entity considering the given accept header.
|
boolean |
returnBodyOnUpdate(String acceptHeader)
Whether to return a response body after updating an entity considering the given accept header.
|
RepositoryRestConfiguration |
setBasePath(String basePath)
Configures the base path to be used by Spring Data REST to expose repository resources.
|
RepositoryRestConfiguration |
setDefaultMediaType(MediaType defaultMediaType)
Set the
MediaType to use as a default when none is specified. |
RepositoryRestConfiguration |
setDefaultPageSize(int defaultPageSize)
Set the default size of
Pageables. |
RepositoryRestConfiguration |
setEnableEnumTranslation(boolean enableEnumTranslation)
Configures whether to enable enum value translation via the Spring Data REST default resource bundle.
|
void |
setExposeRepositoryMethodsByDefault(boolean exposeRepositoryMethodsByDefault)
Sets whether to expose repository methods by default.
|
RepositoryRestConfiguration |
setLimitParamName(String limitParamName)
Set the name of the URL query string parameter that indicates how many results to return at once.
|
RepositoryRestConfiguration |
setLinkRelationProvider(org.springframework.hateoas.server.LinkRelationProvider provider)
Configures the
LinkRelationProvider to be used to calculate the LinkRelation defaults for
repositories. |
RepositoryRestConfiguration |
setMaxPageSize(int maxPageSize)
Set the maximum size of pages.
|
RepositoryRestConfiguration |
setPageParamName(String pageParamName)
Set the name of the URL query string parameter that indicates what page to return.
|
void |
setRelProvider(org.springframework.hateoas.server.LinkRelationProvider relProvider)
Deprecated.
since 3.5, use
setLinkRelationProvider(LinkRelationProvider) instead. |
RepositoryRestConfiguration |
setRepositoryDetectionStrategy(RepositoryDetectionStrategy repositoryDetectionStrategy)
Configures the
RepositoryDetectionStrategy to be used to determine which repositories get exposed. |
ResourceMapping |
setResourceMappingForDomainType(Class<?> domainType)
Deprecated.
for removal in 3.5
|
ResourceMapping |
setResourceMappingForRepository(Class<?> repositoryInterface)
Deprecated.
for removal in 3.5
|
RepositoryRestConfiguration |
setReturnBodyForPutAndPost(Boolean returnBody)
Convenience method to activate returning response bodies for all
PUT and POST requests, i.e. both
creating and updating entities. |
RepositoryRestConfiguration |
setReturnBodyOnCreate(Boolean returnBody)
Set whether to return a response body after creating an entity.
|
RepositoryRestConfiguration |
setReturnBodyOnUpdate(Boolean returnBodyOnUpdate)
Set whether to return a response body after updating an entity.
|
RepositoryRestConfiguration |
setSortParamName(String sortParamName)
Set the name of the URL query string parameter that indicates what direction to sort results.
|
boolean |
useHalAsDefaultJsonMediaType()
Returns whether HAL will be served as primary representation in case on
application/json is requested. |
RepositoryRestConfiguration |
useHalAsDefaultJsonMediaType(boolean useHalAsDefaultJsonMediaType)
Configures whether HAL will be served as primary representation in case on
application/json is requested. |
EntityLookupRegistrar |
withEntityLookup()
Returns the
EntityLookupRegistrar to create custom EntityLookup instances registered in the
configuration. |
public RepositoryRestConfiguration(ProjectionDefinitionConfiguration projectionConfiguration, MetadataConfiguration metadataConfiguration, EnumTranslationConfiguration enumTranslationConfiguration)
RepositoryRestConfiguration with the given ProjectionDefinitionConfiguration.projectionConfiguration - must not be null.metadataConfiguration - must not be null.enumTranslationConfiguration - must not be null.@Deprecated public URI getBaseUri()
getBasePath() instead.public URI getBasePath()
public RepositoryRestConfiguration setBasePath(String basePath)
basePath - the basePath to setpublic int getDefaultPageSize()
Pageables. Default is 20.public RepositoryRestConfiguration setDefaultPageSize(int defaultPageSize)
Pageables.defaultPageSize - The default page size.public int getMaxPageSize()
public RepositoryRestConfiguration setMaxPageSize(int maxPageSize)
maxPageSize - Maximum page size.public String getPageParamName()
public RepositoryRestConfiguration setPageParamName(String pageParamName)
pageParamName - Name of the query parameter used to indicate the page number to return.public String getLimitParamName()
public RepositoryRestConfiguration setLimitParamName(String limitParamName)
limitParamName - Name of the query parameter used to indicate the maximum number of entries to return at a
time.public String getSortParamName()
public RepositoryRestConfiguration setSortParamName(String sortParamName)
sortParamName - Name of the query string parameter used to indicate what field to sort on.public MediaType getDefaultMediaType()
MediaType to use as a default when none is specified.public RepositoryRestConfiguration setDefaultMediaType(MediaType defaultMediaType)
MediaType to use as a default when none is specified.defaultMediaType - default content type if none has been specified.public boolean useHalAsDefaultJsonMediaType()
application/json is requested. This
defaults to true. If configured to false the legacy Spring Data representation will be
rendered.public RepositoryRestConfiguration useHalAsDefaultJsonMediaType(boolean useHalAsDefaultJsonMediaType)
application/json is requested.
This defaults to true. If configured to false the legacy Spring Data representation will be
rendered.useHalAsDefaultJsonMediaType - public RepositoryRestConfiguration setReturnBodyForPutAndPost(Boolean returnBody)
PUT and POST requests, i.e. both
creating and updating entities.returnBody - can be null, expressing the decision shall be derived from the presence of an
Accept header in the request.@Deprecated public Boolean isReturnBodyOnCreate()
returnBodyOnCreate(String)Boolean.TRUE to enforce returning a body on create, Boolean.FALSE
otherwise. If null and an Accept header present in the request will cause a body being
returned. If the Accept header is not present, no body will be rendered.public boolean returnBodyOnCreate(String acceptHeader)
acceptHeader - can be null or empty.public RepositoryRestConfiguration setReturnBodyOnCreate(Boolean returnBody)
returnBody - can be null, expressing the decision shall be derived from the presence of an
Accept header in the request.@Deprecated public Boolean isReturnBodyOnUpdate()
returnBodyOnUpdate(String)Boolean.TRUE to enforce returning a body on create, Boolean.FALSE
otherwise. If null and an Accept header present in the request will cause a body being
returned. If the Accept header is not present, no body will be rendered.public boolean returnBodyOnUpdate(String acceptHeader)
acceptHeader - can be null or empty.public RepositoryRestConfiguration setReturnBodyOnUpdate(Boolean returnBodyOnUpdate)
returnBody - can be null, expressing the decision shall be derived from the presence of an
Accept header in the request.@Deprecated public ResourceMapping setResourceMappingForDomainType(Class<?> domainType)
ResourceMapping for a specific domain type.domainType - The Class of the domain type to configure a mapping for.ResourceMapping for configuring how a domain type is mapped.@Deprecated public ResourceMapping getResourceMappingForDomainType(Class<?> domainType)
ResourceMapping for a specific domain type.domainType - The Class of the domain type.ResourceMapping for that domain type or null if none exists.@Deprecated public boolean hasResourceMappingForDomainType(Class<?> domainType)
ResourceMapping for the given domain type.domainType - The domain type to find a ResourceMapping for.ResourceMapping exists for this domain class, false otherwise.@Deprecated public ResourceMappingConfiguration getDomainTypesResourceMappingConfiguration()
ResourceMappingConfiguration that is currently configured.@Deprecated public ResourceMapping setResourceMappingForRepository(Class<?> repositoryInterface)
ResourceMapping for a specific repository interface.repositoryInterface - The Class of the repository interface to configure a mapping for.ResourceMapping for configuring how a repository interface is mapped.@Deprecated public ResourceMapping getResourceMappingForRepository(Class<?> repositoryInterface)
ResourceMapping for a specific repository interface.repositoryInterface - The Class of the repository interface.ResourceMapping for that repository interface or null if none exists.@Deprecated public boolean hasResourceMappingForRepository(Class<?> repositoryInterface)
ResourceMapping configured for this Repository class.repositoryInterface - @Deprecated public ResourceMapping findRepositoryMappingForPath(String path)
public boolean isIdExposedFor(Class<?> domainType)
domainType - The domain type we may need to expose the ID for.public RepositoryRestConfiguration exposeIdsFor(Class<?>... domainTypes)
domainTypes - Array of types to expose IDs for.@Deprecated public ProjectionDefinitionConfiguration projectionConfiguration()
getProjectionConfiguration() instead.ProjectionDefinitionConfiguration to register addition projections.public ProjectionDefinitionConfiguration getProjectionConfiguration()
ProjectionDefinitionConfiguration to register addition projections.@Deprecated public MetadataConfiguration metadataConfiguration()
getMetadataConfiguration() instead.MetadataConfiguration to customize metadata exposure.public MetadataConfiguration getMetadataConfiguration()
MetadataConfiguration to customize metadata exposure.public RepositoryRestConfiguration setEnableEnumTranslation(boolean enableEnumTranslation)
EnumTranslator.enableEnumTranslation - getEnumTranslationConfiguration()public boolean isEnableEnumTranslation()
public EnumTranslationConfiguration getEnumTranslationConfiguration()
EnumTranslationConfiguration to be used.public RepositoryDetectionStrategy getRepositoryDetectionStrategy()
RepositoryDetectionStrategy to be used to decide which repositories get exposed. Will be
RepositoryDetectionStrategy.RepositoryDetectionStrategies.DEFAULT by default.RepositoryDetectionStrategy.RepositoryDetectionStrategiespublic RepositoryRestConfiguration setRepositoryDetectionStrategy(RepositoryDetectionStrategy repositoryDetectionStrategy)
RepositoryDetectionStrategy to be used to determine which repositories get exposed. Defaults
to RepositoryDetectionStrategy.RepositoryDetectionStrategies.DEFAULT.repositoryDetectionStrategy - can be null.public boolean exposeRepositoryMethodsByDefault()
setExposeRepositoryMethodsByDefault(boolean)public void setExposeRepositoryMethodsByDefault(boolean exposeRepositoryMethodsByDefault)
RestResource explicitly to expose the default set of resources (opt-in). If this is set to true
(default), repository methods methods are exposed unless explictly annotated with RestResource and
RestResource.exported() set to false.setRepositoryDetectionStrategy(RepositoryDetectionStrategy)public void disableDefaultExposure()
RepositoryRestResource and methods need to be annotated with RestResource to trigger
exposure of default resources. Basically a shortcut for calling both
setRepositoryDetectionStrategy(RepositoryDetectionStrategy) to
RepositoryDetectionStrategy.RepositoryDetectionStrategies.ANNOTATED and setting setExposeRepositoryMethodsByDefault(boolean)
to false.public EntityLookupRegistrar withEntityLookup()
EntityLookupRegistrar to create custom EntityLookup instances registered in the
configuration.EntityLookupRegistrar to build custom EntityLookups.public List<EntityLookup<?>> getEntityLookups(Repositories repositories)
EntityLookups considering the customizations made to the configuration.repositories - must not be null.public boolean isLookupType(Class<?> type)
@Deprecated public org.springframework.hateoas.server.LinkRelationProvider getRelProvider()
getLinkRelationProvider() instead.LinkRelationProvider to be used to calculate the link relation defaults for repositories.@Deprecated public void setRelProvider(org.springframework.hateoas.server.LinkRelationProvider relProvider)
setLinkRelationProvider(LinkRelationProvider) instead.RelProvider to be used to calculate the link relation defaults for repositories.public org.springframework.hateoas.server.LinkRelationProvider getLinkRelationProvider()
LinkRelationProvider configured to calculate the link relation defaults for repositories.
Defaults to a delegating wrapper around an AnnotationLinkRelationProvider and
EvoInflectorLinkRelationProvider.setLinkRelationProvider(LinkRelationProvider),
AnnotationLinkRelationProvider,
EvoInflectorLinkRelationProviderpublic RepositoryRestConfiguration setLinkRelationProvider(org.springframework.hateoas.server.LinkRelationProvider provider)
LinkRelationProvider to be used to calculate the LinkRelation defaults for
repositories. The provided instance will replace the default setup completely. For details on the defaults and
setting up a similar, delegating arrangement, see getLinkRelationProvider().provider - must not be null.public ExposureConfiguration getExposureConfiguration()
Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.