Search in sources :

Example 61 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class GroupChangeSnapshotAction method doChange.

@Func(PermissionConstant.CONFIG_SNAPSHOT_CHANGE)
public // Navigator nav,
void doChange(Context context) throws Exception {
    Assert.assertNotNull("form can not be null", form);
    Assert.assertNotNull("form.getGroupSnapshot() can not be null", form.getGroupSnapshot());
    Assert.assertNotNull("form.getSnapshotId() can not be null", form.getSnapshotId());
    ServerGroupCriteria criteria = new ServerGroupCriteria();
    criteria.createCriteria().andGidEqualTo(form.getGroupId()).andRuntEnvironmentEqualTo(this.getAppDomain().getRunEnvironment().getId());
    ServerGroup group = new ServerGroup();
    group.setPublishSnapshotId(form.getSnapshotId());
    if (this.getServerGroupDAO().updateByExampleSelective(group, criteria) < 1) {
        throw new IllegalArgumentException("has not update success");
    }
    this.addActionMessage(context, "已经将第" + this.getServerGroupDAO().selectByPrimaryKey(form.getGroupId()).getGroupIndex() + "组,发布快照切换成:snapshot" + form.getSnapshotId());
}
Also used : ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 62 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class SaveFileContentAction method doSaveContent.

/**
 * 保存文本内容
 */
@Func(PermissionConstant.CONFIG_EDIT)
public void doSaveContent(Context context) throws Exception {
    if (!RunEnvironment.isDevelopMode()) {
        this.addErrorMessage(context, "请先更新日常环境中的配置文件,然后同步到线上环境!");
        return;
    }
    Savefilecontent xmlContent = this.parseJsonPost(Savefilecontent.class);
    Integer snapshotid = xmlContent.getSnapshotid();
    String fileName = xmlContent.getFilename();
    // if (isEditSchemaApply(context, fileName)) return;
    PropteryGetter propertyGetter = createConfigFileGetter(fileName);
    Long userid = 999l;
    try {
        userid = new Long(this.getUserId());
    } catch (Throwable e) {
    }
    ISchemaPluginContext schemaPlugin = SchemaAction.createSchemaPlugin(this.getCollectionName());
    CreateSnapshotResult createResult = createNewSnapshot(context, this.getSnapshotViewDAO().getView(snapshotid, false), propertyGetter, schemaPlugin, xmlContent.getContentBytes(), this, this, xmlContent.getMemo(), userid, this.getLoginUserName());
    if (!createResult.isSuccess()) {
        // forward("edit_" + BasicContentScreen.getResourceName(propertyGetter));
        return;
    }
    this.setBizResult(context, createResult);
    this.addActionMessage(context, "保存文件成功,最新snapshot:" + createResult.getNewId());
}
Also used : Savefilecontent(com.qlangtech.tis.manage.Savefilecontent) ISchemaPluginContext(com.qlangtech.tis.solrdao.ISchemaPluginContext) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 63 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class SnapshotRevsionAction method doSelectRevsion.

