Example #1
0
 /** DELETE /group/:id -> delete the "id" group. */
 @RequestMapping(
     value = "/group/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public void delete(@PathVariable Long id) {
   log.debug("REST request to delete    : {}", id);
   groupRepository.delete(id);
 }
Example #2
0
 /** GET /group -> get all the group. */
 @RequestMapping(
     value = "/group",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<List<Group>> getAll(Pageable pageable) throws URISyntaxException {
   Page<Group> page = groupRepository.findAll(pageable);
   HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/group");
   return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
 }
Example #3
0
 /** GET /group/:id -> get the "id" group. */
 @RequestMapping(
     value = "/group/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Group> get(@PathVariable Long id) {
   log.debug("REST request to get Group : {}", id);
   return Optional.ofNullable(groupRepository.findOne(id))
       .map(group -> new ResponseEntity<>(group, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
Example #4
0
 /** PUT /group -> Updates an existing group. */
 @RequestMapping(
     value = "/group",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> update(@RequestBody Group group) throws URISyntaxException {
   log.debug("REST request to update Group : {}", group);
   if (group.getId() == null) {
     return create(group);
   }
   groupRepository.save(group);
   return ResponseEntity.ok().build();
 }
Example #5
0
 /** POST /group -> Create a new group. */
 @RequestMapping(
     value = "/group",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> create(@RequestBody Group group) throws URISyntaxException {
   log.debug("REST request to save Group : {}", group);
   if (group.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new group cannot already have an ID")
         .build();
   }
   groupRepository.save(group);
   return ResponseEntity.created(new URI("/api/group/" + group.getId())).build();
 }