Esempio n. 1
0
 /** GET /environments/:id -> get the "id" environment. */
 @RequestMapping(
     value = "/environments/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Environment> getEnvironment(@PathVariable Long id) {
   log.debug("REST request to get Environment : {}", id);
   return Optional.ofNullable(environmentRepository.findOne(id))
       .map(environment -> new ResponseEntity<>(environment, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
Esempio n. 2
0
 /** GET /environments -> get all the environments. */
 @RequestMapping(
     value = "/environments",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<List<Environment>> getAllEnvironments(Pageable pageable)
     throws URISyntaxException {
   Page<Environment> page = environmentRepository.findAll(pageable);
   HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/environments");
   return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
 }
Esempio n. 3
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();
 }
Esempio n. 4
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);
 }
Esempio n. 5
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);
 }