Exemple #1
0
 /** SEARCH /_search/roles/:query -> search for the role corresponding to the query. */
 @RequestMapping(
     value = "/_search/roles/{query}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public List<Role> searchRoles(@PathVariable String query) {
   return StreamSupport.stream(
           roleSearchRepository.search(queryStringQuery(query)).spliterator(), false)
       .collect(Collectors.toList());
 }
Exemple #2
0
 /** DELETE /roles/:id -> delete the "id" role. */
 @RequestMapping(
     value = "/roles/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> deleteRole(@PathVariable Long id) {
   log.debug("REST request to delete Role : {}", id);
   roleRepository.delete(id);
   roleSearchRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("role", id.toString()))
       .build();
 }
Exemple #3
0
 /** PUT /roles -> Updates an existing role. */
 @RequestMapping(
     value = "/roles",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Role> updateRole(@Valid @RequestBody Role role) throws URISyntaxException {
   log.debug("REST request to update Role : {}", role);
   if (role.getId() == null) {
     return createRole(role);
   }
   Role result = roleRepository.save(role);
   roleSearchRepository.save(role);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityUpdateAlert("role", role.getId().toString()))
       .body(result);
 }
Exemple #4
0
 /** POST /roles -> Create a new role. */
 @RequestMapping(
     value = "/roles",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Role> createRole(@Valid @RequestBody Role role) throws URISyntaxException {
   log.debug("REST request to save Role : {}", role);
   if (role.getId() != null) {
     return ResponseEntity.badRequest()
         .header("Failure", "A new role cannot already have an ID")
         .body(null);
   }
   Role result = roleRepository.save(role);
   roleSearchRepository.save(result);
   return ResponseEntity.created(new URI("/api/roles/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("role", result.getId().toString()))
       .body(result);
 }