コード例 #1
0
ファイル: PushStatDocController.java プロジェクト: txdas/test
  @ResponseBody
  @RequestMapping(value = "/days/statlist", method = RequestMethod.GET)
  public WebResult getDaysStatList(
      @RequestParam(defaultValue = "all", value = "platform") String platform,
      @RequestParam(defaultValue = "2", value = "type") Integer type,
      @RequestParam(defaultValue = "", value = "startdate") @DateTimeFormat(pattern = "yyyy-MM-dd")
          Date startDate,
      @RequestParam(defaultValue = "", value = "enddate") @DateTimeFormat(pattern = "yyyy-MM-dd")
          Date endDate) {
    WebResult result = new WebResult();
    try {
      Calendar calendar = Calendar.getInstance(Locale.CHINA);
      calendar.setTime(endDate);
      calendar.add(Calendar.DAY_OF_YEAR, 1);
      endDate = calendar.getTime();
      List<PushStatDoc> data =
          pushStatDocMapper.getPushStatDocListByType(type, platform, startDate, endDate);
      result.setData(data);
    } catch (Exception e) {
      result.setResultCode(ResultCode.FAIL);
      logger.error(e.getMessage());
      e.printStackTrace();
    }

    return result;
  }
コード例 #2
0
ファイル: JobController.java プロジェクト: YzPaul3/ankus
  @RequestMapping(value = "list", method = RequestMethod.GET)
  @ResponseStatus(HttpStatus.OK)
  @ResponseBody
  public Response list(
      @RequestParam(defaultValue = "") String startDate,
      @RequestParam(defaultValue = "") String endDate,
      @RequestParam(defaultValue = "") String jobName,
      @RequestParam(defaultValue = "WORKFLOW") String jobType,
      @RequestParam(defaultValue = "0") long engineId,
      @RequestParam(defaultValue = "ALL") String status,
      @RequestParam(defaultValue = "ID") String sort,
      @RequestParam(defaultValue = "DESC") String dir,
      @RequestParam(defaultValue = "0") int start,
      @RequestParam(defaultValue = "16") int limit) {

    Response response = new Response();
    try {
      Engine engine = engineService.getEngine(engineId);
      List<Map> jobs = jobService.getJobs(engine);
      response.getList().addAll(jobs);
      response.setTotal(jobs.size());
      response.getMap().put("current", jobService.getCurrentDate(engine));
      response.setSuccess(true);
    } catch (Exception ex) {
      response.setSuccess(false);
      response.getError().setMessage("배치 작업 목록을 조회할 수 없습니다.");
      if (ex.getCause() != null) response.getError().setCause(ex.getMessage());
      response.getError().setException(ExceptionUtils.getFullStackTrace(ex));
    }
    return response;
  }
コード例 #3
0
  @RequestMapping(value = "/createUser", method = RequestMethod.POST)
  public final BaseResponse createUser(
      @RequestHeader("Accept-Language") final String encoding,
      @RequestParam("username") final String username,
      @RequestParam("password") final String password,
      @RequestParam("enabled") final boolean enabled,
      @RequestParam("email") final String email,
      @RequestParam("groups") final Group group) {
    final BaseResponse response = new BaseResponse();

    try {

      PasswordEncoder encoder = new BCryptPasswordEncoder();
      User user = new User();
      user.setUsername(username);
      String encryptionPassword = encoder.encode(password);
      user.setPassword(encryptionPassword);
      user.setEnabled(enabled);
      user.setEmail(email);
      user.setGroups(Arrays.asList(group));

      userRepository.save(user);

      response.setSuccess();
      response.setResponseMessage("Success!");
    } catch (Exception e) {
      response.setError(ErrorCodeEnum.SQL_QUERY_ERROR, e.getMessage());
      LOGGER.error(e.getMessage());
    }

    return response;
  }
コード例 #4
0
  @RequestMapping(value = "/{id}/resetPassword", method = RequestMethod.POST)
  public final BaseResponse resetPassword(
      @RequestHeader("Accept-Language") final String encoding,
      @PathVariable("id") final long id,
      @RequestParam("oldPassword") final String oldPassword,
      @RequestParam("password") final String password) {
    final BaseResponse response = new BaseResponse();

    try {
      User user = userRepository.findOne(id);
      PasswordEncoder encoder = new BCryptPasswordEncoder();
      if ((oldPassword.length() > 0) && !encoder.matches(oldPassword, user.getPassword())) {
        response.setError(
            ErrorCodeEnum.PASSWORD_NOT_MATCH,
            "The old password and the original password does not match");
        LOGGER.error("The old password and the original password does not match");
        return response;
      }
      String encryptionPassword = encoder.encode(password);
      user.setPassword(encryptionPassword);
      userRepository.save(user);

      response.setSuccess();
      response.setResponseMessage("Success!");
    } catch (Exception e) {
      response.setError(ErrorCodeEnum.SQL_QUERY_ERROR, e.getMessage());
      LOGGER.error(e.getMessage());
    }

    return response;
  }
