use of io.github.ihongs.action.PresetHelper in project HongsCORE by ihongs.
the class PresetInvoker method invoke.
@Override
public void invoke(ActionHelper helper, ActionRunner chains, Annotation anno) throws HongsException {
Preset ann = (Preset) anno;
String conf = ann.conf();
String form = ann.form();
String[] deft = ann.deft();
String[] defs = ann.defs();
// 默认参数可完全由外部指定
if (deft == null || deft.length == 0) {
Map req = helper.getRequestData();
Set<String> uzed = Synt.toTerms(req.get(Cnst.AB_KEY));
Set<String> used = new LinkedHashSet();
if (null != uzed && !uzed.isEmpty()) {
for (String item : uzed) {
/*
// 2021/04/17
// 废弃返回数据模式
// 规避内部不确定性
// 总是返回原始对象
if (item.equals("_str_")) {
Core.getInstance().put(Cnst.STRING_MODE, true );
} else
if (item.equals("_obj_")) {
Core.getInstance().put(Cnst.STRING_MODE, false);
} else
*/
if (item.startsWith("_") == false && !item.startsWith(".") && !item.startsWith(":") && !item.startsWith("!")) {
used.add("." + item);
}
}
deft = used.toArray(new String[0]);
}
}
// 识别路径
if (form.length() == 0) {
form = chains.getEntity();
}
if (conf.length() == 0) {
conf = chains.getModule();
// 照顾 Module Action 的配置规则. 2018/7/7 改为完全由外部预判
// if (FormSet.hasConfFile(conf+"/"+form)) {
// conf = conf+"/"+form ;
// }
}
// 补充参数
try {
Map req;
PresetHelper pre;
req = helper.getRequestData();
pre = new PresetHelper();
pre.addItemsByForm(conf, form, deft, defs);
pre.preset(req, helper);
} catch (HongsException ex) {
int ec = ex.getErrno();
if (ec != 910 && ec != 911 && ec != 913) {
// 非枚举缺失
throw ex;
}
}
chains.doAction();
}
Aggregations