Search in sources :

Example 21 with Application

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);
}
Also used : IAppsFetcher(com.qlangtech.tis.manage.common.apps.IAppsFetcher) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 22 with Application

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

Example 23 with Application

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

Example 24 with Application

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;
        }
    });
}
Also used : MalformedURLException(java.net.MalformedURLException) JSONArray(org.json.JSONArray) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) JSONTokener(org.json.JSONTokener) JSONObject(org.json.JSONObject) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Example 25 with Application

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);
    }
}
Also used : URL(java.net.URL) Department(com.qlangtech.tis.manage.biz.dal.pojo.Department) UploadResource(com.qlangtech.tis.manage.biz.dal.pojo.UploadResource) JSONArray(org.json.JSONArray) MalformedURLException(java.net.MalformedURLException) JSONTokener(org.json.JSONTokener) JSONObject(org.json.JSONObject) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Aggregations

Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)26 ApplicationCriteria (com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria)7 Func (com.qlangtech.tis.manage.spring.aop.Func)5 Department (com.qlangtech.tis.manage.biz.dal.pojo.Department)2 Nullable (com.qlangtech.tis.pubhook.common.Nullable)2 SchemaAction (com.qlangtech.tis.runtime.module.action.SchemaAction)2 File (java.io.File)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 JSONTokener (org.json.JSONTokener)2 JSONObject (com.alibaba.fastjson.JSONObject)1 Pager (com.koubei.web.tag.pager.Pager)1 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)1 TriggerType (com.qlangtech.tis.assemble.TriggerType)1 DBConfigSuit (com.qlangtech.tis.db.parser.DBConfigSuit)1 GitUser (com.qlangtech.tis.git.GitUtils.GitUser)1 Criteria (com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria.Criteria)1 ServerGroup (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup)1