use of app.hongs.action.ActionRunner in project HongsCORE by ihongs.
the class ActsAction method service.
/**
* 服务方法
* Servlet Mapping: *.act<br/>
* 注意: 不支持请求URI的路径中含有"."(句点), 且必须区分大小写;
* 其目的是为了防止产生多种形式的请求路径, 影响动作过滤, 产生安全隐患.
*
* @param req
* @param rsp
* @throws javax.servlet.ServletException
*/
@Override
public void service(HttpServletRequest req, HttpServletResponse rsp) throws ServletException {
String act = ActionDriver.getRecentPath(req);
Core core = ActionDriver.getActualCore(req);
ActionHelper helper = core.get(ActionHelper.class);
Core.THREAD_CORE.set(core);
if (act == null || act.length() == 0) {
senderr(helper, 0x1104, null, "Action URI can not be empty.", "");
return;
}
// 去掉根和扩展名
act = act.substring(1);
int pos = act.lastIndexOf('.');
if (pos != -1)
act = act.substring(0, pos);
// 获取并执行动作
try {
ActionRunner runner = new ActionRunner(helper, act);
runner.doAction();
} catch (ClassCastException ex) {
// 类型转换失败按 400 错误处理
senderr(helper, new HongsException(0x1100, ex));
} catch (HongsException ex) {
senderr(helper, ex);
} catch (HongsExpedient ex) {
senderr(helper, ex);
} catch (HongsError ex) {
senderr(helper, ex);
}
}
use of app.hongs.action.ActionRunner in project HongsCORE by ihongs.
the class DataAction method list.
@Action("revert/search")
public void list(ActionHelper helper) throws HongsException {
ActionRunner runner = (ActionRunner) helper.getAttribute(ActionRunner.class.getName());
String ent = runner.getEntity();
String mod = runner.getModule();
Data sr = (Data) getEntity(helper);
Model mo = sr.getModel();
Map rd = helper.getRequestData();
rd.remove("user_id");
rd.put("form_id", sr.getFormId());
Map sd = mo.search(rd);
// 详情数据转换
if (sd.containsKey("info")) {
Map df = (Map) sd.remove("info");
Map dt = (Map) app.hongs.util.Data.toObject((String) df.remove("data"));
sd.put("logs", df);
sd.put("info", dt);
// 补充枚举和关联
Set ab = Synt.toTerms(rd.get(Cnst.AB_KEY));
if (ab != null) {
byte md = 0;
if (ab.contains("_enum")) {
md += 2;
}
if (ab.contains("_time")) {
md += 4;
}
if (ab.contains("_link")) {
md += 8;
}
if (md != 0) {
new SelectHelper().addItemsByForm(mod, ent).select(sd, md);
}
if (ab.contains("_fork")) {
new SpreadHelper().addItemsByForm(mod, ent).spread(sd);
}
}
}
helper.reply(sd);
}
use of app.hongs.action.ActionRunner in project HongsCORE by ihongs.
the class Common method execAction.
@Cmdlet("exec-action")
public static void execAction(String[] args) throws HongsException {
Map<String, Object> opts;
opts = CmdletHelper.getOpts(args, "request:s", "context:s", "session:s", "cookies:s");
args = (String[]) opts.get("");
if (args.length == 0) {
System.err.println("Action name required!\r\nUsage: ACTION_NAME --request QUERY_STRING --cookies QUERY_STRING --session QUERY_STRING --context QUERY_STRING");
return;
}
ActionHelper helper = Core.getInstance(ActionHelper.class);
helper.setRequestData(data((String) opts.get("request")));
helper.setContextData(data((String) opts.get("context")));
helper.setSessionData(data((String) opts.get("session")));
helper.setCookiesData(data((String) opts.get("cookies")));
ActionRunner runner = new ActionRunner(helper, args[0]);
runner.doAction();
CmdletHelper.preview(helper.getResponseData());
}
use of app.hongs.action.ActionRunner in project HongsCORE by ihongs.
the class DBAction method getRspMsg.
/**
* 获取返回消息
* @param helper
* @param ett
* @param opr
* @param num
* @return
* @throws HongsException
*/
protected String getRspMsg(ActionHelper helper, Model ett, String opr, int num) throws HongsException {
ActionRunner runner = (ActionRunner) helper.getAttribute(ActionRunner.class.getName());
CoreLocale locale = CoreLocale.getInstance().clone();
String mod = runner.getModule();
String ent = runner.getEntity();
String cnt = Integer.toString(num);
String key = "fore." + opr + "." + ent + ".success";
locale.fill(mod);
if (!locale.containsKey(key)) {
key = "fore." + opr + ".success";
Mview view = new Mview(ett);
String tit = view.getTitle();
return locale.translate(key, tit, cnt);
} else {
return locale.translate(key, /**/
cnt);
}
}
use of app.hongs.action.ActionRunner in project HongsCORE by ihongs.
the class JointGate method getRspMsg.
/**
* 获取返回消息
* @param helper
* @param ett
* @param opr
* @param num
* @return
* @throws HongsException
*/
protected String getRspMsg(ActionHelper helper, IEntity ett, String opr, int num) throws HongsException {
ActionRunner runner = (ActionRunner) helper.getAttribute(ActionRunner.class.getName());
CoreLocale locale = CoreLocale.getInstance().clone();
String mod = runner.getModule();
String ent = runner.getEntity();
String cnt = Integer.toString(num);
String key = "fore." + opr + "." + ent + ".success";
locale.fill(mod);
if (!locale.containsKey(key)) {
key = "fore." + opr + ".success";
String tit = getName(locale, mod, ent);
return locale.translate(key, tit, cnt);
} else {
return locale.translate(key, /**/
cnt);
}
}
Aggregations