コード例 #5
0
ファイル: OrgController.java プロジェクト: oreumio/rest
  @RequestMapping(
      value = "orgs/{orgId}/orgUnits/{orgUnitId}/members/{memberId}",
      method = RequestMethod.GET)
  @ResponseBody
  public EmlUserOrgVo getOrgUnitMember(
      HttpServletRequest request,
      @PathVariable String orgId,
      @PathVariable String orgUnitId,
      @PathVariable String memberId) {
    EmlGroupVo groupVo = groupService.getByName(request.getUserPrincipal().getName());

    logger.debug(
        "조직의 단위의 사용자 정보를 취득합니다.: orgId="
            + orgId
            + ", orgUnitId="
            + orgUnitId
            + ", memberId="
            + memberId);
    try {
      return emlOrgService.getSystemUnitUser(orgId, orgUnitId, memberId);
    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException();
    }
  }
コード例 #6
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());
    }
  }
コード例 #7
0
 /**
  * Anular notificación
  *
  * @param idNotificacion a anular
  * @param request con datos de autenticación
  * @return String
  * @throws Exception
  */
 @RequestMapping("/override/{idNotificacion}")
 public String overrideNoti(
     @PathVariable("idNotificacion") String idNotificacion, HttpServletRequest request)
     throws Exception {
   String urlValidacion = "";
   try {
     urlValidacion = seguridadService.validarLogin(request);
     // si la url esta vacia significa que la validaci�n del login fue exitosa
     if (urlValidacion.isEmpty())
       urlValidacion =
           seguridadService.validarAutorizacionUsuario(
               request, ConstantsSecurity.SYSTEM_CODE, true);
   } catch (Exception e) {
     e.printStackTrace();
     urlValidacion = "redirect:/404";
   }
   if (urlValidacion.isEmpty()) {
     FichaRotavirus fichaRotavirus = rotaVirusService.getFichaById(idNotificacion);
     if (fichaRotavirus != null) {
       DaNotificacion notificacion = fichaRotavirus.getDaNotificacion();
       notificacion.setPasivo(true);
       daNotificacionService.updateNotificacion(notificacion);
       rotaVirusService.saveOrUpdate(fichaRotavirus);
       return "redirect:/rotavirus/search/"
           + fichaRotavirus.getDaNotificacion().getPersona().getPersonaId();
     } else {
       return "redirect:/404";
     }
   } else {
     return "redirect:/" + urlValidacion;
   }
 }
コード例 #8
0
  /**
   * méthode pour gérer les problèmes de validation de l'objet resource
   *
   * @param exception
   * @param response
   * @return
   */
  @ExceptionHandler
  @ResponseBody
  public Map<String, Object> handleException(Exception exception, HttpServletResponse response) {

    LOGGER.error("Exception : ", exception);

    Map<String, Object> mapErrorMessage = new HashMap<>();
    if (exception instanceof MethodArgumentNotValidException) {

      BindingResult result = ((MethodArgumentNotValidException) exception).getBindingResult();
      List<FieldError> listFieldErrors = result.getFieldErrors();
      for (FieldError fieldError : listFieldErrors) {
        mapErrorMessage.put(fieldError.getField(), fieldError.getDefaultMessage());
      }
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    }

    if (exception instanceof AccessDeniedException) {

      mapErrorMessage.put("Error : ", exception.getMessage());
      response.setStatus(HttpServletResponse.SC_FORBIDDEN);
    } else if (exception instanceof ValidationException
        || exception instanceof HttpMessageNotReadableException
        || exception instanceof DataAccessException
        || exception instanceof MongoException
        || exception instanceof SocketTimeoutException
        || exception instanceof RuntimeException) {

      mapErrorMessage.put("Error : ", exception.getMessage());
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    }

    LOGGER.error(mapErrorMessage.toString(), exception);
    return mapErrorMessage;
  }
