Пример #1
0
 /** GET /issuers -> get all the issuers. */
 @RequestMapping(
     value = "/issuers",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<List<Issuer>> getAllIssuers(Pageable pageable) throws URISyntaxException {
   log.debug("REST request to get a page of Issuers");
   Page<Issuer> page = issuerRepository.findAll(pageable);
   HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/issuers");
   return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
 }
Пример #2
0
 /** GET /issuers/:id -> get the "id" issuer. */
 @RequestMapping(
     value = "/issuers/{id}",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Issuer> getIssuer(@PathVariable Long id) {
   log.debug("REST request to get Issuer : {}", id);
   Issuer issuer = issuerRepository.findOne(id);
   return Optional.ofNullable(issuer)
       .map(result -> new ResponseEntity<>(result, HttpStatus.OK))
       .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
 }
Пример #3
0
 /** DELETE /issuers/:id -> delete the "id" issuer. */
 @RequestMapping(
     value = "/issuers/{id}",
     method = RequestMethod.DELETE,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Void> deleteIssuer(@PathVariable Long id) {
   log.debug("REST request to delete Issuer : {}", id);
   issuerRepository.delete(id);
   issuerSearchRepository.delete(id);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityDeletionAlert("issuer", id.toString()))
       .build();
 }
Пример #4
0
 /** PUT /issuers -> Updates an existing issuer. */
 @RequestMapping(
     value = "/issuers",
     method = RequestMethod.PUT,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Issuer> updateIssuer(@Valid @RequestBody Issuer issuer)
     throws URISyntaxException {
   log.debug("REST request to update Issuer : {}", issuer);
   if (issuer.getId() == null) {
     return createIssuer(issuer);
   }
   Issuer result = issuerRepository.save(issuer);
   issuerSearchRepository.save(result);
   return ResponseEntity.ok()
       .headers(HeaderUtil.createEntityUpdateAlert("issuer", issuer.getId().toString()))
       .body(result);
 }
Пример #5
0
 /** POST /issuers -> Create a new issuer. */
 @RequestMapping(
     value = "/issuers",
     method = RequestMethod.POST,
     produces = MediaType.APPLICATION_JSON_VALUE)
 @Timed
 public ResponseEntity<Issuer> createIssuer(@Valid @RequestBody Issuer issuer)
     throws URISyntaxException {
   log.debug("REST request to save Issuer : {}", issuer);
   if (issuer.getId() != null) {
     return ResponseEntity.badRequest()
         .headers(
             HeaderUtil.createFailureAlert(
                 "issuer", "idexists", "A new issuer cannot already have an ID"))
         .body(null);
   }
   Issuer result = issuerRepository.save(issuer);
   issuerSearchRepository.save(result);
   return ResponseEntity.created(new URI("/api/issuers/" + result.getId()))
       .headers(HeaderUtil.createEntityCreationAlert("issuer", result.getId().toString()))
       .body(result);
 }