예제 #1
0
 // 激活账号
 @RequestMapping(value = "/active.jspx", method = RequestMethod.GET)
 public String active(
     String username,
     String key,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model)
     throws IOException {
   CmsSite site = CmsUtils.getSite(request);
   WebErrors errors = validateActive(username, key, request, response);
   if (errors.hasErrors()) {
     return FrontUtils.showError(request, response, model, errors);
   }
   UnifiedUser user = unifiedUserMng.active(username, key);
   BbsUser bbsUser = bbsUserMng.findById(user.getId());
   String ip = RequestUtils.getIpAddr(request);
   authMng.activeLogin(user, ip, request, response, session);
   // 登录记录
   BbsLoginLog loginLog = new BbsLoginLog();
   loginLog.setIp(RequestUtils.getIpAddr(request));
   Calendar calendar = Calendar.getInstance();
   loginLog.setLoginTime(calendar.getTime());
   loginLog.setUser(bbsUser);
   bbsLoginMng.save(loginLog);
   // 在线时长统计
   BbsUserOnline online = bbsUser.getUserOnline();
   // 首次登陆
   online = new BbsUserOnline();
   online.setUser(bbsUser);
   online.initial();
   userOnlineMng.save(online);
   FrontUtils.frontData(request, model, site);
   return FrontUtils.getTplPath(
       request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER_ACTIVE_SUCCESS);
 }
예제 #2
0
 private boolean vldExist(Integer id, WebErrors errors) {
   if (errors.ifNull(id, "id")) {
     return true;
   }
   CmsSensitivity entity = manager.findById(id);
   if (errors.ifNotExist(entity, CmsSensitivity.class, id)) {
     return true;
   }
   return false;
 }
예제 #3
0
 private WebErrors validateDelete(Integer[] ids, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   if (errors.ifEmpty(ids, "ids")) {
     return errors;
   }
   for (Integer id : ids) {
     vldExist(id, errors);
   }
   return errors;
 }
예제 #4
0
 @RequestMapping("/sensitivity/o_save.do")
 public String save(CmsSensitivity bean, HttpServletRequest request, ModelMap model) {
   WebErrors errors = validateSave(bean, request);
   if (errors.hasErrors()) {
     return errors.showErrorPage(model);
   }
   Integer siteId = CmsUtils.getSiteId(request);
   bean = manager.save(bean, siteId);
   model.addAttribute("message", "global.success");
   log.info("save CmsSensitivity id={}", bean.getId());
   return list(request, model);
 }
예제 #5
0
 @RequestMapping("/sensitivity/o_delete.do")
 public String delete(Integer[] ids, HttpServletRequest request, ModelMap model) {
   WebErrors errors = validateDelete(ids, request);
   if (errors.hasErrors()) {
     return errors.showErrorPage(model);
   }
   CmsSensitivity[] beans = manager.deleteByIds(ids);
   for (CmsSensitivity bean : beans) {
     log.info("delete CmsSensitivity id={}", bean.getId());
   }
   model.addAttribute("message", "global.success");
   return list(request, model);
 }
예제 #6
0
 @RequestMapping("/sensitivity/o_update.do")
 public String update(
     Integer[] id,
     String[] search,
     String[] replacement,
     HttpServletRequest request,
     ModelMap model) {
   WebErrors errors = validateUpdate(id, search, replacement, request);
   if (errors.hasErrors()) {
     return errors.showErrorPage(model);
   }
   manager.updateEnsitivity(id, search, replacement);
   model.addAttribute("message", "global.success");
   log.info("update CmsSensitivity.");
   return list(request, model);
 }
 @RequestMapping(value = "/group/v_tree.do")
 public String tree(
     String root,
     Integer groupId,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model) {
   log.debug("tree path={}", root);
   boolean isRoot;
   // jquery treeview的根请求为root=source
   if (StringUtils.isBlank(root) || "source".equals(root)) {
     isRoot = true;
   } else {
     isRoot = false;
   }
   model.addAttribute("isRoot", isRoot);
   WebErrors errors = validateTree(root, request);
   if (errors.hasErrors()) {
     log.error(errors.getErrors().get(0));
     ResponseUtils.renderJson(response, "[]");
     return null;
   }
   CmsSite site = CmsUtils.getSite(request);
   BbsUserGroup group = manager.findById(groupId);
   Integer[] postTypeIds = group.fetchIds(group.getPostTypes());
   if (isRoot) {
     List<BbsForum> list;
     list = bbsForumMng.getList(site.getId());
     model.addAttribute("list", list);
   } else {
     List<BbsPostType> list;
     Integer parentId;
     if (StringUtils.isNotBlank(root) && root.contains(",")) {
       parentId = Integer.valueOf(root.split(",")[0]);
       list = bbsPostTypeMng.getList(site.getId(), null, parentId);
     } else {
       parentId = Integer.valueOf(root);
       list = bbsPostTypeMng.getList(site.getId(), parentId, null);
     }
     model.addAttribute("list", list);
   }
   model.put("postTypeIds", postTypeIds);
   response.setHeader("Cache-Control", "no-cache");
   response.setContentType("text/json;charset=UTF-8");
   return "group/tree";
 }