コード例 #9
0
  @RequestMapping(value = "/task/log", method = RequestMethod.GET)
  @ResponseStatus(HttpStatus.OK)
  public Response getTaskLog(
      @RequestParam(defaultValue = "") String clusterName,
      @RequestParam(defaultValue = "") Long id) {
    EngineService engineService = getEngineService(clusterName);

    Response response = new Response();
    try {
      TaskHistory taskHistories = engineService.getTaskHistoryRemoteService().select(id);
      String filename = null;
      String task = taskHistories.getLogDirectory() + "/task.log";
      if (new File(task).exists() && new File(task).length() == 0) {
        String err = taskHistories.getLogDirectory() + "/err.log";
        if (new File(err).exists()) {
          filename = err;
        }
      } else {
        filename = task;
      }

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      FileUtils.copyFile(new File(filename), baos);
      response.getMap().put("text", new String(baos.toByteArray()));
      response.setSuccess(true);
    } catch (Exception ex) {
      // FIXME 여기 WholeBodyException을 수정해야하지 않을까??
      response.setSuccess(false);
      response.getError().setMessage("Unable to load a log file.");
      response.getError().setException(ExceptionUtils.getFullStackTrace(ex));
      if (ex.getCause() != null) response.getError().setCause(ex.getCause().getMessage());
    }
    return response;
  }
コード例 #10
0
  void Initialize() throws Exception {
    try {

      departamentos = divisionPoliticaService.getAllDepartamentos();
      catClasif = catalogoService.getClasificacionesFinalRotavirus();
      catResp = catalogoService.getRespuesta();
      registroVacunas = catalogoService.getRegistrosVacuna();
      tipoVacunaRotavirus = catalogoService.getTiposVacunasRotavirus();
      caracteristaHeceses = catalogoService.getCaracteristasHeces();
      gradoDeshidratacions = catalogoService.getGradosDeshidratacion();
      condicionEgresos = catalogoService.getCondicionEgreso();
      salaRotaVirusList = catalogoService.getSalasRotaVirus();

      mapModel = new HashMap<>();

      mapModel.put("departamentos", departamentos);
      mapModel.put("catClasif", catClasif);
      mapModel.put("catResp", catResp);
      mapModel.put("registroVacunas", registroVacunas);
      mapModel.put("tipoVacunaRotavirus", tipoVacunaRotavirus);
      mapModel.put("caracteristaHeceses", caracteristaHeceses);
      mapModel.put("gradoDeshidratacions", gradoDeshidratacions);
      mapModel.put("condicionEgresos", condicionEgresos);
      mapModel.put("salas", salaRotaVirusList);

    } catch (Exception ex) {
      ex.printStackTrace();
      throw ex;
    }
  }
コード例 #11
0
 @RequestMapping(value = "/100/download", method = RequestMethod.POST)
 public @ResponseBody String multipleSaveDownload(@RequestParam("file") MultipartFile[] files) {
   String fileName = null;
   long fileSize = 0;
   String msg = "";
   if (files != null && files.length > 0) {
     for (int i = 0; i < files.length; i++) {
       try {
         fileName = files[i].getOriginalFilename();
         fileSize = files[i].getSize();
         log.info("fileName: " + fileName + "; fileSize:" + fileSize);
         byte[] bytes = files[i].getBytes();
         BufferedOutputStream buffStream =
             new BufferedOutputStream(new FileOutputStream(new File(fileName)));
         buffStream.write(bytes);
         buffStream.close();
         msg +=
             "You have successfully uploaded "
                 + fileName
                 + " with the file size = "
                 + fileSize
                 + " <br/>";
       } catch (Exception e) {
         return "You failed to upload " + fileName + ": " + e.getMessage() + "<br/>";
       }
     }
     return msg;
   } else {
     return "Unable to upload. File is empty.";
   }
 }
コード例 #12
0
  @RequestMapping(value = "/100", method = RequestMethod.POST)
  public @ResponseBody String handleFileUpload(
      @RequestParam("name") String name, @RequestParam("file") MultipartFile file) {

    log.info("fileName: " + file.getOriginalFilename() + "; fileSize:" + file.getSize());

    if (name == null || name.trim().length() == 0) {
      name = file.getOriginalFilename();
    }

    if (!file.isEmpty()) {
      try {
        byte[] bytes = file.getBytes();
        BufferedOutputStream stream =
            new BufferedOutputStream(new FileOutputStream(new File(name)));
        stream.write(bytes);
        stream.close();
        return "You successfully uploaded (" + file.getOriginalFilename() + ")!";
      } catch (Exception e) {
        return "You failed to upload (" + file.getOriginalFilename() + ") => " + e.getMessage();
      }
    } else {
      return "You failed to upload ("
          + file.getOriginalFilename()
          + ") because the file was empty.";
    }
  }
