use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.
the class AppViewAction method doQueryApp.
@Func(value = PermissionConstant.PERMISSION_INDEX_QUERY, sideEffect = false)
public void doQueryApp(Context context) throws Exception {
final String appNameFuzzy = StringUtils.trimToEmpty(this.getString("query"));
final IAppsFetcher fetcher = UserUtils.getAppsFetcher(this.getRequest(), this);
final List<Application> appresult = fetcher.getApps((criteria) -> {
criteria.andProjectNameLike(StringUtils.startsWith(appNameFuzzy, "search4") ? (appNameFuzzy + "%") : ("%" + appNameFuzzy + "%"));
});
this.setBizResult(context, appresult);
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Application 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));
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.
the class ChangeDomainAction method doChange.
/**
* 切换当前应用
*
* @throws Exception
*/
public // Navigator nav,
void doChange(Context context) throws Exception {
Integer appid = parseSelectedAppid(form, context);
if (appid == null) {
return;
}
final Application app = this.getApplicationDAO().selectByPrimaryKey(appid);
setAppDomainCookie(form, app);
return2OriginUrl(form);
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.
the class ResSynManager method appSuggest.
/**
* 取得daily环境中应用名称的suggest
*
* @param appNamePrefix
* @return
*/
public static List<Application> appSuggest(String appNamePrefix) {
final StringBuffer urlbuffer = new StringBuffer(Config.getTerminatorRepositoryOnline());
// StringBuffer urlbuffer = new StringBuffer("http://localhost");
urlbuffer.append("/config/changedomain.action?action=app_relevant_action&event_submit_do_app_name_suggest=y&query=");
urlbuffer.append(appNamePrefix);
URL requestUrl;
try {
requestUrl = new URL(urlbuffer.toString());
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
return ConfigFileContext.processContent(requestUrl, new StreamProcess<List<Application>>() {
@Override
public List<Application> p(int status, InputStream stream, Map<String, List<String>> headerFields) {
List<Application> suggest = new ArrayList<Application>();
try {
JSONTokener tokener = new JSONTokener(IOUtils.toString(stream));
JSONObject json = new JSONObject(tokener);
JSONArray dataAry = (JSONArray) json.get("data");
JSONArray suggestAry = (JSONArray) json.get("suggestions");
for (int i = 0; i < dataAry.length(); i++) {
Application app = new Application();
app.setAppId(dataAry.getInt(i));
app.setProjectName(suggestAry.getString(i));
suggest.add(app);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return suggest;
}
});
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.
the class ResSynManager method getSynchronizedOnlineSnapshot.
/**
* 执行将日常配置推送到线上的操作
*
* @param context
* @param module
* @return
* @throws UnsupportedEncodingException
* @throws SchemaFileInvalidException
*/
public Boolean getSynchronizedOnlineSnapshot(final Context context, final BasicModule module) throws Exception {
final SnapshotDomain onlineResDomain = this.getOnlineResDomain();
List<ResSyn> reslist = this.getCompareResult();
List<ResSyn> pushResource = new ArrayList<ResSyn>();
for (ResSyn res : reslist) {
if (!res.isSame()) {
// 若日常和线上相等,则该资源就不推送了
pushResource.add(res);
continue;
}
// pushResource.add(res);
}
if (pushResource.size() < 1) {
module.addErrorMessage(context, "all config resource has been updated already");
return false;
}
// return snapshot;
UploadResource push = null;
List<UploadResource> uploadResources = new ArrayList<UploadResource>();
for (ResSyn res : pushResource) {
if (res.getDaily() == null) {
continue;
}
push = new UploadResource();
push.setResourceType(res.getGetter().getFileName());
push.setContent(res.getDaily().getContent());
push.setMd5Code(res.getDaily().getMd5Code());
uploadResources.add(push);
}
ConfigPush configPush = new ConfigPush();
configPush.setCollection(this.collectionName);
configPush.setSnapshotId(this.getDailyRes().getSnapshot().getSnId());
if (this.getOnlineResDomain() != null) {
configPush.setRemoteSnapshotId(this.getOnlineResDomain().getSnapshot().getSnId());
}
configPush.setUploadResources(uploadResources);
if (onlineResDomain == null) {
// 说明线上还没有第一次发布
Department dpt = new Department();
// dpt.setDptId();
// dpt.setFullName();
Application app = this.runContext.getApplicationDAO().loadFromWriteDB(this.getDailyRes().getAppId());
dpt.setFullName(app.getDptName());
configPush.setDepartment(dpt);
configPush.setReception(app.getRecept());
} else {
configPush.setReception(this.getDailyRes().getSnapshot().getCreateUserName());
}
Writer writer = null;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
writer = new OutputStreamWriter(out, BasicModule.getEncode());
HttpConfigFileReader.xstream.toXML(configPush, writer);
writer.flush();
// System.out.println(new String(out.toByteArray(),
// BasicModule.getEncode()));
final URL url = new URL(Config.getTerminatorRepositoryOnline() + "/config/config.ajax?action=app_syn_action&event_submit_do_init_app_from_daily=y");
return HttpUtils.post(url, out.toByteArray(), new PostFormStreamProcess<Boolean>() {
@Override
public ContentType getContentType() {
return ContentType.Multipart_byteranges;
}
@Override
public Boolean p(int status, InputStream stream, Map<String, List<String>> headerFields) {
try {
String result = IOUtils.toString(stream, BasicModule.getEncode());
JSONTokener tokener = new JSONTokener(result);
JSONObject json = new JSONObject(tokener);
JSONArray errs = json.getJSONArray("errormsg");
if (errs.length() > 0) {
for (int i = 0; i < errs.length(); i++) {
module.addErrorMessage(context, errs.getString(i));
}
return false;
}
JSONArray msg = json.getJSONArray("msg");
return true;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
} finally {
IOUtils.closeQuietly(writer);
}
}
Aggregations