@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()); } }
@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(); }
@RequestMapping(value = "/schedules/{scheduleId}/periods", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_SCHEDULE')") public ResponseEntity<OpenLmisResponse> save( @PathVariable("scheduleId") Long scheduleId, @RequestBody ProcessingPeriod processingPeriod, HttpServletRequest request) { processingPeriod.setScheduleId(scheduleId); processingPeriod.setModifiedBy(loggedInUserId(request)); processingPeriod.setCreatedBy(loggedInUserId(request)); try { processingScheduleService.savePeriod(processingPeriod); } catch (Exception e) { return error(new DataException(e.getMessage()), HttpStatus.BAD_REQUEST); } ResponseEntity<OpenLmisResponse> successResponse = success(messageService.message("message.period.added.success")); successResponse.getBody().addData("id", processingPeriod.getId()); return successResponse; }