コード例 #13
0
  @RequestMapping(value = "/{username}/accountInfo", method = RequestMethod.GET)
  public ResponseEntity<TwitterAccountInfo> getAccountInfo(@PathVariable String username) {

    TwitterAccountInfo twitterAccountInfo = new TwitterAccountInfo();

    TwitterCredentials twitterCredentials =
        twitterCredentialsService.getTwitterCredentialsForUsername(username);
    Twitter twitter = TwitterAppFactory.getTwitterInstance();
    AccessToken accessTokenObj =
        new AccessToken(
            twitterCredentials.getAccessToken(), twitterCredentials.getAccessTokenSecret());

    twitter.setOAuthAccessToken(accessTokenObj);

    try {
      String twitterScreenName = twitter.getScreenName();
      User twitterUser = twitter.showUser(twitterScreenName);

      twitterAccountInfo.setUsername(twitterScreenName);
      twitterAccountInfo.setFullName(twitterUser.getName());
      twitterAccountInfo.setProfileImageUrl(twitterUser.getProfileImageURL());
      twitterAccountInfo.setFollowersCount(twitterUser.getFollowersCount());
      twitterAccountInfo.setFriendsCount(twitterUser.getFriendsCount());

    } catch (Exception e) {
      LOG.warn(e.getMessage());
      return new ResponseEntity<TwitterAccountInfo>(HttpStatus.BAD_REQUEST);
    }

    return new ResponseEntity<TwitterAccountInfo>(twitterAccountInfo, HttpStatus.OK);
  }
コード例 #14
0
  @RequestMapping(value = "/listVariablesHdfs", method = RequestMethod.POST)
  @ResponseStatus(HttpStatus.OK)
  public Response listVariablesHdfs(@RequestBody Map params) {

    Response response = new Response();
    try {
      String clusterName = params.get("clusterName").toString();
      EngineService engineService = this.getEngineService(clusterName);

      VisualService service = engineService.getVisualService();
      Map resultMap = service.listVariablesHdfs(params);

      if ((boolean) resultMap.get("success")) {
        response.setSuccess(true);
        response.getMap().putAll(resultMap);
      } else {
        response.setSuccess(false);
      }

    } catch (Exception ex) {
      response.setSuccess(false);
      response.getError().setMessage(ex.getMessage());
      if (ex.getCause() != null) response.getError().setCause(ex.getCause().getMessage());
      response.getError().setException(ExceptionUtils.getFullStackTrace(ex));
      logger.info(ex.toString());
    }
    return response;
  }
コード例 #15
0
  @RequestMapping("/bd_quick_reply/table_data")
  public @ResponseBody Map<String, Object> list(BdQuickReplyDataTableQueryArgWapper arg) {
    Map<String, Object> result = new HashMap<>();
    PageInfo<QuickReply> quickReply = null;
    try {
      quickReply =
          quickReplyService.selectLikePage(
              arg.getSearchText(),
              arg.getPageNum(),
              arg.getLength(),
              "sort asc, " + arg.getOrderStr());
    } catch (Exception e) {
      log.error(e.getMessage(), e);
    }

    List<QuickReplyJson> data = new ArrayList<>();

    int index = 1;
    for (QuickReply info : quickReply.getList()) {
      data.add(new QuickReplyJson(index, info));
      index++;
    }

    result.put("draw", arg.getDraw());
    result.put("recordsTotal", data.size());
    result.put("recordsFiltered", data.size());
    result.put("data", data);

    return result;
  }
コード例 #16
0
 // Update
 @RequestMapping(value = "/centrocusto_update", method = RequestMethod.POST)
 public String update(@ModelAttribute CentroCusto centroCusto, Model model) {
   try {
     centroCustoService.update(centroCusto);
   } catch (Exception e) {
     model.addAttribute("mensagem", e.getCause().getMessage().toString());
     return "mensagemerro";
   }
   return "redirect:/centrocusto_lista";
 }
コード例 #17
0
 @RequestMapping(value = "/subscribe", method = RequestMethod.POST)
 public String addUserToMailList(
     @RequestParam("firstname") String firstname, @RequestParam("email") String email) {
   log.debug("POST Request -> /user/subscribe {}");
   try {
     userService.createUserAccount(
         "temp", "temp", "temp", firstname, "temp", email, true, "ROLE_USER", "user");
   } catch (Exception e) {
     log.debug("Error: " + e.getMessage());
   }
   return "subscribe";
 }
