/** 更新pattern */ public void update() throws Exception { Pattern p = new Pattern(); try { p.setId(Integer.parseInt(request.getParameter("id"))); p.setName(request.getParameter("name")); p.setExpression(request.getParameter("expression")); p.setWarning(request.getParameter("warning")); p.setCategory(request.getParameter("category")); p.setScope(request.getParameter("scope")); p.setExample(request.getParameter("example")); p.setPriority(Integer.parseInt(request.getParameter("priority"))); } catch (Exception e) { // 参数错误 error("Pattern Update Fail:" + e.getMessage()); return; } PatternDao dao = new PatternDaoImpl(); boolean bResult = false; try { bResult = dao.update(p); } catch (Exception e) { // 产生异常 error("Pattern Update Fail:" + e.getMessage()); return; } if (bResult) { Json j = new Json(1, "Pattern Update Success"); j.setData(p.getTBJsonNode()); echo(j.toString()); } else { error("Pattern Update Fail"); } }
/** 获取指定id的pattern */ public void get() throws Exception { try { int id = Integer.parseInt(request.getParameter("id")); PatternDao dao = new PatternDaoImpl(); Pattern p = dao.get(id); Json j = new Json(1, "ok"); j.setData(p.getObjectNode("data")); echo(j.toString()); } catch (Exception e) { error("Exception:" + e.getMessage()); } }