public abstract class AbstractApiController<T extends Model<ID>,ID extends Serializable> extends Object implements WebServicesController<T,ID>, org.springframework.context.ApplicationContextAware
WebServicesController for GET, HEAD, and OPTIONS requests.
Supports dynamic queries of repository resources using annotated Model classes,
field filtering, pagination, and hypermedia support.| Constructor and Description |
|---|
AbstractApiController(RepositoryOperations<T,ID> repository,
Class<T> model,
org.springframework.hateoas.mvc.ResourceAssemblerSupport<T,FilterableResource> assembler) |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.http.HttpEntity<?> |
find(org.springframework.data.domain.Pageable pageable,
org.springframework.data.web.PagedResourcesAssembler<T> pagedResourcesAssembler,
javax.servlet.http.HttpServletRequest request)
Queries the repository using inputted query string paramters, defined within a annotated
Model classes. |
org.springframework.http.HttpEntity<?> |
findById(ID id,
javax.servlet.http.HttpServletRequest request)
GET /{id}
Fetches a single record by its primary ID and returns it, or a Not Found exception if not. |
org.springframework.http.HttpEntity<?> |
findDistinct(String field,
javax.servlet.http.HttpServletRequest request)
GET /distinct
Fetches the distinct values of the model attribute, field, which fulfill the given
query parameters. |
org.springframework.hateoas.mvc.ResourceAssemblerSupport<T,FilterableResource> |
getAssembler() |
Class<T> |
getModel() |
RepositoryOperations<T,ID> |
getRepository() |
org.springframework.http.HttpEntity<?> |
head(javax.servlet.http.HttpServletRequest request)
HEAD /**
Performs a test on the resource endpoints availability. |
org.springframework.http.HttpEntity<?> |
options(javax.servlet.http.HttpServletRequest request)
OPTIONS /
Returns an information about the endpoint and available parameters. |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, delete, updatepublic AbstractApiController(RepositoryOperations<T,ID> repository, Class<T> model, org.springframework.hateoas.mvc.ResourceAssemblerSupport<T,FilterableResource> assembler)
@RequestMapping(value="/{id}",
method=GET,
produces={"application/hal+json","application/json","application/hal+xml","application/xml","text/plain"})
public org.springframework.http.HttpEntity<?> findById(@PathVariable
ID id,
javax.servlet.http.HttpServletRequest request)
GET /{id}
Fetches a single record by its primary ID and returns it, or a Not Found exception if not.findById in interface WebServicesController<T extends Model<ID>,ID extends Serializable>id - primary ID for the target record.T instance@RequestMapping(value="/distinct",
method=GET,
produces={"application/hal+json","application/json","application/hal+xml","application/xml","text/plain"})
public org.springframework.http.HttpEntity<?> findDistinct(@RequestParam
String field,
javax.servlet.http.HttpServletRequest request)
GET /distinct
Fetches the distinct values of the model attribute, field, which fulfill the given
query parameters.findDistinct in interface WebServicesController<T extends Model<ID>,ID extends Serializable>field - Name of the model attribute to retrieve unique values of.request - HttpServletRequest@RequestMapping(value="",
method=GET,
produces={"application/json","application/hal+json","application/hal+xml","application/xml","text/plain"})
public org.springframework.http.HttpEntity<?> find(@PageableDefault(size=1000)
org.springframework.data.domain.Pageable pageable,
org.springframework.data.web.PagedResourcesAssembler<T> pagedResourcesAssembler,
javax.servlet.http.HttpServletRequest request)
Model classes. Supports hypermedia, pagination, sorting, field
filtering, and field exclusion.find in interface WebServicesController<T extends Model<ID>,ID extends Serializable>pagedResourcesAssembler - PagedResourcesAssemblerrequest - HttpServletRequest@RequestMapping(value={"","/**"},
method=HEAD)
public org.springframework.http.HttpEntity<?> head(javax.servlet.http.HttpServletRequest request)
HEAD /**
Performs a test on the resource endpoints availability.head in interface WebServicesController<T extends Model<ID>,ID extends Serializable>@RequestMapping(method=OPTIONS) public org.springframework.http.HttpEntity<?> options(javax.servlet.http.HttpServletRequest request)
OPTIONS /
Returns an information about the endpoint and available parameters.
TODOoptions in interface WebServicesController<T extends Model<ID>,ID extends Serializable>public RepositoryOperations<T,ID> getRepository()
public org.springframework.hateoas.mvc.ResourceAssemblerSupport<T,FilterableResource> getAssembler()
@Autowired public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext in interface org.springframework.context.ApplicationContextAwareCopyright © 2016. All rights reserved.