Пример #1
0
  @RequestMapping(value = "/events/{eventName}/pending-payments/bulk-confirmation", method = POST)
  public List<Triple<Boolean, String, String>> bulkConfirmation(
      @PathVariable("eventName") String eventName,
      Principal principal,
      @RequestBody UploadBase64FileModification file)
      throws IOException {

    try (InputStreamReader isr = new InputStreamReader(file.getInputStream());
        CSVReader reader = new CSVReader(isr)) {
      Event event = loadEvent(eventName, principal);
      return reader
          .readAll()
          .stream()
          .map(
              line -> {
                String reservationID = null;
                try {
                  Validate.isTrue(line.length >= 2);
                  reservationID = line[0];
                  ticketReservationManager.validateAndConfirmOfflinePayment(
                      reservationID, event, new BigDecimal(line[1]));
                  return Triple.of(Boolean.TRUE, reservationID, "");
                } catch (Exception e) {
                  return Triple.of(
                      Boolean.FALSE, Optional.ofNullable(reservationID).orElse(""), e.getMessage());
                }
              })
          .collect(Collectors.toList());
    }
  }
Пример #2
0
 @ExceptionHandler(Exception.class)
 @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
 public String unhandledException(Exception e) {
   if (!IllegalArgumentException.class.isInstance(e)) {
     log.warn("unhandled exception", e);
   }
   return e.getMessage();
 }