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());
}
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());
}
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);
}
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));
}
Aggregations