directory.java

来自「cwbbs 云网论坛源码」· Java 代码 · 共 430 行 · 第 1/2 页

JAVA
430
字号
                    FileInfo fi = (FileInfo) v.elementAt(0);                    if (fi != null)                        logo = fi.getDiskName();                }            }        }        String code = fileupload.getFieldValue("code");        String name = fileupload.getFieldValue("name");        if (code == null) {            throw new ErrMsgException(SkinUtil.LoadString(request, "res.forum.Directory", "err_need_code"));        }        if (name==null) {            throw new ErrMsgException(SkinUtil.LoadString(request, "res.forum.Directory", "err_need_name"));        }        Leaf leaf = getLeaf(code);        String dellogo = StrUtil.getNullString(fileupload.getFieldValue("dellogo"));        if (fileupload.getFiles().size()>0 || dellogo.equals("1")) {            String lg = leaf.getLogo();                        if (lg!=null && !lg.equals("")) {                try {                    File file = new File(realpath + lg);                    file.delete();                }                catch (Exception e) {                    logger.info(e.getMessage());                }            }        }        String description = fileupload.getFieldValue("description");        String ih = StrUtil.getNullString(fileupload.getFieldValue("isHome"));        boolean isHome = ih.equals("true") ? true : false;        String strtype = fileupload.getFieldValue("type");        int type = Integer.parseInt(strtype);        String theme = StrUtil.getNullStr(fileupload.getFieldValue("theme")).trim();        String skin = StrUtil.getNullStr(fileupload.getFieldValue("skin")).trim();        String locked = fileupload.getFieldValue("isLocked");        int isLocked = Integer.parseInt(locked);        String color = fileupload.getFieldValue("color");        String strWebeditAllowType = fileupload.getFieldValue("webeditAllowType");        int webeditAllowType = Leaf.WEBEDIT_ALLOW_TYPE_UBB_NORMAL;        if (StrUtil.isNumeric(strWebeditAllowType))            webeditAllowType = Integer.parseInt(strWebeditAllowType);        String plugin2Code = StrUtil.getNullStr(fileupload.getFieldValue("plugin2Code"));        String strCheckMsg = fileupload.getFieldValue("checkMsg");        int checkMsg = StrUtil.toInt(strCheckMsg, 0);        int delMode = StrUtil.toInt(fileupload.getFieldValue("delMode"), 0);        int displayStyle = StrUtil.toInt(fileupload.getFieldValue("displayStyle"), Leaf.DISPLAY_STYLE_VERTICAL);        String parentCode = fileupload.getFieldValue("parentCode");        if (code.equals(parentCode)) {            throw new ErrMsgException("请选择正确的父节点!");        }        if (!parentCode.equals(leaf.getParentCode())) {                        Leaf lf = getLeaf(parentCode);             while (lf!=null && !lf.getCode().equals(lf.CODE_ROOT)) {                                String pCode = lf.getParentCode();                if (pCode.equals(leaf.getCode()))                    throw new ErrMsgException(SkinUtil.LoadString(request, "res.forum.Directory", "err_parent_code"));                                    lf = getLeaf(pCode);            }        }        boolean isBold = StrUtil.getNullStr(fileupload.getFieldValue("isBold")).equals("true");        leaf.setName(name);        leaf.setDescription(description);        leaf.setIsHome(isHome);                leaf.setType(type);        leaf.setTheme(theme);        leaf.setSkin(skin);        leaf.setLocked(isLocked==1?true:false);        if (dellogo.equals("1"))            leaf.setLogo("");        else if (fileupload.getFiles().size() > 0)            leaf.setLogo(logo);        leaf.setColor(color);        leaf.setWebeditAllowType(webeditAllowType);        leaf.setPlugin2Code(plugin2Code);        leaf.setCheckMsg(checkMsg);        leaf.setDelMode(delMode);        leaf.setDisplayStyle(displayStyle);        leaf.setBold(isBold);        boolean re = false;        if (parentCode.equals(leaf.getParentCode()))            re = leaf.update();        else            re = leaf.updateParent(parentCode);        return re;    }    public synchronized boolean move(HttpServletRequest request) throws            ErrMsgException {        String code = ParamUtil.get(request, "code", false);        String direction = ParamUtil.get(request, "direction", false);        if (code == null) {            throw new ErrMsgException(SkinUtil.LoadString(request, "res.forum.Directory", "err_need_code"));        }        if ( direction == null ) {            throw new ErrMsgException(SkinUtil.LoadString(request, "res.forum.Directory", "err_need_direction"));        }        Leaf lf = new Leaf(code);        return lf.move(direction);    }    public Leaf getLeaf(String code) {        Leaf leaf = new Leaf();        return leaf.getLeaf(code);    }    public Leaf getBrother(String code, String direction) throws            ErrMsgException {        Leaf lf = getLeaf(code);        return lf.getBrother(direction);    }    public Vector getChildren(String code) throws ErrMsgException {        Leaf leaf = getLeaf(code);        return leaf.getChildren();    }        public Menu getMenu(String root_code) throws ErrMsgException {        Directory dir = new Directory();        Leaf leaf = dir.getLeaf(root_code);        Menu menu = new Menu();        MenuItem mi = new MenuItem();        menu.addItem(mi);        mi.setHeadLeaf(leaf);        Vector children = leaf.getChildren();        Iterator ir = children.iterator();        while (ir.hasNext()) {            Leaf lf = (Leaf) ir.next();            mi.addChildLeaf(lf);        }        return menu;    }        public void repairLeaf(Leaf lf) {        Vector children = lf.getChildren();                lf.setChildCount(children.size());        Iterator ir = children.iterator();        int orders = 1;        while (ir.hasNext()) {            Leaf lfch = (Leaf)ir.next();                        lfch.setOrders(orders);                        lfch.update();            orders ++;        }                int layer = 2;        String parentCode = lf.getParentCode();        if (lf.getCode().equals(lf.CODE_ROOT)) {            layer = 1;        }        else {            if (parentCode.equals(lf.CODE_ROOT))                layer = 2;            else {                while (!parentCode.equals(lf.CODE_ROOT)) {                                        Leaf parentLeaf = getLeaf(parentCode);                    if (parentLeaf == null || !parentLeaf.isLoaded())                        break;                    else {                        parentCode = parentLeaf.getParentCode();                    }                    layer++;                }            }        }        lf.setLayer(layer);        lf.update();    }        public void repairTree(Leaf leaf) throws Exception {                repairLeaf(leaf);        Directory dir = new Directory();        Vector children = dir.getChildren(leaf.getCode());        int size = children.size();        if (size == 0)            return;        Iterator ri = children.iterator();                while (ri.hasNext()) {            Leaf childlf = (Leaf) ri.next();            repairTree(childlf);        }                leaf.removeAllFromCache();    }}

⌨️ 快捷键说明

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