public abstract class CRUDController<T extends StorableObject,I extends Serializable> extends Object
Constructor and Description |
---|
CRUDController() |
Modifier and Type | Method and Description |
---|---|
void |
deleteObject(String id)
Delete an existing object
|
protected abstract CRUDService<T> |
getCRUDService()
getCRUDService.
|
T |
getObject(String id,
javax.servlet.http.HttpServletResponse response)
Get a specific object by its id.
|
Iterable<T> |
getObjects(int offset,
int limit)
Get a (potentially paginated) list of objects
|
T |
saveObject(T object)
Save a new object
|
T |
updateObject(I id,
T object,
javax.servlet.http.HttpServletResponse response)
Update an existing object
|
protected abstract CRUDService<T> getCRUDService()
getCRUDService.
CRUDService
object.@RequestMapping(method=GET) @ResponseBody public Iterable<T> getObjects(@RequestParam(value="offset",defaultValue="0") int offset, @RequestParam(value="limit",defaultValue="-1") int limit)
offset
- the page number to get (0 by default is the first page)limit
- the maximum number of entries in the page of results ( > 0 to activate pagination,
-1 thus everything by default )@RequestMapping(value="{id}", method=GET) @ResponseBody public T getObject(@PathVariable(value="id") String id, javax.servlet.http.HttpServletResponse response)
id
- the id of the objectresponse
- a HttpServletResponse
object.@RequestMapping(method=POST, consumes="application/json") @ResponseBody public T saveObject(@RequestBody T object)
object
- the object to save@RequestMapping(value="{id}", method=PUT, consumes="application/json") @ResponseBody public T updateObject(@PathVariable(value="id") I id, @RequestBody T object, javax.servlet.http.HttpServletResponse response)
id
- the id of the object to updateobject
- the object to updateresponse
- a HttpServletResponse
object.@RequestMapping(value="{id}", method=DELETE) @ResponseStatus(value=NO_CONTENT) public void deleteObject(@PathVariable(value="id") String id)
id
- the id of the object to deleteCopyright © 2011–2016 eXo Platform SAS. All rights reserved.