コード例 #18
0
 // Get User
 @RequestMapping(value = "/get")
 @ResponseBody
 public String getById(long id) {
   String userId;
   try {
     User user = userDao.getById(id);
     userId = String.valueOf(user.getId());
   } catch (Exception ex) {
     return "User not found: " + ex.toString();
   }
   return "The user id is: " + userId;
 }
コード例 #19
0
  /**
   * 파일을 업로드한다.
   *
   * @return REST Response JAXB Object
   */
  @RequestMapping(
      value = "/upload",
      method = RequestMethod.POST,
      consumes = {"multipart/form-data"})
  @ResponseStatus(HttpStatus.OK)
  public ResponseEntity<String> upload(HttpServletRequest req) throws IOException {
    Response response = new Response();

    if (!(req instanceof DefaultMultipartHttpServletRequest)) {
      response.setSuccess(false);
      response.getError().setCause("Invalid Request.");
      response.getError().setMessage("Invalid Request.");
      String json = new ObjectMapper().writeValueAsString(response);
      return new ResponseEntity(json, HttpStatus.BAD_REQUEST);
    }

    try {
      DefaultMultipartHttpServletRequest request = (DefaultMultipartHttpServletRequest) req;
      logger.debug(
          "Uploaded File >> Path : {}, Filename : {}, Size: {} bytes",
          new Object[] {
            request.getParameter("path"),
            request.getFile("file").getOriginalFilename(),
            request.getFile("file").getSize()
          });

      String clusterName = request.getParameter("clusterName");
      Map params = new HashMap();

      EngineService engineService = this.getEngineService(clusterName);
      VisualService service = engineService.getVisualService();
      Map resultMap = service.saveFile(request.getFile("file"), request.getParameter("options"));

      response.getMap().putAll(resultMap);
      response.setSuccess(true);
      String json = new ObjectMapper().writeValueAsString(response);
      HttpStatus statusCode = HttpStatus.OK;
      return new ResponseEntity(json, statusCode);
    } catch (Exception ex) {
      response.setSuccess(false);
      response.getError().setMessage(ex.getMessage());
      if (ex.getCause() != null) response.getError().setCause(ex.getCause().getMessage());
      response.getError().setException(ExceptionUtils.getFullStackTrace(ex));

      String json = new ObjectMapper().writeValueAsString(response);
      HttpStatus statusCode = HttpStatus.INTERNAL_SERVER_ERROR;

      logger.debug(ExceptionUtils.getFullStackTrace(ex));

      return new ResponseEntity(json, statusCode);
    }
  }
コード例 #20
0
 /**
  * 查询所有地区
  *
  * @return
  */
 @RequestMapping(value = "/list.json", method = RequestMethod.GET)
 @ResponseBody
 public JSONResult list() {
   JSONResult result = new JSONResult();
   try {
     List<Area> areas = areaService.getAllEntity();
     result.setResult(true);
     result.setData(areas);
   } catch (Exception e) {
     result.setResult(false);
     result.setErrorDesc("出现异常:" + e.getMessage());
   }
   return result;
 }
