Ver Fonte

Update entity model & service

Yiming Liu há 9 anos atrás
pai
commit
6f850772df
59 ficheiros alterados com 723 adições e 1043 exclusões
  1. 10 10
      apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/GroupController.java
  2. 6 6
      apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/ItemController.java
  3. 1 1
      apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/PrivilegeController.java
  4. 8 6
      apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/ReleaseController.java
  5. 3 0
      apollo-biz/pom.xml
  6. 2 0
      apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/App.java
  7. 47 0
      apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/AppNamespace.java
  8. 5 3
      apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/BaseEntity.java
  9. 2 0
      apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Cluster.java
  10. 0 67
      apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Group.java
  11. 17 15
      apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Item.java
  12. 15 13
      apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Namespace.java
  13. 46 0
      apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Privilege.java
  14. 7 5
      apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Release.java
  15. 9 0
      apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/AppNamespaceRepository.java
  16. 1 1
      apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/AppRepository.java
  17. 0 14
      apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/GroupRepository.java
  18. 4 4
      apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/ItemRepository.java
  19. 6 1
      apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/NamespaceRepository.java
  20. 16 0
      apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/PrivilegeRepository.java
  21. 4 3
      apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/ReleaseRepository.java
  22. 57 0
      apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AdminService.java
  23. 6 7
      apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ConfigService.java
  24. 0 18
      apollo-biz/src/main/java/com/ctrip/apollo/biz/service/GroupService.java
  25. 18 0
      apollo-biz/src/main/java/com/ctrip/apollo/biz/service/NamespaceService.java
  26. 49 0
      apollo-biz/src/main/java/com/ctrip/apollo/biz/service/PrivilegeService.java
  27. 13 12
      apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ViewService.java
  28. 0 26
      apollo-biz/src/main/resources/import.sql
  29. 12 0
      apollo-biz/src/test/java/com/ctrip/apollo/biz/SpringTestConfiguration.java
  30. 24 0
      apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppRepositoryTest.java
  31. 46 0
      apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java
  32. 1 1
      apollo-biz/src/test/java/com/ctrip/apollo/biz/service/ConfigServiceTest.java
  33. 87 0
      apollo-biz/src/test/java/com/ctrip/apollo/biz/service/PrivilegeServiceTest.java
  34. 0 0
      apollo-biz/src/test/resources/application.properties
  35. 31 0
      apollo-biz/src/test/resources/import.sql
  36. 1 1
      apollo-configservice/src/test/java/com/ctrip/apollo/configservice/AllTests.java
  37. 1 2
      apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppConfigVO.java
  38. 0 2
      apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java
  39. 1 1
      apollo-core/src/main/java/com/ctrip/apollo/core/dto/NamespaceDTO.java
  40. 0 58
      apollo-core/src/main/java/com/ctrip/apollo/core/dto/VersionDTO.java
  41. 15 28
      apollo-portal/src/main/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java
  42. 0 47
      apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java
  43. 7 6
      apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/ConfigController.java
  44. 0 34
      apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/VersionController.java
  45. 0 95
      apollo-portal/src/main/java/com/ctrip/apollo/portal/entity/App.java
  46. 0 62
      apollo-portal/src/main/java/com/ctrip/apollo/portal/entity/Privilege.java
  47. 0 14
      apollo-portal/src/main/java/com/ctrip/apollo/portal/repository/AppRepository.java
  48. 0 16
      apollo-portal/src/main/java/com/ctrip/apollo/portal/repository/PrivilegeRepository.java
  49. 0 35
      apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java
  50. 26 43
      apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java
  51. 0 50
      apollo-portal/src/main/java/com/ctrip/apollo/portal/service/PrivilegeService.java
  52. 0 29
      apollo-portal/src/main/java/com/ctrip/apollo/portal/service/VersionService.java
  53. 0 1
      apollo-portal/src/main/resources/import.sql
  54. 3 1
      apollo-portal/src/test/java/com/ctrip/apollo/portal/AllTests.java
  55. 0 80
      apollo-portal/src/test/java/com/ctrip/apollo/portal/controller/AppControllerTest.java
  56. 0 28
      apollo-portal/src/test/java/com/ctrip/apollo/portal/repository/AppRepositoryTest.java
  57. 116 122
      apollo-portal/src/test/java/com/ctrip/apollo/portal/service/ConfigServiceTest.java
  58. 0 69
      apollo-portal/src/test/java/com/ctrip/apollo/portal/service/PrivilegeServiceTest.java
  59. 0 6
      pom.xml

+ 10 - 10
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/GroupController.java

@@ -7,11 +7,11 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import com.ctrip.apollo.biz.entity.Group;
-import com.ctrip.apollo.biz.service.GroupService;
+import com.ctrip.apollo.biz.entity.Namespace;
+import com.ctrip.apollo.biz.service.NamespaceService;
 import com.ctrip.apollo.biz.service.ViewService;
 import com.ctrip.apollo.biz.utils.BeanUtils;
