Search in sources :

Example 86 with HongsException

use of app.hongs.HongsException in project HongsCORE by ihongs.

the class JoistBean method getCaseTypes.

/**
 * 获取查询类型映射
 * @return
 */
public Map<String, Set<String>> getCaseTypes() {
    if (null != fcasez) {
        return fcasez;
    }
    try {
        Map<String, Object> m = FormSet.getInstance().getEnum("__cases__");
        fcasez = new HashMap();
        for (Map.Entry<String, Object> et : m.entrySet()) {
            fcasez.put(et.getKey(), Synt.toSet(et.getValue()));
        }
        return fcasez;
    } catch (HongsException e) {
        throw e.toExpedient();
    }
}
Also used : HashMap(java.util.HashMap) HongsException(app.hongs.HongsException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 87 with HongsException

use of app.hongs.HongsException in project HongsCORE by ihongs.

the class AuthTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    try {
        NaviMap nav = NaviMap.getInstance(this.cnf);
        this.ebb = (this.act == null || nav.chkAuth(this.act)) && (this.rol == null || nav.chkRole(this.rol)) && (this.men == null || nav.chkRole(this.men));
    } catch (HongsException ex) {
        throw new JspException(ex);
    }
    if (this.not) {
        this.ebb = !this.ebb;
    }
    if (this.ebb) {
        return BodyTagSupport.EVAL_BODY_BUFFERED;
    } else {
        return BodyTagSupport.SKIP_BODY;
    }
}
Also used : JspException(javax.servlet.jsp.JspException) HongsException(app.hongs.HongsException) NaviMap(app.hongs.action.NaviMap)

Example 88 with HongsException

use of app.hongs.HongsException in project HongsCORE by ihongs.

the class Async method close.

@Override
public void close() {
    if (!servs.isShutdown()) {
        servs.shutdownNow();
    }
    if (back == null) {
        if (!tasks.isEmpty()) {
            CoreLogger.error("There has " + tasks.size() + " task(s) not run.");
        }
        return;
    }
    File file;
    file = back;
    back = null;
    if (!tasks.isEmpty()) {
        try {
            save(file);
            CoreLogger.trace("There has " + tasks.size() + " task(s) not run, save to '" + file.getPath() + "'.");
        } catch (HongsException ex) {
            CoreLogger.error(ex);
        }
    } else if (file.exists()) {
        file.delete();
    }
}
Also used : HongsException(app.hongs.HongsException) File(java.io.File)

Example 89 with HongsException

use of app.hongs.HongsException in project HongsCORE by ihongs.

the class NaviMap method parse.

private void parse(Element element, Map menus, Map manus, Map roles, Set imports, Set actions, Set depends) throws HongsException {
    if (!element.hasChildNodes()) {
        return;
    }
    NodeList nodes = element.getChildNodes();
    for (int i = 0; i < nodes.getLength(); i++) {
        Node node = nodes.item(i);
        if (node.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }
        Element element2 = (Element) node;
        String tagName2 = element2.getTagName();
        if (imports == null && !"action".equals(tagName2) && !"depend".equals(tagName2)) {
            continue;
        }
        if ("menu".equals(tagName2)) {
            Map menu2 = new HashMap();
            String href = element2.getAttribute("href");
            if (href == null)
                href = "";
            menus.put(href, menu2);
            manus.put(href, menu2);
            String hrel = element2.getAttribute("hrel");
            if (hrel == null)
                hrel = "";
            menu2.put("hrel", hrel);
            String icon = element2.getAttribute("icon");
            if (icon == null)
                icon = "";
            menu2.put("icon", icon);
            String text = element2.getAttribute("text");
            if (text == null)
                text = "";
            menu2.put("text", text);
            Map menus2 = new LinkedHashMap();
            Set roles2 = new LinkedHashSet();
            // 获取下级页面和权限
            this.parse(element2, menus2, manus, roles, imports, actions, roles2);
            if (!menus2.isEmpty()) {
                menu2.put("menus", menus2);
            }
            if (!roles2.isEmpty()) {
                menu2.put("roles", roles2);
            }
        } else if ("role".equals(tagName2)) {
            Map role2 = new HashMap();
            String namz = element2.getAttribute("name");
            if (namz == null)
                namz = "";
            roles.put(namz, role2);
            String text = element2.getAttribute("text");
            if (text == null)
                text = "";
            role2.put("text", text);
            Set actions2 = new HashSet();
            Set depends2 = new HashSet();
            // 获取下级动作和依赖
            this.parse(element2, null, null, null, null, actions2, depends2);
            if (!actions2.isEmpty()) {
                role2.put("actions", actions2);
                actions.addAll(actions2);
            }
            if (!depends2.isEmpty()) {
                role2.put("depends", depends2);
            // depends.addAll(depends2);
            }
            // 上级页面依赖的权限
            depends.add(namz);
        } else if ("action".equals(tagName2)) {
            String action = element2.getTextContent();
            actions.add(action);
        } else if ("depend".equals(tagName2)) {
            String depend = element2.getTextContent();
            depends.add(depend);
        } else if ("import".equals(tagName2)) {
            String impart = element2.getTextContent().trim();
            try {
                NaviMap conf = new NaviMap(impart);
                imports.add(impart);
                imports.addAll(conf.imports);
                actions.addAll(conf.actions);
                roles.putAll(conf.roles);
                menus.putAll(conf.menus);
                manus.putAll(conf.manus);
            } catch (HongsException ex) {
                // 找不到文件仅将错误写到日志
                if (0x10e0 == ex.getErrno()) {
                    CoreLogger.error(ex);
                } else {
                    throw ex;
                }
            }
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) LinkedHashMap(java.util.LinkedHashMap) HongsException(app.hongs.HongsException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

HongsException (app.hongs.HongsException)89 Map (java.util.Map)42 HashMap (java.util.HashMap)34 IOException (java.io.IOException)21 ArrayList (java.util.ArrayList)15 HashSet (java.util.HashSet)15 LinkedHashMap (java.util.LinkedHashMap)15 Set (java.util.Set)15 List (java.util.List)13 File (java.io.File)11 SQLException (java.sql.SQLException)10 FileNotFoundException (java.io.FileNotFoundException)9 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)9 PreparedStatement (java.sql.PreparedStatement)8 Iterator (java.util.Iterator)8 DocumentBuilder (javax.xml.parsers.DocumentBuilder)8 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)8 HongsExpedient (app.hongs.HongsExpedient)7 FormSet (app.hongs.action.FormSet)7 Table (app.hongs.db.Table)7