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