⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 leafpriv.java

📁 oa 源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                        Leaf lf = new Leaf();        lf = lf.getLeaf(dirCode);                if (canUserDo(lf, user, groups, roles, privType))            return true;                String parentCode = lf.getParentCode();                while (!parentCode.equals("-1")) {                        Leaf plf = lf.getLeaf(parentCode);            if (plf==null || !plf.isLoaded())                return false;            if (canUserDo(plf, user, groups, roles, privType))                return true;            parentCode = plf.getParentCode();        }        return false;    }        public boolean canUserAppend(String username) {        return canUserDo(username, this.PRIV_APPEND);    }    public boolean canUserDel(String username) {        return canUserDo(username, this.PRIV_DEL);    }    public boolean canUserModify(String username) {        return canUserDo(username, this.PRIV_MODIFY);    }    public boolean canUserExamine(String username) {        return canUserDo(username, this.PRIV_EXAMINE);    }    public boolean add(String dirCode) throws            ErrMsgException {        Conn conn = new Conn(connname);        boolean r = false;        try {            PreparedStatement ps = conn.prepareStatement(QUERY_ADD);            ps.setString(1, UserGroupDb.EVERYONE);            ps.setInt(2, this.TYPE_USERGROUP);            ps.setInt(3, see);            ps.setInt(4, append);            ps.setInt(5, del);            ps.setInt(6, modify);            ps.setInt(7, examine);            ps.setString(8, dirCode);            r = conn.executePreUpdate() == 1 ? true : false;        } catch (SQLException e) {            logger.error(e.getMessage());            throw new ErrMsgException("LeafPriv:数据库操作出错!");        }        finally {            if (conn!=null) {                conn.close();                conn = null;            }        }        return r;    }    public boolean setRoles(String leafCode, String roleCodes) throws ErrMsgException {        String[] ary = StrUtil.split(roleCodes, ",");        int len = 0;        if (ary!=null) {            len = ary.length;        }        String sql = "select id from flow_dir_priv where dir_code=? and priv_type=?";        ResultSet rs = null;        Conn conn = new Conn(connname);        try {            PreparedStatement ps = conn.prepareStatement(sql);            ps.setString(1, leafCode);            ps.setInt(2, TYPE_ROLE);            rs = conn.executePreQuery();                        while (rs.next()) {                getLeafPriv(rs.getInt(1)).del();            }            for (int i=0; i<len; i++) {                add(ary[i], TYPE_ROLE);            }        } catch (SQLException e) {            logger.error("setRoles:" + e.getMessage());        }        finally {            if (conn!=null) {                conn.close();                conn = null;            }        }        return true;    }    public boolean add(String name, int type) throws            ErrMsgException {                Conn conn = new Conn(connname);        boolean r = false;        try {            PreparedStatement ps = conn.prepareStatement(QUERY_ADD);            ps.setString(1, name);            ps.setInt(2, type);            ps.setInt(3, see);            ps.setInt(4, append);            ps.setInt(5, del);            ps.setInt(6, modify);            ps.setInt(7, examine);            ps.setString(8, dirCode);            r = conn.executePreUpdate() == 1 ? true : false;        } catch (SQLException e) {            logger.error("add:" + e.getMessage());            throw new ErrMsgException("请检查是否有重复项存在!");        }        finally {            if (conn!=null) {                conn.close();                conn = null;            }        }        return r;    }    public LeafPriv getLeafPriv(int id) {        LeafPriv leafPriv = null;        try {            leafPriv = new LeafPriv(id);        } catch (Exception e) {            logger.error(e.getMessage());        }        return leafPriv;    }    public boolean delPrivsOfDir() {        RMConn rmconn = new RMConn(connname);        boolean r = false;        try {            String sql = "delete from flow_dir_priv where dir_code=?";            PreparedStatement ps = rmconn.prepareStatement(sql);            ps.setString(1, dirCode);            r = rmconn.executePreUpdate() == 1 ? true : false;        } catch (SQLException e) {            logger.error(e.getMessage());            return false;        }        return r;    }    public boolean delPrivsOfUserOrGroup(String username) {        RMConn rmconn = new RMConn(connname);        boolean r = false;        try {            String sql = "delete from flow_dir_priv where name=?";            PreparedStatement ps = rmconn.prepareStatement(sql);            ps.setString(1, username);            r = rmconn.executePreUpdate() == 1 ? true : false;        } catch (SQLException e) {            logger.error(e.getMessage());            return false;        }        return r;    }    public boolean del() {        RMConn rmconn = new RMConn(connname);        boolean r = false;        try {            PreparedStatement ps = rmconn.prepareStatement(QUERY_DEL);            ps.setInt(1, id);            r = rmconn.executePreUpdate() == 1 ? true : false;        } catch (SQLException e) {            logger.error(e.getMessage());            return false;        }        return r;    }    public int getSee() {        return see;    }    public void setSee(int see) {        this.see = see;    }    public int getAppend() {        return append;    }    public void setAppend(int a) {        this.append = a;    }    public int getDel() {        return del;    }    public void setDel(int d) {        this.del = d;    }    public int getModify() {        return modify;    }    public int getExamine() {        return examine;    }    public void setModify(int m) {        this.modify = m;    }    public void setExamine(int examine) {        this.examine = examine;    }    public ListResult list(String listsql, int curPage, int pageSize) throws            ErrMsgException {        int total = 0;        ResultSet rs = null;        Vector result = new Vector();        Conn conn = new Conn(connname);        try {                        String countsql = SQLFilter.getCountSql(listsql);            rs = conn.executeQuery(countsql);            if (rs != null && rs.next()) {                total = rs.getInt(1);            }            if (rs != null) {                rs.close();                rs = null;            }            if (total != 0)                conn.setMaxRows(curPage * pageSize);             rs = conn.executeQuery(listsql);            if (rs == null) {                return null;            } else {                rs.setFetchSize(pageSize);                int absoluteLocation = pageSize * (curPage - 1) + 1;                if (rs.absolute(absoluteLocation) == false) {                    return null;                }                do {                    LeafPriv lp = getLeafPriv(rs.getInt(1));                    result.addElement(lp);                } while (rs.next());            }        } catch (SQLException e) {            logger.error(e.getMessage());            throw new ErrMsgException("数据库出错!");        } finally {            if (rs != null) {                try {                    rs.close();                } catch (Exception e) {}                rs = null;            }            if (conn != null) {                conn.close();                conn = null;            }        }        ListResult lr = new ListResult();        lr.setResult(result);        lr.setTotal(total);        return lr;    }    public Vector listUserPriv(String userName) {        ResultSet rs = null;        Conn conn = new Conn(connname);        Vector result = new Vector();        PreparedStatement ps = null;        try {            String sql = "select id from flow_dir_priv where name=?";            ps = conn.prepareStatement(sql);            ps.setString(1, userName);            rs = ps.executeQuery();            if (rs == null) {                return null;            } else {                while (rs.next()) {                    LeafPriv lp = getLeafPriv(rs.getInt(1));                    result.addElement(lp);                }            }        } catch (Exception e) {            logger.error("listUserPriv: " + e.getMessage());        } finally {                        if (conn != null) {                conn.close();                conn = null;            }        }        return result;    }        public Vector list() {        ResultSet rs = null;        Conn conn = new Conn(connname);        Vector result = new Vector();        PreparedStatement ps = null;        try {            ps = conn.prepareStatement(QUERY_LIST);            ps.setString(1, dirCode);            rs = ps.executeQuery();            if (rs == null) {                return null;            } else {                while (rs.next()) {                    LeafPriv lp = getLeafPriv(rs.getInt(1));                    result.addElement(lp);                }            }        } catch (Exception e) {            logger.error("list: " + e.getMessage());        } finally {                        if (conn != null) {                conn.close();                conn = null;            }        }        return result;    }    private boolean loaded = false;    private int examine = 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -