diff --git a/apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AdminService.java b/apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AdminService.java index a0c85942ffa8e606874c164245d372df2ace7d6b..1baf72765d7e27726bed5785ad466892e1b9fc17 100644 --- a/apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AdminService.java +++ b/apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AdminService.java @@ -54,7 +54,7 @@ public class AdminService { private void createDefaultAppNamespace(String appId, String createBy) { AppNamespace appNs = new AppNamespace(); appNs.setAppId(appId); - appNs.setName(ConfigConsts.NAMESPACE_APPLICATION); + appNs.setName(appId); appNs.setComment("default app namespace"); appNs.setDataChangeCreatedBy(createBy); appNs.setDataChangeLastModifiedBy(createBy); @@ -79,7 +79,7 @@ public class AdminService { Namespace ns = new Namespace(); ns.setAppId(appId); ns.setClusterName(ConfigConsts.CLUSTER_NAME_DEFAULT); - ns.setNamespaceName(ConfigConsts.NAMESPACE_APPLICATION); + ns.setNamespaceName(appId); ns.setDataChangeCreatedBy(createBy); ns.setDataChangeLastModifiedBy(createBy); namespaceRepository.save(ns); diff --git a/apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java b/apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java index 38aa7aa3a4c161e4e934c615c95aef979936e1d1..4fdab1c4d6c495be2758aeb68ac31b6595273726 100644 --- a/apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java +++ b/apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java @@ -17,6 +17,7 @@ import com.ctrip.apollo.biz.entity.App; import com.ctrip.apollo.biz.entity.Audit; import com.ctrip.apollo.biz.entity.Cluster; import com.ctrip.apollo.biz.entity.Namespace; +import com.ctrip.apollo.core.ConfigConsts; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = BizTestConfiguration.class) @@ -51,11 +52,11 @@ public class AdminServiceTest { List clusters = viewService.findClusters(app.getAppId()); Assert.assertEquals(1, clusters.size()); - Assert.assertEquals("default", clusters.get(0).getName()); + Assert.assertEquals(ConfigConsts.CLUSTER_NAME_DEFAULT, clusters.get(0).getName()); List namespaces = viewService.findNamespaces(appId, clusters.get(0).getName()); Assert.assertEquals(1, namespaces.size()); - Assert.assertEquals("application", namespaces.get(0).getNamespaceName()); + Assert.assertEquals(appId, namespaces.get(0).getNamespaceName()); List audits = auditService.findByOwner(owner); Assert.assertEquals(4, audits.size()); diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java index ac75e7626d6fc5cde892e5ab1eda0c60b8713158..9b1a12ee0147d23ed391fe14b77b91da85d3879e 100644 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java @@ -25,9 +25,9 @@ public class AppController { private AppService appService; - @RequestMapping("/env/{env}") - public List findAllApp(@PathVariable String env){ - return appService.findAll(Env.valueOf(env)); + @RequestMapping("") + public List findAllApp(){ + return appService.findAll(); } @RequestMapping("/{appId}/navtree") diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java index 795359ba7647c9c68cd70842c7c8dbfcf38a9dcc..58025fa7f31f8afe9e651a9de00e7ee6023048d1 100644 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java @@ -29,7 +29,9 @@ public class AppService { @Autowired private AdminServiceAPI.AppAPI appAPI; - public List findAll(Env env) { + public List findAll() { + // TODO: 16/4/21 先从 portalSettings第一个环境去apps,后续可以优化 + Env env = portalSettings.getEnvs().get(0); return appAPI.getApps(env); } diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java index c844dfd93b8743c3791ed5a3e95247c9eb4de177..0a4f5b53fda53ecad8b6937a1fb3ebe0454b30a0 100644 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java @@ -9,6 +9,7 @@ import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.web.client.HttpClientErrorException; +import com.ctrip.apollo.common.utils.ExceptionUtils; import com.ctrip.apollo.core.enums.Env; import com.ctrip.apollo.core.dto.ItemChangeSets; import com.ctrip.apollo.core.dto.ItemDTO; @@ -73,7 +74,7 @@ public class ConfigService { } catch (Exception e) { logger.error("parse namespace error. app id:{}, env:{}, clusterName:{}, namespace:{}", appId, env, clusterName, namespace.getNamespaceName(), e); - return namespaceVOs; + throw e; } } @@ -98,7 +99,7 @@ public class ConfigService { releaseItems = gson.fromJson(release.getConfigurations(), Map.class); }catch (HttpClientErrorException e){ if (e.getStatusCode() == HttpStatus.NOT_FOUND){ - //ignore maybe new app has no release. + logger.warn(ExceptionUtils.toString(e)); }else { throw e; } diff --git a/apollo-portal/src/main/resources/static/scripts/controller/IndexController.js b/apollo-portal/src/main/resources/static/scripts/controller/IndexController.js index 587d7e17a62a80f46be3000a3f1295f013fbcb42..d691bd1967d0da1b075ee52ed01d3712e0f574eb 100644 --- a/apollo-portal/src/main/resources/static/scripts/controller/IndexController.js +++ b/apollo-portal/src/main/resources/static/scripts/controller/IndexController.js @@ -1,10 +1,8 @@ index_module.controller('IndexController', ['$scope', '$window', 'toastr', 'AppService', function ($scope, $window, toastr, AppService) { - $scope.env = 'LOCAL'; - var apps = []; - AppService.find_all_app($scope.env).then(function (result) { + AppService.find_all_app().then(function (result) { apps = result; $scope.apps = apps; $scope.appsCount = apps.length; diff --git a/apollo-portal/src/main/resources/static/scripts/services/AppService.js b/apollo-portal/src/main/resources/static/scripts/services/AppService.js index 7df7e5bcc26df98227a01d37af2908da8f613a7e..681f338da616e6499910555f61bc871625c07e86 100644 --- a/apollo-portal/src/main/resources/static/scripts/services/AppService.js +++ b/apollo-portal/src/main/resources/static/scripts/services/AppService.js @@ -3,7 +3,7 @@ appService.service('AppService', ['$resource', '$q', function ($resource, $q) { find_all_app:{ method: 'GET', isArray: true, - url:'/apps/env/:env' + url:'/apps' }, load_navtree:{ methode: 'GET', @@ -20,11 +20,11 @@ appService.service('AppService', ['$resource', '$q', function ($resource, $q) { } }); return { - find_all_app: function (env) { + find_all_app: function () { var d = $q.defer(); app_resource.find_all_app({ - env: env - }, function (result) { + }, + function (result) { d.resolve(result); }, function (result) { d.reject(result); diff --git a/apollo-portal/src/main/resources/static/views/common/nav.html b/apollo-portal/src/main/resources/static/views/common/nav.html index 7086a10ad138d368d7b88a6b238d8c8c90a31b48..088ef13a98fa15dc7b974f196b10f219080a4591 100644 --- a/apollo-portal/src/main/resources/static/views/common/nav.html +++ b/apollo-portal/src/main/resources/static/views/common/nav.html @@ -2,7 +2,7 @@