Search in sources :

Example 1 with Nullable

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);
}
Also used : AppDomainInfo(com.qlangtech.tis.manage.common.AppDomainInfo) Pager(com.koubei.web.tag.pager.Pager) Nullable(com.qlangtech.tis.pubhook.common.Nullable)

Example 2 with Nullable

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);
}
Also used : AppDomainInfo(com.qlangtech.tis.manage.common.AppDomainInfo) Option(com.qlangtech.tis.manage.common.Option) Nullable(com.qlangtech.tis.pubhook.common.Nullable)

Example 3 with Nullable

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);
}
Also used : AppDomainInfo(com.qlangtech.tis.manage.common.AppDomainInfo) PSchemaField(com.qlangtech.tis.solrdao.pojo.PSchemaField) QueryRequestWrapper(com.qlangtech.tis.runtime.module.screen.IndexQuery.QueryRequestWrapper) Nullable(com.qlangtech.tis.pubhook.common.Nullable)

Example 4 with Nullable

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;
}
Also used : Context(com.alibaba.citrus.turbine.Context) ServletActionContext(org.apache.struts2.ServletActionContext) ActionProxy(com.opensymphony.xwork2.ActionProxy) Func(com.qlangtech.tis.manage.spring.aop.Func) BasicModule(com.qlangtech.tis.runtime.module.action.BasicModule) OperationLog(com.qlangtech.tis.manage.biz.dal.pojo.OperationLog) Method(java.lang.reflect.Method) Date(java.util.Date) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletInputStream(javax.servlet.ServletInputStream) JSONObject(org.json.JSONObject) Map(java.util.Map) Nullable(com.qlangtech.tis.pubhook.common.Nullable)

Example 5 with Nullable

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));
}
Also used : Application(com.qlangtech.tis.manage.biz.dal.pojo.Application) Nullable(com.qlangtech.tis.pubhook.common.Nullable)

Aggregations

Nullable (com.qlangtech.tis.pubhook.common.Nullable)6 AppDomainInfo (com.qlangtech.tis.manage.common.AppDomainInfo)4 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)2 Context (com.alibaba.citrus.turbine.Context)1 Pager (com.koubei.web.tag.pager.Pager)1 ActionProxy (com.opensymphony.xwork2.ActionProxy)1 Department (com.qlangtech.tis.manage.biz.dal.pojo.Department)1 OperationLog (com.qlangtech.tis.manage.biz.dal.pojo.OperationLog)1 Option (com.qlangtech.tis.manage.common.Option)1 Func (com.qlangtech.tis.manage.spring.aop.Func)1 BasicModule (com.qlangtech.tis.runtime.module.action.BasicModule)1 QueryRequestWrapper (com.qlangtech.tis.runtime.module.screen.IndexQuery.QueryRequestWrapper)1 PSchemaField (com.qlangtech.tis.solrdao.pojo.PSchemaField)1 Method (java.lang.reflect.Method)1 Date (java.util.Date)1 Map (java.util.Map)1 ServletInputStream (javax.servlet.ServletInputStream)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 ServletActionContext (org.apache.struts2.ServletActionContext)1 JSONObject (org.json.JSONObject)1