Beispiel #1
0
  // 스케줄러 상태
  // http://localhost:8080/sda/sch/status
  @RequestMapping(value = "/status", method = RequestMethod.GET)
  public @ResponseBody ResponseEntity<ResponseMessage> statusSchList() {
    ResponseMessage resultMsg = new ResponseMessage();
    ResponseEntity<ResponseMessage> entity = null;
    HttpHeaders responseHeaders = new HttpHeaders();
    Gson gson = new Gson();
    String msg = "";

    log.info("status sch begin================>");
    try {
      checkScheduerMainService();
      thm.statusSchList();
      msg = thm.getStatusList();

      resultMsg.setCode(Utils.OK_CODE);
      resultMsg.setMessage(Utils.OK_MSG);
      resultMsg.setContent(gson.toJson(msg));
      entity = new ResponseEntity<ResponseMessage>(resultMsg, responseHeaders, HttpStatus.OK);
    } catch (PersistenceException e) {
      msg = "db connection error...";
      resultMsg = Utils.makeResponseBody(e);
      resultMsg.setContent(gson.toJson(msg));
      entity =
          new ResponseEntity<ResponseMessage>(
              resultMsg, responseHeaders, HttpStatus.valueOf(resultMsg.getCode()));
    } catch (NullPointerException e) {
      msg = "scheduler is not initiated....";
      resultMsg = Utils.makeResponseBody(e);
      resultMsg.setContent(gson.toJson(msg));
      entity =
          new ResponseEntity<ResponseMessage>(
              resultMsg, responseHeaders, HttpStatus.valueOf(resultMsg.getCode()));
    } catch (Exception e) {
      e.printStackTrace();
      resultMsg = Utils.makeResponseBody(e);
      responseHeaders.add("ExceptionCause", e.getMessage());
      responseHeaders.add("ExceptionClass", e.getClass().getName());
      entity =
          new ResponseEntity<ResponseMessage>(
              resultMsg, responseHeaders, HttpStatus.valueOf(resultMsg.getCode()));
    }
    log.info("status sch end ================>");
    return entity;
  }
Beispiel #2
0
  // 스케쥴러 기동
  // http://localhost:8080/sda/sch/init
  @RequestMapping(value = "/init", method = RequestMethod.GET)
  public @ResponseBody ResponseEntity<ResponseMessage> inittSch() {
    ResponseMessage resultMsg = new ResponseMessage();
    ResponseEntity<ResponseMessage> entity = null;
    HttpHeaders responseHeaders = new HttpHeaders();
    Gson gson = new Gson();
    String msg = "";

    log.info("init sch begin================>");
    try {
      // init
      thm = new SchedulerMainService();
      thm.JobInit();
      msg = thm.getStatusList();

      resultMsg.setCode(Utils.OK_CODE);
      resultMsg.setMessage(Utils.OK_MSG);
      resultMsg.setContent(gson.toJson(msg));
      entity = new ResponseEntity<ResponseMessage>(resultMsg, responseHeaders, HttpStatus.OK);
    } catch (ObjectAlreadyExistsException e) {
      msg = "scheduler is already initiated...";
      resultMsg = Utils.makeResponseBody(e);
      resultMsg.setContent(gson.toJson(msg));
      entity =
          new ResponseEntity<ResponseMessage>(
              resultMsg, responseHeaders, HttpStatus.valueOf(resultMsg.getCode()));
    } catch (Exception e) {
      e.printStackTrace();
      resultMsg = Utils.makeResponseBody(e);
      responseHeaders.add("ExceptionCause", e.getMessage());
      responseHeaders.add("ExceptionClass", e.getClass().getName());
      entity =
          new ResponseEntity<ResponseMessage>(
              resultMsg, responseHeaders, HttpStatus.valueOf(resultMsg.getCode()));
    }
    log.info("init sch end================>");
    return entity;
  }