示例#1
0
 private WebErrors validateSave(CmsModelItem bean, Integer modelId, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   if (!StringUtils.isBlank(bean.getOptValue())) {
     bean.setOptValue(replaceLocaleSplit(bean.getOptValue(), request));
   }
   return errors;
 }
示例#2
0
 @RequestMapping("/data/o_revert.do")
 public String revert(
     String filename,
     String db,
     ModelMap model,
     HttpServletRequest request,
     HttpServletResponse response)
     throws IOException {
   String backpath = realPathResolver.get(Constants.BACKUP_PATH);
   String backFilePath = backpath + SLASH + filename;
   String sql = readFile(backFilePath);
   // 还原暂时没做备份提示。
   dataBackMng.executeSQL("use " + SPLIT + db + SPLIT + BR);
   dataBackMng.executeSQL(sql);
   // 若db发生变化,需要处理jdbc
   try {
     String defaultCatalog = dataBackMng.getDefaultCatalog();
     if (!defaultCatalog.equals(db)) {
       String dbXmlPath = realPathResolver.get(dbXmlFileName);
       dbXml(dbXmlPath, defaultCatalog, db);
     }
   } catch (Exception e) {
     WebErrors errors = WebErrors.create(request);
     errors.addErrorCode("db.revert.error");
     errors.addErrorString(e.getMessage());
     if (errors.hasErrors()) {
       return errors.showErrorPage(model);
     }
   }
   // 需要重启web服务器,可能会存在bug
   session.setAttribute(request, response, AUTH_KEY, null);
   request.getSession().invalidate();
   return "login";
 }
示例#3
0
 @RequestMapping(value = "/data/o_export.do")
 public String exportSubmit(
     String[] names, ModelMap model, HttpServletRequest request, HttpServletResponse response)
     throws UnsupportedEncodingException {
   if (validate(names, request)) {
     WebErrors errors = WebErrors.create(request);
     errors.addErrorCode(INVALID_PARAM);
     return errors.showErrorPage(model);
   }
   String backName = "back";
   if (names[0] != null) {
     backName =
         names[0].substring(
             names[0].indexOf(Constants.BACKUP_PATH) + Constants.BACKUP_PATH.length() + 1);
   }
   List<FileEntry> fileEntrys = new ArrayList<FileEntry>();
   response.setContentType("application/x-download;charset=UTF-8");
   response.addHeader("Content-disposition", "filename=" + backName + ".zip");
   for (String filename : names) {
     File file = new File(realPathResolver.get(filename));
     fileEntrys.add(new FileEntry("", "", file));
   }
   try {
     // 模板一般都在windows下编辑,所以默认编码为GBK
     Zipper.zip(response.getOutputStream(), fileEntrys, "GBK");
   } catch (IOException e) {
     log.error("export db error!", e);
   }
   return null;
 }
示例#4
0
 private WebErrors validateEdit(Integer id, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   if (vldExist(id, errors)) {
     return errors;
   }
   return errors;
 }
示例#5
0
 private WebErrors validateDelete(String[] names, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   errors.ifEmpty(names, "names");
   for (String id : names) {
     vldExist(id, errors);
   }
   return errors;
 }
示例#6
0
 private WebErrors validateDelete(Integer[] ids, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   errors.ifEmpty(ids, "ids");
   for (Integer id : ids) {
     vldExist(id, errors);
   }
   return errors;
 }
示例#7
0
 private WebErrors validateUpdate(Integer id, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   CmsSite site = CmsUtils.getSite(request);
   if (vldExist(id, site.getId(), errors)) {
     return errors;
   }
   return errors;
 }
示例#8
0
 private WebErrors validateUpdate(Integer id, CmsModelItem bean, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   if (!StringUtils.isBlank(bean.getOptValue())) {
     bean.setOptValue(replaceLocaleSplit(bean.getOptValue(), request));
   }
   if (vldExist(id, errors)) {
     return errors;
   }
   return errors;
 }
示例#9
0
 private WebErrors validateDelete(Integer[] ids, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   CmsSite site = CmsUtils.getSite(request);
   if (errors.ifEmpty(ids, "ids")) {
     return errors;
   }
   for (Integer id : ids) {
     vldExist(id, site.getId(), errors);
   }
   return errors;
 }
示例#10
0
 private WebErrors validatePasswordSubmit(
     Integer id, String origPwd, String newPwd, String email, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   if (errors.ifBlank(origPwd, "origPwd", 100)) {
     return errors;
   }
   if (errors.ifMaxLength(newPwd, "newPwd", 100)) {
     return errors;
   }
   if (errors.ifMaxLength(email, "email", 100)) {
     return errors;
   }
   if (!cmsUserMng.isPasswordValid(id, origPwd)) {
     errors.addErrorCode("member.origPwdInvalid");
     return errors;
   }
   return errors;
 }
示例#11
0
 private WebErrors validateSubmit(
     String username,
     String email,
     String password,
     String captcha,
     CmsSite site,
     HttpServletRequest request,
     HttpServletResponse response) {
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   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.ifOutOfLength(username, "username", mcfg.getUsernameMinLen(), 100)) {
     return errors;
   }
   if (errors.ifOutOfLength(password, "password", mcfg.getPasswordMinLen(), 100)) {
     return errors;
   }
   if (errors.ifMaxLength(email, "email", 100)) {
     return errors;
   }
   // 保留字检查不通过,返回false。
   if (!mcfg.checkUsernameReserved(username)) {
     errors.addErrorCode("error.usernameReserved");
     return errors;
   }
   // 用户名存在,返回false。
   if (unifiedUserMng.usernameExist(username)) {
     errors.addErrorCode("error.usernameExist");
     return errors;
   }
   return errors;
 }
示例#12
0
 private WebErrors validateSave(CmsVoteTopic bean, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   CmsSite site = CmsUtils.getSite(request);
   bean.setSite(site);
   return errors;
 }
示例#13
0
文件: FtpAct.java 项目: kongdw/jeecms
 private WebErrors validateSave(Ftp bean, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   return errors;
 }