|
@@ -1,7 +1,5 @@
|
|
|
package com.style24.front.support.controller;
|
|
package com.style24.front.support.controller;
|
|
|
|
|
|
|
|
-import java.sql.SQLException;
|
|
|
|
|
-import java.sql.SQLRecoverableException;
|
|
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
|
|
@@ -11,9 +9,6 @@ import javax.validation.Validation;
|
|
|
import javax.validation.Validator;
|
|
import javax.validation.Validator;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
|
|
|
-import org.apache.ibatis.binding.BindingException;
|
|
|
|
|
-import org.springframework.beans.TypeMismatchException;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
|
|
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
|
|
|
import org.springframework.core.env.Environment;
|
|
import org.springframework.core.env.Environment;
|
|
@@ -22,15 +17,9 @@ import org.springframework.mobile.device.DeviceUtils;
|
|
|
import org.springframework.mobile.device.site.SitePreference;
|
|
import org.springframework.mobile.device.site.SitePreference;
|
|
|
import org.springframework.mobile.device.site.SitePreferenceUtils;
|
|
import org.springframework.mobile.device.site.SitePreferenceUtils;
|
|
|
import org.springframework.mobile.device.util.ResolverUtils;
|
|
import org.springframework.mobile.device.util.ResolverUtils;
|
|
|
-import org.springframework.security.access.AccessDeniedException;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.util.Assert;
|
|
|
-import org.springframework.validation.FieldError;
|
|
|
|
|
-import org.springframework.web.HttpRequestMethodNotSupportedException;
|
|
|
|
|
-import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
|
|
|
-import org.springframework.web.bind.MissingServletRequestParameterException;
|
|
|
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
-import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
|
|
import org.springframework.web.bind.annotation.InitBinder;
|
|
import org.springframework.web.bind.annotation.InitBinder;
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
@@ -38,7 +27,6 @@ import org.springframework.web.context.request.RequestAttributes;
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
-import com.fasterxml.jackson.databind.JsonMappingException;
|
|
|
|
|
import com.style24.core.support.message.TscMessageByLocale;
|
|
import com.style24.core.support.message.TscMessageByLocale;
|
|
|
import com.style24.front.support.env.TsfConstants;
|
|
import com.style24.front.support.env.TsfConstants;
|
|
|
import com.style24.front.support.security.session.TsfSession;
|
|
import com.style24.front.support.security.session.TsfSession;
|
|
@@ -195,80 +183,80 @@ public class TsfBaseController {
|
|
|
return GagaResponse.error(GagaResponseStatus.FAIL.getCode(), message);
|
|
return GagaResponse.error(GagaResponseStatus.FAIL.getCode(), message);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ExceptionHandler(AccessDeniedException.class)
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public GagaResponse handleForbidden(Exception e) {
|
|
|
|
|
- return GagaResponse.error(GagaResponseStatus.FORBIDDEN.getCode(), e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @ExceptionHandler(TypeMismatchException.class)
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public GagaResponse handleBadRequestException(Exception e) {
|
|
|
|
|
- errorLogging(e);
|
|
|
|
|
- return GagaResponse.error(GagaResponseStatus.BAD_REQUEST.getCode(), e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @ExceptionHandler(MissingServletRequestParameterException.class)
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public GagaResponse handleRequestParameterException(MissingServletRequestParameterException e) {
|
|
|
|
|
- errorLogging(e);
|
|
|
|
|
- return GagaResponse.error(GagaResponseStatus.BAD_REQUEST.getCode(), e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * HttpRequestMethodNotSupportedException Handler
|
|
|
|
|
- * @param e - HttpRequestMethodNotSupportedException, SQLRecoverableException
|
|
|
|
|
- * @return forwarding URI
|
|
|
|
|
- */
|
|
|
|
|
- @ExceptionHandler({HttpRequestMethodNotSupportedException.class, SQLRecoverableException.class})
|
|
|
|
|
- public String handleException(HttpRequestMethodNotSupportedException e) {
|
|
|
|
|
- return "forward:/error/500";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @ExceptionHandler(Throwable.class)
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public GagaResponse handleException(Throwable throwable) {
|
|
|
|
|
- errorLogging(throwable);
|
|
|
|
|
-
|
|
|
|
|
- Throwable rootCause = ExceptionUtils.getRootCause(throwable);
|
|
|
|
|
-
|
|
|
|
|
- if (rootCause != null) {
|
|
|
|
|
- throwable = rootCause;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (throwable instanceof SQLException || throwable instanceof BindingException ||
|
|
|
|
|
- throwable instanceof JsonMappingException) {
|
|
|
|
|
- String message = String.format("데이터 처리중 에러가 발생하였습니다. 시스템 관리자에게 문의하세요.");
|
|
|
|
|
- return GagaResponse.error(GagaResponseStatus.INTERNAL_SERVER_ERROR.getCode(), message);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return GagaResponse.error(GagaResponseStatus.INTERNAL_SERVER_ERROR.getCode(), throwable.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void errorLogging(Throwable throwable) {
|
|
|
|
|
- if (log.isErrorEnabled()) {
|
|
|
|
|
- Throwable rootCause = ExceptionUtils.getRootCause(throwable);
|
|
|
|
|
-
|
|
|
|
|
- if (rootCause != null) {
|
|
|
|
|
- throwable = rootCause;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (throwable.getMessage() != null) {
|
|
|
|
|
- log.error(throwable.getMessage(), throwable);
|
|
|
|
|
- } else {
|
|
|
|
|
- log.error("ERROR", throwable);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @ExceptionHandler(MethodArgumentNotValidException.class)
|
|
|
|
|
- @ResponseBody
|
|
|
|
|
- public Object processValidationError(MethodArgumentNotValidException ex) {
|
|
|
|
|
- FieldError fieldError = ex.getBindingResult().getFieldErrors().get(0);
|
|
|
|
|
- GagaResponse error = GagaResponse.error(GagaResponseStatus.INTERNAL_SERVER_ERROR.getCode(), fieldError.getDefaultMessage());
|
|
|
|
|
- error.getError().setRequiredKey(fieldError.getField());
|
|
|
|
|
- return error;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// @ExceptionHandler(AccessDeniedException.class)
|
|
|
|
|
+// @ResponseBody
|
|
|
|
|
+// public GagaResponse handleForbidden(Exception e) {
|
|
|
|
|
+// return GagaResponse.error(GagaResponseStatus.FORBIDDEN.getCode(), e.getMessage());
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @ExceptionHandler(TypeMismatchException.class)
|
|
|
|
|
+// @ResponseBody
|
|
|
|
|
+// public GagaResponse handleBadRequestException(Exception e) {
|
|
|
|
|
+// errorLogging(e);
|
|
|
|
|
+// return GagaResponse.error(GagaResponseStatus.BAD_REQUEST.getCode(), e.getMessage());
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @ExceptionHandler(MissingServletRequestParameterException.class)
|
|
|
|
|
+// @ResponseBody
|
|
|
|
|
+// public GagaResponse handleRequestParameterException(MissingServletRequestParameterException e) {
|
|
|
|
|
+// errorLogging(e);
|
|
|
|
|
+// return GagaResponse.error(GagaResponseStatus.BAD_REQUEST.getCode(), e.getMessage());
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /**
|
|
|
|
|
+// * HttpRequestMethodNotSupportedException Handler
|
|
|
|
|
+// * @param e - HttpRequestMethodNotSupportedException, SQLRecoverableException
|
|
|
|
|
+// * @return forwarding URI
|
|
|
|
|
+// */
|
|
|
|
|
+// @ExceptionHandler({HttpRequestMethodNotSupportedException.class, SQLRecoverableException.class})
|
|
|
|
|
+// public String handleException(HttpRequestMethodNotSupportedException e) {
|
|
|
|
|
+// return "forward:/error";
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @ExceptionHandler(Throwable.class)
|
|
|
|
|
+// @ResponseBody
|
|
|
|
|
+// public GagaResponse handleException(Throwable throwable) {
|
|
|
|
|
+// errorLogging(throwable);
|
|
|
|
|
+//
|
|
|
|
|
+// Throwable rootCause = ExceptionUtils.getRootCause(throwable);
|
|
|
|
|
+//
|
|
|
|
|
+// if (rootCause != null) {
|
|
|
|
|
+// throwable = rootCause;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// if (throwable instanceof SQLException || throwable instanceof BindingException ||
|
|
|
|
|
+// throwable instanceof JsonMappingException) {
|
|
|
|
|
+// String message = String.format("데이터 처리중 에러가 발생하였습니다. 시스템 관리자에게 문의하세요.");
|
|
|
|
|
+// return GagaResponse.error(GagaResponseStatus.INTERNAL_SERVER_ERROR.getCode(), message);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// return GagaResponse.error(GagaResponseStatus.INTERNAL_SERVER_ERROR.getCode(), throwable.getMessage());
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// private void errorLogging(Throwable throwable) {
|
|
|
|
|
+// if (log.isErrorEnabled()) {
|
|
|
|
|
+// Throwable rootCause = ExceptionUtils.getRootCause(throwable);
|
|
|
|
|
+//
|
|
|
|
|
+// if (rootCause != null) {
|
|
|
|
|
+// throwable = rootCause;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// if (throwable.getMessage() != null) {
|
|
|
|
|
+// log.error(throwable.getMessage(), throwable);
|
|
|
|
|
+// } else {
|
|
|
|
|
+// log.error("ERROR", throwable);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// @ExceptionHandler(MethodArgumentNotValidException.class)
|
|
|
|
|
+// @ResponseBody
|
|
|
|
|
+// public Object processValidationError(MethodArgumentNotValidException ex) {
|
|
|
|
|
+// FieldError fieldError = ex.getBindingResult().getFieldErrors().get(0);
|
|
|
|
|
+// GagaResponse error = GagaResponse.error(GagaResponseStatus.INTERNAL_SERVER_ERROR.getCode(), fieldError.getDefaultMessage());
|
|
|
|
|
+// error.getError().setRequiredKey(fieldError.getField());
|
|
|
|
|
+// return error;
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Custom Validation using group class
|
|
* Custom Validation using group class
|