예제 #8
0
 private WebErrors validateActive(
     String username,
     String activationCode,
     HttpServletRequest request,
     HttpServletResponse response) {
   WebErrors errors = WebErrors.create(request);
   if (StringUtils.isBlank(username) || StringUtils.isBlank(activationCode)) {
     errors.addErrorCode("error.exceptionParams");
     return errors;
   }
   UnifiedUser user = unifiedUserMng.getByUsername(username);
   if (user == null) {
     errors.addErrorCode("error.usernameNotExist");
     return errors;
   }
   if (user.getActivation() || StringUtils.isBlank(user.getActivationCode())) {
     errors.addErrorCode("error.usernameActivated");
     return errors;
   }
   if (!user.getActivationCode().equals(activationCode)) {
     errors.addErrorCode("error.exceptionActivationCode");
     return errors;
   }
   return errors;
 }
예제 #9
0
 private WebErrors validateSubmit(
     String username,
     String email,
     String password,
     String captcha,
     CmsSite site,
     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.ifMaxLength(email, "email", 100)) {
     return errors;
   }
   // 用户名存在,返回false。
   if (unifiedUserMng.usernameExist(username)) {
     errors.addErrorCode("error.usernameExist");
     return errors;
   }
   return errors;
 }
예제 #10
0
 private WebErrors validateUpdate(
     Integer[] ids, String[] searchs, String[] replacements, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   if (errors.ifEmpty(ids, "id")) {
     return errors;
   }
   if (errors.ifEmpty(searchs, "name")) {
     return errors;
   }
   if (errors.ifEmpty(replacements, "url")) {
     return errors;
   }
   if (ids.length != searchs.length || ids.length != replacements.length) {
     errors.addErrorString("id, searchs, replacements length" + " not equals");
     return errors;
   }
   for (Integer id : ids) {
     vldExist(id, errors);
     return errors;
   }
   return errors;
 }
예제 #11
0
 private WebErrors validateSave(CmsSensitivity bean, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   return errors;
 }
예제 #12
0
  @RequestMapping(value = "/register.jspx", method = RequestMethod.POST)
  public String submit(
      String username,
      String email,
      String password,
      BbsUserExt userExt,
      String captcha,
      String nextUrl,
      HttpServletRequest request,
      HttpServletResponse response,
      ModelMap model)
      throws IOException {
    CmsSite site = CmsUtils.getSite(request);
    BbsConfig config = bbsConfigMng.findById(site.getId());
    WebErrors errors = validateSubmit(username, email, password, captcha, site, request, response);
    if (errors.hasErrors()) {
      return FrontUtils.showError(request, response, model, errors);
    }
    String ip = RequestUtils.getIpAddr(request);
    Integer groupId = null;
    BbsUserGroup group = bbsConfigMng.findById(site.getId()).getRegisterGroup();
    if (group != null) {
      groupId = group.getId();
    }
    BbsUser user = null;
    if (config.getEmailValidate()) {
      EmailSender sender = configMng.getEmailSender();
      MessageTemplate msgTpl = configMng.getRegisterMessageTemplate();
      if (sender == null) {
        // 邮件服务器没有设置好
        model.addAttribute("status", 4);
      } else if (msgTpl == null) {
        // 邮件模板没有设置好
        model.addAttribute("status", 5);
      } else {
        try {
          user =
              bbsUserMng.registerMember(
                  username, email, password, ip, groupId, userExt, false, sender, msgTpl);
          bbsConfigEhCache.setBbsConfigCache(0, 0, 0, 1, user, site.getId());
          model.addAttribute("status", 0);
        } catch (Exception e) {
          // 发送邮件异常
          model.addAttribute("status", 100);
          model.addAttribute("message", e.getMessage());
          log.error("send email exception.", e);
        }
      }
      log.info("member register success. username={}", username);
      if (!StringUtils.isBlank(nextUrl)) {
        response.sendRedirect(nextUrl);
        return null;
      } else {
        FrontUtils.frontData(request, model, site);
        FrontUtils.frontPageData(request, model);
        return FrontUtils.getTplPath(
            request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER_RESULT);
      }
    } else {
      user = bbsUserMng.registerMember(username, email, password, ip, groupId, userExt);
      bbsConfigEhCache.setBbsConfigCache(0, 0, 0, 1, user, site.getId());
      log.info("member register success. username={}", username);
      FrontUtils.frontData(request, model, site);
      FrontUtils.frontPageData(request, model);
      model.addAttribute("success", true);
      return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, LOGIN_INPUT);
    }

    /*
     * BbsUser user = bbsUserMng.registerMember(username, email, password,
     * ip, groupId, userExt);
     */
  }
 private WebErrors validateTree(String path, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   return errors;
 }