コード例 #21
0
ファイル: ModuleController.java プロジェクト: zivboy/RS
 @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET)
 public ModelAndView edit(@PathVariable Integer id) {
   ModelAndView mav = new ModelAndView(MODULE_EDIT);
   try {
     Module module = moduleService.get(Long.parseLong(id + ""));
     ObjectMapper mapper = JacksonMapper.getInstance();
     String json = mapper.writeValueAsString(module);
     mav.addObject("message", "success");
     mav.addObject("module", json);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return mav;
 }
コード例 #22
0
 /**
  * 删除 地区
  *
  * @param id
  * @return
  */
 @RequestMapping(value = "/{id}.json", method = RequestMethod.DELETE)
 @ResponseBody
 public JSONResult delete(@PathVariable String id) {
   JSONResult result = new JSONResult();
   try {
     areaService.deleteEntityByKey(id);
     result.setResult(true);
     result.setData(null);
   } catch (Exception e) {
     result.setResult(false);
     result.setErrorDesc("出现异常:" + e.getMessage());
   }
   return result;
 }
コード例 #23
0
 /**
  * 查询相应的地区
  *
  * @param id
  * @return
  */
 @RequestMapping(value = "/{id}.json", method = RequestMethod.GET)
 @ResponseBody
 public JSONResult get(@PathVariable String id) {
   JSONResult result = new JSONResult();
   try {
     Area area = areaService.findEntityBykey(id);
     result.setResult(true);
     result.setData(area);
   } catch (Exception e) {
     result.setResult(false);
     result.setErrorDesc("出现异常:" + e.getMessage());
   }
   return result;
 }
コード例 #24
0
ファイル: PushStatDocController.java プロジェクト: txdas/test
  @ResponseBody
  @RequestMapping(value = "/{docid}/statlist", method = RequestMethod.GET)
  public WebResult getStatListByDocid(@PathVariable String docid) {
    WebResult result = new WebResult();
    try {
      List<PushStatDoc> data = pushStatDocMapper.getPushStatDoc(docid);
      result.setData(data);
    } catch (Exception e) {
      result.setResultCode(ResultCode.FAIL);
      logger.error(e.getMessage());
      e.printStackTrace();
    }

    return result;
  }
コード例 #25
0
ファイル: ModuleController.java プロジェクト: zivboy/RS
  @RequestMapping(value = "/add", method = RequestMethod.GET)
  public ModelAndView add() {

    ModelAndView mav = new ModelAndView(MODULE_EDIT);
    Module module = new Module();
    try {
      ObjectMapper mapper = JacksonMapper.getInstance();
      String json = mapper.writeValueAsString(module);
      mav.addObject("message", "success");
      mav.addObject("module", json);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return mav;
  }
コード例 #26
0
  @RequestMapping(value = "/bd_quick_reply", method = RequestMethod.GET)
  public @ResponseBody Map<String, Object> allList() {
    Map<String, Object> result = new HashMap<>();
    List<QuickReply> quickReply = null;
    try {
      OrderByHelper.orderBy("sort asc");
      quickReply = quickReplyService.selectAll();
    } catch (Exception e) {
      log.error(e.getMessage(), e);
    }

    result.put("data", quickReply);

    return result;
  }
コード例 #27
0
 @RequestMapping(
     value = "/addRecord",
     params = {"tableName"},
     method = RequestMethod.POST)
 public String addingRecord(
     Model model, @RequestParam(value = "tableName") String tableName, HttpSession session) {
   DatabaseManager manager = getManager(session);
   try {
     model.addAttribute("columnCount", getColumnCount(manager, tableName));
     model.addAttribute("tableName", tableName);
   } catch (Exception e) {
     e.printStackTrace();
     return "error";
   }
   return "create";
 }
コード例 #28
0
  @RequestMapping(value = "/connect", method = RequestMethod.POST)
  public String connecting(
      @ModelAttribute("connection") Connection connection, HttpSession session, Model model) {

    try {
      DatabaseManager manager =
          service.connect(
              connection.getDbName(), connection.getUserName(), connection.getPassword());
      session.setAttribute("db_manager", manager);
      return "redirect:" + connection.getFromPage();
    } catch (Exception e) {
      e.printStackTrace();
      model.addAttribute("message", e.getMessage());
      return "error";
    }
  }
コード例 #29
0
ファイル: JobController.java プロジェクト: YzPaul3/ankus
 @RequestMapping(value = "valid", method = RequestMethod.POST)
 @ResponseStatus(HttpStatus.OK)
 @ResponseBody
 public Response isValidCronExpression(@RequestParam String cronExpression) {
   Response response = new Response();
   try {
     CronExpression.isValidExpression(cronExpression);
     response.setSuccess(true);
   } catch (Exception ex) {
     response.setSuccess(false);
     response.getError().setMessage("유효하지 않은 Cron Expression입니다.");
     if (ex.getCause() != null) response.getError().setCause(ex.getMessage());
     response.getError().setException(ExceptionUtils.getFullStackTrace(ex));
   }
   return response;
 }
コード例 #30
0
  @RequestMapping(value = "/files/shared", method = RequestMethod.POST)
  public ResponseEntity<String> shareFile(@RequestBody @Valid SharedFileDetail sharedFileDetail) {

    try {
      final String documentId = fileService.shareFile(sharedFileDetail);
      if (documentId != null) {
        return new ResponseEntity<String>(
            String.format("{\"docId\":\"%s\"}", documentId), HttpStatus.CREATED);
      } else {
        return new ResponseEntity<String>(HttpStatus.NO_CONTENT);
      }
    } catch (Exception e) {
      e.printStackTrace();
      return new ResponseEntity<String>(
          String.format("{\"error\":\"%s\"}", e.getMessage()), HttpStatus.SERVICE_UNAVAILABLE);
    }
  }