@Func(value = PermissionConstant.CONFIG_SNAPSHOT_CHANGE)
public void doSelectRevsion(Context context) throws Exception {
    this.errorsPageShow(context);
    Integer snapshotid = this.getInt("selectedSnapshotid");
    // 只作数据库保存,不推送到远到引擎中
    boolean justSave = this.getBoolean("justSave");
    // final Integer groupid = this.getInt("groupid");
    final String memo = this.getString("memo");
    if (snapshotid == null) {
        throw new IllegalArgumentException("snapshotid can not be null");
    }
    if (StringUtils.isBlank(memo)) {
        this.addErrorMessage(context, "请填写操作日志");
        return;
    }
    SnapshotDomain toSnapshot = this.getSnapshotViewDAO().getView(snapshotid);
    if (toSnapshot == null) {
        this.addErrorMessage(context, "版本号:" + snapshotid + "对应的配置已经被删除");
        return;
    }
    final ServerGroup group = getAppServerGroup();
    Assert.assertNotNull(group);
    final AppDomainInfo domain = this.getAppDomain();
    if (domain.getAppid() != (toSnapshot.getAppId() + 0)) {
        this.addErrorMessage(context, "执行的实例与当前实例“" + domain.getAppName() + "”不一致,请关闭当前页面重新打开");
        return;
    }
    if (group.getPublishSnapshotId() != null && snapshotid == (int) group.getPublishSnapshotId()) {
        this.addErrorMessage(context, "SNAPSHOT已经设置为:" + snapshotid + ",请重新设置");
        return;
    }
    Application app = new Application();
    app.setAppId(domain.getAppid());
    app.setProjectName(domain.getAppName());
    change2newSnapshot(snapshotid, memo, group, app, domain.getRunEnvironment(), this);
    if (!justSave) {
        DocCollection docCollection = TISZkStateReader.getCollectionLive(this.getZkStateReader(), this.getCollectionName());
        CoreAction.pushConfig2Engine(this, context, docCollection, snapshotid, false);
    }
    addActionMessage(context, "已经将" + domain.getRunEnvironment().getDescribe() + "" + domain.getAppName() + "的配置切换成了snapshot:" + snapshotid);
}
Also used : AppDomainInfo(com.qlangtech.tis.manage.common.AppDomainInfo) SnapshotDomain(com.qlangtech.tis.manage.common.SnapshotDomain) DocCollection(org.apache.solr.common.cloud.DocCollection) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 64 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class SnapshotRevsionAction method doGetLatestSnapshot.

/**
 * 取得最新的快照记录
 *
 * @param context
 */
@Func(PermissionConstant.CONFIG_SNAPSHOT_CHANGE)
public void doGetLatestSnapshot(Context context) throws Exception {
    Integer snapshotId = this.getInt("maxsnapshotid");
    SnapshotCriteria criteria = new SnapshotCriteria();
    criteria.createCriteria().andSnIdGreaterThan(snapshotId).andAppidEqualTo(this.getAppDomain().getAppid());
    final SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    JSONArray jsonArray = new JSONArray();
    JSONObject obj = null;
    for (Snapshot snapshot : this.getSnapshotDAO().selectByExample(criteria, 1, 20)) {
        obj = new JSONObject();
        obj.put("snid", snapshot.getSnId());
        obj.put("createtime", format.format(snapshot.getCreateTime()));
        obj.put("creator", snapshot.getCreateUserName());
        obj.put("parent", snapshot.getPreSnId());
        obj.put("memo", StringUtils.trimToEmpty(snapshot.getMemo()));
        jsonArray.put(obj);
    }
    context.put("query_result", jsonArray.toString(1));
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) SimpleDateFormat(java.text.SimpleDateFormat) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

Func (com.qlangtech.tis.manage.spring.aop.Func)64 JSONObject (com.alibaba.fastjson.JSONObject)12 DataXJobWorker (com.qlangtech.tis.datax.job.DataXJobWorker)6 File (java.io.File)6 Date (java.util.Date)6 Context (com.alibaba.citrus.turbine.Context)5 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)5 JSONObject (org.json.JSONObject)5 Validator (com.qlangtech.tis.plugin.annotation.Validator)4 IControlMsgHandler (com.qlangtech.tis.runtime.module.misc.IControlMsgHandler)4 IFieldErrorHandler (com.qlangtech.tis.runtime.module.misc.IFieldErrorHandler)4 DelegateControl4JsonPostMsgHandler (com.qlangtech.tis.runtime.module.misc.impl.DelegateControl4JsonPostMsgHandler)4 WorkFlow (com.qlangtech.tis.workflow.pojo.WorkFlow)4 JSONArray (org.json.JSONArray)4 ExecResult (com.qlangtech.tis.assemble.ExecResult)3 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)3 IndexStreamCodeGenerator (com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator)3 DescriptorExtensionList (com.qlangtech.tis.extension.DescriptorExtensionList)3 IOException (java.io.IOException)3 Matcher (java.util.regex.Matcher)3