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 |
---|---|
RepositoryRestConfiguration |
exposeIdsFor(Class<?>... domainTypes)
Set the list of domain types for which we will expose the ID value as a normal property.
|
ResourceMapping |
findRepositoryMappingForPath(String path) |
URI |
getBasePath()
The base path to expose repository resources under.
|
URI |
getBaseUri()
The base URI against which the exporter should calculate its links.
|
MediaType |
getDefaultMediaType()
Get the
MediaType to use as a default when none is specified. |
int |
getDefaultPageSize()
Get the default size of
Pageable s. |
ResourceMappingConfiguration |
getDomainTypesResourceMappingConfiguration()
Get the
ResourceMappingConfiguration that is currently configured. |
EnumTranslationConfiguration |
getEnumSerializationConfiguration()
Returns the
EnumTranslator for |
String |
getLimitParamName()
Get the name of the URL query string parameter that indicates how many results to return at once.
|
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. |
ResourceMapping |
getResourceMappingForDomainType(Class<?> domainType)
Get the
ResourceMapping for a specific domain type. |
ResourceMapping |
getResourceMappingForRepository(Class<?> repositoryInterface)
Get the
ResourceMapping for a specific repository interface. |
String |
getSortParamName()
Get the name of the URL query string parameter that indicates what direction to sort results.
|
boolean |
hasResourceMappingForDomainType(Class<?> domainType)
Whether there is a
ResourceMapping for the given domain type. |
boolean |
hasResourceMappingForRepository(Class<?> repositoryInterface)
Whether there is a
ResourceMapping configured for this Repository class. |
boolean |
isEnableEnumTranslation()
Returns whether enum value translation is enabled.
|
boolean |
isIdExposedFor(Class<?> domainType)
Should we expose the ID property for this domain 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.
|
void |
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
Pageable s. |
void |
setEnableEnumTranslation(boolean enableEnumTranslation)
Configures whether to enable enum value translation via the Spring Data REST default resource bundle.
|
RepositoryRestConfiguration |
setLimitParamName(String limitParamName)
Set the name of the URL query string parameter that indicates how many results to return at once.
|
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.
|
ResourceMapping |
setResourceMappingForDomainType(Class<?> domainType)
Start configuration a
ResourceMapping for a specific domain type. |
ResourceMapping |
setResourceMappingForRepository(Class<?> repositoryInterface)
Start configuration a
ResourceMapping for a specific repository interface. |
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. |
public RepositoryRestConfiguration(ProjectionDefinitionConfiguration projectionConfiguration, MetadataConfiguration metadataConfiguration, EnumTranslationConfiguration enumTranslationConfiguration)
RepositoryRestConfiguration
with the given ProjectionDefinitionConfiguration
.projectionConfiguration
- must not be null.metadataConfiguration
- must not be null.public URI getBaseUri()
public URI getBasePath()
public void setBasePath(String basePath)
basePath
- the basePath to setpublic int getDefaultPageSize()
Pageable
s. Default is 20.public RepositoryRestConfiguration setDefaultPageSize(int defaultPageSize)
Pageable
s.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.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.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.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.public ResourceMappingConfiguration getDomainTypesResourceMappingConfiguration()
ResourceMappingConfiguration
that is currently configured.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.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.public boolean hasResourceMappingForRepository(Class<?> repositoryInterface)
ResourceMapping
configured for this Repository class.repositoryInterface
- 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 void setEnableEnumTranslation(boolean enableEnumTranslation)
EnumTranslator
.enableEnumTranslation
- getEnumSerializationConfiguration()
public boolean isEnableEnumTranslation()
public EnumTranslationConfiguration getEnumSerializationConfiguration()
EnumTranslator
forCopyright © 2011-2015–2016 Pivotal Software, Inc.. All rights reserved.