code cleanup
This commit is contained in:
parent
a62117fada
commit
dcbee28e48
@ -1,10 +1,10 @@
|
|||||||
package me.chyxion.tigon.codegen.service;
|
package me.chyxion.tigon.codegen.service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.List;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang3.CharEncoding;
|
import java.nio.charset.StandardCharsets;
|
||||||
import me.chyxion.tigon.codegen.CodeGenCustomizer;
|
import me.chyxion.tigon.codegen.CodeGenCustomizer;
|
||||||
import me.chyxion.tigon.codegen.model.CodeGenArgs;
|
import me.chyxion.tigon.codegen.model.CodeGenArgs;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -57,7 +57,7 @@ public abstract class CodeGenerator {
|
|||||||
// write result
|
// write result
|
||||||
FileUtils.write(new File(baseTool.getProjDir(), args.getFile()),
|
FileUtils.write(new File(baseTool.getProjDir(), args.getFile()),
|
||||||
baseTool.renderFtl(args.getFtl(), args.getModel()),
|
baseTool.renderFtl(args.getFtl(), args.getModel()),
|
||||||
CharEncoding.UTF_8);
|
StandardCharsets.UTF_8);
|
||||||
return args.getFile();
|
return args.getFile();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -19,7 +19,7 @@ public class ListForm extends BaseForm {
|
|||||||
private int start;
|
private int start;
|
||||||
@Min(1)
|
@Min(1)
|
||||||
@Max(2048)
|
@Max(2048)
|
||||||
private int limit;
|
private int limit = 16;
|
||||||
private String search;
|
private String search;
|
||||||
@Trim
|
@Trim
|
||||||
@EmptyToNull
|
@EmptyToNull
|
||||||
|
@ -6,8 +6,8 @@ import java.util.Collection;
|
|||||||
import me.chyxion.tigon.model.BaseModel;
|
import me.chyxion.tigon.model.BaseModel;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import org.hibernate.validator.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,9 +6,8 @@ import me.chyxion.tigon.mybatis.Search;
|
|||||||
import me.chyxion.tigon.model.BaseModel;
|
import me.chyxion.tigon.model.BaseModel;
|
||||||
import me.chyxion.tigon.model.ViewModel;
|
import me.chyxion.tigon.model.ViewModel;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import me.chyxion.tigon.validation.annotation.NotNullOrBlank;
|
import me.chyxion.tigon.validation.annotation.NotNullOrBlank;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version 0.0.1
|
* @version 0.0.1
|
||||||
|
@ -4,7 +4,7 @@ import java.util.List;
|
|||||||
import me.chyxion.tigon.model.BaseModel;
|
import me.chyxion.tigon.model.BaseModel;
|
||||||
import me.chyxion.tigon.model.ViewModel;
|
import me.chyxion.tigon.model.ViewModel;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @version 0.0.1
|
* @version 0.0.1
|
||||||
|
@ -72,9 +72,9 @@ public class AuthUser<U> implements Serializable {
|
|||||||
* @param authUser auth user
|
* @param authUser auth user
|
||||||
*/
|
*/
|
||||||
public static void save(Session session, AuthUser<?> authUser) {
|
public static void save(Session session, AuthUser<?> authUser) {
|
||||||
Assert.notNull(session);
|
Assert.notNull(session, "Session could not be null");
|
||||||
Assert.notNull(authUser);
|
Assert.notNull(authUser, "Auth user could not be null");
|
||||||
Assert.state(authUser.getUserId() != null, "User Id Is Null");
|
Assert.state(authUser.getUserId() != null, "Auth user id could not be null");
|
||||||
session.setAttribute(SESSION_AUTH_USER_KEY, authUser);
|
session.setAttribute(SESSION_AUTH_USER_KEY, authUser);
|
||||||
session.touch();
|
session.touch();
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ public class AuthUser<U> implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public AuthUser<U> setAttr(String name, Serializable value) {
|
public AuthUser<U> setAttr(String name, Serializable value) {
|
||||||
if (attrs == null) {
|
if (attrs == null) {
|
||||||
attrs = new HashMap<String, Serializable>();
|
attrs = new HashMap<>();
|
||||||
}
|
}
|
||||||
attrs.put(name, value);
|
attrs.put(name, value);
|
||||||
return this;
|
return this;
|
||||||
|
@ -35,17 +35,17 @@ public class DefaultViewResolver implements ViewResolver, Ordered {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public View resolveViewName(String rawViewName, Locale locale) throws Exception {
|
public View resolveViewName(String rawViewName, Locale locale) throws Exception {
|
||||||
log.debug("Base View Resolver Resolve View Name [{}].", rawViewName);
|
log.debug("Base view resolver resolve view name [{}].", rawViewName);
|
||||||
// parse view name
|
// parse view name
|
||||||
View view = null;
|
View view = null;
|
||||||
if (rawViewName.startsWith(ResponseTool.PREFIX_DATA)) {
|
if (rawViewName.startsWith(ResponseTool.PREFIX_DATA)) {
|
||||||
String viewName = rawViewName.substring(ResponseTool.PREFIX_DATA.length());
|
String viewName = rawViewName.substring(ResponseTool.PREFIX_DATA.length());
|
||||||
log.debug("Resolve View Name [{}] As JSON Data.", viewName);
|
log.debug("Resolve view name [{}] As JSON data.", viewName);
|
||||||
view = new JSONView(new JSONViewDataModel(viewName), jsonViewConfig);
|
view = new JSONView(new JSONViewDataModel(viewName), jsonViewConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
log.debug("No View Type Found, Render As JSON View [{}].", rawViewName);
|
log.debug("No view type found, render as JSON view [{}].", rawViewName);
|
||||||
view = new JSONView(rawViewName, jsonViewConfig);
|
view = new JSONView(rawViewName, jsonViewConfig);
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
|
@ -77,7 +77,7 @@ public class JSONView extends FastJsonJsonView {
|
|||||||
config.getDataKey(), config.getCodeKey(), config.getMessageKey());
|
config.getDataKey(), config.getCodeKey(), config.getMessageKey());
|
||||||
}
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Render JSON Response [{}].", JSON.toJSONString(dataResp, true));
|
log.debug("Render JSON response [{}].", JSON.toJSONString(dataResp, true));
|
||||||
}
|
}
|
||||||
return dataResp;
|
return dataResp;
|
||||||
}
|
}
|
||||||
@ -100,21 +100,21 @@ public class JSONView extends FastJsonJsonView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JSONViewDataModel buildDataModel(Map<String, Object> model) {
|
private JSONViewDataModel buildDataModel(Map<String, Object> model) {
|
||||||
log.debug("Build Data Model From Map Model.");
|
log.debug("Build data model from map model.");
|
||||||
Object objData = null;
|
Object objData = null;
|
||||||
if (Boolean.TRUE.equals(model.get(MAP_DATA))) {
|
if (Boolean.TRUE.equals(model.get(MAP_DATA))) {
|
||||||
objData = model.get(DATA_KEY);
|
objData = model.get(DATA_KEY);
|
||||||
log.debug("Render Map Data [{}].", objData);
|
log.debug("Render map data [{}].", objData);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// default bean name
|
// default bean name
|
||||||
String beanName = getBeanName();
|
String beanName = getBeanName();
|
||||||
if (!requestURI.equals("/" + beanName)) {
|
if (!requestURI.equals("/" + beanName)) {
|
||||||
objData = beanName;
|
objData = beanName;
|
||||||
log.debug("Could Not Find Any Resource, Render As String Data [{}].", objData);
|
log.debug("Could not find any resource, render as string data [{}].", objData);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.debug("View Name Is Request URI, No Data To Response..");
|
log.debug("View name is request URI, no data to response.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new JSONViewDataModel(objData);
|
return new JSONViewDataModel(objData);
|
||||||
|
@ -18,13 +18,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Getter
|
@Getter
|
||||||
public class JSONViewConfig {
|
public class JSONViewConfig {
|
||||||
@Value("${tigon.webmvc.jsonview.success_key:success}")
|
@Value("${tigon.webmvc.jsonview.success-key:success}")
|
||||||
private String successKey;
|
private String successKey;
|
||||||
@Value("${tigon.webmvc.jsonview.data_key:data}")
|
@Value("${tigon.webmvc.jsonview.data-key:data}")
|
||||||
private String dataKey;
|
private String dataKey;
|
||||||
@Value("${tigon.webmvc.jsonview.code_key:errcode}")
|
@Value("${tigon.webmvc.jsonview.code-key:errcode}")
|
||||||
private String codeKey;
|
private String codeKey;
|
||||||
@Value("${tigon.webmvc.jsonview.message_key:errmsg}")
|
@Value("${tigon.webmvc.jsonview.message-key:errmsg}")
|
||||||
private String messageKey;
|
private String messageKey;
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private JSONViewDataModelAssembler dataModelAssembler;
|
private JSONViewDataModelAssembler dataModelAssembler;
|
||||||
@ -32,7 +32,7 @@ public class JSONViewConfig {
|
|||||||
// init json serialize config
|
// init json serialize config
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
void init() {
|
void init() {
|
||||||
log.info("Init FastJSON Global Serialize Config To Serialize ViewModelable.");
|
log.info("Init FastJSON global serialize config to serialize view modelable.");
|
||||||
final SerializeConfig serializeConfig = SerializeConfig.getGlobalInstance();
|
final SerializeConfig serializeConfig = SerializeConfig.getGlobalInstance();
|
||||||
final ViewModelableSerializer viewModelableSerializer = new ViewModelableSerializer();
|
final ViewModelableSerializer viewModelableSerializer = new ViewModelableSerializer();
|
||||||
serializeConfig.put(ViewModel.class, viewModelableSerializer);
|
serializeConfig.put(ViewModel.class, viewModelableSerializer);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package me.chyxion.tigon.webmvc;
|
package me.chyxion.tigon.webmvc;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.slf4j.Logger;
|
import lombok.Getter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import org.slf4j.LoggerFactory;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
@ -21,21 +21,21 @@ import org.springframework.core.io.InputStreamResource;
|
|||||||
* chyxion@163.com <br>
|
* chyxion@163.com <br>
|
||||||
* Jan 16, 2015 5:33:30 PM
|
* Jan 16, 2015 5:33:30 PM
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Getter
|
||||||
public class ResourceModel {
|
public class ResourceModel {
|
||||||
private static final Logger log =
|
|
||||||
LoggerFactory.getLogger(ResourceModel.class);
|
|
||||||
|
|
||||||
private String contentType;
|
private String contentType;
|
||||||
private long contentLength;
|
private long contentLength;
|
||||||
private String name;
|
private String name;
|
||||||
private Resource resource;
|
private Resource resource;
|
||||||
|
|
||||||
public ResourceModel(Resource resource,
|
public ResourceModel(final Resource resource,
|
||||||
String contentType, long contentLength, String name) throws IOException {
|
String contentType, long contentLength, String name) throws IOException {
|
||||||
Assert.notNull(resource);
|
Assert.notNull(resource, "Resource model resource could not be null");
|
||||||
Assert.state(!(InputStreamResource.class ==
|
Assert.state(!(InputStreamResource.class ==
|
||||||
resource.getClass() && contentLength <= 0),
|
resource.getClass() && contentLength <= 0),
|
||||||
"Input Stream Resource Content Length Must Provide.");
|
"Input stream resource content length must provide.");
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
this.contentType = contentType;
|
this.contentType = contentType;
|
||||||
this.contentLength = contentLength > 0 ?
|
this.contentLength = contentLength > 0 ?
|
||||||
@ -43,63 +43,32 @@ public class ResourceModel {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceModel(File file, String contentType, String name) {
|
public ResourceModel(final File file, final String contentType, final String name) {
|
||||||
this.resource = new FileSystemResource(file);
|
this.resource = new FileSystemResource(file);
|
||||||
this.contentType = contentType;
|
this.contentType = contentType;
|
||||||
this.contentLength = file.length();
|
this.contentLength = file.length();
|
||||||
this.name = StringUtils.defaultIfBlank(name, file.getName());
|
this.name = StringUtils.defaultIfBlank(name, file.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceModel(InputStream inputStream,
|
public ResourceModel(final InputStream inputStream,
|
||||||
String contentType, long contentLength, String name) {
|
String contentType, long contentLength, String name) {
|
||||||
Assert.notNull(inputStream);
|
Assert.notNull(inputStream, "Resource model input stream could not be null");
|
||||||
Assert.state(contentLength > 0,
|
Assert.state(contentLength > 0,
|
||||||
"Input Stream Resource Content Length Must Provide.");
|
"Input stream resource content length must provide.");
|
||||||
this.contentType = contentType;
|
this.contentType = contentType;
|
||||||
this.contentLength = contentLength;
|
this.contentLength = contentLength;
|
||||||
this.resource = new InputStreamResource(inputStream);
|
this.resource = new InputStreamResource(inputStream);
|
||||||
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceModel(byte[] data, String contentType, String name) {
|
public ResourceModel(byte[] data, String contentType, String name) {
|
||||||
Assert.notNull(data);
|
Assert.notNull(data, "Resource model data could not be null");
|
||||||
this.resource = new ByteArrayResource(data);
|
this.resource = new ByteArrayResource(data);
|
||||||
this.contentType = contentType;
|
this.contentType = contentType;
|
||||||
this.contentLength = data.length;
|
this.contentLength = data.length;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the name
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name the name to set
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ResourceModel setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the resource
|
|
||||||
*/
|
|
||||||
public Resource getResource() {
|
|
||||||
return resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param resource the resource to set
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ResourceModel setResource(Resource resource) {
|
|
||||||
this.resource = resource;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the contentType
|
* @return the contentType
|
||||||
*/
|
*/
|
||||||
@ -119,21 +88,4 @@ public class ResourceModel {
|
|||||||
}
|
}
|
||||||
return contentType;
|
return contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param contentType the contentType to set
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ResourceModel setContentType(String contentType) {
|
|
||||||
this.contentType = contentType;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the contentLength
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public long getContentLength() throws IOException {
|
|
||||||
return contentLength;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.chyxion.tigon.webmvc;
|
package me.chyxion.tigon.webmvc;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -107,33 +108,33 @@ public class TigonReturnValueHandler
|
|||||||
ResourceModel resourceModel = null;
|
ResourceModel resourceModel = null;
|
||||||
HttpEntity<?> entity = null;
|
HttpEntity<?> entity = null;
|
||||||
if (returnValue instanceof ResourceModel) {
|
if (returnValue instanceof ResourceModel) {
|
||||||
log.debug("Found Download Model Return.");
|
log.debug("Found download model return.");
|
||||||
resourceModel = (ResourceModel) returnValue;
|
resourceModel = (ResourceModel) returnValue;
|
||||||
}
|
}
|
||||||
else if (returnValue instanceof HttpEntity) {
|
else if (returnValue instanceof HttpEntity) {
|
||||||
log.debug("Found HttpEntity Return.");
|
log.debug("Found http entity return.");
|
||||||
entity = (HttpEntity<?>) returnValue;
|
entity = (HttpEntity<?>) returnValue;
|
||||||
}
|
}
|
||||||
else if (returnValue instanceof File) {
|
else if (returnValue instanceof File) {
|
||||||
log.debug("Found File [{}] Return.", returnValue);
|
log.debug("Found file [{}] return.", returnValue);
|
||||||
resourceModel = new ResourceModel((File) returnValue, null, null);
|
resourceModel = new ResourceModel((File) returnValue, null, null);
|
||||||
}
|
}
|
||||||
else if (returnValue instanceof Resource) {
|
else if (returnValue instanceof Resource) {
|
||||||
log.debug("Found Resouce [{}] Return.", returnValue);
|
log.debug("Found resource [{}] return.", returnValue);
|
||||||
resourceModel = new ResourceModel((Resource) returnValue, null, 0, null);
|
resourceModel = new ResourceModel((Resource) returnValue, null, 0, null);
|
||||||
}
|
}
|
||||||
else if (returnValue instanceof byte[]) {
|
else if (returnValue instanceof byte[]) {
|
||||||
log.debug("Found Byte Array Return.");
|
log.debug("Found byte array return.");
|
||||||
resourceModel = new ResourceModel((byte[]) returnValue, null, null);
|
resourceModel = new ResourceModel((byte[]) returnValue, null, null);
|
||||||
}
|
}
|
||||||
// assemble http entity
|
// assemble http entity
|
||||||
if (resourceModel != null) {
|
if (resourceModel != null) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
final HttpHeaders headers = new HttpHeaders();
|
||||||
String name = resourceModel.getName();
|
String name = resourceModel.getName();
|
||||||
if (StringUtils.isNotBlank(name)) {
|
if (StringUtils.isNotBlank(name)) {
|
||||||
log.info("Found Resource Name [{}], Set Content-Disposition Header.", name);
|
log.info("Found resource name [{}], set Content-Disposition header.", name);
|
||||||
name = URLEncoder.encode(name, CharEncoding.UTF_8);
|
name = URLEncoder.encode(name, StandardCharsets.UTF_8.name());
|
||||||
StringBuilder sbDispo =
|
final StringBuilder sbDispo =
|
||||||
new StringBuilder("attachment; filename=\"")
|
new StringBuilder("attachment; filename=\"")
|
||||||
.append(name)
|
.append(name)
|
||||||
.append("\"; filename*=utf-8''")
|
.append("\"; filename*=utf-8''")
|
||||||
|
@ -20,14 +20,14 @@ public class StringToJSONArrayTypeConverter
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public JSONArray convert(String text) {
|
public JSONArray convert(final String text) {
|
||||||
try {
|
try {
|
||||||
return StringUtils.isNotBlank(text) ?
|
return StringUtils.isNotBlank(text) ?
|
||||||
JSON.parseArray(text) : null;
|
JSON.parseArray(text) : null;
|
||||||
}
|
}
|
||||||
catch (JSONException e) {
|
catch (JSONException e) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Invalid JSONArray [" + text + "] Param", e);
|
"Invalid JSONArray [" + text + "] param", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,14 @@ public class StringToJSONObjectTypeConverter
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public JSONObject convert(String text) {
|
public JSONObject convert(final String text) {
|
||||||
try {
|
try {
|
||||||
return StringUtils.isNotBlank(text) ?
|
return StringUtils.isNotBlank(text) ?
|
||||||
JSON.parseObject(text) : null;
|
JSON.parseObject(text) : null;
|
||||||
}
|
}
|
||||||
catch (JSONException e) {
|
catch (JSONException e) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Invalid JSONObject [" + text + "] Param", e);
|
"Invalid JSONObject [" + text + "] param", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,32 +33,6 @@ public class DefaultExceptionResolver implements ExceptionResolver {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
{
|
{
|
||||||
// Database Exceptions
|
// Database Exceptions
|
||||||
// put(CannotAcquireLockException.class, 5030);
|
|
||||||
// put(CannotSerializeTransactionException.class, 5031);
|
|
||||||
// put(CleanupFailureDataAccessException.class, 5032);
|
|
||||||
// put(ConcurrencyFailureException.class, 5033);
|
|
||||||
// put(DataAccessException.class, 5034);
|
|
||||||
// put(DataAccessResourceFailureException.class, 5035);
|
|
||||||
// put(DataIntegrityViolationException.class, 5036);
|
|
||||||
// put(DataRetrievalFailureException.class, 5037);
|
|
||||||
// put(DeadlockLoserDataAccessException.class, 5038);
|
|
||||||
// put(DuplicateKeyException.class, 5039);
|
|
||||||
// put(EmptyResultDataAccessException.class, 5040);
|
|
||||||
// put(IncorrectResultSizeDataAccessException.class, 5041);
|
|
||||||
// put(IncorrectUpdateSemanticsDataAccessException.class, 5042);
|
|
||||||
// put(InvalidDataAccessApiUsageException.class, 5043);
|
|
||||||
// put(InvalidDataAccessResourceUsageException.class, 5044);
|
|
||||||
// put(NonTransientDataAccessException.class, 5045);
|
|
||||||
// put(NonTransientDataAccessResourceException.class, 5046);
|
|
||||||
// put(OptimisticLockingFailureException.class, 5047);
|
|
||||||
// put(PermissionDeniedDataAccessException.class, 5048);
|
|
||||||
// put(PessimisticLockingFailureException.class, 5049);
|
|
||||||
// put(QueryTimeoutException.class, 5050);
|
|
||||||
// put(RecoverableDataAccessException.class, 5051);
|
|
||||||
// put(TransientDataAccessException.class, 5052);
|
|
||||||
// put(TransientDataAccessResourceException.class, 5053);
|
|
||||||
// put(TypeMismatchDataAccessException.class, 5054);
|
|
||||||
// put(UncategorizedDataAccessException.class, 5055);
|
|
||||||
// 4002
|
// 4002
|
||||||
put(IllegalStateException.class, InvalidStateException.CODE);
|
put(IllegalStateException.class, InvalidStateException.CODE);
|
||||||
put(ConversionFailedException.class, InvalidStateException.CODE);
|
put(ConversionFailedException.class, InvalidStateException.CODE);
|
||||||
|
@ -6,8 +6,8 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.apache.commons.lang3.CharEncoding;
|
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
import org.springframework.test.web.servlet.MvcResult;
|
import org.springframework.test.web.servlet.MvcResult;
|
||||||
import org.springframework.test.web.servlet.ResultActions;
|
import org.springframework.test.web.servlet.ResultActions;
|
||||||
@ -173,7 +173,7 @@ public final class ControllerTestTool {
|
|||||||
|
|
||||||
ResultActions request(
|
ResultActions request(
|
||||||
MockHttpServletRequestBuilder requestBuilder) {
|
MockHttpServletRequestBuilder requestBuilder) {
|
||||||
requestBuilder.characterEncoding(CharEncoding.UTF_8);
|
requestBuilder.characterEncoding(StandardCharsets.UTF_8.name());
|
||||||
try {
|
try {
|
||||||
return mvc.perform(requestBuilder);
|
return mvc.perform(requestBuilder);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user