Package com.jeecms.core.web

Examples of com.jeecms.core.web.WebErrors


    return RESULT_PAGE;
  }

  private WebErrors validate(String filename, MultipartFile file,
      HttpServletRequest request) {
    WebErrors errors = WebErrors.create(request);
    if (file == null) {
      errors.addErrorCode("imageupload.error.noFileToUpload");
      return errors;
    }
    if (StringUtils.isBlank(filename)) {
      filename = file.getOriginalFilename();
    }
    String ext = FilenameUtils.getExtension(filename);
    if (!ImageUtils.isValidImageExt(ext)) {
      errors.addErrorCode("imageupload.error.notSupportExt", ext);
      return errors;
    }
    try {
      if (!ImageUtils.isImage(file.getInputStream())) {
        errors.addErrorCode("imageupload.error.notImage", ext);
        return errors;
      }
    } catch (IOException e) {
      log.error("image upload error", e);
      errors.addErrorCode("imageupload.error.ioError", ext);
      return errors;
    }
    return errors;
  }
View Full Code Here


  public String submit(String username, String password, String captcha,
      String processUrl, String returnUrl, String message,
      HttpServletRequest request, HttpServletResponse response,
      ModelMap model) {
    Integer errorRemaining = unifiedUserMng.errorRemaining(username);
    WebErrors errors = validateSubmit(username, password, captcha,
        errorRemaining, request, response);
    if (!errors.hasErrors()) {
      try {
        String ip = RequestUtils.getIpAddr(request);
        Authentication auth = authMng.login(username, password, ip,
            request, response, session);
        // 是否需要在这里加上登录次数的更新?按正常的方式,应该在process里面处理的,不过这里处理也没大问题。
        cmsUserMng.updateLoginInfo(auth.getUid(), ip);
        CmsUser user = cmsUserMng.findById(auth.getUid());
        if (user.getDisabled()) {
          // 如果已经禁用,则退出登录。
          authMng.deleteById(auth.getId());
          session.logout(request, response);
          throw new DisabledException("user disabled");
        }
        removeCookieErrorRemaining(request, response);
        returnUrl="/jeeadmin/jeecms/index.do";
        System.out.println("我在com.jeecms.cms.action.admin.CmsLoginAct.submit加 returnUrl= /jeeadmin/jeecms/index.do");
        String view = getView(processUrl, returnUrl, auth.getId());
        cmsLogMng.loginSuccess(request, user, "login.log.loginSuccess");
        if (view != null) {
          return view;
        } else {
          return "redirect:login.jspx";
        }
      } catch (UsernameNotFoundException e) {
        errors.addErrorString(e.getMessage());
        cmsLogMng.loginFailure(request, "login.log.loginFailure",
            "username=" + username + ";password=" + password);
      } catch (BadCredentialsException e) {
        errors.addErrorString(e.getMessage());
        cmsLogMng.loginFailure(request, "login.log.loginFailure",
            "username=" + username + ";password=" + password);
      } catch (DisabledException e) {
        errors.addErrorString(e.getMessage());
        cmsLogMng.loginFailure(request, "login.log.loginFailure",
            "username=" + username + ";password=" + password);
      }
    }
    // 登录失败
    writeCookieErrorRemaining(errorRemaining, request, response, model);
    errors.toModel(model);
    if (!StringUtils.isBlank(processUrl)) {
      model.addAttribute(PROCESS_URL, processUrl);
    }
    if (!StringUtils.isBlank(returnUrl)) {
      model.addAttribute(RETURN_URL, returnUrl);
View Full Code Here

  }

  private WebErrors validateSubmit(String username, String password,
      String captcha, Integer errorRemaining, HttpServletRequest request,
      HttpServletResponse response) {
    WebErrors errors = WebErrors.create(request);
    if (errors.ifOutOfLength(username, "username", 1, 100)) {
      return errors;
    }
    if (errors.ifOutOfLength(password, "password", 1, 32)) {
      return errors;
    }
    // 如果输入了验证码,那么必须验证;如果没有输入验证码,则根据当前用户判断是否需要验证码。
    if (!StringUtils.isBlank(captcha)
        || (errorRemaining != null && errorRemaining < 0)) {
      if (errors.ifBlank(captcha, "captcha", 100)) {
        return errors;
      }
      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;
      }
    }
    return errors;
View Full Code Here

    return "site/add";
  }

  @RequestMapping("/site/v_edit.do")
  public String edit(Integer id, HttpServletRequest request, ModelMap model) {
    WebErrors errors = validateEdit(id, request);
    if (errors.hasErrors()) {
      return errors.showErrorPage(model);
    }
    List<Ftp> ftpList = ftpMng.getList();
    model.addAttribute("ftpList", ftpList);
    model.addAttribute("cmsSite", manager.findById(id));
    return "site/edit";
View Full Code Here

  @RequestMapping("/site/o_save.do")
  public String save(CmsSite bean, Integer uploadFtpId,
      HttpServletRequest request, ModelMap model) throws IOException {
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    WebErrors errors = validateSave(bean, uploadFtpId, request);
    if (errors.hasErrors()) {
      return errors.showErrorPage(model);
    }
    bean = manager.save(site, user, bean, uploadFtpId);
    log.info("save CmsSite id={}", bean.getId());
    cmsLogMng.operating(request, "cmsSite.log.save", "id=" + bean.getId()
        + ";name=" + bean.getName());
View Full Code Here

  }

  @RequestMapping("/site/o_update.do")
  public String update(CmsSite bean, Integer uploadFtpId, Integer pageNo,
      HttpServletRequest request, ModelMap model) {
    WebErrors errors = validateUpdate(bean.getId(), uploadFtpId, request);
    if (errors.hasErrors()) {
      return errors.showErrorPage(model);
    }
    bean = manager.update(bean, uploadFtpId);
    log.info("update CmsSite id={}.", bean.getId());
    cmsLogMng.operating(request, "cmsSite.log.update", "id=" + bean.getId()
        + ";name=" + bean.getName());
View Full Code Here

  }

  @RequestMapping("/site/o_delete.do")
  public String delete(Integer[] ids, Integer pageNo,
      HttpServletRequest request, ModelMap model) {
    WebErrors errors = validateDelete(ids, request);
    if (errors.hasErrors()) {
      return errors.showErrorPage(model);
    }
    CmsSite[] beans = manager.deleteByIds(ids);
    for (CmsSite bean : beans) {
      log.info("delete CmsSite id={}", bean.getId());
      cmsLogMng.operating(request, "cmsSite.log.delete", "id="
View Full Code Here

    ResponseUtils.renderJson(response, pass);
  }

  private WebErrors validateSave(CmsSite bean, Integer uploadFtpId,
      HttpServletRequest request) {
    WebErrors errors = WebErrors.create(request);
    if (vldFtpExist(uploadFtpId, errors)) {
      return errors;
    }
    // 加上config信息
    bean.setConfig(configMng.get());
View Full Code Here

    bean.setConfig(configMng.get());
    return errors;
  }

  private WebErrors validateEdit(Integer id, HttpServletRequest request) {
    WebErrors errors = WebErrors.create(request);
    if (vldExist(id, errors)) {
      return errors;
    }
    return errors;
  }
View Full Code Here

    return errors;
  }

  private WebErrors validateUpdate(Integer id, Integer uploadFtpId,
      HttpServletRequest request) {
    WebErrors errors = WebErrors.create(request);
    if (vldExist(id, errors)) {
      return errors;
    }
    if (vldFtpExist(uploadFtpId, errors)) {
      return errors;
View Full Code Here

TOP

Related Classes of com.jeecms.core.web.WebErrors

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.