protected ListInfo getDataList(String sortKey, boolean desc, long offset, int maxPagesize) { ListInfo listInfo = new ListInfo(); String executorID = super.accessControl.getUserID(); int j = Integer.parseInt(executorID); SchedularManagerImpl sch = new SchedularManagerImpl(); String sdBeginTime = request.getParameter("beginTime"); String sdEndTime = request.getParameter("endTime"); try { String sql = "select * from TD_SD_SCHEDULAR where status = 0 and executor_id = " + j + " " + " and begintime < " + SQLManager.getInstance() .getDBAdapter() .getDateString(StringUtil.stringToDate(sdEndTime)) + " " + " and endtime > " + SQLManager.getInstance() .getDBAdapter() .getDateString(StringUtil.stringToDate(sdBeginTime)) + "" + " order by begintime"; listInfo = sch.getSchedularList(sql, (int) offset, maxPagesize); } catch (Exception e) { e.printStackTrace(); } return listInfo; }
/** * 添加新评论 * * @param docId 文档ID * @param commentUser 评论用户名 * @param isGuest 是否是匿名用户 * @param docComment 评论内容 * @param status 评论状态 * @param request HttpServletRequest * @return String * @throws Exception */ public @ResponseBody(datatype = "jsonp") CommentResult addNewComment( long channelId, int docId, String commentUser, String isGuest, String docComment, HttpServletRequest request) throws Exception { DocComment docCommentBean = new DocComment(); if (StringUtil.isEmpty(commentUser)) { if (Boolean.parseBoolean(isGuest)) docCommentBean.setUserName("__quest"); } else { docCommentBean.setUserName(URLDecoder.decode(commentUser, "UTF-8")); } docCommentBean.setDocId(docId); if (!StringUtil.isEmpty(docComment)) { docCommentBean.setDocComment(URLDecoder.decode(docComment, "UTF-8")); } docCommentBean.setUserIP(com.frameworkset.util.StringUtil.getClientIP(request)); // 默认即可发布 int status = 1; // 获取频道的评论审核开关 Integer aduitSwitchFlag = docCommentManager.getChannelCommentAduitSwitch((int) channelId); if (aduitSwitchFlag != null) { // 如果评论为开通状态,则评论的状态为待审核,否则为即可发布状态 status = aduitSwitchFlag == 0 ? 2 : 1; } docCommentBean.setStatus(status); CommentResult result = new CommentResult(); result.setAduitSwitchFlag(aduitSwitchFlag + ""); try { docCommentManager.addOneComment(docCommentBean); result.setMsg("success"); } catch (DocCommentManagerException e) { result.setMsg("failed"); result.setError(StringUtil.exceptionToString(e)); } return result; }
/** 得到某天某执行人的日程 */ public List getDaySchedular(String date, int executorID) throws ManagerException { Date start = StringUtil.stringToDate(date + " 00:00:00"); Date end = StringUtil.stringToDate(date + " 23:59:59"); DBUtil dbUtil = new DBUtil(); List list = new ArrayList(); String sql = "select * from TD_SD_SCHEDULAR where status=0 and executor_id = " + executorID + " and beginTime>=" + SQLManager.getInstance().getDBAdapter().getDateString(start) + "" + "and beginTime <=" + SQLManager.getInstance().getDBAdapter().getDateString(end); try { dbUtil.executeSelect(sql); for (int i = 0; i < dbUtil.size(); i++) { Schedular sch = new Schedular(); sch.setSchedularID(dbUtil.getInt(i, "SCHEDULAR_ID")); sch.setPlannerID(dbUtil.getInt(i, "PLANNER_ID")); sch.setExecutorID(dbUtil.getInt(i, "EXECUTOR_ID")); sch.setRequestID(dbUtil.getInt(i, "REQUEST_ID")); sch.setBeginTime(dbUtil.getDate(i, "BEGINTIME")); sch.setEndTime(dbUtil.getDate(i, "ENDTIME")); sch.setType(dbUtil.getString(i, "TYPE")); sch.setIsLeisure(dbUtil.getInt(i, "ISLEISURE")); sch.setIsPublicAffair(dbUtil.getInt(i, "ISPUBLICAFFAIR")); sch.setContent(dbUtil.getString(i, "CONTENT")); sch.setPlace(dbUtil.getString(i, "PLACE")); sch.setTopic(dbUtil.getString(i, "TOPIC")); sch.setEssentiality(dbUtil.getString(i, "ESSENTIALITY")); sch.setStatus(dbUtil.getInt(i, "STATUS")); sch.setIsHistory(dbUtil.getInt(i, "ISHISTORY")); list.add(sch); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return list; }
private String _getFileContent(String path, String charset, int encodeType) { String content = ""; try { if (encodeType == HTMLNoBREncode) content = StringUtil.HTMLNoBREncode(FileUtil.getFileContent(path, charset)); else if (encodeType == HTMLEncode) content = StringUtil.HTMLEncode(FileUtil.getFileContent(path, charset)); else if (encodeType == HTMLEncodej) content = StringUtil.HTMLEncodej(FileUtil.getFileContent(path, charset)); else content = FileUtil.getFileContent(path, charset); } catch (IOException e) { log.error( "Get File Content Error:path=" + path + ",charset=" + charset + ",convertHtmlTag=" + encodeType, e); } return content; }
public void init(FilterConfig arg0) throws ServletException { super.init(arg0); this.config = arg0; this.RequestEncoding = config.getInitParameter("RequestEncoding"); this.ResponseEncoding = config.getInitParameter("ResponseEncoding"); String refererDefender_ = config.getInitParameter("refererDefender"); boolean refererDefender = StringUtil.getBoolean(refererDefender_, false); referHelper = new ReferHelper(); referHelper.setRefererDefender(refererDefender); String wallfilterrules_ = config.getInitParameter("wallfilterrules"); String wallwhilelist_ = config.getInitParameter("wallwhilelist"); String refererwallwhilelist_ = config.getInitParameter("refererwallwhilelist"); String defaultwall = config.getInitParameter("defaultwall"); if (StringUtil.isNotEmpty(wallwhilelist_)) { String[] wallwhilelist = wallwhilelist_.split(","); referHelper.setWallwhilelist(wallwhilelist); } if (StringUtil.isNotEmpty(wallfilterrules_)) { String[] wallfilterrules = wallfilterrules_.split(","); referHelper.setWallfilterrules(wallfilterrules); } else if (defaultwall != null && defaultwall.equals("true")) { String[] wallfilterrules = ReferHelper.wallfilterrules_default; referHelper.setWallfilterrules(wallfilterrules); } if (StringUtil.isNotEmpty(refererwallwhilelist_)) { String[] refererwallwhilelist = refererwallwhilelist_.split(","); referHelper.setRefererwallwhilelist(refererwallwhilelist); } String _checkiemodeldialog = config.getInitParameter("checkiemodeldialog"); if (_checkiemodeldialog != null && _checkiemodeldialog.equals("true")) this.checkiemodeldialog = true; mode = config.getInitParameter("mode"); if (mode == null) mode = "0"; }
/** 得到该执行人的所有有日程的日期 */ public String getArrDays(int executorID) throws ManagerException { String days = ""; String str; DBUtil db = new DBUtil(); String sql = "select distinct begintime from TD_SD_SCHEDULAR where status = 0 and executor_id = " + executorID + " order by begintime"; try { db.executeSelect(sql); for (int i = 0; i < db.size(); i++) { Schedular sch = new Schedular(); sch.setBeginTime(db.getDate(i, "begintime")); str = StringUtil.getFormatDate(sch.getBeginTime(), "yyyy-MM-dd"); if (days.indexOf(str) == -1) { days = days + "<" + StringUtil.getFormatDate(sch.getBeginTime(), "yyyy-MM-dd") + ">"; } } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return days; }
public void init(FilterConfig arg0) throws ServletException { String tokendualtime = arg0.getInitParameter("tokendualtime"); String redirectpath_ = arg0.getInitParameter("redirecturl"); String tokenfailpath_ = arg0.getInitParameter("tokenfailpath"); String tokenstore_ = arg0.getInitParameter("tokenstore"); if(!StringUtil.isEmpty(tokenstore_)) { if(tokenstore_.toLowerCase().equals("mem") || tokenstore_.toLowerCase().equals("session")) { tokenstore = tokenstore_.toLowerCase(); log.debug("Set tokenstore["+tokenstore_+"] failed,tokens will be stored in session."); } else { log.debug("Set tokenstore["+tokenstore_+"] success,tokens will be stored in session."); } } String tokenscaninterval = arg0.getInitParameter("tokenscaninterval"); if(!StringUtil.isEmpty(redirectpath_)) { redirectpath = redirectpath_; } if(!StringUtil.isEmpty(tokenfailpath_)) { tokenfailpath = tokenfailpath_; } // else // { // tokenfailpath = redirectpath; // } String enableToken_ = arg0.getInitParameter("enableToken"); if(!StringUtil.isEmpty(enableToken_)) { try { enableToken = Boolean.parseBoolean(enableToken_); } catch (Exception e) { log.debug("Set enableToken failed,false will be used.",(e)); } } // String tmp = arg0.getServletContext().getServletContextName(); // this.redirectpath = StringUtil.getRealPath(tmp, redirectpath); long dualtime = 3600000; long tokenscaninterval_ = 1800000; if(!StringUtil.isEmpty(tokendualtime)) { try { dualtime = Long.parseLong(tokendualtime); } catch (NumberFormatException e) { log.debug("Set tokendualtime failed,-1 will be used.",(e)); } } if(!StringUtil.isEmpty(tokenscaninterval)) { try { tokenscaninterval_ = Long.parseLong(tokenscaninterval); } catch (NumberFormatException e) { log.debug("Set tokendualtime failed,-1 will be used.",(e)); } } if(enableToken) memTokenManager = MemTokenManagerFactory.getMemTokenManager(dualtime,tokenscaninterval_,enableToken,this.tokenstore,this); }
/** * 强制要求系统必须携带令牌 * * @return */ @AssertDToken public void ssowithtoken(HttpServletRequest request, HttpServletResponse response) { // return "path:sso"; String u = "", p = "", ck = ""; String successRedirect = request.getParameter("successRedirect"); if (!StringUtil.isEmpty(successRedirect)) { successRedirect = StringUtil.getRealPath(request, successRedirect, true); } String userName = (String) request.getAttribute(TokenStore.token_request_account_key); String worknumber = (String) request.getAttribute(TokenStore.token_request_worknumber_key); String loginType = "1"; if (StringUtil.isEmpty(userName)) { userName = worknumber; loginType = "2"; } String loginMenu = request.getParameter("loginMenu"); String contextpath = request.getContextPath(); String menuid = "newGetDoc"; if (loginMenu != null) { menuid = loginMenu; } HttpSession session = request.getSession(); boolean isWebSealServer = ConfigManager.getInstance().getConfigBooleanValue("isWebSealServer", false); if (isWebSealServer && userName == null) { String subsystem = "sany-mms"; try // uim检测 { CommonInfo info = new CommonInfo(); UimUserInfo userinfo = null; String ip = ""; userinfo = info.validateUIM(request); ip = userinfo.getUser_ip(); userName = userinfo.getUser_name(); AccessControl control = AccessControl.getInstance(); control.checkAccess(request, response, false); String user = control.getUserAccount(); request.setAttribute("fromsso", "true"); if (user == null || "".equals(user) || !userName.equals(user)) { try { if (!userName.equals(user)) control.resetSession(session); String password = SSOUserMapping.getUserPassword(userName); control = AccessControl.getInstance(); control.login(request, response, userName, password); if (StringUtil.isEmpty(successRedirect)) { Framework framework = Framework.getInstance(control.getCurrentSystemID()); MenuItem menuitem = framework.getMenuByID(menuid); if (menuitem instanceof Item) { Item menu = (Item) menuitem; successRedirect = MenuHelper.getRealUrl( contextpath, Framework.getWorkspaceContent(menu, control), MenuHelper.sanymenupath_menuid, menu.getId()); } else { Module menu = (Module) menuitem; String framepath = contextpath + "/sanydesktop/singleframe.page?" + MenuHelper.sanymenupath + "=" + menu.getPath(); successRedirect = framepath; } AccessControl.recordIndexPage(request, successRedirect); } else { successRedirect = URLDecoder.decode(successRedirect); } response.sendRedirect(successRedirect); return; } catch (Exception e) { response.sendRedirect( contextpath + "/webseal/websealloginfail.jsp?userName="******"&ip=" + ip + "&errormsg=" + java.net.URLEncoder.encode(e.getMessage(), "UTF-8")); return; } } else { control.resetUserAttributes(); if (StringUtil.isEmpty(successRedirect)) { Framework framework = Framework.getInstance(control.getCurrentSystemID()); MenuItem menuitem = framework.getMenuByID(menuid); if (menuitem instanceof Item) { Item menu = (Item) menuitem; successRedirect = MenuHelper.getRealUrl( contextpath, Framework.getWorkspaceContent(menu, control), MenuHelper.sanymenupath_menuid, menu.getId()); } else { Module menu = (Module) menuitem; String framepath = contextpath + "/sanydesktop/singleframe.page?" + MenuHelper.sanymenupath + "=" + menu.getPath(); successRedirect = framepath; } AccessControl.recordIndexPage(request, successRedirect); } else { successRedirect = URLDecoder.decode(successRedirect); } response.sendRedirect(successRedirect); return; } } catch (Exception e) // 检测失败,继续平台登录 { } } else { try { AccessControl control = AccessControl.getInstance(); control.checkAccess(request, response, false); String user = control.getUserAccount(); worknumber = control.getUserAttribute("userWorknumber"); boolean issameuser = false; if (loginType.equals("2")) { if (worknumber != null && !worknumber.equals("")) issameuser = userName.equals(worknumber); } else { if (user != null && !user.equals("")) issameuser = userName.equals(user); } if (user == null || "".equals(user) || !issameuser) { if (!issameuser) { control.resetSession(session); } try { // 1-域账号登录 2-工号登录 String password = null; if (loginType.equals("1")) { password = SSOUserMapping.getUserPassword(userName); } else { java.util.Map data = SSOUserMapping.getUserNameAndPasswordByWorknumber(userName); userName = (String) data.get("USER_NAME"); password = (String) data.get("USER_PASSWORD"); } control = AccessControl.getInstance(); request.setAttribute("fromsso", "true"); control.login(request, response, userName, password); if (StringUtil.isEmpty(successRedirect)) { Framework framework = Framework.getInstance(control.getCurrentSystemID()); MenuItem menuitem = framework.getMenuByID(menuid); if (menuitem instanceof Item) { Item menu = (Item) menuitem; successRedirect = MenuHelper.getRealUrl( contextpath, Framework.getWorkspaceContent(menu, control), MenuHelper.sanymenupath_menuid, menu.getId()); } else { Module menu = (Module) menuitem; String framepath = contextpath + "/sanydesktop/singleframe.page?" + MenuHelper.sanymenupath + "=" + menu.getPath(); successRedirect = framepath; } AccessControl.recordIndexPage(request, successRedirect); } else { successRedirect = URLDecoder.decode(successRedirect); } response.sendRedirect(successRedirect); return; } catch (Exception e) { response.sendRedirect( contextpath + "/webseal/websealloginfail.jsp?userName="******"&errormsg=" + java.net.URLEncoder.encode(e.getMessage(), "UTF-8")); return; } } else { control.resetUserAttributes(); if (StringUtil.isEmpty(successRedirect)) { Framework framework = Framework.getInstance(control.getCurrentSystemID()); MenuItem menuitem = framework.getMenuByID(menuid); if (menuitem instanceof Item) { Item menu = (Item) menuitem; successRedirect = MenuHelper.getRealUrl( contextpath, Framework.getWorkspaceContent(menu, control), MenuHelper.sanymenupath_menuid, menu.getId()); } else { Module menu = (Module) menuitem; String framepath = contextpath + "/sanydesktop/singleframe.page?" + MenuHelper.sanymenupath + "=" + menu.getPath(); successRedirect = framepath; } AccessControl.recordIndexPage(request, successRedirect); } else { successRedirect = URLDecoder.decode(successRedirect); } response.sendRedirect(successRedirect); return; } } catch (Throwable ex) { String errorMessage = ex.getMessage(); if (errorMessage == null) errorMessage = ""; errorMessage = errorMessage.replaceAll("\\n", "\\\\n"); errorMessage = errorMessage.replaceAll("\\r", "\\\\r"); try { response.getWriter().print(errorMessage + "登陆失败,请确保输入的用户名和口令是否正确!"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
/** * @param beginTime * @param endTime * @param interval * @param intervalType * @return * @throws ManagerException */ public String generateCrontime(Date beginTime, Date endTime, double interval, int intervalType) throws ManagerException { String begintime = StringUtil.getFormatDate(beginTime, "yyyy-MM-dd HH:mm:ss"); String endtime = StringUtil.getFormatDate(endTime, "yyyy-MM-dd HH:mm:ss"); String expression = ""; // 设置年份,如果开始年和结束年一致则为"yyyy",否则为yyyy1-yyyy2格式的串 // yyyy1为开始年份,yyyy2为结束时间连份 if (begintime.regionMatches(0, endtime, 0, 4)) // yyyy { expression = expression + begintime.substring(0, 4); } else { expression = expression + begintime.substring(0, 4) + "-" + endtime.substring(0, 4); } // 设置星期 expression = " ? " + expression; // 间隔类型为月时,设置每月执行的次数 if (intervalType == 3) { expression = "/" + interval + expression; } if (begintime.regionMatches(5, endtime, 5, 2)) // mm { expression = " " + begintime.substring(5, 7) + expression; } else { expression = " " + begintime.substring(5, 7) + "-" + endtime.substring(5, 7) + expression; } if (intervalType == 2) { expression = "/" + interval + expression; } if (begintime.regionMatches(8, endtime, 8, 2)) // dd { expression = " " + begintime.substring(8, 10) + expression; } else { expression = " " + begintime.substring(8, 10) + "-" + endtime.substring(8, 10) + expression; } if (intervalType == 1) { expression = "/" + interval + expression; } if (begintime.regionMatches(11, endtime, 11, 2)) // hh { expression = " " + begintime.substring(11, 13) + expression; } else { expression = " " + begintime.substring(11, 13) + "-" + endtime.substring(11, 13) + expression; } if (intervalType == 0) { expression = "/" + interval + expression; } if (begintime.regionMatches(14, endtime, 14, 2)) // mm { expression = " " + begintime.substring(14, 16) + expression; } else { expression = " " + begintime.substring(14, 16) + "-" + endtime.substring(14, 16) + expression; } if (begintime.regionMatches(17, endtime, 17, 2)) // ss { expression = begintime.substring(17) + expression; } else { expression = begintime.substring(17) + "-" + endtime.substring(17) + expression; } return expression; }