public MultipartFile convert(String source) {
    if (!"".equals(StringUtil.trimToEmpty(source))) {
      MultipartFile mfile = request.getFile(source);

      return mfile;

    } else {
      return null;
    }
  }
Example #2
0
  /**
   * RequestDispatcher에서 넘겨받은 익셉션 처리
   *
   * @param errorCode : 에러코드
   * @throws Exception
   */
  @RequestMapping(value = "/error/{errorCode}")
  public void getFailure(@PathVariable(value = "errorCode") String errorCode) throws Exception {
    validator.checkEmpty(errorCode, "에러코드");

    String statusCode = StringUtil.trimToEmpty((String) request.getAttribute("statusCode"));

    logger.info("statusCode : {}", statusCode);
    logger.info("errorCode : {}", errorCode);

    /*SimpleMappingExceptionResolverWrapper에 의한 오류가 아닐 경우*/
    if ("".equals(statusCode)) {
      /*AuthenticationException*/
      if (ErrorCodeConstants.EC_AUTHENTICATION_REQUIRED.equals(StringUtil.trimToEmpty(errorCode))) {
        throw new AuthenticationException(errorCode);

      }
      /*RuntimeException*/
      else if (ErrorCodeConstants.EC_INTERNAL_SERVER_ERROR.equals(
          StringUtil.trimToEmpty(errorCode))) {
        throw new RuntimeException(MessageUtils.getMessage(errorCode));

      }
      /*FailureException*/
      else {
        Object[] params = (Object[]) request.getAttribute("params");

        if (params == null || params.length == 0) {
          throw new FailureException(errorCode);

        } else {
          throw new FailureException(errorCode, params);
        }
      }

      /*SimpleMappingExceptionResolverWrapper에 의한 오류일 경우*/
    } else {
      throw new SimpleMappingException(Integer.parseInt(statusCode), errorCode);
    }
  }