use of io.github.ihongs.HongsExemption in project HongsCORE by ihongs.
the class SearchEntity method revert.
@Override
public void revert() {
super.revert();
if (WRITES.isEmpty()) {
return;
}
try {
IndexWriter iw = getWriter();
synchronized (iw) {
iw.rollback();
}
} catch (HongsException ex) {
throw ex.toExemption();
} catch (IOException ex) {
throw new HongsExemption(1056, ex);
} finally {
WRITES.clear();
DOCK = null;
}
}
use of io.github.ihongs.HongsExemption in project HongsCORE by ihongs.
the class SystemCmdlet method getTin.
private static Date getTin(String ds, Date dt) {
Matcher dm = TIN_FMT_PAT.matcher(ds);
if (!dm.matches()) {
return getTim(ds, dt);
}
try {
String dz;
dz = dm.group(1);
if (dz != null) {
return new SimpleDateFormat("yyyy/MM/ddTHH:mm:ss").parse(dz);
}
dz = dm.group(2);
if (dz != null) {
return new SimpleDateFormat("yyyy/MM/dd").parse(dz);
}
dz = dm.group(3);
if (dz != null) {
return new SimpleDateFormat("HH:mm:ss").parse(dz);
}
dz = dm.group(4);
if (dz != null) {
return new SimpleDateFormat("HH:mm").parse(dz);
}
return null;
} catch (ParseException ex) {
throw new HongsExemption(ex);
}
}
use of io.github.ihongs.HongsExemption in project HongsCORE by ihongs.
the class SearchQuery method wdr.
@Override
public Query wdr(String k, Object v) {
if (null == v) {
throw new NullPointerException("Query for " + k + " must be string, but null");
}
if ("".equals(v)) {
throw new NullPointerException("Query for " + k + " can not be empty string");
}
QueryParser qp = new QueryParser("$" + k, ana != null ? ana : new StandardAnalyzer());
String s = v.toString();
// 是否转义
if (des == null || !des) {
s = QueryParser.escape(s);
}
// 词间关系
if (dor == null || !dor) {
qp.setDefaultOperator(QueryParser.AND_OPERATOR);
} else {
qp.setDefaultOperator(QueryParser.OR_OPERATOR);
}
// 其他设置
if (phr != null)
qp.setPhraseSlop(phr);
if (fms != null)
qp.setFuzzyMinSim(fms);
if (fpl != null)
qp.setFuzzyPrefixLength(fpl);
if (sow != null)
qp.setSplitOnWhitespace(sow);
// if (art != null) qp.setAnalyzeRangeTerms(art);
if (alw != null)
qp.setAllowLeadingWildcard(alw);
// if (let != null) qp.setLowercaseExpandedTerms (let);
if (epi != null)
qp.setEnablePositionIncrements(epi);
if (agp != null)
qp.setAutoGeneratePhraseQueries(agp);
try {
Query q2 = qp.parse(s);
return q2;
} catch (ParseException e) {
throw new HongsExemption(e);
}
}
use of io.github.ihongs.HongsExemption in project HongsCORE by ihongs.
the class Data method getFields.
/**
* 获取字段
* 当前表单不在管理区之内时,
* 会用当前表单覆盖管理表单,
* 配置文件不存在则抛出异常 404
* @return
*/
@Override
public Map getFields() {
try {
return gotFields();
} catch (NullPointerException ex) {
// 使用超类管理字段
// 拿不到就进行填充
}
/**
* 字段以 centra/data 的字段为基础
* 但可在 centre/data 重设部分字段
*
* 配置文件不得放在资源包里面
* 此处会校验表单文件是否存在
*/
Map fields = null;
Map fieldx = null;
String cnf = conf;
do {
try {
fields = FormSet.getInstance(cnf).getForm(form);
} catch (HongsException ex) {
if (ex.getErrno() != 910 && ex.getErrno() != 912) {
// 非表单缺失
throw ex.toExemption();
}
break;
}
if (fields == null) {
break;
}
cnf = getBgConf();
if (cnf.equals(conf)) {
break;
}
try {
fieldx = FormSet.getInstance(cnf).getForm(form);
} catch (HongsException ex) {
if (ex.getErrno() != 910 && ex.getErrno() != 912) {
// 非表单缺失
throw ex.toExemption();
}
break;
}
if (fieldx == null) {
break;
}
if (fieldx.isEmpty()) {
break;
}
/**
* 注意:
* 1. 不可破坏原始配置
* 2. 当前的覆盖后台的
*/
fieldx = new LinkedHashMap(fieldx);
for (Object ot : fields.entrySet()) {
Map.Entry et = (Map.Entry) ot;
String fn = (String) et.getKey();
Map fc = (Map) et.getValue();
Map fx = (Map) fieldx.get(fn);
if (fx != null) {
fx = new LinkedHashMap(fx);
fx.putAll(fc);
fieldx.put(fn, fx);
} else {
fieldx.put(fn, fc);
}
}
fields = fieldx;
} while (false);
if (null == fields) {
throw new HongsExemption(910, "Data form '" + conf + "." + form + "' is not exists").setLocalizedContent("matrix.form.not.exists").setLocalizedContext("matrix");
}
setFields(fields);
return fields;
}
use of io.github.ihongs.HongsExemption in project HongsCORE by ihongs.
the class ActionHelper method updateHelper.
/**
* 供 ActionDriver 重设助手
* @param req
* @param rsp
*/
public final void updateHelper(HttpServletRequest req, HttpServletResponse rsp) {
this.request = req;
this.response = rsp;
try {
if (null != this.request) {
this.request.setCharacterEncoding("UTF-8");
}
if (null != this.response) {
this.response.setCharacterEncoding("UTF-8");
}
} catch (UnsupportedEncodingException ex) {
throw new HongsExemption(1111, "Can not set encoding.", ex);
}
this.outputStream = null;
this.outputWriter = null;
}
Aggregations