use of app.hongs.CoreLocale in project HongsCORE by ihongs.
the class FileAction method delete.
@Override
@Action("delete")
public void delete(ActionHelper helper) throws HongsException {
CoreLocale lang = CoreLocale.getInstance("manage");
Set<String> list = Synt.asSet(helper.getRequestData().get("path"));
if (list == null || list.isEmpty()) {
helper.fault(lang.translate("core.manage.file.path.required"));
return;
}
for (String path : list) {
File file;
if (path == null) {
helper.fault(lang.translate("core.manage.file.path.required"));
return;
}
path = realPath(path);
if (path == null) {
helper.fault(lang.translate("core.manage.file.path.is.error"));
return;
}
file = new File(path);
if (!file.exists()) {
helper.fault(lang.translate("core.manage.file.path.is.not.exist"));
return;
}
if (isDenyDire(file)) {
helper.fault(lang.translate("core.manage.file.path.is.not.empty"));
return;
}
if (isDenyFile(file)) {
helper.fault(lang.translate("core.manage.file.interdicted"));
return;
}
if (!file.delete()) {
helper.fault(lang.translate("core.manage.file.delete.failed"));
return;
}
}
helper.reply("");
}
use of app.hongs.CoreLocale in project HongsCORE by ihongs.
the class AuthKit method getWrong.
/**
* 快速输出登录的错误
* @param k 字段
* @param w 错误
* @return
* @throws HongsException
*/
public static Map getWrong(String k, String w) throws HongsException {
Map m = new HashMap();
Map e = new HashMap();
CoreLocale lang = CoreLocale.getInstance("master");
if (k != null && !"".equals(k)) {
m.put(k, new Wrong(w).setLocalizedContext("master"));
e.put("errs", new Wrongs(m).getErrors());
e.put("msg", lang.translate(w));
} else {
e.put("msg", lang.translate(w));
}
e.put("ok", false);
return e;
}
use of app.hongs.CoreLocale in project HongsCORE by ihongs.
the class DeptAction method doSave.
@Action("save")
@CommitSuccess
public void doSave(ActionHelper helper) throws HongsException {
Map rd = helper.getRequestData();
String id = model.set(rd);
rd = new HashMap();
rd.put("id", id);
rd.put("name", rd.get("name"));
CoreLocale ln = CoreLocale.getInstance().clone();
ln.load("master");
String ms = ln.translate("core.save.dept.success");
helper.reply(ms, rd);
}
use of app.hongs.CoreLocale in project HongsCORE by ihongs.
the class UserAction method doDelete.
@Action("delete")
@CommitSuccess
public void doDelete(ActionHelper helper) throws HongsException {
Map rd = helper.getRequestData();
FetchCase fc = model.fetchCase();
fc.setOption("INCLUDE_REMOVED", Synt.declare(rd.get("include-removed"), false));
// 不能删除自己和超级管理员
Set rs = Synt.asSet(rd.get(model.table.primaryKey));
if (rs != null) {
if (rs.contains(helper.getSessibute(Cnst.UID_SES))) {
helper.fault("不能删除当前登录用户");
return;
}
if (rs.contains(Cnst.ADM_UID)) {
helper.fault("不能删除超级管理账号");
return;
}
}
int rn = model.delete(rd, fc);
CoreLocale ln = CoreLocale.getInstance().clone();
ln.load("master");
String ms = ln.translate("core.delete.user.success", Integer.toString(rn));
helper.reply(ms, rn);
}
use of app.hongs.CoreLocale in project HongsCORE by ihongs.
the class FormAction method doSave.
@Action("save")
public void doSave(ActionHelper helper) throws HongsException {
Map data = helper.getRequestData();
String id = model.set(data);
Map info = new HashMap();
info.put("id", id);
info.put("name", data.get("name"));
CoreLocale lang = CoreLocale.getInstance().clone();
lang.load("matrix");
String ms = lang.translate("core.save.form.success");
helper.reply(ms, info);
}
Aggregations