Search in sources :

Example 1 with AppDTO

use of com.ctrip.framework.apollo.common.dto.AppDTO in project apollo by ctripcorp.

the class CreationListener method onAppCreationEvent.

@EventListener
public void onAppCreationEvent(AppCreationEvent event) {
    AppDTO appDTO = BeanUtils.transform(AppDTO.class, event.getApp());
    List<Env> envs = portalSettings.getActiveEnvs();
    for (Env env : envs) {
        try {
            appAPI.createApp(env, appDTO);
        } catch (Throwable e) {
            LOGGER.error("Create app failed. appId = {}, env = {})", appDTO.getAppId(), env, e);
            Tracer.logError(String.format("Create app failed. appId = %s, env = %s", appDTO.getAppId(), env), e);
        }
    }
}
Also used : AppDTO(com.ctrip.framework.apollo.common.dto.AppDTO) Env(com.ctrip.framework.apollo.portal.environment.Env) EventListener(org.springframework.context.event.EventListener)

Example 2 with AppDTO

use of com.ctrip.framework.apollo.common.dto.AppDTO in project apollo by ctripcorp.

the class AppService method createAppInRemote.

public void createAppInRemote(Env env, App app) {
    if (StringUtils.isBlank(app.getDataChangeCreatedBy())) {
        String username = userInfoHolder.getUser().getUserId();
        app.setDataChangeCreatedBy(username);
        app.setDataChangeLastModifiedBy(username);
    }
    AppDTO appDTO = BeanUtils.transform(AppDTO.class, app);
    appAPI.createApp(env, appDTO);
}
Also used : AppDTO(com.ctrip.framework.apollo.common.dto.AppDTO)

Example 3 with AppDTO

use of com.ctrip.framework.apollo.common.dto.AppDTO in project apollo by ctripcorp.

the class AppInfoChangedListener method onAppInfoChange.

@EventListener
public void onAppInfoChange(AppInfoChangedEvent event) {
    AppDTO appDTO = BeanUtils.transform(AppDTO.class, event.getApp());
    String appId = appDTO.getAppId();
    List<Env> envs = portalSettings.getActiveEnvs();
    for (Env env : envs) {
        try {
            appAPI.updateApp(env, appDTO);
        } catch (Throwable e) {
            logger.error("Update app's info failed. Env = {}, AppId = {}", env, appId, e);
            Tracer.logError(String.format("Update app's info failed. Env = %s, AppId = %s", env, appId), e);
        }
    }
}
Also used : AppDTO(com.ctrip.framework.apollo.common.dto.AppDTO) Env(com.ctrip.framework.apollo.portal.environment.Env) EventListener(org.springframework.context.event.EventListener)

Example 4 with AppDTO

use of com.ctrip.framework.apollo.common.dto.AppDTO in project apollo by ctripcorp.

the class DeletionListener method onAppDeletionEvent.

@EventListener
public void onAppDeletionEvent(AppDeletionEvent event) {
    AppDTO appDTO = BeanUtils.transform(AppDTO.class, event.getApp());
    String appId = appDTO.getAppId();
    String operator = appDTO.getDataChangeLastModifiedBy();
    List<Env> envs = portalSettings.getActiveEnvs();
    for (Env env : envs) {
        try {
            appAPI.deleteApp(env, appId, operator);
        } catch (Throwable e) {
            logger.error("Delete app failed. Env = {}, AppId = {}", env, appId, e);
            Tracer.logError(String.format("Delete app failed. Env = %s, AppId = %s", env, appId), e);
        }
    }
}
Also used : AppDTO(com.ctrip.framework.apollo.common.dto.AppDTO) Env(com.ctrip.framework.apollo.portal.environment.Env) EventListener(org.springframework.context.event.EventListener)

Example 5 with AppDTO

use of com.ctrip.framework.apollo.common.dto.AppDTO in project apollo by ctripcorp.

the class ControllerIntegrationExceptionTest method generateSampleDTOData.

private AppDTO generateSampleDTOData() {
    AppDTO dto = new AppDTO();
    dto.setAppId("someAppId");
    dto.setName("someName");
    dto.setOwnerName("someOwner");
    dto.setOwnerEmail("someOwner@ctrip.com");
    return dto;
}
Also used : AppDTO(com.ctrip.framework.apollo.common.dto.AppDTO)

Aggregations

AppDTO (com.ctrip.framework.apollo.common.dto.AppDTO)28 Test (org.junit.Test)20 Sql (org.springframework.test.context.jdbc.Sql)17 App (com.ctrip.framework.apollo.common.entity.App)7 AbstractControllerTest (com.ctrip.framework.apollo.adminservice.controller.AbstractControllerTest)6 HttpEntity (org.springframework.http.HttpEntity)5 HttpHeaders (org.springframework.http.HttpHeaders)5 ClusterDTO (com.ctrip.framework.apollo.common.dto.ClusterDTO)4 ItemDTO (com.ctrip.framework.apollo.common.dto.ItemDTO)4 NamespaceDTO (com.ctrip.framework.apollo.common.dto.NamespaceDTO)4 Item (com.ctrip.framework.apollo.biz.entity.Item)3 ItemChangeSets (com.ctrip.framework.apollo.common.dto.ItemChangeSets)3 Env (com.ctrip.framework.apollo.portal.environment.Env)3 TestRestTemplate (org.springframework.boot.test.web.client.TestRestTemplate)3 EventListener (org.springframework.context.event.EventListener)3 RestTemplate (org.springframework.web.client.RestTemplate)3 Pageable (org.springframework.data.domain.Pageable)2 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)2 ReleaseDTO (com.ctrip.framework.apollo.common.dto.ReleaseDTO)1 ServiceException (com.ctrip.framework.apollo.common.exception.ServiceException)1