Package com.jeecms.core.web

Examples of com.jeecms.core.web.WebErrors


    WebErrors errors = WebErrors.create(request);
    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, HttpServletRequest request) {
    WebErrors errors = WebErrors.create(request);
    if (vldExist(id, errors)) {
      return errors;
    }
    return errors;
  }
View Full Code Here

    }
    return errors;
  }

  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;
  }
View Full Code Here

  @RequestMapping(value = "/login.jspx", method = RequestMethod.POST)
  public String submit(String username, String password, String processUrl,
      String returnUrl, String message, HttpServletRequest request,
      HttpServletResponse response, ModelMap model) {
    WebErrors errors = validateSubmit(username, password, request);
    if (!errors.hasErrors()) {
      try {
        Authentication auth = authMng.login(username, password,
            RequestUtils.getIpAddr(request), request, response,
            session);
        String view = getView(processUrl, returnUrl, auth.getId());
        if (view != null) {
          return view;
        } else {
          model.addAttribute("auth", auth);
          return LOGIN_SUCCESS;
        }
      } catch (UsernameNotFoundException e) {
        errors.addErrorString(e.getMessage());
      } catch (BadCredentialsException e) {
        errors.addErrorString(e.getMessage());
      }
    }
    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,
      HttpServletRequest request) {
    WebErrors errors = WebErrors.create(request);
    if (errors.ifOutOfLength(username, "username", 3, 100)) {
      return errors;
    }
    if (errors.ifOutOfLength(password, "password", 3, 32)) {
      return errors;
    }
    return errors;
  }
View Full Code Here

      HttpServletRequest request, HttpServletResponse response,
      ModelMap model) {
    Integer errorRemaining = unifiedUserMng.errorRemaining(username);
    CmsSite site = CmsUtils.getSite(request);
    String sol = site.getSolutionPath();
    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);
        String view = getView(processUrl, returnUrl, auth.getId());
        if (view != null) {
          return view;
        } else {
          FrontUtils.frontData(request, model, site);
          return "redirect:login.jspx";
        }
      } catch (UsernameNotFoundException e) {
        errors.addErrorString(e.getMessage());
      } catch (BadCredentialsException e) {
        errors.addErrorString(e.getMessage());
      } catch (DisabledException e) {
        errors.addErrorString(e.getMessage());
      }
    }
    // 登录失败
    writeCookieErrorRemaining(errorRemaining, request, response, model);
    errors.toModel(model);
    FrontUtils.frontData(request, model, site);
    if (!StringUtils.isBlank(processUrl)) {
      model.addAttribute(PROCESS_URL, processUrl);
    }
    if (!StringUtils.isBlank(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

      String filename,
      Integer uploadNum,
      Boolean mark,
      @RequestParam(value = "uploadFile", required = false) MultipartFile file,
      HttpServletRequest request, ModelMap model) {
    WebErrors errors = validate(filename, file, request);
    CmsSite site = CmsUtils.getSite(request);
    CmsUser user = CmsUtils.getUser(request);
    FrontUtils.frontData(request, model, site);
    MemberConfig mcfg = site.getConfig().getMemberConfig();
    if (!mcfg.isMemberOn()) {
      return FrontUtils.showMessage(request, model, "member.memberClose");
    }
    if (user == null) {
      return FrontUtils.showLogin(request, model, site);
    }
    if (errors.hasErrors()) {
      model.addAttribute(ERROR, errors.getErrors().get(0));
      return FrontUtils.getTplPath(request, site.getSolutionPath(),
          TPLDIR_MEMBER, RESULT_PAGE);
    }
    MarkConfig conf = site.getConfig().getMarkConfig();
    if (mark == null) {
View Full Code Here

        TPLDIR_MEMBER, 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

      String filename,
      Integer uploadNum,
      Boolean mark,
      @RequestParam(value = "uploadFile", required = false) MultipartFile file,
      HttpServletRequest request, ModelMap model) {
    WebErrors errors = validate(filename, file, request);
    if (errors.hasErrors()) {
      model.addAttribute(ERROR, errors.getErrors().get(0));
      return RESULT_PAGE;
    }
    CmsSite site = CmsUtils.getSite(request);
    MarkConfig conf = site.getConfig().getMarkConfig();
    if (mark == null) {
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.