Example #1
1
 @RequestMapping(
     value = {"/ws/1.0/error/{requestId}"},
     method = RequestMethod.GET,
     produces = "text/plain")
 public ResponseEntity<String> error(@PathVariable("requestId") String requestId)
     throws IOException {
   return ResponseEntity.status(HttpStatus.OK).body(reportService.error(requestId));
 }
Example #2
1
 @RequestMapping(
     value = {"/ws/1.0/detail/{requestId}"},
     method = RequestMethod.GET,
     produces = "application/json")
 public ResponseEntity<ReportTask> detail(@PathVariable("requestId") String requestId) {
   ReportTask task = reportService.detail(requestId);
   if (task == null) { // başlamamış
     logManager.info("output :YOK !!! " + requestId);
     return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
   }
   return ResponseEntity.status(HttpStatus.OK).body(task);
 }
Example #3
1
 @RequestMapping(
     value = {"/ws/1.0/cancel/{requestId}"},
     method = RequestMethod.GET,
     produces = "application/json")
 public ResponseEntity<ReportTask> cancel(@PathVariable("requestId") String requestId) {
   try {
     reportService.cancel(requestId);
     return ResponseEntity.status(HttpStatus.OK).body(null);
   } catch (NoSuchElementException e) {
     logManager.info("rapor :YOK !!! " + requestId);
     return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
   }
 }
Example #4
0
 @RequestMapping(
     value = {"/ws/1.0/reports"},
     method = RequestMethod.GET,
     produces = "application/json")
 public ResponseEntity<List<String>> reports() {
   return ResponseEntity.ok(reportService.reports());
 }
Example #5
0
 @RequestMapping(
     value = {"/ws/1.0/reportList"},
     method = RequestMethod.GET,
     produces = "application/json")
 public ResponseEntity<List<ReportDefinition>> reportList() throws IOException, JRException {
   return ResponseEntity.ok(reportService.reportList());
 }
Example #6
0
 @RequestMapping(
     value = {"/ws/1.0/dataSourceNames"},
     method = RequestMethod.GET,
     produces = "application/json")
 public ResponseEntity<List<String>> dataSourceNames() {
   return ResponseEntity.ok(new ArrayList<String>(reportService.dataSourceNames()));
 }
Example #7
0
 @RequestMapping(
     value = {"/ws/1.0/request"},
     method = RequestMethod.POST,
     produces = "application/json",
     consumes = "application/json")
 @SuppressWarnings("ThrowableResultIgnored")
 public ResponseEntity<ReportResponse> request(@RequestBody(required = true) ReportRequest req) {
   ReportTask res = reportService.request(req);
   return ResponseEntity.status(res.getStatus().getHttpStatus()).body(res.getResponse());
 }
Example #8
0
 @RequestMapping(
     value = {"/ws/1.0/output/{requestId}"},
     method = RequestMethod.GET)
 public ResponseEntity<byte[]> output(@PathVariable("requestId") String requestId)
     throws IOException {
   try {
     byte[] output = reportService.output(requestId);
     ReportTask task = reportService.detail(requestId);
     logManager.info("output :" + requestId);
     return ResponseEntity.status(HttpStatus.OK)
         .contentType(ReportOutputFormat.valueOf(task.getRequest().getExtension()).getMediaType())
         .lastModified(task.getEnded())
         .header(
             "Content-Disposition",
             "inline; filename=" + requestId + "." + task.getRequest().getExtension())
         .body(output);
   } catch (NoSuchElementException e) {
     logManager.info("output :YOK !!! " + requestId);
     return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
   }
 }
Example #9
0
  @RequestMapping(
      value = {"/ws/1.0/status/{requestId}"},
      method = RequestMethod.GET,
      produces = "application/json")
  public ResponseEntity<ReportResponse> status(@PathVariable("requestId") String requestId) {
    Status status = reportService.status(requestId);
    if (status == null) { // başlamamış
      logManager.info("status query :YOK !!! " + requestId);
      return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
    }
    logManager.info("status query :" + requestId);
    switch (status) {
      case WAIT:
        logManager.info("status query :" + requestId + " :başlamış");
        return ResponseEntity.status(HttpStatus.CREATED).body(null);

      case RUN:
        logManager.info("status query :" + requestId + " :devam ediyor");
        return ResponseEntity.status(HttpStatus.PROCESSING).body(null);

      case EXCEPTION:
        logManager.info("status query :" + requestId + " :hata");
        return ResponseEntity.status(420).body(null); // 420 Method Failure

      case FINISH:
        logManager.info("status query :" + requestId + " :bitmiş");
        return ResponseEntity.status(HttpStatus.OK).body(null);

      case CANCEL:
        logManager.info("status query :" + requestId + " :iptal");
        return ResponseEntity.status(HttpStatus.OK).body(null);

      case SCHEDULED:
        logManager.info("status query :" + requestId + " :başlamış");
        return ResponseEntity.status(HttpStatus.CREATED).body(null);
      default:
        throw new IllegalArgumentException(status.name());
    }
  }