Class ClipController
- java.lang.Object
-
- edu.cnm.deepdive.tunefull.controller.ClipController
-
@RestController @RequestMapping("/clips") @ExposesResourceFor(Clip.class) public class ClipController extends java.lang.Object
ClipController
provides endpoints which allow the client to access data relating toClip
.- Since:
- 1.0
- Version:
- 1.0
- Author:
- Robert Dominugez, Roderick Frechette, Laura Steiner
-
-
Constructor Summary
Constructors Constructor Description ClipController(ClipService clipService)
Autowired constructor forClipController
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(org.springframework.security.core.Authentication auth, Clip clip)
Deletes a clip only if it has been posted by the current user.Clip
get(org.springframework.security.core.Authentication auth, long clipId)
Gets a selected clip by id.java.util.List<Clip>
getAll(org.springframework.security.core.Authentication auth, int limit, int offset, ClipService.Source source)
Returns all of the most recent clips, limited by parameters.Clip
post(org.springframework.security.core.Authentication auth, Clip clip)
Posts a clip for the current user.
-
-
-
Constructor Detail
-
ClipController
@Autowired public ClipController(ClipService clipService)
Autowired constructor forClipController
.- Parameters:
clipService
- ClipService
-
-
Method Detail
-
getAll
@GetMapping(produces="application/json") public java.util.List<Clip> getAll(org.springframework.security.core.Authentication auth, @RequestParam(required=false,defaultValue="10") int limit, @RequestParam(required=false,defaultValue="0") int offset, @RequestParam(required=false,defaultValue="ALL") ClipService.Source source)
Returns all of the most recent clips, limited by parameters. The source parameter allows for the client to get all clips, only clips by friends, only clips by followers, only clips by users in a relationship with the user, or only clips by the user.- Parameters:
auth
- Authenticationlimit
- intoffset
- intsource
- Source enum- Returns:
- List<Clip>
-
get
@GetMapping(value="/{clipId}", produces="application/json") public Clip get(org.springframework.security.core.Authentication auth, @PathVariable long clipId)
Gets a selected clip by id.- Parameters:
auth
- AuthenticationclipId
- long- Returns:
- a selected clip
-
post
@ResponseStatus(CREATED) @PostMapping(consumes="application/json", produces="application/json") public Clip post(org.springframework.security.core.Authentication auth, @RequestBody Clip clip)
Posts a clip for the current user.- Parameters:
auth
- Authenticationclip
- Clip- Returns:
- the clip that was posted
-
delete
@ResponseStatus(NO_CONTENT) @DeleteMapping(consumes="application/json") public void delete(org.springframework.security.core.Authentication auth, @RequestBody Clip clip)
Deletes a clip only if it has been posted by the current user.- Parameters:
auth
- Authenticationclip
- Clip
-
-