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();
}
}
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;
}
}
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();
}
}
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;
}
}
}
}
}
Aggregations