private WebErrors validateSave(String title, String author,
String description, String txt, String tagStr, Integer channelId,
CmsSite site, CmsUser user, String captcha,
HttpServletRequest request, HttpServletResponse response) {
WebErrors errors = WebErrors.create(request);
try {
if (!imageCaptchaService.validateResponseForID(session
.getSessionId(request, response), captcha)) {
errors.addErrorCode("error.invalidCaptcha");
return errors;
}
} catch (CaptchaServiceException e) {
errors.addErrorCode("error.exceptionCaptcha");
log.warn("", e);
return errors;
}
if (errors.ifBlank(title, "title", 150)) {
return errors;
}
if (errors.ifMaxLength(author, "author", 100)) {
return errors;
}
if (errors.ifMaxLength(description, "description", 255)) {
return errors;
}
// 内容不能大于1M
if (errors.ifBlank(txt, "txt", 1048575)) {
return errors;
}
if (errors.ifMaxLength(tagStr, "tagStr", 255)) {
return errors;
}
if (errors.ifNull(channelId, "channelId")) {
return errors;
}
if (vldChannel(errors, site, user, channelId)) {
return errors;
}