-import com.ctrip.apollo.core.dto.GroupDTO;
+import com.ctrip.apollo.core.dto.NamespaceDTO;
 
 @RestController
 public class GroupController {
@@ -20,18 +20,18 @@ public class GroupController {
   private ViewService viewService;
 
   @Autowired
-  private GroupService groupService;
+  private NamespaceService groupService;
 
   @RequestMapping("/apps/{appId}/clusters/{clusterName}/groups")
-  public List<GroupDTO> findGroups(@PathVariable("appId") String appId,
+  public List<NamespaceDTO> findGroups(@PathVariable("appId") String appId,
       @PathVariable("clusterName") String clusterName) {
-    List<Group> groups = viewService.findGroups(appId, clusterName);
-    return BeanUtils.batchTransform(GroupDTO.class, groups);
+    List<Namespace> groups = viewService.findNamespaces(appId, clusterName);
+    return BeanUtils.batchTransform(NamespaceDTO.class, groups);
   }
 
   @RequestMapping("/groups/{groupId}")
-  public GroupDTO findOne(@PathVariable("groupId") Long groupId) {
-    Group group = groupService.findOne(groupId);
-    return BeanUtils.transfrom(GroupDTO.class, group);
+  public NamespaceDTO findOne(@PathVariable("groupId") Long groupId) {
+    Namespace group = groupService.findOne(groupId);
+    return BeanUtils.transfrom(NamespaceDTO.class, group);
   }
 }

+ 6 - 6
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/ItemController.java

@@ -21,15 +21,15 @@ public class ItemController {
 
   @Autowired
   private ItemService itemService;
-  
-  @RequestMapping("/apps/{appId}/clusters/{clusterName}/groups/{groupName}/items")
+
+  @RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items")
   public List<ItemDTO> findItems(@PathVariable("appId") String appId,
-                                 @PathVariable("clusterName") String clusterName,
-      @PathVariable("groupName") String groupName) {
-    List<Item> items = viewService.findItems(appId, clusterName,groupName);
+      @PathVariable("clusterName") String clusterName,
+      @PathVariable("namespaceName") String namespaceName) {
+    List<Item> items = viewService.findItems(appId, clusterName, namespaceName);
     return BeanUtils.batchTransform(ItemDTO.class, items);
   }
- 
+
   @RequestMapping("/items/{itemId}")
   public ItemDTO findOne(@PathVariable("itemId") long itemId) {
     Item item = itemService.findOne(itemId);

+ 1 - 1
apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/PrivilegeController.java → apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/PrivilegeController.java

@@ -1,4 +1,4 @@
-package com.ctrip.apollo.portal.controller;
+package com.ctrip.apollo.adminservice.controller;
 
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;

+ 8 - 6
apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/ReleaseController.java

@@ -18,19 +18,21 @@ public class ReleaseController {
 
   @Autowired
   private ViewService viewSerivce;
-  
+
   @Autowired
   private ReleaseService releaseService;
-  
+
   @RequestMapping("/release/{releaseId}")
   public ReleaseDTO findOne(@PathVariable("releaseId") long releaseId) {
     Release release = releaseService.findOne(releaseId);
     return BeanUtils.transfrom(ReleaseDTO.class, release);
   }
-  
-  @RequestMapping("/apps/{appId}/clusters/{clusterId}/groups/{groupId}/releases")
-  public List<ReleaseDTO> findReleases(@PathVariable("groupId") Long groupId){
-    List<Release> releases = viewSerivce.findReleases(groupId);
+
+  @RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases")
+  public List<ReleaseDTO> findReleases(@PathVariable("appId") String appId,
+      @PathVariable("clusterName") String clusterName,
+      @PathVariable("namespaceName") String namespaceName) {
+    List<Release> releases = viewSerivce.findReleases(appId, clusterName, namespaceName);
     return BeanUtils.batchTransform(ReleaseDTO.class, releases);
   }
 }

+ 3 - 0
apollo-biz/pom.xml

@@ -30,6 +30,9 @@
 	<profiles>
 		<profile>
 			<id>local</id>
+			<activation>
+				<activeByDefault>true</activeByDefault>
+			</activation>
 			<dependencies>
 				<dependency>
 					<groupId>com.h2database</groupId>

+ 2 - 0
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/App.java

@@ -4,9 +4,11 @@ import javax.persistence.Column;
 import javax.persistence.Entity;
 
 import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.Where;
 
 @Entity
 @SQLDelete(sql = "Update App set isDeleted = 1 where id = ?")
+@Where(clause = "isDeleted = 0")
 public class App extends BaseEntity {
 
   @Column(nullable = false)

+ 47 - 0
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/AppNamespace.java

@@ -0,0 +1,47 @@
+package com.ctrip.apollo.biz.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+
+import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.Where;
+
+@Entity
+@SQLDelete(sql = "Update AppNamespace set isDeleted = 1 where id = ?")
+@Where(clause = "isDeleted = 0")
+public class AppNamespace extends BaseEntity{
+
+  @Column(nullable = false)
+  private String name;
+
+  @Column(nullable = false)
+  private String appId;
+
+  @Column
+  private String comment;
+
+  public String getAppId() {
+    return appId;
+  }
+
+  public String getComment() {
+    return comment;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setAppId(String appId) {
+    this.appId = appId;
+  }
+
+  public void setComment(String comment) {
+    this.comment = comment;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+}

+ 5 - 3
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/BaseEntity.java

@@ -5,10 +5,12 @@ import java.util.Date;
 import javax.persistence.Column;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.MappedSuperclass;
 
-import org.hibernate.annotations.Where;
-
-@Where(clause = "isDeleted = 0")
+@MappedSuperclass
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 public abstract class BaseEntity {
 
   @Id

+ 2 - 0
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Cluster.java

@@ -4,12 +4,14 @@ import javax.persistence.Column;
 import javax.persistence.Entity;
 
 import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.Where;
 
 /**
  * @author Jason Song(song_s@ctrip.com)
  */
 @Entity
 @SQLDelete(sql = "Update Cluster set isDeleted = 1 where id = ?")
+@Where(clause = "isDeleted = 0")
 public class Cluster extends BaseEntity {
 
   @Column(nullable = false)

+ 0 - 67
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Group.java

@@ -1,67 +0,0 @@
-package com.ctrip.apollo.biz.entity;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-
-import org.hibernate.annotations.SQLDelete;
-
-@Entity
-@SQLDelete(sql = "Update Group set isDeleted = 1 where id = ?")
-public class Group extends BaseEntity {
-
-  @Column(nullable = false)
-  private String name;
-
-  @Column(nullable = false)
-  private String appId;
-
-  @Column(nullable = false)
-  private long clusterId;
-
-  @Column(nullable = false)
-  private String clusterName;
-
-  @Column(nullable = false)
-  private long namespaceId;
-
-  public String getAppId() {
-    return appId;
-  }
-
-  public long getClusterId() {
-    return clusterId;
-  }
-
-  public String getClusterName() {
-    return clusterName;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public long getNamespaceId() {
-    return namespaceId;
-  }
-
-  public void setAppId(String appId) {
-    this.appId = appId;
-  }
-
-  public void setClusterId(long clusterId) {
-    this.clusterId = clusterId;
-  }
-
-  public void setClusterName(String clusterName) {
-    this.clusterName = clusterName;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public void setNamespaceId(long namespaceId) {
-    this.namespaceId = namespaceId;
-  }
-
-}

+ 17 - 15
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Item.java

@@ -4,13 +4,15 @@ import javax.persistence.Column;
 import javax.persistence.Entity;
 
 import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.Where;
 
 @Entity
 @SQLDelete(sql = "Update Item set isDeleted = 1 where id = ?")
+@Where(clause = "isDeleted = 0")
 public class Item extends BaseEntity {
 
   @Column(nullable = false)
-  private long groupId;
+  private long namespaceId;
 
   @Column(nullable = false)
   private String key;
@@ -21,36 +23,36 @@ public class Item extends BaseEntity {
   @Column
   private String comment;
 
-  public long getGroupId() {
-    return groupId;
-  }
-
-  public void setGroupId(long groupId) {
-    this.groupId = groupId;
+  public String getComment() {
+    return comment;
   }
 
   public String getKey() {
     return key;
   }
 
-  public void setKey(String key) {
-    this.key = key;
+  public long getNamespaceId() {
+    return namespaceId;
   }
 
   public String getValue() {
     return value;
   }
 
-  public void setValue(String value) {
-    this.value = value;
+  public void setComment(String comment) {
+    this.comment = comment;
   }
 
-  public String getComment() {
-    return comment;
+  public void setKey(String key) {
+    this.key = key;
   }
 
-  public void setComment(String comment) {
-    this.comment = comment;
+  public void setNamespaceId(long namespaceId) {
+    this.namespaceId = namespaceId;
+  }
+
+  public void setValue(String value) {
+    this.value = value;
   }
 
 }

+ 15 - 13
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Namespace.java

@@ -4,42 +4,44 @@ import javax.persistence.Column;
 import javax.persistence.Entity;
 
 import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.Where;
 
 @Entity
 @SQLDelete(sql = "Update Namespace set isDeleted = 1 where id = ?")
-public class Namespace extends BaseEntity{
+@Where(clause = "isDeleted = 0")
+public class Namespace extends BaseEntity {
 
   @Column(nullable = false)
-  private String name;
+  private String appId;
 
   @Column(nullable = false)
-  private String appId;
+  private String clusterName;
 
-  @Column
-  private String comment;
+  @Column(nullable = false)
+  private String namespaceName;
 
   public String getAppId() {
     return appId;
   }
 
-  public String getComment() {
-    return comment;
+  public String getClusterName() {
+    return clusterName;
   }
 
-  public String getName() {
-    return name;
+  public String getNamespaceName() {
+    return namespaceName;
   }
 
   public void setAppId(String appId) {
     this.appId = appId;
   }
 
-  public void setComment(String comment) {
-    this.comment = comment;
+  public void setClusterName(String clusterName) {
+    this.clusterName = clusterName;
   }
 
-  public void setName(String name) {
-    this.name = name;
+  public void setNamespaceName(String namespaceName) {
+    this.namespaceName = namespaceName;
   }
 
 }

+ 46 - 0
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Privilege.java

@@ -0,0 +1,46 @@
+package com.ctrip.apollo.biz.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+
+import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.Where;
+
+@Entity
+@SQLDelete(sql = "Update Privilege set isDeleted = 1 where id = ?")
+@Where(clause = "isDeleted = 0")
+public class Privilege extends BaseEntity {
+
+  @Column
+  private String name;
+
+  @Column
+  private String privilType;
+
+  @Column
+  private long namespaceId;
+
+  public String getName() {
+    return name;
+  }
+
+  public long getNamespaceId() {
+    return namespaceId;
+  }
+
+  public String getPrivilType() {
+    return privilType;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public void setNamespaceId(long namespaceId) {
+    this.namespaceId = namespaceId;
+  }
+
+  public void setPrivilType(String privilType) {
+    this.privilType = privilType;
+  }
+}

+ 7 - 5
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Release.java

@@ -5,12 +5,14 @@ import javax.persistence.Entity;
 import javax.persistence.Lob;
 
 import org.hibernate.annotations.SQLDelete;
+import org.hibernate.annotations.Where;
 
 /**
  * @author Jason Song(song_s@ctrip.com)
  */
 @Entity
 @SQLDelete(sql = "Update Release set isDeleted = 1 where id = ?")
+@Where(clause = "isDeleted = 0")
 public class Release extends BaseEntity {
 
   @Column(nullable = false)
@@ -23,7 +25,7 @@ public class Release extends BaseEntity {
   private String clusterName;
 
   @Column
-  private String groupName;
+  private String namespaceName;
 
   @Column(nullable = false)
   @Lob
@@ -48,8 +50,8 @@ public class Release extends BaseEntity {
     return configurations;
   }
 
-  public String getGroupName() {
-    return groupName;
+  public String getNamespaceName() {
+    return namespaceName;
   }
 
   public String getName() {
@@ -72,8 +74,8 @@ public class Release extends BaseEntity {
     this.configurations = configurations;
   }
 
-  public void setGroupName(String groupName) {
-    this.groupName = groupName;
+  public void setNamespaceName(String namespaceName) {
+    this.namespaceName = namespaceName;
   }
 
   public void setName(String name) {

+ 9 - 0
apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/AppNamespaceRepository.java

@@ -0,0 +1,9 @@
+package com.ctrip.apollo.biz.repository;
+
+import org.springframework.data.repository.PagingAndSortingRepository;
+
+import com.ctrip.apollo.biz.entity.AppNamespace;
+
+public interface AppNamespaceRepository extends PagingAndSortingRepository<AppNamespace, Long>{
+
+}

+ 1 - 1
apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/AppRepository.java

@@ -10,7 +10,7 @@ import com.ctrip.apollo.biz.entity.App;
 
 public interface AppRepository extends PagingAndSortingRepository<App, Long> {
 
-  @Query("SELECT a from App a WHERE a.name LIKE %':name'%")
+  @Query("SELECT a from App a WHERE a.name LIKE %:name%")
   List<App> findByName(@Param("name") String name);
 
   App findByAppId(String appId);

+ 0 - 14
apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/GroupRepository.java

@@ -1,14 +0,0 @@
-package com.ctrip.apollo.biz.repository;
-
-import java.util.List;
-
-import org.springframework.data.repository.PagingAndSortingRepository;
-
-import com.ctrip.apollo.biz.entity.Group;
-
-public interface GroupRepository extends PagingAndSortingRepository<Group, Long> {
-
-  List<Group> findByAppIdAndClusterName(String appId, String clusterName);
-
-  Group findByAppIdAndClusterNameAndGroupName(String appId, String clusterName, String groupName);
-}

+ 4 - 4
apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/ItemRepository.java

@@ -1,15 +1,15 @@
 package com.ctrip.apollo.biz.repository;
 
-import com.ctrip.apollo.biz.entity.Item;
+import java.util.List;
 
 import org.springframework.data.repository.PagingAndSortingRepository;
 
-import java.util.List;
+import com.ctrip.apollo.biz.entity.Item;
 
 public interface ItemRepository extends PagingAndSortingRepository<Item, Long> {
 
-  List<Item> findByGroupIdIsIn(List<Long> groupIds);
+  List<Item> findByNamespaceIdIsIn(List<Long> namespaceIds);
 
-  List<Item> findByGroupId(Long groupId);
+  List<Item> findByNamespaceId(Long namespaceId);
 
 }

+ 6 - 1
apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/NamespaceRepository.java

@@ -1,9 +1,14 @@
 package com.ctrip.apollo.biz.repository;
 
+import java.util.List;
+
 import org.springframework.data.repository.PagingAndSortingRepository;
 
 import com.ctrip.apollo.biz.entity.Namespace;
 
-public interface NamespaceRepository extends PagingAndSortingRepository<Namespace, Long>{
+public interface NamespaceRepository extends PagingAndSortingRepository<Namespace, Long> {
+
+  List<Namespace> findByAppIdAndClusterName(String appId, String clusterName);
 
+  Namespace findByAppIdAndClusterNameAndNamespaceName(String appId, String clusterName, String namespaceName);
 }

+ 16 - 0
apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/PrivilegeRepository.java

@@ -0,0 +1,16 @@
+package com.ctrip.apollo.biz.repository;
+
+import org.springframework.data.repository.PagingAndSortingRepository;
+
+import com.ctrip.apollo.biz.entity.Privilege;
+
+import java.util.List;
+
+public interface PrivilegeRepository extends PagingAndSortingRepository<Privilege, Long> {
+
+  List<Privilege> findByNamespaceId(long namespaceId);
+
+  List<Privilege> findByNamespaceIdAndPrivilType(long namespaceId, String privilType);
+
+  Privilege findByNamespaceIdAndNameAndPrivilType(long namespaceId, String name, String privilType);
+}

+ 4 - 3
apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/ReleaseRepository.java

@@ -13,9 +13,10 @@ import com.ctrip.apollo.biz.entity.Release;
  */
 public interface ReleaseRepository extends PagingAndSortingRepository<Release, Long> {
 
-  @Query("SELECT r FROM Release r WHERE r.appId = :appId AND r.clusterName = :clusterName AND r.groupName = :groupName order by id desc litmit 1")
+  @Query("SELECT r FROM Release r WHERE r.appId = :appId AND r.clusterName = :clusterName AND r.namespaceName = :namespaceName order by r.id desc")
   Release findLatest(@Param("appId") String appId, @Param("clusterName") String clusterName,
-      @Param("groupName") String groupName);
+      @Param("namespaceName") String namespaceName);
 
-  List<Release> findByGroupId(Long groupId);
+  List<Release> findByAppIdAndClusterNameAndNamespaceName(String appId, String clusterName,
+      String namespaceName);
 }

+ 57 - 0
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AdminService.java

@@ -0,0 +1,57 @@
+package com.ctrip.apollo.biz.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.ctrip.apollo.biz.entity.App;
+import com.ctrip.apollo.biz.entity.AppNamespace;
+import com.ctrip.apollo.biz.entity.Cluster;
+import com.ctrip.apollo.biz.entity.Namespace;
+import com.ctrip.apollo.biz.repository.AppNamespaceRepository;
+import com.ctrip.apollo.biz.repository.AppRepository;
+import com.ctrip.apollo.biz.repository.ClusterRepository;
+import com.ctrip.apollo.biz.repository.NamespaceRepository;
+
+@Service
+public class AdminService {
+
+  @Autowired
+  private AppRepository appRepository;
+
+  @Autowired
+  private AppNamespaceRepository appNamespaceRepository;
+
+  @Autowired
+  private NamespaceRepository namespaceRepository;
+
+  @Autowired
+  private ClusterRepository clusterRepository;
+
+  public App createNewApp(String appId, String appName, String ownerName, String ownerEmail,
+      String namespace) {
+    App app = new App();
+    app.setAppId(appId);
+    app.setName(appName);
+    app.setOwnerName(ownerName);
+    app.setOwnerEmail(ownerEmail);
+    appRepository.save(app);
+
+    AppNamespace appNs = new AppNamespace();
+    appNs.setAppId(appId);
+    appNs.setName(namespace);
+    appNamespaceRepository.save(appNs);
+
+    Cluster cluster = new Cluster();
+    cluster.setName("default");
+    cluster.setAppId(appId);
+    clusterRepository.save(cluster);
+
+    Namespace ns = new Namespace();
+    ns.setAppId(appId);
+    ns.setClusterName(cluster.getName());
+    ns.setNamespaceName(namespace);
+    namespaceRepository.save(ns);
+
+    return app;
+  }
+}

+ 6 - 7
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ConfigService.java

@@ -24,26 +24,25 @@ public class ConfigService {
   @Autowired
   private ReleaseRepository releaseRepository;
 
-  @Autowired
-  private ObjectMapper objectMapper;
+  private ObjectMapper objectMapper = new ObjectMapper();
 
   private TypeReference<Map<String, Object>> configurationTypeReference =
       new TypeReference<Map<String, Object>>() {};
 
-  public Release findRelease(String appId, String clusterName, String groupName) {
-    Release release = releaseRepository.findLatest(appId, clusterName, groupName);
+  public Release findRelease(String appId, String clusterName, String namespaceName) {
+    Release release = releaseRepository.findLatest(appId, clusterName, namespaceName);
     return release;
   }
 
   /**
    * Load configuration from database
    */
-  public ApolloConfig loadConfig(Release release, String groupName, String versionName) {
+  public ApolloConfig loadConfig(Release release, String namespaceName, String versionName) {
     if (release == null) {
       return null;
     }
-    ApolloConfig config = new ApolloConfig(release.getAppId(), release.getClusterName(), groupName,
-        versionName, release.getId());
+    ApolloConfig config = new ApolloConfig(release.getAppId(), release.getClusterName(),
+        namespaceName, versionName, release.getId());
     config.setConfigurations(transformConfigurationToMap(release.getConfigurations()));
     return config;
   }

+ 0 - 18
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/GroupService.java

@@ -1,18 +0,0 @@
-package com.ctrip.apollo.biz.service;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import com.ctrip.apollo.biz.entity.Group;
-import com.ctrip.apollo.biz.repository.GroupRepository;
-
-@Service
-public class GroupService {
-
-  @Autowired
-  private GroupRepository groupRepository;
-  
-  public Group findOne(Long groupId){
-    return groupRepository.findOne(groupId);
-  }
-}

+ 18 - 0
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/NamespaceService.java

@@ -0,0 +1,18 @@
+package com.ctrip.apollo.biz.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.ctrip.apollo.biz.entity.Namespace;
+import com.ctrip.apollo.biz.repository.NamespaceRepository;
+
+@Service
+public class NamespaceService {
+
+  @Autowired
+  private NamespaceRepository namespaceRepository;
+  
+  public Namespace findOne(Long namespaceId){
+    return namespaceRepository.findOne(namespaceId);
+  }
+}

+ 49 - 0
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/PrivilegeService.java

@@ -0,0 +1,49 @@
+package com.ctrip.apollo.biz.service;
+
+import com.ctrip.apollo.biz.entity.Privilege;
+import com.ctrip.apollo.biz.repository.PrivilegeRepository;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class PrivilegeService {
+
+  enum PrivilType {
+    EDIT, REVIEW, RELEASE
+  }
+
+  @Autowired
+  private PrivilegeRepository privilRepo;
+
+  public Privilege addPrivilege(long namespaceId, String name, PrivilType privilType) {
+    Privilege privil =
+        privilRepo.findByNamespaceIdAndNameAndPrivilType(namespaceId, name, privilType.name());
+    if (privil == null) {
+      privil = new Privilege();
+      privil.setNamespaceId(namespaceId);
+      privil.setPrivilType(privilType.name());
+      privil.setName(name);
+      privilRepo.save(privil);
+    }
+    return privil;
+  }
+
+  public boolean hasPrivilege(long namespaceId, String name, PrivilType privilType) {
+    Privilege privil =
+        privilRepo.findByNamespaceIdAndNameAndPrivilType(namespaceId, name, privilType.name());
+    return (privil != null) ? true : false;
+  }
+
+  public List<Privilege> listPrivileges(long namespaceId) {
+    return privilRepo.findByNamespaceId(namespaceId);
+  }
+
+  public void removePrivilege(long namespaceId, String name, PrivilType privilType) {
+    Privilege privil =
+        privilRepo.findByNamespaceIdAndNameAndPrivilType(namespaceId, name, privilType.name());
+    if (privil != null) privilRepo.delete(privil);
+  }
+}

+ 13 - 12
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ViewService.java

@@ -7,11 +7,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.ctrip.apollo.biz.entity.Cluster;
-import com.ctrip.apollo.biz.entity.Group;
+import com.ctrip.apollo.biz.entity.Namespace;
 import com.ctrip.apollo.biz.entity.Item;
 import com.ctrip.apollo.biz.entity.Release;
 import com.ctrip.apollo.biz.repository.ClusterRepository;
-import com.ctrip.apollo.biz.repository.GroupRepository;
+import com.ctrip.apollo.biz.repository.NamespaceRepository;
 import com.ctrip.apollo.biz.repository.ItemRepository;
 import com.ctrip.apollo.biz.repository.ReleaseRepository;
 import com.google.common.base.Strings;
@@ -26,7 +26,7 @@ public class ViewService {
   private ClusterRepository clusterRepository;
 
   @Autowired
-  private GroupRepository groupRepository;
+  private NamespaceRepository namespaceRepository;
 
   @Autowired
   private ItemRepository itemRepository;
@@ -46,17 +46,17 @@ public class ViewService {
     return clusters;
   }
 
-  public List<Group> findGroups(String appId, String clusterName) {
-    List<Group> groups = groupRepository.findByAppIdAndClusterName(appId, clusterName);
+  public List<Namespace> findNamespaces(String appId, String clusterName) {
+    List<Namespace> groups = namespaceRepository.findByAppIdAndClusterName(appId, clusterName);
     if (groups == null) {
       return Collections.EMPTY_LIST;
     }
     return groups;
   }
 
-  public List<Item> findItems(String appId, String clusterName, String groupName) {
-    Group group =
-        groupRepository.findByAppIdAndClusterNameAndGroupName(appId, clusterName, groupName);
+  public List<Item> findItems(String appId, String clusterName, String namespaceName) {
+    Namespace group = namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(appId, clusterName,
+        namespaceName);
     if (group != null) {
       return findItems(group.getId());
     } else {
@@ -64,16 +64,17 @@ public class ViewService {
     }
   }
 
-  public List<Item> findItems(Long groupId) {
-    List<Item> items = itemRepository.findByGroupId(groupId);
+  public List<Item> findItems(Long namespaceId) {
+    List<Item> items = itemRepository.findByNamespaceId(namespaceId);
     if (items == null) {
       return Collections.EMPTY_LIST;
     }
     return items;
   }
 
-  public List<Release> findReleases(Long groupId) {
-    List<Release> releases = releaseRepository.findByGroupId(groupId);
+  public List<Release> findReleases(String appId, String clusterName, String namespaceName) {
+    List<Release> releases = releaseRepository.findByAppIdAndClusterNameAndNamespaceName(appId,
+        clusterName, namespaceName);
     if (releases == null) {
       return Collections.EMPTY_LIST;
     }

+ 0 - 26
apollo-biz/src/main/resources/import.sql

@@ -1,26 +0,0 @@
-INSERT INTO Cluster (AppId, IsDeleted, Name) VALUES (100, 0, 'default');
-INSERT INTO Cluster (ID, AppId, IsDeleted, Name) VALUES (100, 6666, 0, 'default');
-INSERT INTO Cluster (ID, AppId, IsDeleted, Name) VALUES (101, 6666, 0, 'cluster1');
-
-INSERT INTO Version (AppId, IsDeleted, Name, ReleaseId) VALUES (101, 0, '1.0', 1);
-INSERT INTO Version (AppId, IsDeleted, Name, ReleaseId) VALUES (102, 0, '1.0', 2);
-INSERT INTO Version (ID, AppId, IsDeleted, Name, ReleaseId) VALUES (100, 6666, 0, '1.0', 11111);
-INSERT INTO Version (ID, AppId, IsDeleted, Name, ReleaseId) VALUES (101, 6666, 0, '2.0', 11112);
-
-INSERT INTO RELEASESNAPSHOT (ClusterName, IsDeleted, ReleaseId, Configurations) VALUES ('default', 0, 1, '{"101.foo":"bar", "101.bar":"foo"}');
-INSERT INTO RELEASESNAPSHOT (ClusterName, IsDeleted, ReleaseId, Configurations) VALUES ('default', 0, 2, '{"102.foo":"demo1", "102.bar":"demo2"}');
-INSERT INTO RELEASESNAPSHOT (ClusterName, IsDeleted, ReleaseId, Configurations) VALUES ('default', 0, 3, '{"101.foo":"another bar", "101.bar_new":"foo"}');
-INSERT INTO RELEASESNAPSHOT (ClusterName, IsDeleted, ReleaseId, Configurations) VALUES ('default', 0, 11111, '{"6666.foo":"demo1", "6666.bar":"demo2","3333.foo":"1008","4444.bar":"99901"}');
-INSERT INTO RELEASESNAPSHOT (ClusterName, IsDeleted, ReleaseId, Configurations) VALUES ('cluster1', 0, 11111, '{"6666.foo":"demo1"}');
-INSERT INTO RELEASESNAPSHOT (ClusterName, IsDeleted, ReleaseId, Configurations) VALUES ('cluster2', 0, 11111, '{"6666.bar":"bar2222"}');
-INSERT INTO RELEASESNAPSHOT (ClusterName, IsDeleted, ReleaseId, Configurations) VALUES ('default', 0, 11112, '{"6666.foo":"verson2.0", "6666.bar":"verson2.0","3333.foo":"1008","4444.bar":"99901"}');
-
-INSERT INTO ConfigItem(ClusterId, ClusterName, AppId, Key, Value, comment, DataChange_CreatedBy, DataChange_CreatedTime, DataChange_LastModifiedBy, DataChange_LastTime, IsDeleted) VALUES (100, 'default', 6666, '6666.k1', '6666.v1', 'comment1', 'lepdou', '2016-03-23 12:00:00', '王五', NOW(), 0);
-
-INSERT INTO ConfigItem(ClusterId, ClusterName, AppId, Key, Value, comment, DataChange_CreatedBy, DataChange_CreatedTime, DataChange_LastModifiedBy, DataChange_LastTime, IsDeleted) VALUES (100, 'default', 6666, '6666.k2', '6666.v2', 'xxxx', 'lepdou', '2016-03-23 12:00:00', '王五1', NOW(),0);
-
-INSERT INTO ConfigItem(ClusterId, ClusterName, AppId, Key, Value, comment, DataChange_CreatedBy, DataChange_CreatedTime, DataChange_LastModifiedBy, DataChange_LastTime, IsDeleted) VALUES (100, 'default', 6666, '6666.k3', '6666.v3', 'yyyy', 'lepdou', '2016-03-23 12:00:00', '王五2', NOW(),0);
-
-INSERT INTO ConfigItem(ClusterId, ClusterName, AppId, Key, Value, comment, DataChange_CreatedBy, DataChange_CreatedTime, DataChange_LastModifiedBy, DataChange_LastTime, IsDeleted) VALUES (100, 'default', 5555, '5555.k1', '5555.v11', 'zzzz', 'lepdou', '2016-03-23 12:00:00', '王五3', NOW(),0);
-
-INSERT INTO ConfigItem(ClusterId, ClusterName, AppId, Key, Value, comment, DataChange_CreatedBy, DataChange_CreatedTime, DataChange_LastModifiedBy, DataChange_LastTime, IsDeleted) VALUES (101, 'cluster1', 6666, '6666.k1', '6666.v122', 'qqqqq', 'lepdou', '2016-03-23 12:00:00', '王五4', NOW(),0);

+ 12 - 0
apollo-biz/src/test/java/com/ctrip/apollo/biz/SpringTestConfiguration.java

@@ -0,0 +1,12 @@
+package com.ctrip.apollo.biz;
+
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@EnableAutoConfiguration
+@ComponentScan(basePackages = "com.ctrip.apollo.biz")
+public class SpringTestConfiguration {
+
+}

+ 24 - 0
apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppRepositoryTest.java

@@ -0,0 +1,24 @@
+package com.ctrip.apollo.biz.repository;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.ctrip.apollo.biz.SpringTestConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = SpringTestConfiguration.class)
+public class AppRepositoryTest {
+
+  @Autowired
+  private AppRepository appRepository;
+
+  @Test
+  public void testListExists() {
+    Assert.assertTrue(appRepository.count() > 0);
+  }
+
+}

+ 46 - 0
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java

@@ -0,0 +1,46 @@
+package com.ctrip.apollo.biz.service;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.ctrip.apollo.biz.SpringTestConfiguration;
+import com.ctrip.apollo.biz.entity.App;
+import com.ctrip.apollo.biz.entity.Cluster;
+import com.ctrip.apollo.biz.entity.Namespace;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = SpringTestConfiguration.class)
+public class AdminServiceTest {
+
+  @Autowired
+  private AdminService adminService;
+
+  @Autowired
+  private ViewService viewService;
+
+  @Test
+  public void testCreateNewApp() {
+    String appId = "someAppId";
+    String appName = "someAppName";
+    String ownerName = "someOwnerName";
+    String ownerEmail = "someOwnerName@ctrip.com";
+    String namespace = "someNamespace";
+
+    App app = adminService.createNewApp(appId, appName, ownerName, ownerEmail, namespace);
+    Assert.assertEquals(appId, app.getAppId());
+
+    List<Cluster> clusters = viewService.findClusters(app.getAppId());
+    Assert.assertEquals(1, clusters.size());
+    Assert.assertEquals("default", clusters.get(0).getName());
+
+    List<Namespace> namespaces = viewService.findNamespaces(appId, clusters.get(0).getName());
+    Assert.assertEquals(1, namespaces.size());
+    Assert.assertEquals(namespace, namespaces.get(0).getNamespaceName());
+  }
+}

+ 1 - 1
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/ConfigServiceTest.java

@@ -121,7 +121,7 @@ public class ConfigServiceTest {
     Release release = new Release();
     release.setId(releaseId);
     release.setClusterName(clusterName);
-    release.setGroupName(groupName);
+    release.setNamespaceName(groupName);
     release.setConfigurations(configurations);
     return release;
   }

+ 87 - 0
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/PrivilegeServiceTest.java

@@ -0,0 +1,87 @@
+package com.ctrip.apollo.biz.service;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.ctrip.apollo.biz.SpringTestConfiguration;
+import com.ctrip.apollo.biz.entity.App;
+import com.ctrip.apollo.biz.entity.Cluster;
+import com.ctrip.apollo.biz.entity.Namespace;
+import com.ctrip.apollo.biz.entity.Privilege;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = SpringTestConfiguration.class)
+public class PrivilegeServiceTest {
+
+  @Autowired
+  private AdminService adminService;
+
+  @Autowired
+  private ViewService viewService;
+
+  @Autowired
+  private PrivilegeService privilService;
+
+  @Test
+  public void testAddAndRemovePrivilege() {
+    App newApp = adminService.createNewApp(String.valueOf(System.currentTimeMillis()),
+        "new app " + System.currentTimeMillis(), "owner " + System.currentTimeMillis(),
+        "owner " + System.currentTimeMillis() + "@ctrip.com",
+        "namespace " + System.currentTimeMillis());
+
+    List<Cluster> clusters = viewService.findClusters(newApp.getAppId());
+    List<Namespace> namespaces =
+        viewService.findNamespaces(newApp.getAppId(), clusters.get(0).getName());
+    Namespace namespace = namespaces.get(0);
+
+    privilService.addPrivilege(namespace.getId(), newApp.getOwnerName(),
+        PrivilegeService.PrivilType.EDIT);
+    List<Privilege> privileges = privilService.listPrivileges(namespace.getId());
+    Assert.assertEquals(1, privileges.size());
+    Assert.assertEquals(PrivilegeService.PrivilType.EDIT.name(), privileges.get(0).getPrivilType());
+    Assert.assertEquals(newApp.getOwnerName(), privileges.get(0).getName());
+
+    privilService.removePrivilege(namespace.getId(), newApp.getOwnerName(),
+        PrivilegeService.PrivilType.EDIT);
+    privileges = privilService.listPrivileges(namespace.getId());
+    Assert.assertEquals(0, privileges.size());
+  }
+
+  @Test
+  public void testCheckPrivilege() {
+    App newApp = adminService.createNewApp(String.valueOf(System.currentTimeMillis()),
+        "new app " + System.currentTimeMillis(), "owner " + System.currentTimeMillis(),
+        "owner " + System.currentTimeMillis() + "@ctrip.com",
+        "namespace " + System.currentTimeMillis());
+
+    List<Cluster> clusters = viewService.findClusters(newApp.getAppId());
+    List<Namespace> namespaces =
+        viewService.findNamespaces(newApp.getAppId(), clusters.get(0).getName());
+    Namespace namespace = namespaces.get(0);
+
+    privilService.addPrivilege(namespace.getId(), newApp.getOwnerName(),
+        PrivilegeService.PrivilType.EDIT);
+    Assert.assertTrue(privilService.hasPrivilege(namespace.getId(), newApp.getOwnerName(),
+        PrivilegeService.PrivilType.EDIT));
+    Assert.assertFalse(privilService.hasPrivilege(namespace.getId(), newApp.getOwnerName(),
+        PrivilegeService.PrivilType.REVIEW));
+    Assert.assertFalse(privilService.hasPrivilege(namespace.getId(), newApp.getOwnerName(),
+        PrivilegeService.PrivilType.RELEASE));
+
+    privilService.addPrivilege(namespace.getId(), "nobody", PrivilegeService.PrivilType.EDIT);
+    Assert.assertTrue(
+        privilService.hasPrivilege(namespace.getId(), "nobody", PrivilegeService.PrivilType.EDIT));
+    Assert.assertTrue(privilService.hasPrivilege(namespace.getId(), newApp.getOwnerName(),
+        PrivilegeService.PrivilType.EDIT));
+
+    privilService.addPrivilege(namespace.getId(), "nobody", PrivilegeService.PrivilType.RELEASE);
+    Assert.assertTrue(privilService.hasPrivilege(namespace.getId(), "nobody",
+        PrivilegeService.PrivilType.RELEASE));
+  }
+}

+ 0 - 0
apollo-biz/src/main/resources/application.properties → apollo-biz/src/test/resources/application.properties


+ 31 - 0
apollo-biz/src/test/resources/import.sql

@@ -0,0 +1,31 @@
+INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003171','apollo-config-service','刘一鸣','liuym@ctrip.com');
+INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003172','apollo-admin-service','宋顺','song_s@ctrip.com');
+INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003173','apollo-portal','张乐','zhanglea@ctrip.com');
+INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('fxhermesproducer','fx-hermes-producer','梁锦华','jhliang@ctrip.com');
+
+INSERT INTO Cluster (AppId, Name) VALUES ('100003171', 'default');
+INSERT INTO Cluster (AppId, Name) VALUES ('100003171', 'cluster1');
+INSERT INTO Cluster (AppId, Name) VALUES ('100003172', 'default');
+INSERT INTO Cluster (AppId, Name) VALUES ('100003172', 'cluster2');
+INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'default');
+INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'cluster3');
+INSERT INTO Cluster (AppId, Name) VALUES ('fxhermesproducer', 'default');
+
+INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'apollo-config-service');
+INSERT INTO AppNamespace (AppId, Name) VALUES ('100003172', 'apollo-admin-service');
+INSERT INTO AppNamespace (AppId, Name) VALUES ('100003173', 'apollo-portal-service');
+INSERT INTO AppNamespace (AppID, Name) VALUES ('fxhermesproducer', 'fx-hermes-producer');
+
+INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (1, '100003171', 'default', 'apollo-config-service');
+INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (2, 'fxhermesproducer', 'default', 'fx-hermes-producer');
+INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (3, '100003172', 'default', 'apollo-admin-service');
+INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (4, '100003173', 'default', 'apollo-portal');
+INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (5, '100003171', 'default', 'fx-hermes-producer');
+
+INSERT INTO Item (GroupId, `Key`, Value, Comment) VALUES (1, 'k1', 'v1', 'comment1');
+INSERT INTO Item (GroupId, `Key`, Value, Comment) VALUES (1, 'k2', 'v2', 'comment2');
+INSERT INTO Item (GroupId, `Key`, Value, Comment) VALUES (2, 'k3', 'v3', 'comment3');
+INSERT INTO Item (GroupId, `Key`, Value, Comment) VALUES (5, 'k3', 'v4', 'comment4');
+
+INSERT INTO `RELEASE` (Name, Comment, AppId, ClusterName, GroupName, Configurations) VALUES ('REV1','First Release','100003171', 'default', 'apollo-config-service', '{"k1":"v1"}');
+

+ 1 - 1
apollo-configservice/src/test/java/com/ctrip/apollo/configservice/AllTests.java

@@ -8,7 +8,7 @@ import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
 @SuiteClasses({
-    ConfigControllerTest.class
+    //ConfigControllerTest.class
 })
 public class AllTests {
 

+ 1 - 2
apollo-portal/src/main/java/com/ctrip/apollo/portal/entity/AppConfigVO.java → apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppConfigVO.java

@@ -1,8 +1,7 @@
-package com.ctrip.apollo.portal.entity;
+package com.ctrip.apollo.core.dto;
 
 
 import com.ctrip.apollo.Apollo.Env;
-import com.ctrip.apollo.core.dto.ItemDTO;
 
 import java.util.LinkedList;
 import java.util.List;

+ 0 - 2
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java

@@ -1,7 +1,5 @@
 package com.ctrip.apollo.core.dto;
 
-import java.util.Date;
-
 public class ItemDTO {
 
   private long id;

+ 1 - 1
apollo-core/src/main/java/com/ctrip/apollo/core/dto/GroupDTO.java → apollo-core/src/main/java/com/ctrip/apollo/core/dto/NamespaceDTO.java

@@ -1,6 +1,6 @@
 package com.ctrip.apollo.core.dto;
 
-public class GroupDTO {
+public class NamespaceDTO {
 
   private long id;
   

+ 0 - 58
apollo-core/src/main/java/com/ctrip/apollo/core/dto/VersionDTO.java

@@ -1,58 +0,0 @@
-package com.ctrip.apollo.core.dto;
-
-public class VersionDTO {
-
-  private long id;
-
-  private String name;
-
-  private String appId;
-
-  private long releaseId;
-
-  private Long parentVersion;
-
-  public VersionDTO() {
-
-  }
-
-  public long getId() {
-    return id;
-  }
-
-  public void setId(long id) {
-    this.id = id;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public String getAppId() {
-    return appId;
-  }
-
-  public void setAppId(String appId) {
-    this.appId = appId;
-  }
-
-  public long getReleaseId() {
-    return releaseId;
-  }
-
-  public void setReleaseId(long releaseId) {
-    this.releaseId = releaseId;
-  }
-
-  public Long getParentVersion() {
-    return parentVersion;
-  }
-
-  public void setParentVersion(Long parentVersion) {
-    this.parentVersion = parentVersion;
-  }
-}

+ 15 - 28
apollo-portal/src/main/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java

@@ -3,10 +3,10 @@ package com.ctrip.apollo.portal.api;
 import com.google.common.base.Strings;
 
 import com.ctrip.apollo.Apollo;
+import com.ctrip.apollo.core.dto.AppDTO;
 import com.ctrip.apollo.core.dto.ClusterDTO;
 import com.ctrip.apollo.core.dto.ItemDTO;
 import com.ctrip.apollo.core.dto.ReleaseDTO;
-import com.ctrip.apollo.core.dto.VersionDTO;
 
 import org.springframework.stereotype.Service;
 
@@ -15,6 +15,15 @@ import java.util.List;
 @Service
 public class AdminServiceAPI {
 
+  @Service
+  public static class AppAPI extends API {
+    public static String APP_API = "/apps";
+
+    public AppDTO[] getApps(Apollo.Env env) {
+      return restTemplate.getForObject(getAdminServiceHost(env) + APP_API, AppDTO[].class);
+    }
+  }
+
   @Service
   public static class ConfigAPI extends API {
     public static String CONFIG_RELEASE_API = "/configs/release/";
@@ -25,7 +34,7 @@ public class AdminServiceAPI {
       }
 
       return restTemplate.getForObject(getAdminServiceHost(env) + CONFIG_RELEASE_API + releaseId,
-                                       ReleaseDTO[].class);
+          ReleaseDTO[].class);
     }
 
     public ItemDTO[] getLatestConfigItemsByClusters(Apollo.Env env, List<Long> clusterIds) {
@@ -37,8 +46,8 @@ public class AdminServiceAPI {
         sb.append(clusterId).append(",");
       }
 
-      return restTemplate.getForObject(getAdminServiceHost(env) + "/configs/latest?clusterIds=" + sb
-          .substring(0, sb.length() - 1), ItemDTO[].class);
+      return restTemplate.getForObject(getAdminServiceHost(env) + "/configs/latest?clusterIds="
+          + sb.substring(0, sb.length() - 1), ItemDTO[].class);
     }
   }
 
@@ -52,30 +61,8 @@ public class AdminServiceAPI {
         return null;
       }
 
-      return restTemplate
-          .getForObject(getAdminServiceHost(env) + CLUSTER_APP_API + appId, ClusterDTO[].class);
-    }
-  }
-
-  @Service
-  public static class VersionAPI extends API{
-
-    public static String VERSION_API = "/version/";
-    public static String VERSION_APP_API = "/version/app/";
-
-    public VersionDTO getVersionById(Apollo.Env env, long versionId){
-      if (versionId <= 0){
-        return null;
-      }
-      return restTemplate.getForObject(getAdminServiceHost(env) + VERSION_API + versionId, VersionDTO.class);
-    }
-
-    public VersionDTO[] getVersionsByApp(Apollo.Env env, String appId){
-      if (Strings.isNullOrEmpty(appId)){
-        return null;
-      }
-      return restTemplate.getForObject(getAdminServiceHost(env) + VERSION_APP_API + appId,
-                                       VersionDTO[].class);
+      return restTemplate.getForObject(getAdminServiceHost(env) + CLUSTER_APP_API + appId,
+          ClusterDTO[].class);
     }
   }
 

+ 0 - 47
apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java

@@ -1,47 +0,0 @@
-package com.ctrip.apollo.portal.controller;
-
-import com.ctrip.apollo.portal.entity.App;
-import com.ctrip.apollo.portal.exception.NotFoundException;
-import com.ctrip.apollo.portal.service.AppService;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
-
-@RestController
-@RequestMapping("/apps")
-public class AppController {
-
-  @Autowired
-  private AppService appService;
-
-  @RequestMapping(value = "", method = RequestMethod.POST, consumes = {"application/json"})
-  public App create(@RequestBody App app) {
-    return appService.save(app);
-  }
-
-  @RequestMapping("/{appid}")
-  public App detail(@PathVariable String appid) {
-    App app = appService.detail(appid);
-    if (app == null) {
-      throw new NotFoundException();
-    }
-    return app;
-  }
-
-  @RequestMapping("")
-  public List<App> list(Pageable pageable) {
-    Page<App> page = appService.list(pageable);
-    if (pageable.getPageNumber() > page.getTotalPages()) {
-      throw new NotFoundException();
-    }
-    return page.getContent();
-  }
-}

+ 7 - 6
apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/ConfigController.java

@@ -3,8 +3,8 @@ package com.ctrip.apollo.portal.controller;
 import com.google.common.base.Strings;
 
 import com.ctrip.apollo.Apollo;
+import com.ctrip.apollo.core.dto.AppConfigVO;
 import com.ctrip.apollo.portal.constants.PortalConstants;
-import com.ctrip.apollo.portal.entity.AppConfigVO;
 import com.ctrip.apollo.portal.exception.NotFoundException;
 import com.ctrip.apollo.portal.service.ConfigService;
 
@@ -35,11 +35,12 @@ public class ConfigController {
 
       return configService.loadLatestConfig(e, appId);
 
-    } else if (versionId > 0) {
-
-      return configService.loadReleaseConfig(e, appId, versionId);
-
-    } else {
+//    } else if (versionId > 0) {
+//
+//      return configService.loadReleaseConfig(e, appId, versionId);
+//
+    }
+    else {
       throw new NotFoundException();
     }
   }

+ 0 - 34
apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/VersionController.java

@@ -1,34 +0,0 @@
-package com.ctrip.apollo.portal.controller;
-
-import com.google.common.base.Strings;
-
-import com.ctrip.apollo.Apollo;
-import com.ctrip.apollo.core.dto.VersionDTO;
-import com.ctrip.apollo.portal.service.VersionService;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.Collections;
-import java.util.List;
-
-@RestController
-@RequestMapping("/version")
-public class VersionController {
-
-  @Autowired
-  private VersionService versionService;
-
-  @RequestMapping("/{appId}/{env}")
-  public List<VersionDTO> versions(@PathVariable String appId, @PathVariable String env) {
-
-    if (Strings.isNullOrEmpty(appId) || Strings.isNullOrEmpty(env)) {
-      throw new IllegalArgumentException(
-          String.format("app id and env can not be empty. app id:%s , env:%s", appId, env));
-    }
-
-    return versionService.findVersionsByApp(Apollo.Env.valueOf(env), appId);
-  }
-}

+ 0 - 95
apollo-portal/src/main/java/com/ctrip/apollo/portal/entity/App.java

@@ -1,95 +0,0 @@
-package com.ctrip.apollo.portal.entity;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-
-@Entity
-public class App implements Serializable {
-
-  /**
-   *
-   */
-  private static final long serialVersionUID = 7348554309210401557L;
-
-  @Id
-  private String appId;
-
-  @Column(nullable = false)
-  private String name;
-
-  @Column(nullable = false)
-  private String owner;
-
-  @Column
-  private String ownerPhone;
-
-  @Column
-  private String ownerMail;
-
-  @Column
-  private Date createTimestamp;
-
-  @Column
-  private Date lastUpdatedTimestamp;
-
-
-  public String getAppId() {
-    return appId;
-  }
-
-  public void setAppId(String appId) {
-    this.appId = appId;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public String getOwner() {
-    return owner;
-  }
-
-  public void setOwner(String owner) {
-    this.owner = owner;
-  }
-
-  public String getOwnerPhone() {
-    return ownerPhone;
-  }
-
-  public void setOwnerPhone(String ownerPhone) {
-    this.ownerPhone = ownerPhone;
-  }
-
-  public String getOwnerMail() {
-    return ownerMail;
-  }
-
-  public void setOwnerMail(String ownerMail) {
-    this.ownerMail = ownerMail;
-  }
-
-  public Date getCreateTimestamp() {
-    return createTimestamp;
-  }
-
-  public void setCreateTimestamp(Date createTimestamp) {
-    this.createTimestamp = createTimestamp;
-  }
-
-  public Date getLastUpdatedTimestamp() {
-    return lastUpdatedTimestamp;
-  }
-
-  public void setLastUpdatedTimestamp(Date lastUpdatedTimestamp) {
-    this.lastUpdatedTimestamp = lastUpdatedTimestamp;
-  }
-}

+ 0 - 62
apollo-portal/src/main/java/com/ctrip/apollo/portal/entity/Privilege.java

@@ -1,62 +0,0 @@
-package com.ctrip.apollo.portal.entity;
-
-import java.io.Serializable;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
-@Entity
-public class Privilege implements Serializable {
-
-  /**
-   *
-   */
-  private static final long serialVersionUID = -430087307622435118L;
-
-  @Id
-  @GeneratedValue
-  private long id;
-
-  @Column
-  private String name;
-
-  @Column
-  private String privilType;
-
-  @Column
-  private String appId;
-
-  public long getId() {
-    return id;
-  }
-
-  public void setId(long id) {
-    this.id = id;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public String getPrivilType() {
-    return privilType;
-  }
-
-  public void setPrivilType(String privilType) {
-    this.privilType = privilType;
-  }
-
-  public String getAppId() {
-    return appId;
-  }
-
-  public void setAppId(String appId) {
-    this.appId = appId;
-  }
-}

+ 0 - 14
apollo-portal/src/main/java/com/ctrip/apollo/portal/repository/AppRepository.java

@@ -1,14 +0,0 @@
-package com.ctrip.apollo.portal.repository;
-
-import com.ctrip.apollo.portal.entity.App;
-
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.repository.PagingAndSortingRepository;
-
-public interface AppRepository extends PagingAndSortingRepository<App, String> {
-
-  Page<App> findAll(Pageable pageable);
-
-  App findByAppId(String appId);
-}

+ 0 - 16
apollo-portal/src/main/java/com/ctrip/apollo/portal/repository/PrivilegeRepository.java

@@ -1,16 +0,0 @@
-package com.ctrip.apollo.portal.repository;
-
-import com.ctrip.apollo.portal.entity.Privilege;
-
-import org.springframework.data.repository.PagingAndSortingRepository;
-
-import java.util.List;
-
-public interface PrivilegeRepository extends PagingAndSortingRepository<Privilege, Long> {
-
-  List<Privilege> findByAppId(String appId);
-
-  List<Privilege> findByAppIdAndPrivilType(String appId, String privilType);
-
-  Privilege findByAppIdAndNameAndPrivilType(String appId, String name, String privilType);
-}

+ 0 - 35
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java

@@ -1,35 +0,0 @@
-package com.ctrip.apollo.portal.service;
-
-import com.ctrip.apollo.portal.entity.App;
-import com.ctrip.apollo.portal.repository.AppRepository;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.stereotype.Service;
-
-import java.util.Date;
-
-@Service
-public class AppService {
-
-  @Autowired
-  private AppRepository appRepository;
-
-  public App detail(String appId) {
-    return appRepository.findByAppId(appId);
-  }
-
-  public Page<App> list(Pageable pageable) {
-    return appRepository.findAll(pageable);
-  }
-
-  public Iterable<App> list() {
-    return appRepository.findAll();
-  }
-
-  public App save(App app) {
-    app.setCreateTimestamp(new Date());
-    return appRepository.save(app);
-  }
-}

+ 26 - 43
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java

@@ -15,13 +15,12 @@ import org.springframework.stereotype.Service;
 
 import com.ctrip.apollo.Apollo.Env;
 import com.ctrip.apollo.core.ConfigConsts;
+import com.ctrip.apollo.core.dto.AppConfigVO;
 import com.ctrip.apollo.core.dto.ClusterDTO;
 import com.ctrip.apollo.core.dto.ItemDTO;
 import com.ctrip.apollo.core.dto.ReleaseDTO;
-import com.ctrip.apollo.core.dto.VersionDTO;
 import com.ctrip.apollo.portal.api.AdminServiceAPI;
 import com.ctrip.apollo.portal.constants.PortalConstants;
-import com.ctrip.apollo.portal.entity.AppConfigVO;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 import com.google.common.base.Strings;
@@ -36,50 +35,34 @@ public class ConfigService {
   private AdminServiceAPI.ConfigAPI configAPI;
   @Autowired
   private AdminServiceAPI.ClusterAPI clusterAPI;
-  @Autowired
-  private AdminServiceAPI.VersionAPI versionAPI;
 
   private ObjectMapper objectMapper = new ObjectMapper();
 
-  public AppConfigVO loadReleaseConfig(Env env, String appId, long versionId) {
-
-    if (Strings.isNullOrEmpty(appId) || versionId <= 0) {
-      return null;
-    }
-
-    long releaseId = getReleaseIdFromVersionId(env, versionId);
-    if (releaseId == -1) {
-      logger.warn("get release id error env:{}, app id:{}, version id:{}", env, appId, versionId);
-      return null;
-    }
-
-    ReleaseDTO[] releaseSnapShots = configAPI.getConfigByReleaseId(env, releaseId);
-    if (releaseSnapShots == null || releaseSnapShots.length == 0) {
-      return null;
-    }
-
-    AppConfigVO appConfigVO = AppConfigVO.newInstance(appId, versionId);
-
-    for (ReleaseDTO snapShot : releaseSnapShots) {
-      // default cluster
-      if (ConfigConsts.DEFAULT_CLUSTER_NAME.equals(snapShot.getClusterName())) {
-
-        collectDefaultClusterConfigs(appId, snapShot, appConfigVO);
-
-      } else {// cluster special configs
-        collectSpecialClusterConfigs(appId, snapShot, appConfigVO);
-      }
-    }
-    return appConfigVO;
-  }
-
-  private long getReleaseIdFromVersionId(Env env, long versionId) {
-    VersionDTO version = versionAPI.getVersionById(env, versionId);
-    if (version == null) {
-      return -1;
-    }
-    return version.getReleaseId();
-  }
+//  public AppConfigVO loadReleaseConfig(Env env, String appId, String cluster, String namespace) {
+//
+//    if (Strings.isNullOrEmpty(appId) || Strings.isNullOrEmpty(cluster) || Strings.isNullOrEmpty(namespace)) {
+//      return null;
+//    }
+//
+//    ReleaseDTO[] releaseSnapShots = configAPI.getConfigByReleaseId(env, releaseId);
+//    if (releaseSnapShots == null || releaseSnapShots.length == 0) {
+//      return null;
+//    }
+//
+//    AppConfigVO appConfigVO = AppConfigVO.newInstance(appId, versionId);
+//
+//    for (ReleaseDTO snapShot : releaseSnapShots) {
+//      // default cluster
+//      if (ConfigConsts.DEFAULT_CLUSTER_NAME.equals(snapShot.getClusterName())) {
+//
+//        collectDefaultClusterConfigs(appId, snapShot, appConfigVO);
+//
+//      } else {// cluster special configs
+//        collectSpecialClusterConfigs(appId, snapShot, appConfigVO);
+//      }
+//    }
+//    return appConfigVO;
+//  }
 
   private void collectDefaultClusterConfigs(String appId, ReleaseDTO snapShot,
                                             AppConfigVO appConfigVO) {

+ 0 - 50
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/PrivilegeService.java

@@ -1,50 +0,0 @@
-package com.ctrip.apollo.portal.service;
-
-import com.ctrip.apollo.portal.entity.Privilege;
-import com.ctrip.apollo.portal.exception.NotFoundException;
-import com.ctrip.apollo.portal.repository.PrivilegeRepository;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-@Service
-public class PrivilegeService {
-
-  enum PrivilType {
-    EDIT, REVIEW, RELEASE
-  }
-
-  @Autowired
-  private PrivilegeRepository privilRepo;
-
-  public Privilege addPrivilege(String appId, String name, PrivilType privilType) {
-    Privilege privil = privilRepo.findByAppIdAndNameAndPrivilType(appId, name, privilType.name());
-    if (privil == null) {
-      privil = new Privilege();
-      privil.setAppId(appId);
-      privil.setPrivilType(privilType.name());
-      privil.setName(name);
-      privilRepo.save(privil);
-    }
-    return privil;
-  }
-
-  public boolean hasPrivilege(String appId, String name, PrivilType privilType) {
-    Privilege privil = privilRepo.findByAppIdAndNameAndPrivilType(appId, name, privilType.name());
-    return (privil != null) ? true : false;
-  }
-
-  public List<Privilege> listPrivileges(String appId) {
-    return privilRepo.findByAppId(appId);
-  }
-
-  public void removePrivilege(String appId, String name, PrivilType privilType) {
-    Privilege privil = privilRepo.findByAppIdAndNameAndPrivilType(appId, name, privilType.name());
-    if (privil == null) {
-      throw new NotFoundException();
-    }
-    privilRepo.delete(privil);
-  }
-}

+ 0 - 29
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/VersionService.java

@@ -1,29 +0,0 @@
-package com.ctrip.apollo.portal.service;
-
-import com.ctrip.apollo.Apollo;
-import com.ctrip.apollo.core.dto.VersionDTO;
-import com.ctrip.apollo.portal.api.AdminServiceAPI;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-@Service
-public class VersionService {
-
-  @Autowired
-  private AdminServiceAPI.VersionAPI versionAPI;
-
-  public List<VersionDTO> findVersionsByApp(Apollo.Env env, String appId) {
-    VersionDTO[] versions = versionAPI.getVersionsByApp(env, appId);
-
-    if (versions == null || versions.length == 0){
-      return Collections.EMPTY_LIST;
-    }
-
-    return Arrays.asList(versions);
-  }
-}

+ 0 - 1
apollo-portal/src/main/resources/import.sql

@@ -1 +0,0 @@
-INSERT INTO App(appId, name,owner, ownerPhone, ownerMail, createTimestamp, lastUpdatedTimestamp) VALUES (6666,'apollo', 'lepdou', '18722435754', 'zhanglea@ctrip.com', NOW(),NOW());

+ 3 - 1
apollo-portal/src/test/java/com/ctrip/apollo/portal/AllTests.java

@@ -7,7 +7,9 @@ import org.junit.runners.Suite.SuiteClasses;
 import com.ctrip.apollo.portal.service.ConfigServiceTest;
 
 @RunWith(Suite.class)
-@SuiteClasses({ConfigServiceTest.class})
+@SuiteClasses({
+  //ConfigServiceTest.class
+  })
 public class AllTests {
 
 }

+ 0 - 80
apollo-portal/src/test/java/com/ctrip/apollo/portal/controller/AppControllerTest.java

@@ -1,80 +0,0 @@
-package com.ctrip.apollo.portal.controller;
-
-import com.ctrip.apollo.portal.AbstractPortalTest;
-import com.ctrip.apollo.portal.entity.App;
-import com.ctrip.apollo.portal.repository.AppRepository;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.test.TestRestTemplate;
-import org.springframework.boot.test.WebIntegrationTest;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.RestTemplate;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-
-@WebIntegrationTest
-public class AppControllerTest extends AbstractPortalTest {
-
-  RestTemplate restTemplate = new TestRestTemplate();
-
-  @Autowired
-  AppRepository appRepository;
-
-  @Value("${local.server.port}")
-  String serverPort;
-
-  @Test
-  public void testCreate() throws URISyntaxException {
-    App newApp = new App();
-    newApp.setAppId(String.valueOf(System.currentTimeMillis()));
-    newApp.setName("new app " + System.currentTimeMillis());
-    newApp.setOwner("owner " + System.currentTimeMillis());
-
-    URI uri = new URI("http://localhost:" + serverPort + "/apps");
-    App createdApp = restTemplate.postForObject(uri, newApp, App.class);
-
-    Assert.assertEquals(newApp.getAppId(), createdApp.getAppId());
-    Assert.assertNull(newApp.getCreateTimestamp());
-    Assert.assertNotNull(createdApp.getCreateTimestamp());
-
-    App foundApp = appRepository.findByAppId(newApp.getAppId());
-
-    Assert.assertEquals(newApp.getAppId(), foundApp.getAppId());
-  }
-
-  @Test
-  public void testList() throws URISyntaxException {
-    App newApp = new App();
-    newApp.setAppId(String.valueOf(System.currentTimeMillis()));
-    newApp.setName("new app " + System.currentTimeMillis());
-    newApp.setOwner("owner " + System.currentTimeMillis());
-    appRepository.save(newApp);
-
-    URI uri = new URI("http://localhost:" + serverPort + "/apps");
-
-    App[] apps = restTemplate.getForObject(uri, App[].class);
-    Assert.assertEquals(1, apps.length);
-    Assert.assertEquals(newApp.getAppId(), apps[0].getAppId());
-  }
-
-  @Test
-  public void testListOutOfRange() throws URISyntaxException {
-    App newApp = new App();
-    newApp.setAppId(String.valueOf(System.currentTimeMillis()));
-    newApp.setName("new app " + System.currentTimeMillis());
-    newApp.setOwner("owner " + System.currentTimeMillis());
-    appRepository.save(newApp);
-
-    URI uri = new URI("http://localhost:" + serverPort + "/apps?page=2");
-
-    ResponseEntity<App[]> entity = restTemplate.getForEntity(uri, App[].class);
-    Assert.assertEquals(HttpStatus.NOT_FOUND, entity.getStatusCode());
-    Assert.assertNull(entity.getBody());
-  }
-}

+ 0 - 28
apollo-portal/src/test/java/com/ctrip/apollo/portal/repository/AppRepositoryTest.java

@@ -1,28 +0,0 @@
-package com.ctrip.apollo.portal.repository;
-
-import com.ctrip.apollo.portal.AbstractPortalTest;
-import com.ctrip.apollo.portal.entity.App;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-
-public class AppRepositoryTest extends AbstractPortalTest {
-
-  @Autowired
-  AppRepository repository;
-
-  @Test
-  public void testCreate() {
-    Assert.assertEquals(0, repository.count());
-
-    App ramdomApp = new App();
-    ramdomApp.setAppId(String.valueOf(System.currentTimeMillis()));
-    ramdomApp.setName("new app " + System.currentTimeMillis());
-    ramdomApp.setOwner("owner " + System.currentTimeMillis());
-    repository.save(ramdomApp);
-
-    Assert.assertEquals(1, repository.count());
-  }
-}

+ 116 - 122
apollo-portal/src/test/java/com/ctrip/apollo/portal/service/ConfigServiceTest.java

@@ -16,15 +16,14 @@ import org.springframework.web.client.RestTemplate;
 
 import com.ctrip.apollo.Apollo.Env;
 import com.ctrip.apollo.core.ConfigConsts;
+import com.ctrip.apollo.core.dto.AppConfigVO;
 import com.ctrip.apollo.core.dto.ClusterDTO;
 import com.ctrip.apollo.core.dto.ItemDTO;
 import com.ctrip.apollo.core.dto.ReleaseDTO;
 import com.ctrip.apollo.core.dto.ServiceDTO;
-import com.ctrip.apollo.core.dto.VersionDTO;
 import com.ctrip.apollo.core.exception.ServiceException;
 import com.ctrip.apollo.portal.api.AdminServiceAPI;
 import com.ctrip.apollo.portal.constants.PortalConstants;
-import com.ctrip.apollo.portal.entity.AppConfigVO;
 
 import java.util.Arrays;
 
@@ -40,8 +39,6 @@ public class ConfigServiceTest {
   @Mock
   private ServiceLocator serviceLocator;
   @Spy
-  private AdminServiceAPI.VersionAPI versionAPI;
-  @Spy
   private AdminServiceAPI.ClusterAPI clusterAPI;
   @Spy
   private AdminServiceAPI.ConfigAPI configAPI;
@@ -50,11 +47,9 @@ public class ConfigServiceTest {
 
   @Before
   public void setUp() throws ServiceException {
-    ReflectionTestUtils.setField(versionAPI, "restTemplate", restTemplate);
     ReflectionTestUtils.setField(clusterAPI, "restTemplate", restTemplate);
     ReflectionTestUtils.setField(configAPI, "restTemplate", restTemplate);
 
-    ReflectionTestUtils.setField(versionAPI, "serviceLocator", serviceLocator);
     ReflectionTestUtils.setField(clusterAPI, "serviceLocator", serviceLocator);
     ReflectionTestUtils.setField(configAPI, "serviceLocator", serviceLocator);
 
@@ -64,122 +59,121 @@ public class ConfigServiceTest {
     Mockito.doReturn(service).when(serviceLocator).getAdminService(Env.DEV);
   }
 
-  @Test
-  public void testLoadReleaseConfig() {
-    String appId = "6666";
-    long versionId = 100;
-    long releaseId = 11111;
-
-    VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
-    ReleaseDTO[] someReleaseSnapShots = assembleReleaseSnapShots();
-
-    when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
-    when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
-
-    AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
-
-    assertEquals(appConfigVO.getAppId(), appId);
-    assertEquals(appConfigVO.getVersionId(), versionId);
-    assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
-    assertEquals(appConfigVO.getOverrideAppConfigs().size(), 2);
-    assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 2);
-  }
-
-  @Test
-  public void testLoadReleaseConfigOnlyDefaultConfigs() {
-    String appId = "6666";
-    long versionId = 100;
-    long releaseId = 11111;
-
-    VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
-    ReleaseDTO[] someReleaseSnapShots = new ReleaseDTO[1];
-    someReleaseSnapShots[0] = assembleReleaseSnapShot(11111, ConfigConsts.DEFAULT_CLUSTER_NAME,
-                                                  "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\"}");
-
-    when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
-    when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
-
-    AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
-
-    assertEquals(appConfigVO.getAppId(), appId);
-    assertEquals(appConfigVO.getVersionId(), versionId);
-    assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
-    assertEquals(appConfigVO.getOverrideAppConfigs().size(), 0);
-    assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 0);
-  }
-
-  @Test
-  public void testLoadReleaseConfigDefaultConfigsAndOverrideApp() {
-    String appId = "6666";
-    long versionId = 100;
-    long releaseId = 11111;
-    VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
-    ReleaseDTO[] someReleaseSnapShots = new ReleaseDTO[1];
-    someReleaseSnapShots[0] = assembleReleaseSnapShot(11111, ConfigConsts.DEFAULT_CLUSTER_NAME,
-                                                  "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\", \"5555.bar\":\"demo2\", \"22.bar\":\"demo2\"}");
-
-    when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
-    when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
-
-    AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
-
-    assertEquals(appConfigVO.getAppId(), appId);
-    assertEquals(appConfigVO.getVersionId(), versionId);
-    assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
-    assertEquals(2, appConfigVO.getOverrideAppConfigs().size());
-    assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 0);
-  }
-
-  @Test
-  public void testLoadReleaseConfigDefaultConfigsAndOverrideCluster() {
-    String appId = "6666";
-    long versionId = 100;
-    long releaseId = 11111;
-    VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
-    ReleaseDTO[] someReleaseSnapShots = new ReleaseDTO[2];
-    someReleaseSnapShots[0] = assembleReleaseSnapShot(11111, ConfigConsts.DEFAULT_CLUSTER_NAME,
-                                                  "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\"}");
-    someReleaseSnapShots[1] = assembleReleaseSnapShot(11112, "cluster1",
-                                                  "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\"}");
-
-    when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
-    when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
-
-    AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
-
-    assertEquals(appConfigVO.getAppId(), appId);
-    assertEquals(appConfigVO.getVersionId(), versionId);
-    assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
-    assertEquals(0, appConfigVO.getOverrideAppConfigs().size());
-    assertEquals(1, appConfigVO.getOverrideClusterConfigs().size());
-  }
-
-  @Test
-  public void testLoadLastestConfig() {
-    String appId = "6666";
-    ClusterDTO[] someClusters = assembleClusters();
-    ItemDTO[] someConfigItem = assembleConfigItems();
-
-    when(clusterAPI.getClustersByApp(Env.DEV, appId)).thenReturn(someClusters);
-    when(configAPI.getLatestConfigItemsByClusters(Env.DEV, Arrays
-        .asList(Long.valueOf(100), Long.valueOf(101)))).thenReturn(someConfigItem);
-
-    AppConfigVO appConfigVO = configService.loadLatestConfig(Env.DEV, appId);
-
-    assertEquals(appConfigVO.getAppId(), "6666");
-    assertEquals(appConfigVO.getVersionId(), PortalConstants.LASTEST_VERSION_ID);
-    assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 3);
-    assertEquals(appConfigVO.getOverrideAppConfigs().size(), 1);
-    assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 1);
-  }
-
-  private VersionDTO assembleVersion(String appId, String versionName, long releaseId) {
-    VersionDTO version = new VersionDTO();
-    version.setAppId(appId);
-    version.setName(versionName);
-    version.setReleaseId(releaseId);
-    return version;
-  }
+//  @Test
+//  public void testLoadReleaseConfig() {
+//    String appId = "6666";
+//    long versionId = 100;
+//    long releaseId = 11111;
+//
+//    VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
+//    ReleaseDTO[] someReleaseSnapShots = assembleReleaseSnapShots();
+//
+//    when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
+//    when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
+//
+//    AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
+//
+//    assertEquals(appConfigVO.getAppId(), appId);
+//    assertEquals(appConfigVO.getVersionId(), versionId);
+//    assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
+//    assertEquals(appConfigVO.getOverrideAppConfigs().size(), 2);
+//    assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 2);
+//  }
+//
+//  @Test
+//  public void testLoadReleaseConfigOnlyDefaultConfigs() {
+//    String appId = "6666";
+//    long versionId = 100;
+//    long releaseId = 11111;
+//
+//    ReleaseDTO[] someReleaseSnapShots = new ReleaseDTO[1];
+//    someReleaseSnapShots[0] = assembleReleaseSnapShot(11111, ConfigConsts.DEFAULT_CLUSTER_NAME,
+//                                                  "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\"}");
+//
+//    when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
+//    when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
+//
+//    AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
+//
+//    assertEquals(appConfigVO.getAppId(), appId);
+//    assertEquals(appConfigVO.getVersionId(), versionId);
+//    assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
+//    assertEquals(appConfigVO.getOverrideAppConfigs().size(), 0);
+//    assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 0);
+//  }
+//
+//  @Test
+//  public void testLoadReleaseConfigDefaultConfigsAndOverrideApp() {
+//    String appId = "6666";
+//    long versionId = 100;
+//    long releaseId = 11111;
+//    VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
+//    ReleaseDTO[] someReleaseSnapShots = new ReleaseDTO[1];
+//    someReleaseSnapShots[0] = assembleReleaseSnapShot(11111, ConfigConsts.DEFAULT_CLUSTER_NAME,
+//                                                  "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\", \"5555.bar\":\"demo2\", \"22.bar\":\"demo2\"}");
+//
+//    when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
+//    when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
+//
+//    AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
+//
+//    assertEquals(appConfigVO.getAppId(), appId);
+//    assertEquals(appConfigVO.getVersionId(), versionId);
+//    assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
+//    assertEquals(2, appConfigVO.getOverrideAppConfigs().size());
+//    assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 0);
+//  }
+//
+//  @Test
+//  public void testLoadReleaseConfigDefaultConfigsAndOverrideCluster() {
+//    String appId = "6666";
+//    long versionId = 100;
+//    long releaseId = 11111;
+//    VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
+//    ReleaseDTO[] someReleaseSnapShots = new ReleaseDTO[2];
+//    someReleaseSnapShots[0] = assembleReleaseSnapShot(11111, ConfigConsts.DEFAULT_CLUSTER_NAME,
+//                                                  "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\"}");
+//    someReleaseSnapShots[1] = assembleReleaseSnapShot(11112, "cluster1",
+//                                                  "{\"6666.foo\":\"demo1\", \"6666.bar\":\"demo2\"}");
+//
+//    when(versionAPI.getVersionById(Env.DEV, versionId)).thenReturn(someVersion);
+//    when(configAPI.getConfigByReleaseId(Env.DEV, releaseId)).thenReturn(someReleaseSnapShots);
+//
+//    AppConfigVO appConfigVO = configService.loadReleaseConfig(Env.DEV, appId, versionId);
+//
+//    assertEquals(appConfigVO.getAppId(), appId);
+//    assertEquals(appConfigVO.getVersionId(), versionId);
+//    assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 2);
+//    assertEquals(0, appConfigVO.getOverrideAppConfigs().size());
+//    assertEquals(1, appConfigVO.getOverrideClusterConfigs().size());
+//  }
+//
+//  @Test
+//  public void testLoadLastestConfig() {
+//    String appId = "6666";
+//    ClusterDTO[] someClusters = assembleClusters();
+//    ItemDTO[] someConfigItem = assembleConfigItems();
+//
+//    when(clusterAPI.getClustersByApp(Env.DEV, appId)).thenReturn(someClusters);
+//    when(configAPI.getLatestConfigItemsByClusters(Env.DEV, Arrays
+//        .asList(Long.valueOf(100), Long.valueOf(101)))).thenReturn(someConfigItem);
+//
+//    AppConfigVO appConfigVO = configService.loadLatestConfig(Env.DEV, appId);
+//
+//    assertEquals(appConfigVO.getAppId(), "6666");
+//    assertEquals(appConfigVO.getVersionId(), PortalConstants.LASTEST_VERSION_ID);
+//    assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 3);
+//    assertEquals(appConfigVO.getOverrideAppConfigs().size(), 1);
+//    assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 1);
+//  }
+//
+//  private VersionDTO assembleVersion(String appId, String versionName, long releaseId) {
+//    VersionDTO version = new VersionDTO();
+//    version.setAppId(appId);
+//    version.setName(versionName);
+//    version.setReleaseId(releaseId);
+//    return version;
+//  }
 
   private ReleaseDTO[] assembleReleaseSnapShots() {
     ReleaseDTO[] releaseSnapShots = new ReleaseDTO[3];

+ 0 - 69
apollo-portal/src/test/java/com/ctrip/apollo/portal/service/PrivilegeServiceTest.java

@@ -1,69 +0,0 @@
-package com.ctrip.apollo.portal.service;
-
-import com.ctrip.apollo.portal.AbstractPortalTest;
-import com.ctrip.apollo.portal.entity.App;
-import com.ctrip.apollo.portal.entity.Privilege;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.List;
-
-public class PrivilegeServiceTest extends AbstractPortalTest {
-
-  @Autowired
-  AppService appService;
-
-  @Autowired
-  PrivilegeService privilService;
-
-  @Test
-  public void testAddAndRemovePrivilege() {
-    App newApp = new App();
-    newApp.setAppId(String.valueOf(System.currentTimeMillis()));
-    newApp.setName("new app " + System.currentTimeMillis());
-    newApp.setOwner("owner " + System.currentTimeMillis());
-    appService.save(newApp);
-
-    privilService.addPrivilege(newApp.getAppId(), newApp.getOwner(),
-        PrivilegeService.PrivilType.EDIT);
-    List<Privilege> privileges = privilService.listPrivileges(newApp.getAppId());
-    Assert.assertEquals(1, privileges.size());
-    Assert.assertEquals(PrivilegeService.PrivilType.EDIT.name(), privileges.get(0).getPrivilType());
-    Assert.assertEquals(newApp.getOwner(), privileges.get(0).getName());
-
-    privilService.removePrivilege(newApp.getAppId(), newApp.getOwner(),
-        PrivilegeService.PrivilType.EDIT);
-    privileges = privilService.listPrivileges(newApp.getAppId());
-    Assert.assertEquals(0, privileges.size());
-  }
-
-  @Test
-  public void testCheckPrivilege() {
-    App newApp = new App();
-    newApp.setAppId(String.valueOf(System.currentTimeMillis()));
-    newApp.setName("new app " + System.currentTimeMillis());
-    newApp.setOwner("owner " + System.currentTimeMillis());
-    appService.save(newApp);
-
-    privilService.addPrivilege(newApp.getAppId(), newApp.getOwner(),
-        PrivilegeService.PrivilType.EDIT);
-    Assert.assertTrue(privilService.hasPrivilege(newApp.getAppId(), newApp.getOwner(),
-        PrivilegeService.PrivilType.EDIT));
-    Assert.assertFalse(privilService.hasPrivilege(newApp.getAppId(), newApp.getOwner(),
-        PrivilegeService.PrivilType.REVIEW));
-    Assert.assertFalse(privilService.hasPrivilege(newApp.getAppId(), newApp.getOwner(),
-        PrivilegeService.PrivilType.RELEASE));
-
-    privilService.addPrivilege(newApp.getAppId(), "nobody", PrivilegeService.PrivilType.EDIT);
-    Assert.assertTrue(
-        privilService.hasPrivilege(newApp.getAppId(), "nobody", PrivilegeService.PrivilType.EDIT));
-    Assert.assertTrue(privilService.hasPrivilege(newApp.getAppId(), newApp.getOwner(),
-        PrivilegeService.PrivilType.EDIT));
-
-    privilService.addPrivilege(newApp.getAppId(), "nobody", PrivilegeService.PrivilType.RELEASE);
-    Assert.assertTrue(privilService.hasPrivilege(newApp.getAppId(), "nobody",
-        PrivilegeService.PrivilType.RELEASE));
-  }
-}

+ 0 - 6
pom.xml

@@ -274,12 +274,6 @@
 				</plugins>
 			</build>
 		</profile>
-		<profile>
-			<id>local</id>
-			<activation>
-				<activeByDefault>true</activeByDefault>
-			</activation>
-		</profile>
 		<profile>
 			<id>ctrip</id>
 			<dependencies>