提交 64a609af 编写于 作者: J Jason Song 提交者: GitHub

Merge pull request #526 from lepdou/branch_operation_check_namespace

check namespace and branch exist when update gray rules
...@@ -56,7 +56,7 @@ public class AppController { ...@@ -56,7 +56,7 @@ public class AppController {
appService.delete(entity.getId(), operator); appService.delete(entity.getId(), operator);
} }
@RequestMapping("/apps") @RequestMapping(value = "/apps", method = RequestMethod.GET)
public List<AppDTO> find(@RequestParam(value = "name", required = false) String name, public List<AppDTO> find(@RequestParam(value = "name", required = false) String name,
Pageable pageable) { Pageable pageable) {
List<App> app = null; List<App> app = null;
...@@ -68,7 +68,7 @@ public class AppController { ...@@ -68,7 +68,7 @@ public class AppController {
return BeanUtils.batchTransform(AppDTO.class, app); return BeanUtils.batchTransform(AppDTO.class, app);
} }
@RequestMapping("/apps/{appId}") @RequestMapping(value = "/apps/{appId}", method = RequestMethod.GET)
public AppDTO get(@PathVariable("appId") String appId) { public AppDTO get(@PathVariable("appId") String appId) {
App app = appService.findOne(appId); App app = appService.findOne(appId);
if (app == null) { if (app == null) {
...@@ -77,7 +77,7 @@ public class AppController { ...@@ -77,7 +77,7 @@ public class AppController {
return BeanUtils.transfrom(AppDTO.class, app); 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) { public boolean isAppIdUnique(@PathVariable("appId") String appId) {
return appService.isAppIdUnique(appId); return appService.isAppIdUnique(appId);
} }
......
...@@ -58,13 +58,13 @@ public class ClusterController { ...@@ -58,13 +58,13 @@ public class ClusterController {
clusterService.delete(entity.getId(), operator); 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) { public List<ClusterDTO> find(@PathVariable("appId") String appId) {
List<Cluster> clusters = clusterService.findParentClusters(appId); List<Cluster> clusters = clusterService.findParentClusters(appId);
return BeanUtils.batchTransform(ClusterDTO.class, clusters); 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, public ClusterDTO get(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName) { @PathVariable("clusterName") String clusterName) {
Cluster cluster = clusterService.findOne(appId, clusterName); Cluster cluster = clusterService.findOne(appId, clusterName);
...@@ -74,7 +74,7 @@ public class ClusterController { ...@@ -74,7 +74,7 @@ public class ClusterController {
return BeanUtils.transfrom(ClusterDTO.class, cluster); 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, public boolean isAppIdUnique(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName) { @PathVariable("clusterName") String clusterName) {
return clusterService.isClusterNameUnique(appId, clusterName); return clusterService.isClusterNameUnique(appId, clusterName);
......
...@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
...@@ -20,7 +21,7 @@ public class CommitController { ...@@ -20,7 +21,7 @@ public class CommitController {
@Autowired @Autowired
private CommitService commitService; 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, public List<CommitDTO> find(@PathVariable String appId, @PathVariable String clusterName,
@PathVariable String namespaceName, Pageable pageable){ @PathVariable String namespaceName, Pageable pageable){
......
package com.ctrip.framework.apollo.adminservice.controller; package com.ctrip.framework.apollo.adminservice.controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping(path = "/") @RequestMapping(path = "/")
public class IndexController { public class IndexController {
@RequestMapping(path = "") @RequestMapping(path = "", method = RequestMethod.GET)
public String index() { public String index() {
return "apollo-adminservice"; return "apollo-adminservice";
} }
......
...@@ -125,14 +125,14 @@ public class ItemController { ...@@ -125,14 +125,14 @@ public class ItemController {
commitService.save(commit); 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, public List<ItemDTO> findItems(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) { @PathVariable("namespaceName") String namespaceName) {
return BeanUtils.batchTransform(ItemDTO.class, itemService.findItems(appId, clusterName, 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) { public ItemDTO get(@PathVariable("itemId") long itemId) {
Item item = itemService.findOne(itemId); Item item = itemService.findOne(itemId);
if (item == null) { if (item == null) {
...@@ -141,7 +141,7 @@ public class ItemController { ...@@ -141,7 +141,7 @@ public class ItemController {
return BeanUtils.transfrom(ItemDTO.class, item); 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, public ItemDTO get(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @PathVariable("key") String key) { @PathVariable("namespaceName") String namespaceName, @PathVariable("key") String key) {
......
...@@ -54,14 +54,14 @@ public class NamespaceController { ...@@ -54,14 +54,14 @@ public class NamespaceController {
namespaceService.deleteNamespace(entity, operator); 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, public List<NamespaceDTO> find(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName) { @PathVariable("clusterName") String clusterName) {
List<Namespace> groups = namespaceService.findNamespaces(appId, clusterName); List<Namespace> groups = namespaceService.findNamespaces(appId, clusterName);
return BeanUtils.batchTransform(NamespaceDTO.class, groups); return BeanUtils.batchTransform(NamespaceDTO.class, groups);
} }
@RequestMapping("/namespaces/{namespaceId}") @RequestMapping(value = "/namespaces/{namespaceId}", method = RequestMethod.GET)
public NamespaceDTO get(@PathVariable("namespaceId") Long namespaceId) { public NamespaceDTO get(@PathVariable("namespaceId") Long namespaceId) {
Namespace namespace = namespaceService.findOne(namespaceId); Namespace namespace = namespaceService.findOne(namespaceId);
if (namespace == null) if (namespace == null)
...@@ -69,7 +69,7 @@ public class NamespaceController { ...@@ -69,7 +69,7 @@ public class NamespaceController {
return BeanUtils.transfrom(NamespaceDTO.class, namespace); 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, public NamespaceDTO get(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) { @PathVariable("namespaceName") String namespaceName) {
...@@ -79,7 +79,8 @@ public class NamespaceController { ...@@ -79,7 +79,8 @@ public class NamespaceController {
return BeanUtils.transfrom(NamespaceDTO.class, namespace); 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, public NamespaceDTO findPublicNamespaceForAssociatedNamespace(@PathVariable String appId,
@PathVariable String clusterName, @PathVariable String clusterName,
@PathVariable String namespaceName) { @PathVariable String namespaceName) {
...@@ -95,7 +96,7 @@ public class NamespaceController { ...@@ -95,7 +96,7 @@ public class NamespaceController {
/** /**
* cluster -> cluster has not published namespaces? * 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) { public Map<String, Boolean> namespacePublishInfo(@PathVariable String appId) {
return namespaceService.namespacePublishInfo(appId); return namespaceService.namespacePublishInfo(appId);
} }
......
...@@ -12,6 +12,7 @@ import com.ctrip.framework.apollo.common.utils.BeanUtils; ...@@ -12,6 +12,7 @@ import com.ctrip.framework.apollo.common.utils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
...@@ -25,7 +26,7 @@ public class NamespaceLockController { ...@@ -25,7 +26,7 @@ public class NamespaceLockController {
@Autowired @Autowired
private BizConfig bizConfig; 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, public NamespaceLockDTO getNamespaceLockOwner(@PathVariable String appId, @PathVariable String clusterName,
@PathVariable String namespaceName) { @PathVariable String namespaceName) {
Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName); Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName);
......
package com.ctrip.framework.apollo.adminservice.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/privileges")
public class PrivilegeController {
}
...@@ -48,7 +48,7 @@ public class ReleaseController { ...@@ -48,7 +48,7 @@ public class ReleaseController {
private NamespaceBranchService namespaceBranchService; private NamespaceBranchService namespaceBranchService;
@RequestMapping("/releases/{releaseId}") @RequestMapping(value = "/releases/{releaseId}", method = RequestMethod.GET)
public ReleaseDTO get(@PathVariable("releaseId") long releaseId) { public ReleaseDTO get(@PathVariable("releaseId") long releaseId) {
Release release = releaseService.findOne(releaseId); Release release = releaseService.findOne(releaseId);
if (release == null) { if (release == null) {
...@@ -57,7 +57,7 @@ public class ReleaseController { ...@@ -57,7 +57,7 @@ public class ReleaseController {
return BeanUtils.transfrom(ReleaseDTO.class, release); return BeanUtils.transfrom(ReleaseDTO.class, release);
} }
@RequestMapping("/releases") @RequestMapping(value = "/releases", method = RequestMethod.GET)
public List<ReleaseDTO> findReleaseByIds(@RequestParam("releaseIds") String releaseIds) { public List<ReleaseDTO> findReleaseByIds(@RequestParam("releaseIds") String releaseIds) {
Set<Long> releaseIdSet = RELEASES_SPLITTER.splitToList(releaseIds).stream().map(Long::parseLong) Set<Long> releaseIdSet = RELEASES_SPLITTER.splitToList(releaseIds).stream().map(Long::parseLong)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
...@@ -67,7 +67,7 @@ public class ReleaseController { ...@@ -67,7 +67,7 @@ public class ReleaseController {
return BeanUtils.batchTransform(ReleaseDTO.class, releases); 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, public List<ReleaseDTO> findAllReleases(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @PathVariable("namespaceName") String namespaceName,
...@@ -77,7 +77,7 @@ public class ReleaseController { ...@@ -77,7 +77,7 @@ public class ReleaseController {
} }
@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, public List<ReleaseDTO> findActiveReleases(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @PathVariable("namespaceName") String namespaceName,
...@@ -86,7 +86,7 @@ public class ReleaseController { ...@@ -86,7 +86,7 @@ public class ReleaseController {
return BeanUtils.batchTransform(ReleaseDTO.class, releases); 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, public ReleaseDTO getLatest(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) { @PathVariable("namespaceName") String namespaceName) {
......
...@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.adminservice; ...@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.adminservice;
import com.ctrip.framework.apollo.adminservice.aop.NamespaceLockTest; import com.ctrip.framework.apollo.adminservice.aop.NamespaceLockTest;
import com.ctrip.framework.apollo.adminservice.controller.AppControllerTest; 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.ControllerExceptionTest;
import com.ctrip.framework.apollo.adminservice.controller.ControllerIntegrationExceptionTest; import com.ctrip.framework.apollo.adminservice.controller.ControllerIntegrationExceptionTest;
import com.ctrip.framework.apollo.adminservice.controller.InstanceConfigControllerTest; import com.ctrip.framework.apollo.adminservice.controller.InstanceConfigControllerTest;
...@@ -16,7 +17,7 @@ import org.junit.runners.Suite.SuiteClasses; ...@@ -16,7 +17,7 @@ import org.junit.runners.Suite.SuiteClasses;
@SuiteClasses({ @SuiteClasses({
AppControllerTest.class, ReleaseControllerTest.class, ItemSetControllerTest.class, AppControllerTest.class, ReleaseControllerTest.class, ItemSetControllerTest.class,
ControllerExceptionTest.class, ControllerIntegrationExceptionTest.class, ControllerExceptionTest.class, ControllerIntegrationExceptionTest.class,
NamespaceLockTest.class, InstanceConfigControllerTest.class NamespaceLockTest.class, InstanceConfigControllerTest.class, AppNamespaceControllerTest.class
}) })
public class AllTests { public class AllTests {
......
package com.ctrip.framework.apollo.biz.service;
import com.ctrip.framework.apollo.biz.entity.Audit;
import com.ctrip.framework.apollo.biz.entity.Privilege;
import com.ctrip.framework.apollo.biz.repository.PrivilegeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class PrivilegeService {
enum PrivilType {
EDIT, REVIEW, RELEASE
}
@Autowired
private PrivilegeRepository privilRepo;
@Autowired
private AuditService auditService;
@Transactional
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);
auditService.audit(Privilege.class.getSimpleName(), privil.getId(), Audit.OP.INSERT, name);
}
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);
}
@Transactional
public void removePrivilege(long namespaceId, String name, PrivilType privilType) {
Privilege privil =
privilRepo.findByNamespaceIdAndNameAndPrivilType(namespaceId, name, privilType.name());
if (privil != null) {
privilRepo.delete(privil);
auditService.audit(Privilege.class.getSimpleName(), privil.getId(), Audit.OP.DELETE, name);
}
}
}
...@@ -10,7 +10,8 @@ import com.ctrip.framework.apollo.biz.service.AdminServiceTransactionTest; ...@@ -10,7 +10,8 @@ import com.ctrip.framework.apollo.biz.service.AdminServiceTransactionTest;
import com.ctrip.framework.apollo.biz.service.ClusterServiceTest; import com.ctrip.framework.apollo.biz.service.ClusterServiceTest;
import com.ctrip.framework.apollo.biz.service.InstanceServiceTest; import com.ctrip.framework.apollo.biz.service.InstanceServiceTest;
import com.ctrip.framework.apollo.biz.service.NamespaceBranchServiceTest; 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.ReleaseCreationTest;
import com.ctrip.framework.apollo.biz.service.ReleaseServiceTest; import com.ctrip.framework.apollo.biz.service.ReleaseServiceTest;
import com.ctrip.framework.apollo.biz.service.BizDBPropertySourceTest; import com.ctrip.framework.apollo.biz.service.BizDBPropertySourceTest;
...@@ -25,7 +26,6 @@ import org.junit.runners.Suite.SuiteClasses; ...@@ -25,7 +26,6 @@ import org.junit.runners.Suite.SuiteClasses;
AppRepositoryTest.class, AppRepositoryTest.class,
AppNamespaceRepositoryTest.class, AppNamespaceRepositoryTest.class,
AdminServiceTest.class, AdminServiceTest.class,
PrivilegeServiceTest.class,
AdminServiceTransactionTest.class, AdminServiceTransactionTest.class,
DatabaseMessageSenderTest.class, DatabaseMessageSenderTest.class,
BizDBPropertySourceTest.class, BizDBPropertySourceTest.class,
...@@ -36,7 +36,9 @@ import org.junit.runners.Suite.SuiteClasses; ...@@ -36,7 +36,9 @@ import org.junit.runners.Suite.SuiteClasses;
InstanceServiceTest.class, InstanceServiceTest.class,
GrayReleaseRulesHolderTest.class, GrayReleaseRulesHolderTest.class,
NamespaceBranchServiceTest.class, NamespaceBranchServiceTest.class,
ReleaseCreationTest.class ReleaseCreationTest.class,
NamespacePublishInfoTest.class,
NamespaceServiceTest.class
}) })
public class AllTests { public class AllTests {
......
...@@ -24,9 +24,6 @@ import static org.junit.Assert.assertNotNull; ...@@ -24,9 +24,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/**
* @author lepdou 2016-11-28
*/
public class NamespaceServiceTest extends AbstractIntegrationTest { public class NamespaceServiceTest extends AbstractIntegrationTest {
......
package com.ctrip.framework.apollo.biz.service;
import com.ctrip.framework.apollo.biz.AbstractIntegrationTest;
import com.ctrip.framework.apollo.biz.entity.Cluster;
import com.ctrip.framework.apollo.biz.entity.Namespace;
import com.ctrip.framework.apollo.biz.entity.Privilege;
import com.ctrip.framework.apollo.common.entity.App;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.List;
public class PrivilegeServiceTest extends AbstractIntegrationTest {
@Autowired
private AdminService adminService;
@Autowired
private ClusterService clusterService;
@Autowired
private NamespaceService namespaceService;
@Autowired
private PrivilegeService privilService;
@Test
public void testAddAndRemovePrivilege() {
App app = new App();
app.setAppId(String.valueOf(System.currentTimeMillis()));
app.setName("new app " + System.currentTimeMillis());
String owner = "owner " + System.currentTimeMillis();
app.setOwnerName(owner);
app.setOwnerEmail("owner " + System.currentTimeMillis() + "@ctrip.com");
app.setDataChangeCreatedBy(owner);
app.setDataChangeLastModifiedBy(owner);
app.setDataChangeCreatedTime(new Date());
App newApp = adminService.createNewApp(app);
List<Cluster> clusters = clusterService.findParentClusters(newApp.getAppId());
List<Namespace> namespaces =
namespaceService.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 app = new App();
app.setAppId(String.valueOf(System.currentTimeMillis()));
app.setName("new app " + System.currentTimeMillis());
String owner = "owner " + System.currentTimeMillis();
app.setOwnerName(owner);
app.setOwnerEmail("owner " + System.currentTimeMillis() + "@ctrip.com");
app.setDataChangeCreatedBy(owner);
app.setDataChangeLastModifiedBy(owner);
app.setDataChangeCreatedTime(new Date());
App newApp = adminService.createNewApp(app);
List<Cluster> clusters = clusterService.findParentClusters(newApp.getAppId());
List<Namespace> namespaces =
namespaceService.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));
}
}
...@@ -12,7 +12,7 @@ import com.ctrip.framework.apollo.openapi.entity.ConsumerToken; ...@@ -12,7 +12,7 @@ import com.ctrip.framework.apollo.openapi.entity.ConsumerToken;
import com.ctrip.framework.apollo.openapi.repository.ConsumerAuditRepository; import com.ctrip.framework.apollo.openapi.repository.ConsumerAuditRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerRepository; import com.ctrip.framework.apollo.openapi.repository.ConsumerRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerTokenRepository; import com.ctrip.framework.apollo.openapi.repository.ConsumerTokenRepository;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import org.apache.commons.lang.time.FastDateFormat; import org.apache.commons.lang.time.FastDateFormat;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
...@@ -4,12 +4,13 @@ import com.ctrip.framework.apollo.common.dto.ClusterDTO; ...@@ -4,12 +4,13 @@ import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.openapi.dto.OpenEnvClusterDTO; import com.ctrip.framework.apollo.openapi.dto.OpenEnvClusterDTO;
import com.ctrip.framework.apollo.portal.components.PortalSettings; import com.ctrip.framework.apollo.portal.component.PortalSettings;
import com.ctrip.framework.apollo.portal.service.ClusterService; import com.ctrip.framework.apollo.portal.service.ClusterService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -24,7 +25,7 @@ public class AppController { ...@@ -24,7 +25,7 @@ public class AppController {
@Autowired @Autowired
private ClusterService clusterService; private ClusterService clusterService;
@RequestMapping("/apps/{appId}/envclusters") @RequestMapping(value = "/apps/{appId}/envclusters", method = RequestMethod.GET)
public List<OpenEnvClusterDTO> loadEnvClusterInfo(@PathVariable String appId){ public List<OpenEnvClusterDTO> loadEnvClusterInfo(@PathVariable String appId){
List<OpenEnvClusterDTO> envClusters = new LinkedList<>(); List<OpenEnvClusterDTO> envClusters = new LinkedList<>();
......
package com.ctrip.framework.apollo.portal.api; package com.ctrip.framework.apollo.portal.api;
import com.ctrip.framework.apollo.portal.components.RetryableRestTemplate; import com.ctrip.framework.apollo.portal.component.RetryableRestTemplate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
package com.ctrip.framework.apollo.portal.components; package com.ctrip.framework.apollo.portal.component;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
......
package com.ctrip.framework.apollo.portal.components; package com.ctrip.framework.apollo.portal.component;
import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
......
package com.ctrip.framework.apollo.portal.components; package com.ctrip.framework.apollo.portal.component;
import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.portal.constant.PermissionType; import com.ctrip.framework.apollo.portal.constant.PermissionType;
......
package com.ctrip.framework.apollo.portal.components; package com.ctrip.framework.apollo.portal.component;
import com.ctrip.framework.apollo.core.MetaDomainConsts; import com.ctrip.framework.apollo.core.MetaDomainConsts;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory; import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
......
package com.ctrip.framework.apollo.portal.components; package com.ctrip.framework.apollo.portal.component;
import com.google.common.io.BaseEncoding; import com.google.common.io.BaseEncoding;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import org.apache.http.Header; import org.apache.http.Header;
import org.apache.http.auth.AuthScope; import org.apache.http.auth.AuthScope;
......
package com.ctrip.framework.apollo.portal.components; package com.ctrip.framework.apollo.portal.component;
import com.ctrip.framework.apollo.common.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
import com.ctrip.framework.apollo.core.MetaDomainConsts; import com.ctrip.framework.apollo.core.MetaDomainConsts;
......
package com.ctrip.framework.apollo.portal.components.config; package com.ctrip.framework.apollo.portal.component.config;
import com.google.common.base.Strings; import com.google.common.base.Strings;
...@@ -15,7 +15,6 @@ import com.ctrip.framework.apollo.portal.service.PortalDBPropertySource; ...@@ -15,7 +15,6 @@ import com.ctrip.framework.apollo.portal.service.PortalDBPropertySource;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.Collections; import java.util.Collections;
......
package com.ctrip.framework.apollo.portal.components.emailbuilder; package com.ctrip.framework.apollo.portal.component.emailbuilder;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
...@@ -9,7 +9,7 @@ import com.ctrip.framework.apollo.common.dto.ReleaseDTO; ...@@ -9,7 +9,7 @@ import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.constant.RoleType; import com.ctrip.framework.apollo.portal.constant.RoleType;
import com.ctrip.framework.apollo.portal.entity.bo.Email; import com.ctrip.framework.apollo.portal.entity.bo.Email;
import com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO; import com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO;
......
package com.ctrip.framework.apollo.portal.components.emailbuilder; package com.ctrip.framework.apollo.portal.component.emailbuilder;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.gson.Gson; import com.google.gson.Gson;
......
package com.ctrip.framework.apollo.portal.components.emailbuilder; package com.ctrip.framework.apollo.portal.component.emailbuilder;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
......
package com.ctrip.framework.apollo.portal.components.emailbuilder; package com.ctrip.framework.apollo.portal.component.emailbuilder;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
......
package com.ctrip.framework.apollo.portal.components.emailbuilder; package com.ctrip.framework.apollo.portal.component.emailbuilder;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
......
package com.ctrip.framework.apollo.portal.components.txtresolver; package com.ctrip.framework.apollo.portal.component.txtresolver;
import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
......
package com.ctrip.framework.apollo.portal.components.txtresolver; package com.ctrip.framework.apollo.portal.component.txtresolver;
import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
......
package com.ctrip.framework.apollo.portal.components.txtresolver; package com.ctrip.framework.apollo.portal.component.txtresolver;
import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
......
...@@ -10,7 +10,7 @@ import com.ctrip.framework.apollo.common.http.RichResponseEntity; ...@@ -10,7 +10,7 @@ import com.ctrip.framework.apollo.common.http.RichResponseEntity;
import com.ctrip.framework.apollo.common.utils.InputValidator; import com.ctrip.framework.apollo.common.utils.InputValidator;
import com.ctrip.framework.apollo.common.utils.RequestPrecondition; import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.components.PortalSettings; import com.ctrip.framework.apollo.portal.component.PortalSettings;
import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
import com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo; import com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo;
import com.ctrip.framework.apollo.portal.listener.AppCreationEvent; import com.ctrip.framework.apollo.portal.listener.AppCreationEvent;
...@@ -50,7 +50,7 @@ public class AppController { ...@@ -50,7 +50,7 @@ public class AppController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@RequestMapping("") @RequestMapping(value = "", method = RequestMethod.GET)
public List<App> findApps(@RequestParam(value = "appIds", required = false) String appIds) { public List<App> findApps(@RequestParam(value = "appIds", required = false) String appIds) {
if (StringUtils.isEmpty(appIds)){ if (StringUtils.isEmpty(appIds)){
return appService.findAll(); return appService.findAll();
...@@ -60,12 +60,12 @@ public class AppController { ...@@ -60,12 +60,12 @@ public class AppController {
} }
@RequestMapping("/by-owner") @RequestMapping(value = "/by-owner", method = RequestMethod.GET)
public List<App> findAppsByOwner(@RequestParam("owner") String owner, Pageable page){ public List<App> findAppsByOwner(@RequestParam("owner") String owner, Pageable page){
return appService.findByOwnerName(owner, page); return appService.findByOwnerName(owner, page);
} }
@RequestMapping("/{appId}/navtree") @RequestMapping(value = "/{appId}/navtree", method = RequestMethod.GET)
public MultiResponseEntity<EnvClusterInfo> nav(@PathVariable String appId) { public MultiResponseEntity<EnvClusterInfo> nav(@PathVariable String appId) {
MultiResponseEntity<EnvClusterInfo> response = MultiResponseEntity.ok(); MultiResponseEntity<EnvClusterInfo> response = MultiResponseEntity.ok();
...@@ -130,7 +130,7 @@ public class AppController { ...@@ -130,7 +130,7 @@ public class AppController {
return appService.load(appId); return appService.load(appId);
} }
@RequestMapping(value = "/{appId}/miss_envs") @RequestMapping(value = "/{appId}/miss_envs", method = RequestMethod.GET)
public MultiResponseEntity<Env> findMissEnvs(@PathVariable String appId) { public MultiResponseEntity<Env> findMissEnvs(@PathVariable String appId) {
MultiResponseEntity<Env> response = MultiResponseEntity.ok(); MultiResponseEntity<Env> response = MultiResponseEntity.ok();
......
...@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.portal.service.CommitService; ...@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.portal.service.CommitService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -20,7 +21,7 @@ public class CommitController { ...@@ -20,7 +21,7 @@ public class CommitController {
@Autowired @Autowired
private CommitService commitService; private CommitService commitService;
@RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits") @RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits", method = RequestMethod.GET)
public List<CommitDTO> find(@PathVariable String appId, @PathVariable String env, public List<CommitDTO> find(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String clusterName, @PathVariable String namespaceName,
@RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size) { @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size) {
......
package com.ctrip.framework.apollo.portal.controller; package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.components.PortalSettings; import com.ctrip.framework.apollo.portal.component.PortalSettings;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
......
...@@ -27,7 +27,7 @@ public class FavoriteController { ...@@ -27,7 +27,7 @@ public class FavoriteController {
} }
@RequestMapping("/favorites") @RequestMapping(value = "/favorites", method = RequestMethod.GET)
public List<Favorite> findFavorites(@RequestParam(value = "userId", required = false) String userId, public List<Favorite> findFavorites(@RequestParam(value = "userId", required = false) String userId,
@RequestParam(value = "appId", required = false) String appId, @RequestParam(value = "appId", required = false) String appId,
Pageable page) { Pageable page) {
......
...@@ -14,6 +14,7 @@ import org.springframework.http.ResponseEntity; ...@@ -14,6 +14,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -30,7 +31,7 @@ public class InstanceController { ...@@ -30,7 +31,7 @@ public class InstanceController {
@Autowired @Autowired
private InstanceService instanceService; private InstanceService instanceService;
@RequestMapping("/envs/{env}/instances/by-release") @RequestMapping(value = "/envs/{env}/instances/by-release", method = RequestMethod.GET)
public PageDTO<InstanceDTO> getByRelease(@PathVariable String env, @RequestParam long releaseId, public PageDTO<InstanceDTO> getByRelease(@PathVariable String env, @RequestParam long releaseId,
@RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "20") int size) { @RequestParam(defaultValue = "20") int size) {
...@@ -38,7 +39,7 @@ public class InstanceController { ...@@ -38,7 +39,7 @@ public class InstanceController {
return instanceService.getByRelease(Env.valueOf(env), releaseId, page, size); return instanceService.getByRelease(Env.valueOf(env), releaseId, page, size);
} }
@RequestMapping("/envs/{env}/instances/by-namespace") @RequestMapping(value = "/envs/{env}/instances/by-namespace", method = RequestMethod.GET)
public PageDTO<InstanceDTO> getByNamespace(@PathVariable String env, @RequestParam String appId, public PageDTO<InstanceDTO> getByNamespace(@PathVariable String env, @RequestParam String appId,
@RequestParam String clusterName, @RequestParam String namespaceName, @RequestParam String clusterName, @RequestParam String namespaceName,
@RequestParam(required = false) String instanceAppId, @RequestParam(required = false) String instanceAppId,
...@@ -48,7 +49,7 @@ public class InstanceController { ...@@ -48,7 +49,7 @@ public class InstanceController {
return instanceService.getByNamespace(Env.valueOf(env), appId, clusterName, namespaceName, instanceAppId, page, size); return instanceService.getByNamespace(Env.valueOf(env), appId, clusterName, namespaceName, instanceAppId, page, size);
} }
@RequestMapping("/envs/{env}/instances/by-namespace/count") @RequestMapping(value = "/envs/{env}/instances/by-namespace/count", method = RequestMethod.GET)
public ResponseEntity<Number> getInstanceCountByNamespace(@PathVariable String env, @RequestParam String appId, public ResponseEntity<Number> getInstanceCountByNamespace(@PathVariable String env, @RequestParam String appId,
@RequestParam String clusterName, @RequestParam String clusterName,
@RequestParam String namespaceName) { @RequestParam String namespaceName) {
...@@ -57,7 +58,7 @@ public class InstanceController { ...@@ -57,7 +58,7 @@ public class InstanceController {
return ResponseEntity.ok(new Number(count)); return ResponseEntity.ok(new Number(count));
} }
@RequestMapping("/envs/{env}/instances/by-namespace-and-releases-not-in") @RequestMapping(value = "/envs/{env}/instances/by-namespace-and-releases-not-in", method = RequestMethod.GET)
public List<InstanceDTO> getByReleasesNotIn(@PathVariable String env, @RequestParam String appId, public List<InstanceDTO> getByReleasesNotIn(@PathVariable String env, @RequestParam String appId,
@RequestParam String clusterName, @RequestParam String namespaceName, @RequestParam String clusterName, @RequestParam String namespaceName,
@RequestParam String releaseIds) { @RequestParam String releaseIds) {
......
...@@ -96,7 +96,7 @@ public class ItemController { ...@@ -96,7 +96,7 @@ public class ItemController {
} }
@RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items") @RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items", method = RequestMethod.GET)
public List<ItemDTO> findItems(@PathVariable String appId, @PathVariable String env, public List<ItemDTO> findItems(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String clusterName, @PathVariable String namespaceName,
@RequestParam(defaultValue = "lineNum") String orderBy) { @RequestParam(defaultValue = "lineNum") String orderBy) {
...@@ -116,7 +116,7 @@ public class ItemController { ...@@ -116,7 +116,7 @@ public class ItemController {
return items; return items;
} }
@RequestMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/items") @RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/items", method = RequestMethod.GET)
public List<ItemDTO> findBranchItems(@PathVariable("appId") String appId, @PathVariable String env, public List<ItemDTO> findBranchItems(@PathVariable("appId") String appId, @PathVariable String env,
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @PathVariable("namespaceName") String namespaceName,
......
...@@ -5,8 +5,8 @@ import com.ctrip.framework.apollo.common.dto.NamespaceDTO; ...@@ -5,8 +5,8 @@ import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import com.ctrip.framework.apollo.common.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.components.PermissionValidator; import com.ctrip.framework.apollo.portal.component.PermissionValidator;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel; import com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel;
import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO; import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO;
import com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent; import com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent;
...@@ -38,7 +38,7 @@ public class NamespaceBranchController { ...@@ -38,7 +38,7 @@ public class NamespaceBranchController {
@Autowired @Autowired
private PortalConfig portalConfig; private PortalConfig portalConfig;
@RequestMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches") @RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches", method = RequestMethod.GET)
public NamespaceBO findBranch(@PathVariable String appId, public NamespaceBO findBranch(@PathVariable String appId,
@PathVariable String env, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String clusterName,
......
...@@ -62,26 +62,27 @@ public class NamespaceController { ...@@ -62,26 +62,27 @@ public class NamespaceController {
@Autowired @Autowired
private RolePermissionService rolePermissionService; private RolePermissionService rolePermissionService;
@RequestMapping("/appnamespaces/public") @RequestMapping(value = "/appnamespaces/public", method = RequestMethod.GET)
public List<AppNamespace> findPublicAppNamespaces() { public List<AppNamespace> findPublicAppNamespaces() {
return appNamespaceService.findPublicAppNamespaces(); return appNamespaceService.findPublicAppNamespaces();
} }
@RequestMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces") @RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces", method = RequestMethod.GET)
public List<NamespaceBO> findNamespaces(@PathVariable String appId, @PathVariable String env, public List<NamespaceBO> findNamespaces(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName) { @PathVariable String clusterName) {
return namespaceService.findNamespaceBOs(appId, Env.valueOf(env), clusterName); return namespaceService.findNamespaceBOs(appId, Env.valueOf(env), clusterName);
} }
@RequestMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName:.+}") @RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName:.+}", method = RequestMethod.GET)
public NamespaceBO findNamespace(@PathVariable String appId, @PathVariable String env, public NamespaceBO findNamespace(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName) { @PathVariable String clusterName, @PathVariable String namespaceName) {
return namespaceService.loadNamespaceBO(appId, Env.valueOf(env), clusterName, namespaceName); return namespaceService.loadNamespaceBO(appId, Env.valueOf(env), clusterName, namespaceName);
} }
@RequestMapping("/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace") @RequestMapping(value = "/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace",
method = RequestMethod.GET)
public NamespaceBO findPublicNamespaceForAssociatedNamespace(@PathVariable String env, public NamespaceBO findPublicNamespaceForAssociatedNamespace(@PathVariable String env,
@PathVariable String appId, @PathVariable String appId,
@PathVariable String namespaceName, @PathVariable String namespaceName,
...@@ -170,7 +171,6 @@ public class NamespaceController { ...@@ -170,7 +171,6 @@ public class NamespaceController {
return createdAppNamespace; return createdAppNamespace;
} }
/** /**
* env -> cluster -> cluster has not published namespace? * env -> cluster -> cluster has not published namespace?
* Example: * Example:
...@@ -178,7 +178,7 @@ public class NamespaceController { ...@@ -178,7 +178,7 @@ public class NamespaceController {
* default -> true (default cluster has not published namespace) * default -> true (default cluster has not published namespace)
* customCluster -> false (customCluster cluster's all namespaces had published) * customCluster -> false (customCluster cluster's all namespaces had published)
*/ */
@RequestMapping("/apps/{appId}/namespaces/publish_info") @RequestMapping(value = "/apps/{appId}/namespaces/publish_info", method = RequestMethod.GET)
public Map<String, Map<String, Boolean>> getNamespacesPublishInfo(@PathVariable String appId) { public Map<String, Map<String, Boolean>> getNamespacesPublishInfo(@PathVariable String appId) {
return namespaceService.getNamespacesPublishInfo(appId); return namespaceService.getNamespacesPublishInfo(appId);
} }
......
...@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.portal.service.NamespaceLockService; ...@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.portal.service.NamespaceLockService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
...@@ -17,14 +18,14 @@ public class NamespaceLockController { ...@@ -17,14 +18,14 @@ public class NamespaceLockController {
private NamespaceLockService namespaceLockService; private NamespaceLockService namespaceLockService;
@Deprecated @Deprecated
@RequestMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock") @RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock", method = RequestMethod.GET)
public NamespaceLockDTO getNamespaceLock(@PathVariable String appId, @PathVariable String env, public NamespaceLockDTO getNamespaceLock(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName) { @PathVariable String clusterName, @PathVariable String namespaceName) {
return namespaceLockService.getNamespaceLock(appId, Env.valueOf(env), clusterName, namespaceName); return namespaceLockService.getNamespaceLock(appId, Env.valueOf(env), clusterName, namespaceName);
} }
@RequestMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock-info") @RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock-info", method = RequestMethod.GET)
public LockInfo getNamespaceLockInfo(@PathVariable String appId, @PathVariable String env, public LockInfo getNamespaceLockInfo(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName) { @PathVariable String clusterName, @PathVariable String namespaceName) {
......
package com.ctrip.framework.apollo.portal.controller; package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.vo.Organization; import com.ctrip.framework.apollo.portal.entity.vo.Organization;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
...@@ -38,7 +38,7 @@ public class PermissionController { ...@@ -38,7 +38,7 @@ public class PermissionController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@RequestMapping("/apps/{appId}/permissions/{permissionType}") @RequestMapping(value = "/apps/{appId}/permissions/{permissionType}", method = RequestMethod.GET)
public ResponseEntity<PermissionCondition> hasPermission(@PathVariable String appId, @PathVariable String permissionType) { public ResponseEntity<PermissionCondition> hasPermission(@PathVariable String appId, @PathVariable String permissionType) {
PermissionCondition permissionCondition = new PermissionCondition(); PermissionCondition permissionCondition = new PermissionCondition();
...@@ -48,7 +48,7 @@ public class PermissionController { ...@@ -48,7 +48,7 @@ public class PermissionController {
return ResponseEntity.ok().body(permissionCondition); return ResponseEntity.ok().body(permissionCondition);
} }
@RequestMapping("/apps/{appId}/namespaces/{namespaceName}/permissions/{permissionType}") @RequestMapping(value = "/apps/{appId}/namespaces/{namespaceName}/permissions/{permissionType}", method = RequestMethod.GET)
public ResponseEntity<PermissionCondition> hasPermission(@PathVariable String appId, @PathVariable String namespaceName, public ResponseEntity<PermissionCondition> hasPermission(@PathVariable String appId, @PathVariable String namespaceName,
@PathVariable String permissionType) { @PathVariable String permissionType) {
PermissionCondition permissionCondition = new PermissionCondition(); PermissionCondition permissionCondition = new PermissionCondition();
...@@ -60,7 +60,7 @@ public class PermissionController { ...@@ -60,7 +60,7 @@ public class PermissionController {
return ResponseEntity.ok().body(permissionCondition); return ResponseEntity.ok().body(permissionCondition);
} }
@RequestMapping("/permissions/root") @RequestMapping(value = "/permissions/root", method = RequestMethod.GET)
public ResponseEntity<PermissionCondition> hasRootPermission() { public ResponseEntity<PermissionCondition> hasRootPermission() {
PermissionCondition permissionCondition = new PermissionCondition(); PermissionCondition permissionCondition = new PermissionCondition();
...@@ -70,7 +70,7 @@ public class PermissionController { ...@@ -70,7 +70,7 @@ public class PermissionController {
} }
@RequestMapping("/apps/{appId}/namespaces/{namespaceName}/role_users") @RequestMapping(value = "/apps/{appId}/namespaces/{namespaceName}/role_users", method = RequestMethod.GET)
public NamespaceRolesAssignedUsers getNamespaceRoles(@PathVariable String appId, @PathVariable String namespaceName) { public NamespaceRolesAssignedUsers getNamespaceRoles(@PathVariable String appId, @PathVariable String namespaceName) {
NamespaceRolesAssignedUsers assignedUsers = new NamespaceRolesAssignedUsers(); NamespaceRolesAssignedUsers assignedUsers = new NamespaceRolesAssignedUsers();
...@@ -121,7 +121,7 @@ public class PermissionController { ...@@ -121,7 +121,7 @@ public class PermissionController {
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@RequestMapping(value = "/apps/{appId}/role_users") @RequestMapping(value = "/apps/{appId}/role_users", method = RequestMethod.GET)
public AppRolesAssignedUsers getAppRoles(@PathVariable String appId) { public AppRolesAssignedUsers getAppRoles(@PathVariable String appId) {
AppRolesAssignedUsers users = new AppRolesAssignedUsers(); AppRolesAssignedUsers users = new AppRolesAssignedUsers();
users.setAppId(appId); users.setAppId(appId);
......
...@@ -4,7 +4,7 @@ import com.ctrip.framework.apollo.common.dto.ReleaseDTO; ...@@ -4,7 +4,7 @@ import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.common.utils.RequestPrecondition; import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel; import com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel;
import com.ctrip.framework.apollo.portal.entity.vo.ReleaseCompareResult; import com.ctrip.framework.apollo.portal.entity.vo.ReleaseCompareResult;
import com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO; import com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO;
...@@ -100,7 +100,7 @@ public class ReleaseController { ...@@ -100,7 +100,7 @@ public class ReleaseController {
} }
@RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all") @RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all", method = RequestMethod.GET)
public List<ReleaseBO> findAllReleases(@PathVariable String appId, public List<ReleaseBO> findAllReleases(@PathVariable String appId,
@PathVariable String env, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String clusterName,
...@@ -114,7 +114,7 @@ public class ReleaseController { ...@@ -114,7 +114,7 @@ public class ReleaseController {
return releaseService.findAllReleases(appId, Env.valueOf(env), clusterName, namespaceName, page, size); return releaseService.findAllReleases(appId, Env.valueOf(env), clusterName, namespaceName, page, size);
} }
@RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/active") @RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/active", method = RequestMethod.GET)
public List<ReleaseDTO> findActiveReleases(@PathVariable String appId, public List<ReleaseDTO> findActiveReleases(@PathVariable String appId,
@PathVariable String env, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String clusterName,
...@@ -128,7 +128,7 @@ public class ReleaseController { ...@@ -128,7 +128,7 @@ public class ReleaseController {
return releaseService.findActiveReleases(appId, Env.valueOf(env), clusterName, namespaceName, page, size); return releaseService.findActiveReleases(appId, Env.valueOf(env), clusterName, namespaceName, page, size);
} }
@RequestMapping(value = "/envs/{env}/releases/compare") @RequestMapping(value = "/envs/{env}/releases/compare", method = RequestMethod.GET)
public ReleaseCompareResult compareRelease(@PathVariable String env, public ReleaseCompareResult compareRelease(@PathVariable String env,
@RequestParam long baseReleaseId, @RequestParam long baseReleaseId,
@RequestParam long toCompareReleaseId) { @RequestParam long toCompareReleaseId) {
......
...@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.portal.spi.UserService; ...@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.portal.spi.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -28,24 +29,24 @@ public class UserInfoController { ...@@ -28,24 +29,24 @@ public class UserInfoController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@RequestMapping("/user") @RequestMapping(value = "/user", method = RequestMethod.GET)
public UserInfo getCurrentUserName() { public UserInfo getCurrentUserName() {
return userInfoHolder.getUser(); return userInfoHolder.getUser();
} }
@RequestMapping("/user/logout") @RequestMapping(value = "/user/logout", method = RequestMethod.GET)
public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException { public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
logoutHandler.logout(request, response); logoutHandler.logout(request, response);
} }
@RequestMapping("/users") @RequestMapping(value = "/users", method = RequestMethod.GET)
public List<UserInfo> searchUsersByKeyword(@RequestParam(value = "keyword") String keyword, public List<UserInfo> searchUsersByKeyword(@RequestParam(value = "keyword") String keyword,
@RequestParam(value = "offset", defaultValue = "0") int offset, @RequestParam(value = "offset", defaultValue = "0") int offset,
@RequestParam(value = "limit", defaultValue = "10") int limit) { @RequestParam(value = "limit", defaultValue = "10") int limit) {
return userService.searchUsers(keyword, offset, limit); return userService.searchUsers(keyword, offset, limit);
} }
@RequestMapping("/users/{userId}") @RequestMapping(value = "/users/{userId}", method = RequestMethod.GET)
public UserInfo getUserByUserId(@PathVariable String userId) { public UserInfo getUserByUserId(@PathVariable String userId) {
return userService.findByUserId(userId); return userService.findByUserId(userId);
} }
......
...@@ -2,11 +2,11 @@ package com.ctrip.framework.apollo.portal.listener; ...@@ -2,11 +2,11 @@ package com.ctrip.framework.apollo.portal.listener;
import com.ctrip.framework.apollo.common.constants.ReleaseOperation; import com.ctrip.framework.apollo.common.constants.ReleaseOperation;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.components.emailbuilder.GrayPublishEmailBuilder; import com.ctrip.framework.apollo.portal.component.emailbuilder.GrayPublishEmailBuilder;
import com.ctrip.framework.apollo.portal.components.emailbuilder.MergeEmailBuilder; import com.ctrip.framework.apollo.portal.component.emailbuilder.MergeEmailBuilder;
import com.ctrip.framework.apollo.portal.components.emailbuilder.NormalPublishEmailBuilder; import com.ctrip.framework.apollo.portal.component.emailbuilder.NormalPublishEmailBuilder;
import com.ctrip.framework.apollo.portal.components.emailbuilder.RollbackEmailBuilder; import com.ctrip.framework.apollo.portal.component.emailbuilder.RollbackEmailBuilder;
import com.ctrip.framework.apollo.portal.entity.bo.Email; import com.ctrip.framework.apollo.portal.entity.bo.Email;
import com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO; import com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO;
import com.ctrip.framework.apollo.portal.service.ReleaseHistoryService; import com.ctrip.framework.apollo.portal.service.ReleaseHistoryService;
......
...@@ -5,7 +5,7 @@ import com.ctrip.framework.apollo.common.dto.AppNamespaceDTO; ...@@ -5,7 +5,7 @@ import com.ctrip.framework.apollo.common.dto.AppNamespaceDTO;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.components.PortalSettings; import com.ctrip.framework.apollo.portal.component.PortalSettings;
import com.ctrip.framework.apollo.tracer.Tracer; import com.ctrip.framework.apollo.tracer.Tracer;
import org.slf4j.Logger; import org.slf4j.Logger;
......
...@@ -10,7 +10,7 @@ import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; ...@@ -10,7 +10,7 @@ import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.components.txtresolver.ConfigTextResolver; import com.ctrip.framework.apollo.portal.component.txtresolver.ConfigTextResolver;
import com.ctrip.framework.apollo.portal.constant.CatEventType; import com.ctrip.framework.apollo.portal.constant.CatEventType;
import com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel; import com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel;
import com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs; import com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs;
......
...@@ -8,8 +8,8 @@ import com.ctrip.framework.apollo.common.dto.ReleaseDTO; ...@@ -8,8 +8,8 @@ import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import com.ctrip.framework.apollo.common.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.components.ItemsComparator; import com.ctrip.framework.apollo.portal.component.ItemsComparator;
import com.ctrip.framework.apollo.portal.components.PermissionValidator; import com.ctrip.framework.apollo.portal.component.PermissionValidator;
import com.ctrip.framework.apollo.portal.constant.CatEventType; import com.ctrip.framework.apollo.portal.constant.CatEventType;
import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO; import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
......
...@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.portal.service; ...@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.common.dto.NamespaceLockDTO; import com.ctrip.framework.apollo.common.dto.NamespaceLockDTO;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.vo.LockInfo; import com.ctrip.framework.apollo.portal.entity.vo.LockInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
package com.ctrip.framework.apollo.portal.service; package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -15,7 +15,7 @@ import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; ...@@ -15,7 +15,7 @@ import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.components.PortalSettings; import com.ctrip.framework.apollo.portal.component.PortalSettings;
import com.ctrip.framework.apollo.portal.constant.CatEventType; import com.ctrip.framework.apollo.portal.constant.CatEventType;
import com.ctrip.framework.apollo.portal.entity.bo.ItemBO; import com.ctrip.framework.apollo.portal.entity.bo.ItemBO;
import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO; import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO;
......
...@@ -6,7 +6,7 @@ import com.google.common.collect.HashMultimap; ...@@ -6,7 +6,7 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.po.Permission; import com.ctrip.framework.apollo.portal.entity.po.Permission;
import com.ctrip.framework.apollo.portal.entity.po.Role; import com.ctrip.framework.apollo.portal.entity.po.Role;
import com.ctrip.framework.apollo.portal.entity.po.RolePermission; import com.ctrip.framework.apollo.portal.entity.po.RolePermission;
......
...@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.portal.spi.configuration; ...@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.portal.spi.configuration;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.spi.LogoutHandler; import com.ctrip.framework.apollo.portal.spi.LogoutHandler;
import com.ctrip.framework.apollo.portal.spi.SsoHeartbeatHandler; import com.ctrip.framework.apollo.portal.spi.SsoHeartbeatHandler;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
......
package com.ctrip.framework.apollo.portal.spi.ctrip; package com.ctrip.framework.apollo.portal.spi.ctrip;
import com.ctrip.framework.apollo.common.customize.LoggingCustomizer; import com.ctrip.framework.apollo.common.customize.LoggingCustomizer;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
......
package com.ctrip.framework.apollo.portal.spi.ctrip; package com.ctrip.framework.apollo.portal.spi.ctrip;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.bo.Email; import com.ctrip.framework.apollo.portal.entity.bo.Email;
import com.ctrip.framework.apollo.tracer.Tracer; import com.ctrip.framework.apollo.tracer.Tracer;
...@@ -8,7 +8,6 @@ import org.apache.commons.lang.time.DateUtils; ...@@ -8,7 +8,6 @@ import org.apache.commons.lang.time.DateUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Calendar; import java.util.Calendar;
......
package com.ctrip.framework.apollo.portal.spi.ctrip; package com.ctrip.framework.apollo.portal.spi.ctrip;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.bo.Email; import com.ctrip.framework.apollo.portal.entity.bo.Email;
import com.ctrip.framework.apollo.portal.spi.EmailService; import com.ctrip.framework.apollo.portal.spi.EmailService;
import com.ctrip.framework.apollo.tracer.Tracer; import com.ctrip.framework.apollo.tracer.Tracer;
......
package com.ctrip.framework.apollo.portal.spi.ctrip; package com.ctrip.framework.apollo.portal.spi.ctrip;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.spi.LogoutHandler; import com.ctrip.framework.apollo.portal.spi.LogoutHandler;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
...@@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableMap; ...@@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
import com.ctrip.framework.apollo.portal.spi.UserService; import com.ctrip.framework.apollo.portal.spi.UserService;
......
...@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.portal.spi.ctrip; ...@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.portal.spi.ctrip;
import com.ctrip.framework.apollo.portal.spi.ctrip.filters.UserAccessFilter; import com.ctrip.framework.apollo.portal.spi.ctrip.filters.UserAccessFilter;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
...@@ -4,7 +4,7 @@ import com.ctrip.framework.apollo.openapi.entity.Consumer; ...@@ -4,7 +4,7 @@ import com.ctrip.framework.apollo.openapi.entity.Consumer;
import com.ctrip.framework.apollo.openapi.entity.ConsumerToken; import com.ctrip.framework.apollo.openapi.entity.ConsumerToken;
import com.ctrip.framework.apollo.openapi.repository.ConsumerRepository; import com.ctrip.framework.apollo.openapi.repository.ConsumerRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerTokenRepository; import com.ctrip.framework.apollo.openapi.repository.ConsumerTokenRepository;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
......
...@@ -6,14 +6,17 @@ import com.ctrip.framework.apollo.openapi.service.ConsumerRolePermissionServiceT ...@@ -6,14 +6,17 @@ import com.ctrip.framework.apollo.openapi.service.ConsumerRolePermissionServiceT
import com.ctrip.framework.apollo.openapi.service.ConsumerServiceTest; import com.ctrip.framework.apollo.openapi.service.ConsumerServiceTest;
import com.ctrip.framework.apollo.openapi.util.ConsumerAuditUtilTest; import com.ctrip.framework.apollo.openapi.util.ConsumerAuditUtilTest;
import com.ctrip.framework.apollo.openapi.util.ConsumerAuthUtilTest; import com.ctrip.framework.apollo.openapi.util.ConsumerAuthUtilTest;
import com.ctrip.framework.apollo.portal.components.txtresolver.FileTextResolverTest; import com.ctrip.framework.apollo.portal.component.txtresolver.FileTextResolverTest;
import com.ctrip.framework.apollo.portal.components.txtresolver.PropertyResolverTest; import com.ctrip.framework.apollo.portal.component.txtresolver.PropertyResolverTest;
import com.ctrip.framework.apollo.portal.config.ConfigTest;
import com.ctrip.framework.apollo.portal.controller.ConsumerControllerTest; import com.ctrip.framework.apollo.portal.controller.ConsumerControllerTest;
import com.ctrip.framework.apollo.portal.service.AppNamespaceServiceTest; import com.ctrip.framework.apollo.portal.service.AppNamespaceServiceTest;
import com.ctrip.framework.apollo.portal.service.ConfigServiceTest; import com.ctrip.framework.apollo.portal.service.ConfigServiceTest;
import com.ctrip.framework.apollo.portal.service.FavoriteServiceTest;
import com.ctrip.framework.apollo.portal.service.NamespaceServiceTest; import com.ctrip.framework.apollo.portal.service.NamespaceServiceTest;
import com.ctrip.framework.apollo.portal.service.RoleInitializationServiceTest; import com.ctrip.framework.apollo.portal.service.RoleInitializationServiceTest;
import com.ctrip.framework.apollo.portal.service.RolePermissionServiceTest; import com.ctrip.framework.apollo.portal.service.RolePermissionServiceTest;
import com.ctrip.framework.apollo.portal.spi.ctrip.CtripUserServiceTest;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Suite; import org.junit.runners.Suite;
...@@ -26,7 +29,9 @@ import org.junit.runners.Suite.SuiteClasses; ...@@ -26,7 +29,9 @@ import org.junit.runners.Suite.SuiteClasses;
AppNamespaceServiceTest.class, RoleInitializationServiceTest.class, FileTextResolverTest.class, AppNamespaceServiceTest.class, RoleInitializationServiceTest.class, FileTextResolverTest.class,
RetryableRestTemplateTest.class, ConsumerRolePermissionServiceTest.class, RetryableRestTemplateTest.class, ConsumerRolePermissionServiceTest.class,
ConsumerAuthenticationFilterTest.class, ConsumerAuthUtilTest.class, ConsumerServiceTest.class, ConsumerAuthenticationFilterTest.class, ConsumerAuthUtilTest.class, ConsumerServiceTest.class,
ConsumerControllerTest.class, ConsumerAuditUtilTest.class ConsumerControllerTest.class, ConsumerAuditUtilTest.class, ConfigTest.class, FavoriteServiceTest.class,
CtripUserServiceTest.class
}) })
public class AllTests { public class AllTests {
......
...@@ -3,8 +3,8 @@ package com.ctrip.framework.apollo.portal; ...@@ -3,8 +3,8 @@ package com.ctrip.framework.apollo.portal;
import com.ctrip.framework.apollo.common.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
import com.ctrip.framework.apollo.core.dto.ServiceDTO; import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.components.AdminServiceAddressLocator; import com.ctrip.framework.apollo.portal.component.AdminServiceAddressLocator;
import com.ctrip.framework.apollo.portal.components.RetryableRestTemplate; import com.ctrip.framework.apollo.portal.component.RetryableRestTemplate;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.conn.ConnectTimeoutException;
...@@ -19,7 +19,6 @@ import org.springframework.http.ResponseEntity; ...@@ -19,7 +19,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.client.ResourceAccessException; import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.net.ConnectException;
import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
......
package com.ctrip.framework.apollo.portal.components.txtresolver; package com.ctrip.framework.apollo.portal.component.txtresolver;
import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.common.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
......
package com.ctrip.framework.apollo.portal.components.txtresolver; package com.ctrip.framework.apollo.portal.component.txtresolver;
import com.ctrip.framework.apollo.common.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
......
package com.ctrip.framework.apollo.portal.config; package com.ctrip.framework.apollo.portal.config;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.AbstractUnitTest;
import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.ConfigurableEnvironment;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class) public class ConfigTest extends AbstractUnitTest{
public class ConfigTest {
@Mock @Mock
private ConfigurableEnvironment environment; private ConfigurableEnvironment environment;
...@@ -27,7 +25,7 @@ public class ConfigTest { ...@@ -27,7 +25,7 @@ public class ConfigTest {
String testKey = "key"; String testKey = "key";
String testDefaultValue = "value"; String testDefaultValue = "value";
when(environment.getProperty(testKey)).thenReturn(null); when(environment.getProperty(testKey, testDefaultValue)).thenReturn(testDefaultValue);
Assert.assertEquals(testDefaultValue, config.getValue(testKey, testDefaultValue)); Assert.assertEquals(testDefaultValue, config.getValue(testKey, testDefaultValue));
} }
......
...@@ -9,7 +9,7 @@ import com.ctrip.framework.apollo.core.enums.Env; ...@@ -9,7 +9,7 @@ import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder; import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
import com.ctrip.framework.apollo.portal.components.txtresolver.PropertyResolver; import com.ctrip.framework.apollo.portal.component.txtresolver.PropertyResolver;
import com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel; import com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel;
import com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs; import com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs;
import com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifier; import com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifier;
......
...@@ -7,7 +7,7 @@ import com.ctrip.framework.apollo.common.entity.AppNamespace; ...@@ -7,7 +7,7 @@ import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.components.txtresolver.PropertyResolver; import com.ctrip.framework.apollo.portal.component.txtresolver.PropertyResolver;
import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO; import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO;
import org.junit.Before; import org.junit.Before;
......
...@@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableMap; ...@@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.ctrip.framework.apollo.portal.AbstractUnitTest; import com.ctrip.framework.apollo.portal.AbstractUnitTest;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig; import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; import com.ctrip.framework.apollo.portal.entity.bo.UserInfo;
import org.junit.Before; import org.junit.Before;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册