Skip to content

Commit

Permalink
Merge pull request apolloconfig#526 from lepdou/branch_operation_chec…
Browse files Browse the repository at this point in the history
…k_namespace

check namespace and branch exist when update gray rules
  • Loading branch information
nobodyiam authored Jan 22, 2017
2 parents e2c8c9c + bc8ec05 commit 64a609a
Show file tree
Hide file tree
Showing 68 changed files with 139 additions and 300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void delete(@PathVariable("appId") String appId, @RequestParam String ope
appService.delete(entity.getId(), operator);
}

@RequestMapping("/apps")
@RequestMapping(value = "/apps", method = RequestMethod.GET)
public List<AppDTO> find(@RequestParam(value = "name", required = false) String name,
Pageable pageable) {
List<App> app = null;
Expand All @@ -68,7 +68,7 @@ public List<AppDTO> find(@RequestParam(value = "name", required = false) String
return BeanUtils.batchTransform(AppDTO.class, app);
}

@RequestMapping("/apps/{appId}")
@RequestMapping(value = "/apps/{appId}", method = RequestMethod.GET)
public AppDTO get(@PathVariable("appId") String appId) {
App app = appService.findOne(appId);
if (app == null) {
Expand All @@ -77,7 +77,7 @@ public AppDTO get(@PathVariable("appId") String appId) {
return BeanUtils.transfrom(AppDTO.class, app);
}

@RequestMapping("/apps/{appId}/unique")
@RequestMapping(value = "/apps/{appId}/unique", method = RequestMethod.GET)
public boolean isAppIdUnique(@PathVariable("appId") String appId) {
return appService.isAppIdUnique(appId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public void delete(@PathVariable("appId") String appId,
clusterService.delete(entity.getId(), operator);
}

@RequestMapping("/apps/{appId}/clusters")
@RequestMapping(value = "/apps/{appId}/clusters", method = RequestMethod.GET)
public List<ClusterDTO> find(@PathVariable("appId") String appId) {
List<Cluster> clusters = clusterService.findParentClusters(appId);
return BeanUtils.batchTransform(ClusterDTO.class, clusters);
}

@RequestMapping("/apps/{appId}/clusters/{clusterName:.+}")
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName:.+}", method = RequestMethod.GET)
public ClusterDTO get(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName) {
Cluster cluster = clusterService.findOne(appId, clusterName);
Expand All @@ -74,7 +74,7 @@ public ClusterDTO get(@PathVariable("appId") String appId,
return BeanUtils.transfrom(ClusterDTO.class, cluster);
}

@RequestMapping("/apps/{appId}/cluster/{clusterName}/unique")
@RequestMapping(value = "/apps/{appId}/cluster/{clusterName}/unique", method = RequestMethod.GET)
public boolean isAppIdUnique(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName) {
return clusterService.isClusterNameUnique(appId, clusterName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.PathVariable;
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;
Expand All @@ -20,7 +21,7 @@ public class CommitController {
@Autowired
private CommitService commitService;

@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit")
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit", method = RequestMethod.GET)
public List<CommitDTO> find(@PathVariable String appId, @PathVariable String clusterName,
@PathVariable String namespaceName, Pageable pageable){

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.ctrip.framework.apollo.adminservice.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(path = "/")
public class IndexController {

@RequestMapping(path = "")
@RequestMapping(path = "", method = RequestMethod.GET)
public String index() {
return "apollo-adminservice";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ public void delete(@PathVariable("itemId") long itemId, @RequestParam String ope
commitService.save(commit);
}

@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items")
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items", method = RequestMethod.GET)
public List<ItemDTO> findItems(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) {
return BeanUtils.batchTransform(ItemDTO.class, itemService.findItems(appId, clusterName, namespaceName));
}

@RequestMapping("/items/{itemId}")
@RequestMapping(value = "/items/{itemId}", method = RequestMethod.GET)
public ItemDTO get(@PathVariable("itemId") long itemId) {
Item item = itemService.findOne(itemId);
if (item == null) {
Expand All @@ -141,7 +141,7 @@ public ItemDTO get(@PathVariable("itemId") long itemId) {
return BeanUtils.transfrom(ItemDTO.class, item);
}

@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}")
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}", method = RequestMethod.GET)
public ItemDTO get(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @PathVariable("key") String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ public void delete(@PathVariable("appId") String appId,
namespaceService.deleteNamespace(entity, operator);
}

@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces")
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces", method = RequestMethod.GET)
public List<NamespaceDTO> find(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName) {
List<Namespace> groups = namespaceService.findNamespaces(appId, clusterName);
return BeanUtils.batchTransform(NamespaceDTO.class, groups);
}

@RequestMapping("/namespaces/{namespaceId}")
@RequestMapping(value = "/namespaces/{namespaceId}", method = RequestMethod.GET)
public NamespaceDTO get(@PathVariable("namespaceId") Long namespaceId) {
Namespace namespace = namespaceService.findOne(namespaceId);
if (namespace == null)
throw new NotFoundException(String.format("namespace not found for %s", namespaceId));
return BeanUtils.transfrom(NamespaceDTO.class, namespace);
}

@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}")
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}", method = RequestMethod.GET)
public NamespaceDTO get(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) {
Expand All @@ -79,7 +79,8 @@ public NamespaceDTO get(@PathVariable("appId") String appId,
return BeanUtils.transfrom(NamespaceDTO.class, namespace);
}

@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace")
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace",
method = RequestMethod.GET)
public NamespaceDTO findPublicNamespaceForAssociatedNamespace(@PathVariable String appId,
@PathVariable String clusterName,
@PathVariable String namespaceName) {
Expand All @@ -95,7 +96,7 @@ public NamespaceDTO findPublicNamespaceForAssociatedNamespace(@PathVariable Stri
/**
* cluster -> cluster has not published namespaces?
*/
@RequestMapping("/apps/{appId}/namespaces/publish_info")
@RequestMapping(value = "/apps/{appId}/namespaces/publish_info", method = RequestMethod.GET)
public Map<String, Boolean> namespacePublishInfo(@PathVariable String appId) {
return namespaceService.namespacePublishInfo(appId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
Expand All @@ -25,7 +26,7 @@ public class NamespaceLockController {
@Autowired
private BizConfig bizConfig;

@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock")
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock", method = RequestMethod.GET)
public NamespaceLockDTO getNamespaceLockOwner(@PathVariable String appId, @PathVariable String clusterName,
@PathVariable String namespaceName) {
Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ReleaseController {
private NamespaceBranchService namespaceBranchService;


@RequestMapping("/releases/{releaseId}")
@RequestMapping(value = "/releases/{releaseId}", method = RequestMethod.GET)
public ReleaseDTO get(@PathVariable("releaseId") long releaseId) {
Release release = releaseService.findOne(releaseId);
if (release == null) {
Expand All @@ -57,7 +57,7 @@ public ReleaseDTO get(@PathVariable("releaseId") long releaseId) {
return BeanUtils.transfrom(ReleaseDTO.class, release);
}

@RequestMapping("/releases")
@RequestMapping(value = "/releases", method = RequestMethod.GET)
public List<ReleaseDTO> findReleaseByIds(@RequestParam("releaseIds") String releaseIds) {
Set<Long> releaseIdSet = RELEASES_SPLITTER.splitToList(releaseIds).stream().map(Long::parseLong)
.collect(Collectors.toSet());
Expand All @@ -67,7 +67,7 @@ public List<ReleaseDTO> findReleaseByIds(@RequestParam("releaseIds") String rele
return BeanUtils.batchTransform(ReleaseDTO.class, releases);
}

@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all")
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all", method = RequestMethod.GET)
public List<ReleaseDTO> findAllReleases(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName,
Expand All @@ -77,7 +77,7 @@ public List<ReleaseDTO> findAllReleases(@PathVariable("appId") String appId,
}


@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/active")
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/active", method = RequestMethod.GET)
public List<ReleaseDTO> findActiveReleases(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName,
Expand All @@ -86,7 +86,7 @@ public List<ReleaseDTO> findActiveReleases(@PathVariable("appId") String appId,
return BeanUtils.batchTransform(ReleaseDTO.class, releases);
}

@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest")
@RequestMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest", method = RequestMethod.GET)
public ReleaseDTO getLatest(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.ctrip.framework.apollo.adminservice.aop.NamespaceLockTest;
import com.ctrip.framework.apollo.adminservice.controller.AppControllerTest;
import com.ctrip.framework.apollo.adminservice.controller.AppNamespaceControllerTest;
import com.ctrip.framework.apollo.adminservice.controller.ControllerExceptionTest;
import com.ctrip.framework.apollo.adminservice.controller.ControllerIntegrationExceptionTest;
import com.ctrip.framework.apollo.adminservice.controller.InstanceConfigControllerTest;
Expand All @@ -16,7 +17,7 @@
@SuiteClasses({
AppControllerTest.class, ReleaseControllerTest.class, ItemSetControllerTest.class,
ControllerExceptionTest.class, ControllerIntegrationExceptionTest.class,
NamespaceLockTest.class, InstanceConfigControllerTest.class
NamespaceLockTest.class, InstanceConfigControllerTest.class, AppNamespaceControllerTest.class
})
public class AllTests {

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import com.ctrip.framework.apollo.biz.service.ClusterServiceTest;
import com.ctrip.framework.apollo.biz.service.InstanceServiceTest;
import com.ctrip.framework.apollo.biz.service.NamespaceBranchServiceTest;
import com.ctrip.framework.apollo.biz.service.PrivilegeServiceTest;
import com.ctrip.framework.apollo.biz.service.NamespacePublishInfoTest;
import com.ctrip.framework.apollo.biz.service.NamespaceServiceTest;
import com.ctrip.framework.apollo.biz.service.ReleaseCreationTest;
import com.ctrip.framework.apollo.biz.service.ReleaseServiceTest;
import com.ctrip.framework.apollo.biz.service.BizDBPropertySourceTest;
Expand All @@ -25,7 +26,6 @@
AppRepositoryTest.class,
AppNamespaceRepositoryTest.class,
AdminServiceTest.class,
PrivilegeServiceTest.class,
AdminServiceTransactionTest.class,
DatabaseMessageSenderTest.class,
BizDBPropertySourceTest.class,
Expand All @@ -36,7 +36,9 @@
InstanceServiceTest.class,
GrayReleaseRulesHolderTest.class,
NamespaceBranchServiceTest.class,
ReleaseCreationTest.class
ReleaseCreationTest.class,
NamespacePublishInfoTest.class,
NamespaceServiceTest.class
})
public class AllTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

/**
* @author lepdou 2016-11-28
*/
public class NamespaceServiceTest extends AbstractIntegrationTest {


Expand Down
Loading

0 comments on commit 64a609a

Please sign in to comment.