public int validate() { String s = DataUtil.toTextRow(this.qq); if (DataUtil.isEmpty(s) || s.length() > 20) { return Err.CMPCONTACT_QQ_ERROR; } if (DataUtil.isEmpty(qqhtml) || this.qqhtml.length() > 1000) { return Err.CMPCONTACT_QQHTML_ERROR; } if (!HkValidate.validateLength(this.name, true, 20)) { return Err.CMPCONTACT_NAME_ERROR; } return Err.SUCCESS; }
/** * 更新机构标题的背景图片 * * @param cmpOrg * @param file * @return * @throws IOException 2010-7-13 */ public int updateCmpOrgPath(CmpOrg cmpOrg, File file) throws IOException { if (file != null) { if (DataUtil.isBigger(file, 100)) { return Err.IMG_OUTOFSIZE_ERROR; } String dbPath = ImageConfig.getCmpOrgBgDbPath(cmpOrg.getCompanyId(), cmpOrg.getOrgId()); String filePath = ImageConfig.getCmpOrgBgFilePath(dbPath); DataUtil.copyFile(file, filePath, "h.jpg"); cmpOrg.setPath(dbPath); this.cmpOrgService.updateCmpOrg(cmpOrg); } return Err.SUCCESS; }
/** * 为栏目选择专业 * * @param req * @param resp * @return * @throws Exception 2010-7-11 */ public String selkind(HkRequest req, HkResponse resp) throws Exception { long companyId = req.getLong("companyId"); long oid = req.getLongAndSetAttr("oid"); CmpNav cmpNav = this.cmpNavService.getCmpNav(oid); req.setAttribute("cmpNav", cmpNav); if (this.isForwardPage(req)) { String name = req.getHtmlRow("name"); long parentId = req.getLongAndSetAttr("parentId"); CmpStudyKind parent = this.cmpStudyKindService.getCmpStudyKind(companyId, parentId); req.setAttribute("parent", parent); SimplePage page = req.getSimplePage(20); List<CmpStudyKind> list = this.cmpStudyKindService.getCmpStudyKindListByCompanyIdAndParentIdEx( companyId, parentId, name, page.getBegin(), page.getSize() + 1); this.processListForPage(page, list); req.setAttribute("list", list); return this.getWebPath("admin/cmpnav/selkind.jsp"); } long kindId = req.getLong("kindId"); if (cmpNav != null) { CmpStudyKind cmpStudyKind = this.cmpStudyKindService.getCmpStudyKind(companyId, kindId); if (cmpStudyKind == null) { return null; } cmpNav.setKindId(kindId); this.cmpNavService.updateCmpNav(cmpNav); this.setOpFuncSuccessMsg(req); } String return_url = req.getReturnUrl(); if (DataUtil.isEmpty(return_url)) { return null; } return "r:" + return_url; }
/** * pc发送短消息 * * @param req * @param resp * @return */ public String send(HkRequest req, HkResponse resp) { String nickName = req.getString("nickName"); User user = this.userService.getUserByNickName(nickName); if (user == null) { return this.onError(req, Err.USER_NOT_EXIST, "msgerror", null); } long receiverId = user.getUserId(); long senderId = this.getLoginUser(req).getUserId(); Follow follow = this.followService.getFollow(receiverId, senderId); if (follow == null) { // receiver 没有关注sender 就不能发送私信 return this.onError(req, Err.MSG_CANNOT_SEND_FORNOTFOLLOW, "msgerror", null); } String msg = req.getString("msg"); msg = DataUtil.toHtml(msg); int code = MsgValidate.validateMsg(msg); if (code != Err.SUCCESS) { return this.onError(req, code, "msgerror", null); } byte smsflg = PvtChat.SmsFLG_N; FmtUrlContent fmtUrlContent = new FmtUrlContent(msg, true, HkWebConfig.getShortUrlDomain()); msg = fmtUrlContent.getFmtContent(); SendInfo sendInfo = this.msgService.sendMsg(receiverId, senderId, msg, smsflg); // 私信已发送 PvtChat chat = sendInfo.getSenderPvtChat(); chat.setSender(this.getLoginUser(req)); req.setAttribute("msg", chat); return this.getWeb4Jsp("msg/sendok_inc.jsp"); }
/** * 如果喇叭内容除了人名,没有其他任何内容,不允许提交 * * @return */ public boolean isEmptyContent() { String s = this.parsedContent.replaceAll(DataUtil.nickNameRegx, ""); if (DataUtil.isEmpty(s)) { return true; } return false; }
@Test public void testIndexDoc() throws IOException { DataUtil.mkdir(path); List<String> list = new ArrayList<String>(); list.add("中国上海天安门手机购买"); list.add("美国北京纽约手机e71电池购买"); list.add( "也能启动tomcat6的,我的环境下不包含任何tomcat的信息哦。" + " 重命名了jdk的文件夹,记住修改jdk的环境变量哈。" + "你安装的6.0 myeclipse下不能启动,就去查下myeclipse下tomcat的配置," + "和你jdk的配置是否正确。tomcat的启动"); list.add("不错啊"); list.add("我手机不错,哈哈"); list.add("我的tomcat不能启动,大家帮我看看"); list.add("tom and lily"); SearchUtil.indexDocUseIK( true, path, list, new AddDocProc<String>() { @Override public Document buildDoc(String t) { Document doc = new Document(); doc.add(new Field("name", t, Store.YES, Index.ANALYZED)); return doc; } }); }
public int validate() { String name = DataUtil.toTextRow(getName()); if (DataUtil.isEmpty(name)) { return Err.INFORMATION_NAME_ERROR; } if (name.length() > 16) { return Err.INFORMATION_NAME_LEN_TOOLONG; } if (getUserId() <= 0) { return Err.USERID_ERROR; } if (DataUtil.isEmpty(getTag())) { return Err.INFORMATION_TAG_ERROR; } if (DataUtil.toTextRow(getTag()).length() > 15) { return Err.INFORMATION_TAG_LEN_TOOLONG; } String intro = DataUtil.toText(getIntro()); if (!DataUtil.isEmpty(intro)) { if (intro.length() > 300) { return Err.INFROMATION_INTRO_LEN_TOOLONG; } } return Err.SUCCESS; }
public String regwap(HkRequest req, HkResponse resp) throws Exception { if (this.getLoginUser(req) != null) { return "r:/square.do"; } req.reSetAttribute("inviteCode"); int agree = req.getInt("agree"); req.setAttribute("agree", agree); String input = req.getString("input", ""); input = input.replaceAll(" ", ""); String password = req.getString("password"); String password1 = req.getString("password1"); req.setAttribute("input", input); /** ************* 验证码 ********************* */ // String code = req.getString("code"); // String session_code = (String) req // .getSessionValue(HkUtil.CLOUD_IMAGE_AUTH); // if (session_code == null || !session_code.equals(code)) { // req.setText(String.valueOf(Err.REG_INPUT_VALIDATECODE)); // return "/reg_toreg.do"; // } /** ************* 验证码 end ********************* */ if (agree != 1) { req.setMessage("只有同意火酷协议,才可以注册为会员"); return "/reg_toreg.do"; } if (input == null || password == null) { return "/reg_toreg.do"; } if (!password.equals(password1)) { req.setMessage(req.getText("func.reg.pwdnotequal")); return "/reg_toreg.do"; } int vacode = User.validateReg(input, password); if (vacode != Err.SUCCESS) { req.setText(vacode + ""); return "/reg_toreg.do"; } UserRegData userRegData = new UserRegData(); userRegData.setEmail(input); userRegData.setPassword(password); userRegData.setIp(req.getRemoteAddr()); userRegData.setInviteCode(req.getString("inviteCode")); userRegData.setNickName(DataUtil.toHtmlRow(req.getString("nickName"))); try { UserRegResult userRegResult = this.userProcessor.reg(userRegData, true); if (userRegResult.getErrorCode() != Err.SUCCESS) { req.setText(String.valueOf(userRegResult.getErrorCode())); return "/reg_toreg.do"; } long userId = userRegResult.getUserId(); req.setSessionValue("login_userId", userId); if (input.indexOf("@") != -1) { HkWebUtil.sendRegMail(req, input); } return this.processLoginAndReg( req, resp, input, "/next/op/op_toUpdateNickName.do", true, false); } catch (EmailDuplicateException e) { req.setMessage(req.getText("func.mailalreadyexist")); return "/reg_toreg.do"; } catch (MobileDuplicateException e) { req.setMessage(req.getText("func.mobilealreadyexist")); return "/reg_toreg.do"; } }