use of com.qlangtech.tis.pubhook.common.Nullable in project tis by qlangtech.
the class SnapshotRevsionAction method doGetSnapshotList.
/**
* @param context
*/
public void doGetSnapshotList(Context context) {
AppDomainInfo domain = this.getAppDomain();
if (domain instanceof Nullable) {
this.addErrorMessage(context, "has not select app");
// 是否已经选择了域
return;
}
context.put("hasselectdomain", true);
Pager pager = this.createPager();
SnapshotCriteria query = new SnapshotCriteria();
// 一览先不考虑有 版本设置
query.createCriteria().andAppidEqualTo(domain.getAppid());
query.setOrderByClause("snapshot.sn_id desc");
query.setPageSize(PAGE_SIZE);
pager.setTotalCount(this.getSnapshotDAO().countByExample(query));
ServerGroup group = getAppServerGroup();
SnapshotList snapshotList = new SnapshotList();
snapshotList.publishSnapshotid = group.getPublishSnapshotId();
snapshotList.snapshotList = this.getSnapshotDAO().selectByExample(query, pager.getCurPage(), PAGE_SIZE);
this.setBizResult(context, new PaginationResult(pager, snapshotList.snapshotList, snapshotList.publishSnapshotid));
Assert.assertNotNull("group can not be null,app:" + domain.getAppName() + ", runtime:" + domain.getRunEnvironment().getKeyName(), group);
// context.put("selectgroup", group);
}
use of com.qlangtech.tis.pubhook.common.Nullable in project tis by qlangtech.
the class Appselectboxcontrol method execute.
public void execute(Context context) throws Exception {
// ${contextid}
// if (context.get("contextid") == null) {
// context.put("contextid", StringUtils.EMPTY);
// }
AppOptionsList optionslist = (AppOptionsList) this.getRequest().getAttribute(key);
if (optionslist == null) {
final List<Option> bizlist = this.getBizLineList();
List<Option> applist = null;
AppDomainInfo domain = this.getAppDomain();
if (!(domain instanceof Nullable)) {
// if (bizid != null) {
applist = this.getAppList(domain.getDptid());
// }
}
optionslist = new AppOptionsList(bizlist, applist);
this.getRequest().setAttribute(key, optionslist);
}
context.put("bizlinelist", optionslist.bizlinelist);
context.put("applist", optionslist.applist);
}
use of com.qlangtech.tis.pubhook.common.Nullable in project tis by qlangtech.
the class IndexQueryAction method doGetServerNodes.
/**
* @param context
*/
public void doGetServerNodes(Context context) throws Exception {
AppDomainInfo domain = this.getAppDomain();
if (domain instanceof Nullable) {
throw new IllegalStateException("execute phase must be Collection aware");
}
QueryResutStrategy queryStrategy = QueryIndexServlet.createQueryResutStrategy(domain, new QueryRequestWrapper(getRequest(), context), getResponse(), getDaoContext());
List<ServerJoinGroup> nodes = queryStrategy.queryProcess();
List<PSchemaField> sfields = IndexQuery.getSfields(this.getRequest(), queryStrategy, nodes);
Map<String, Object> props = Maps.newHashMap();
props.put("nodes", queryStrategy.selectCandiate);
props.put("fields", sfields.stream().map((c) -> c.getName()).collect(Collectors.toList()));
this.setBizResult(context, props);
}
use of com.qlangtech.tis.pubhook.common.Nullable in project tis by qlangtech.
the class OperationLogInterceptor method doIntercept.
@Override
protected String doIntercept(ActionInvocation invocation) throws Exception {
BasicModule action = (BasicModule) invocation.getAction();
final Method method = action.getExecuteMethod();
final String result = invocation.invoke();
Func func = method.getAnnotation(Func.class);
if (func != null && !func.sideEffect()) {
return result;
}
AppDomainInfo appDomain = CheckAppDomainExistValve.getAppDomain(daoContext);
OperationLog log = new OperationLog();
log.setOpType(BasicModule.parseMehtodName());
if (StringUtils.startsWith(log.getOpType(), "doGet")) {
return result;
}
log.setCreateTime(new Date());
if (!(appDomain instanceof Nullable)) {
log.setAppName(appDomain.getAppName());
}
ActionProxy proxy = invocation.getProxy();
// log.setOpType(proxy.getMethod());
HttpServletRequest request = ServletActionContext.getRequest();
if (StringUtils.indexOf(request.getClass().getSimpleName(), "Mock") > -1) {
// 当前是测试流程的话就不需要记录日志了
return result;
}
IUser user = UserUtils.getUser(request, daoContext);
if (user == null) {
throw new IllegalStateException("user can not be null");
}
StringBuffer jsonObject = new StringBuffer();
JSONObject params = null;
Map<String, String[]> paramsMap = null;
String url = request.getRequestURL().toString();
jsonObject.append("request:");
jsonObject.append(url).append("\n");
String requestBody = null;
if (!ConfigFileContext.HTTPMethod.GET.name().equals(request.getMethod())) {
paramsMap = request.getParameterMap();
if (paramsMap.size() > 0) {
params = new JSONObject();
for (Map.Entry<String, String[]> entry : paramsMap.entrySet()) {
if (entry.getValue().length == 1) {
params.put(entry.getKey(), entry.getValue()[0]);
} else {
params.put(entry.getKey(), entry.getValue());
}
}
jsonObject.append("params:").append("\n");
jsonObject.append(params.toString(1)).append("\n");
}
try (ServletInputStream input = request.getInputStream()) {
if (!input.isFinished()) {
requestBody = IOUtils.toString(input, TisUTF8.get());
jsonObject.append("body:").append("\n");
jsonObject.append(requestBody).append("\n");
}
}
}
Context context = new MockContext();
jsonObject.append("\n=================================");
jsonObject.append("response:").append("\n");
jsonObject.append(AjaxValve.buildResultStruct(context));
log.setTabName(proxy.getActionName());
log.setUsrId(user.getId());
log.setUsrName(user.getName());
log.setOpDesc(jsonObject.toString());
operationLogDAO.insertSelective(log);
return result;
}
use of com.qlangtech.tis.pubhook.common.Nullable in project tis by qlangtech.
the class ChangeDomainAction method doChangeAppAjax.
/**
* 利用AJAX切换选择的应用
*
* @param context
* @throws Exception
*/
public void doChangeAppAjax(Context context) throws Exception {
Integer appid = this.getInt("appid");
if (appid == null) {
appid = this.getInt("selappid");
}
if (appid == null) {
this.addErrorMessage(context, "请选择应用");
return;
}
if (this.getAppDomain() instanceof Nullable) {
this.addErrorMessage(context, "请先选择应用环境,日常? 预发? 线上?");
return;
}
Application app = this.getApplicationDAO().loadFromWriteDB(appid);
setAppdomainCookie(getResponse(), this.getRequest(), this.getAppDomain().getRunEnvironment(), app);
this.addActionMessage(context, "已经将当前应用切换成:" + AppDomain.getAppDescribe(app));
}
Aggregations