Search in sources :

Example 11 with CoreLocale

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("");
}
Also used : CoreLocale(app.hongs.CoreLocale) File(java.io.File) IAction(app.hongs.dh.IAction) Action(app.hongs.action.anno.Action)

Example 12 with CoreLocale

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;
}
Also used : CoreLocale(app.hongs.CoreLocale) Wrong(app.hongs.util.verify.Wrong) HashMap(java.util.HashMap) Wrongs(app.hongs.util.verify.Wrongs) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with CoreLocale

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);
}
Also used : CoreLocale(app.hongs.CoreLocale) HashMap(java.util.HashMap) HashMap(java.util.HashMap) NaviMap(app.hongs.action.NaviMap) Map(java.util.Map) RoleMap(app.hongs.serv.auth.RoleMap) Action(app.hongs.action.anno.Action) CommitSuccess(app.hongs.action.anno.CommitSuccess)

Example 14 with CoreLocale

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);
}
Also used : CoreLocale(app.hongs.CoreLocale) FetchCase(app.hongs.db.util.FetchCase) Set(java.util.Set) HashMap(java.util.HashMap) NaviMap(app.hongs.action.NaviMap) Map(java.util.Map) RoleMap(app.hongs.serv.auth.RoleMap) Action(app.hongs.action.anno.Action) CommitSuccess(app.hongs.action.anno.CommitSuccess)

Example 15 with CoreLocale

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);
}
Also used : CoreLocale(app.hongs.CoreLocale) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) Action(app.hongs.action.anno.Action)

Aggregations

CoreLocale (app.hongs.CoreLocale)22 HashMap (java.util.HashMap)15 Map (java.util.Map)15 Action (app.hongs.action.anno.Action)12 CommitSuccess (app.hongs.action.anno.CommitSuccess)7 NaviMap (app.hongs.action.NaviMap)5 IAction (app.hongs.dh.IAction)4 RoleMap (app.hongs.serv.auth.RoleMap)4 File (java.io.File)4 LinkedHashMap (java.util.LinkedHashMap)4 HongsException (app.hongs.HongsException)3 ActionRunner (app.hongs.action.ActionRunner)2 Verify (app.hongs.action.anno.Verify)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 Core (app.hongs.Core)1 HongsError (app.hongs.HongsError)1 HongsExpedient (app.hongs.HongsExpedient)1 FetchCase (app.hongs.db.util.FetchCase)1 Wrong (app.hongs.util.verify.Wrong)1