提交 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 {
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;
......@@ -68,7 +68,7 @@ public class AppController {
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) {
......@@ -77,7 +77,7 @@ public class AppController {
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);
}
......
......@@ -58,13 +58,13 @@ public class ClusterController {
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);
......@@ -74,7 +74,7 @@ public class ClusterController {
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);
......
......@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
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;
......@@ -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){
......
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";
}
......
......@@ -125,14 +125,14 @@ public class ItemController {
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) {
......@@ -141,7 +141,7 @@ public class ItemController {
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) {
......
......@@ -54,14 +54,14 @@ public class NamespaceController {
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)
......@@ -69,7 +69,7 @@ public class NamespaceController {
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) {
......@@ -79,7 +79,8 @@ public class NamespaceController {
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) {
......@@ -95,7 +96,7 @@ public class NamespaceController {
/**
* 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);
}
......
......@@ -12,6 +12,7 @@ import com.ctrip.framework.apollo.common.utils.BeanUtils;
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
......@@ -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);
......
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 {
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) {
......@@ -57,7 +57,7 @@ public class ReleaseController {
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());
......@@ -67,7 +67,7 @@ public class ReleaseController {
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,
......@@ -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,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName,
......@@ -86,7 +86,7 @@ public class ReleaseController {
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) {
......
......@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.adminservice;
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;
......@@ -16,7 +17,7 @@ import org.junit.runners.Suite.SuiteClasses;
@SuiteClasses({
AppControllerTest.class, ReleaseControllerTest.class, ItemSetControllerTest.class,
ControllerExceptionTest.class, ControllerIntegrationExceptionTest.class,
NamespaceLockTest.class, InstanceConfigControllerTest.class
NamespaceLockTest.class, InstanceConfigControllerTest.class, AppNamespaceControllerTest.class
})
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;
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;
......@@ -25,7 +26,6 @@ import org.junit.runners.Suite.SuiteClasses;
AppRepositoryTest.class,
AppNamespaceRepositoryTest.class,
AdminServiceTest.class,
PrivilegeServiceTest.class,
AdminServiceTransactionTest.class,
DatabaseMessageSenderTest.class,
BizDBPropertySourceTest.class,
......@@ -36,7 +36,9 @@ import org.junit.runners.Suite.SuiteClasses;
InstanceServiceTest.class,
GrayReleaseRulesHolderTest.class,
NamespaceBranchServiceTest.class,
ReleaseCreationTest.class
ReleaseCreationTest.class,
NamespacePublishInfoTest.class,
NamespaceServiceTest.class
})
public class AllTests {
......
......@@ -24,9 +24,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
* @author lepdou 2016-11-28
*/
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;
import com.ctrip.framework.apollo.openapi.repository.ConsumerAuditRepository;
import com.ctrip.framework.apollo.openapi.repository.ConsumerRepository;
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.springframework.beans.factory.annotation.Autowired;
......
......@@ -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.core.enums.Env;
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 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;
import java.util.LinkedList;
......@@ -24,7 +25,7 @@ public class AppController {
@Autowired
private ClusterService clusterService;
@RequestMapping("/apps/{appId}/envclusters")
@RequestMapping(value = "/apps/{appId}/envclusters", method = RequestMethod.GET)
public List<OpenEnvClusterDTO> loadEnvClusterInfo(@PathVariable String appId){
List<OpenEnvClusterDTO> envClusters = new LinkedList<>();
......
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;
......
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.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.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.enums.Env;
import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
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.LoggerFactory;
......
package com.ctrip.framework.apollo.portal.components;
package com.ctrip.framework.apollo.portal.component;
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.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.core.MetaDomainConsts;
......
package com.ctrip.framework.apollo.portal.components.config;
package com.ctrip.framework.apollo.portal.component.config;
import com.google.common.base.Strings;
......@@ -15,7 +15,6 @@ import com.ctrip.framework.apollo.portal.service.PortalDBPropertySource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.lang.reflect.Type;
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;
......@@ -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.core.enums.ConfigFileFormat;
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.entity.bo.Email;
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.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;
......
package com.ctrip.framework.apollo.portal.components.emailbuilder;
package com.ctrip.framework.apollo.portal.component.emailbuilder;
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;
......
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.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.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.ItemDTO;
......
......@@ -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.RequestPrecondition;
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.vo.EnvClusterInfo;
import com.ctrip.framework.apollo.portal.listener.AppCreationEvent;
......@@ -50,7 +50,7 @@ public class AppController {
@Autowired
private UserService userService;
@RequestMapping("")
@RequestMapping(value = "", method = RequestMethod.GET)
public List<App> findApps(@RequestParam(value = "appIds", required = false) String appIds) {
if (StringUtils.isEmpty(appIds)){
return appService.findAll();
......@@ -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){
return appService.findByOwnerName(owner, page);
}
@RequestMapping("/{appId}/navtree")
@RequestMapping(value = "/{appId}/navtree", method = RequestMethod.GET)
public MultiResponseEntity<EnvClusterInfo> nav(@PathVariable String appId) {
MultiResponseEntity<EnvClusterInfo> response = MultiResponseEntity.ok();
......@@ -130,7 +130,7 @@ public class AppController {
return appService.load(appId);
}
@RequestMapping(value = "/{appId}/miss_envs")
@RequestMapping(value = "/{appId}/miss_envs", method = RequestMethod.GET)
public MultiResponseEntity<Env> findMissEnvs(@PathVariable String appId) {
MultiResponseEntity<Env> response = MultiResponseEntity.ok();
......
......@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.portal.service.CommitService;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -20,7 +21,7 @@ public class CommitController {
@Autowired
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,
@PathVariable String clusterName, @PathVariable String namespaceName,
@RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size) {
......
package com.ctrip.framework.apollo.portal.controller;
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.web.bind.annotation.RequestMapping;
......
......@@ -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,
@RequestParam(value = "appId", required = false) String appId,
Pageable page) {
......
......@@ -14,6 +14,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.util.CollectionUtils;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -30,7 +31,7 @@ public class InstanceController {
@Autowired
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,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "20") int size) {
......@@ -38,7 +39,7 @@ public class InstanceController {
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,
@RequestParam String clusterName, @RequestParam String namespaceName,
@RequestParam(required = false) String instanceAppId,
......@@ -48,7 +49,7 @@ public class InstanceController {
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,
@RequestParam String clusterName,
@RequestParam String namespaceName) {
......@@ -57,7 +58,7 @@ public class InstanceController {
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,
@RequestParam String clusterName, @RequestParam String namespaceName,
@RequestParam String releaseIds) {
......
......@@ -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,
@PathVariable String clusterName, @PathVariable String namespaceName,
@RequestParam(defaultValue = "lineNum") String orderBy) {
......@@ -116,7 +116,7 @@ public class ItemController {
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,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName,
......
......@@ -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.exception.BadRequestException;
import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.components.PermissionValidator;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig;
import com.ctrip.framework.apollo.portal.component.PermissionValidator;
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.bo.NamespaceBO;
import com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent;
......@@ -38,7 +38,7 @@ public class NamespaceBranchController {
@Autowired
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,
@PathVariable String env,
@PathVariable String clusterName,
......
......@@ -62,26 +62,27 @@ public class NamespaceController {
@Autowired
private RolePermissionService rolePermissionService;
@RequestMapping("/appnamespaces/public")
@RequestMapping(value = "/appnamespaces/public", method = RequestMethod.GET)
public List<AppNamespace> 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,
@PathVariable String 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,
@PathVariable String clusterName, @PathVariable String 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,
@PathVariable String appId,
@PathVariable String namespaceName,
......@@ -170,7 +171,6 @@ public class NamespaceController {
return createdAppNamespace;
}
/**
* env -> cluster -> cluster has not published namespace?
* Example:
......@@ -178,7 +178,7 @@ public class NamespaceController {
* default -> true (default cluster has not published namespace)
* 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) {
return namespaceService.getNamespacesPublishInfo(appId);
}
......
......@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.portal.service.NamespaceLockService;
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
......@@ -17,14 +18,14 @@ public class NamespaceLockController {
private NamespaceLockService namespaceLockService;
@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,
@PathVariable String clusterName, @PathVariable String 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,
@PathVariable String clusterName, @PathVariable String namespaceName) {
......
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 org.springframework.beans.factory.annotation.Autowired;
......
......@@ -38,7 +38,7 @@ public class PermissionController {
@Autowired
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) {
PermissionCondition permissionCondition = new PermissionCondition();
......@@ -48,7 +48,7 @@ public class PermissionController {
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,
@PathVariable String permissionType) {
PermissionCondition permissionCondition = new PermissionCondition();
......@@ -60,7 +60,7 @@ public class PermissionController {
return ResponseEntity.ok().body(permissionCondition);
}
@RequestMapping("/permissions/root")
@RequestMapping(value = "/permissions/root", method = RequestMethod.GET)
public ResponseEntity<PermissionCondition> hasRootPermission() {
PermissionCondition permissionCondition = new PermissionCondition();
......@@ -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) {
NamespaceRolesAssignedUsers assignedUsers = new NamespaceRolesAssignedUsers();
......@@ -121,7 +121,7 @@ public class PermissionController {
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) {
AppRolesAssignedUsers users = new AppRolesAssignedUsers();
users.setAppId(appId);
......
......@@ -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.utils.RequestPrecondition;
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.vo.ReleaseCompareResult;
import com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO;
......@@ -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,
@PathVariable String env,
@PathVariable String clusterName,
......@@ -114,7 +114,7 @@ public class ReleaseController {
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,
@PathVariable String env,
@PathVariable String clusterName,
......@@ -128,7 +128,7 @@ public class ReleaseController {
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,
@RequestParam long baseReleaseId,
@RequestParam long toCompareReleaseId) {
......
......@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.portal.spi.UserService;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
......@@ -28,24 +29,24 @@ public class UserInfoController {
@Autowired
private UserService userService;
@RequestMapping("/user")
@RequestMapping(value = "/user", method = RequestMethod.GET)
public UserInfo getCurrentUserName() {
return userInfoHolder.getUser();
}
@RequestMapping("/user/logout")
@RequestMapping(value = "/user/logout", method = RequestMethod.GET)
public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
logoutHandler.logout(request, response);
}
@RequestMapping("/users")
@RequestMapping(value = "/users", method = RequestMethod.GET)
public List<UserInfo> searchUsersByKeyword(@RequestParam(value = "keyword") String keyword,
@RequestParam(value = "offset", defaultValue = "0") int offset,
@RequestParam(value = "limit", defaultValue = "10") int limit) {
return userService.searchUsers(keyword, offset, limit);
}
@RequestMapping("/users/{userId}")
@RequestMapping(value = "/users/{userId}", method = RequestMethod.GET)
public UserInfo getUserByUserId(@PathVariable String userId) {
return userService.findByUserId(userId);
}
......
......@@ -2,11 +2,11 @@ package com.ctrip.framework.apollo.portal.listener;
import com.ctrip.framework.apollo.common.constants.ReleaseOperation;
import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.components.config.PortalConfig;
import com.ctrip.framework.apollo.portal.components.emailbuilder.GrayPublishEmailBuilder;
import com.ctrip.framework.apollo.portal.components.emailbuilder.MergeEmailBuilder;
import com.ctrip.framework.apollo.portal.components.emailbuilder.NormalPublishEmailBuilder;
import com.ctrip.framework.apollo.portal.components.emailbuilder.RollbackEmailBuilder;
import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import com.ctrip.framework.apollo.portal.component.emailbuilder.GrayPublishEmailBuilder;
import com.ctrip.framework.apollo.portal.component.emailbuilder.MergeEmailBuilder;
import com.ctrip.framework.apollo.portal.component.emailbuilder.NormalPublishEmailBuilder;
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.ReleaseHistoryBO;
import com.ctrip.framework.apollo.portal.service.ReleaseHistoryService;
......
......@@ -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.core.enums.Env;
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 org.slf4j.Logger;
......
......@@ -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.utils.StringUtils;
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.entity.model.NamespaceTextModel;
import com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs;
......
......@@ -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.core.enums.Env;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.components.ItemsComparator;
import com.ctrip.framework.apollo.portal.components.PermissionValidator;
import com.ctrip.framework.apollo.portal.component.ItemsComparator;
import com.ctrip.framework.apollo.portal.component.PermissionValidator;
import com.ctrip.framework.apollo.portal.constant.CatEventType;
import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
......
......@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.common.dto.NamespaceLockDTO;
import com.ctrip.framework.apollo.core.enums.Env;
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 org.springframework.beans.factory.annotation.Autowired;
......
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.gson.Gson;
......@@ -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.utils.StringUtils;
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.entity.bo.ItemBO;
import com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO;
......
......@@ -6,7 +6,7 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
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.Role;
import com.ctrip.framework.apollo.portal.entity.po.RolePermission;
......
......@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.portal.spi.configuration;
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.SsoHeartbeatHandler;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
......
package com.ctrip.framework.apollo.portal.spi.ctrip;
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.context.annotation.Profile;
......
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.tracer.Tracer;
......@@ -8,7 +8,6 @@ import org.apache.commons.lang.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import java.lang.reflect.Method;
import java.util.Calendar;
......
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.spi.EmailService;
import com.ctrip.framework.apollo.tracer.Tracer;
......
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 org.springframework.beans.factory.annotation.Autowired;
......
......@@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
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.spi.UserService;
......
......@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.portal.spi.ctrip;
import com.ctrip.framework.apollo.portal.spi.ctrip.filters.UserAccessFilter;
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 org.springframework.beans.factory.annotation.Autowired;
......
......@@ -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.repository.ConsumerRepository;
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.Test;
......
......@@ -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.util.ConsumerAuditUtilTest;
import com.ctrip.framework.apollo.openapi.util.ConsumerAuthUtilTest;
import com.ctrip.framework.apollo.portal.components.txtresolver.FileTextResolverTest;
import com.ctrip.framework.apollo.portal.components.txtresolver.PropertyResolverTest;
import com.ctrip.framework.apollo.portal.component.txtresolver.FileTextResolverTest;
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.service.AppNamespaceServiceTest;
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.RoleInitializationServiceTest;
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.runners.Suite;
......@@ -26,7 +29,9 @@ import org.junit.runners.Suite.SuiteClasses;
AppNamespaceServiceTest.class, RoleInitializationServiceTest.class, FileTextResolverTest.class,
RetryableRestTemplateTest.class, ConsumerRolePermissionServiceTest.class,
ConsumerAuthenticationFilterTest.class, ConsumerAuthUtilTest.class, ConsumerServiceTest.class,
ConsumerControllerTest.class, ConsumerAuditUtilTest.class
ConsumerControllerTest.class, ConsumerAuditUtilTest.class, ConfigTest.class, FavoriteServiceTest.class,
CtripUserServiceTest.class
})
public class AllTests {
......
......@@ -3,8 +3,8 @@ package com.ctrip.framework.apollo.portal;
import com.ctrip.framework.apollo.common.exception.ServiceException;
import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.components.AdminServiceAddressLocator;
import com.ctrip.framework.apollo.portal.components.RetryableRestTemplate;
import com.ctrip.framework.apollo.portal.component.AdminServiceAddressLocator;
import com.ctrip.framework.apollo.portal.component.RetryableRestTemplate;
import org.apache.http.HttpHost;
import org.apache.http.conn.ConnectTimeoutException;
......@@ -19,7 +19,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestTemplate;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.util.Arrays;
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.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;
......
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.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.core.env.ConfigurableEnvironment;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class ConfigTest {
public class ConfigTest extends AbstractUnitTest{
@Mock
private ConfigurableEnvironment environment;
......@@ -27,7 +25,7 @@ public class ConfigTest {
String testKey = "key";
String testDefaultValue = "value";
when(environment.getProperty(testKey)).thenReturn(null);
when(environment.getProperty(testKey, testDefaultValue)).thenReturn(testDefaultValue);
Assert.assertEquals(testDefaultValue, config.getValue(testKey, testDefaultValue));
}
......
......@@ -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.spi.UserInfoHolder;
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.vo.ItemDiffs;
import com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifier;
......
......@@ -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.Env;
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 org.junit.Before;
......
......@@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
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 org.junit.Before;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册