apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java/AppService/importAppInLocal
class AppService:  @Transactional
  public App importAppInLocal(App app) {
    String appId = app.getAppId();
    App managedApp = appRepository.findByAppId(appId);

    if (managedApp != null) {
      return app;
    }

    UserInfo owner = userService.findByUserId(app.getOwnerName());
    if (owner == null) {
      throw new BadRequestException("Application's owner not exist.");
    }

    app.setOwnerEmail(owner.getEmail());

    App createdApp = appRepository.save(app);

    roleInitializationService.initAppRoles(createdApp);

    Tracer.logEvent(TracerEventType.CREATE_APP, appId);

    return createdApp;
  }