提交 0ecaebe4 编写于 作者: J Jason Song 提交者: GitHub

Merge pull request #357 from lepdou/coverity

fix coverity bugs
...@@ -8,10 +8,10 @@ import com.ctrip.framework.apollo.biz.service.ItemService; ...@@ -8,10 +8,10 @@ import com.ctrip.framework.apollo.biz.service.ItemService;
import com.ctrip.framework.apollo.biz.service.NamespaceLockService; import com.ctrip.framework.apollo.biz.service.NamespaceLockService;
import com.ctrip.framework.apollo.biz.service.NamespaceService; import com.ctrip.framework.apollo.biz.service.NamespaceService;
import com.ctrip.framework.apollo.biz.utils.ApolloSwitcher; import com.ctrip.framework.apollo.biz.utils.ApolloSwitcher;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Before;
......
...@@ -16,9 +16,9 @@ import com.ctrip.framework.apollo.biz.service.AdminService; ...@@ -16,9 +16,9 @@ import com.ctrip.framework.apollo.biz.service.AdminService;
import com.ctrip.framework.apollo.biz.service.AppService; import com.ctrip.framework.apollo.biz.service.AppService;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.common.utils.InputValidator; import com.ctrip.framework.apollo.common.utils.InputValidator;
import com.ctrip.framework.apollo.core.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.NotFoundException; import com.ctrip.framework.apollo.common.exception.NotFoundException;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
@RestController @RestController
......
package com.ctrip.framework.apollo.adminservice.controller; package com.ctrip.framework.apollo.adminservice.controller;
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.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
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.RequestMethod;
...@@ -10,13 +9,11 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -10,13 +9,11 @@ import org.springframework.web.bind.annotation.RestController;
import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.biz.service.AppNamespaceService; import com.ctrip.framework.apollo.biz.service.AppNamespaceService;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.AppNamespaceDTO; import com.ctrip.framework.apollo.common.dto.AppNamespaceDTO;
import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
import java.util.List;
@RestController @RestController
public class AppNamespaceController { public class AppNamespaceController {
......
...@@ -14,9 +14,9 @@ import com.ctrip.framework.apollo.biz.entity.Cluster; ...@@ -14,9 +14,9 @@ import com.ctrip.framework.apollo.biz.entity.Cluster;
import com.ctrip.framework.apollo.biz.service.ClusterService; import com.ctrip.framework.apollo.biz.service.ClusterService;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.common.utils.InputValidator; import com.ctrip.framework.apollo.common.utils.InputValidator;
import com.ctrip.framework.apollo.core.dto.ClusterDTO; import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.NotFoundException; import com.ctrip.framework.apollo.common.exception.NotFoundException;
@RestController @RestController
public class ClusterController { public class ClusterController {
......
...@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.adminservice.controller; ...@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.adminservice.controller;
import com.ctrip.framework.apollo.biz.entity.Commit; import com.ctrip.framework.apollo.biz.entity.Commit;
import com.ctrip.framework.apollo.biz.service.CommitService; import com.ctrip.framework.apollo.biz.service.CommitService;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.CommitDTO; import com.ctrip.framework.apollo.common.dto.CommitDTO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
......
...@@ -19,9 +19,9 @@ import com.ctrip.framework.apollo.biz.service.ItemService; ...@@ -19,9 +19,9 @@ import com.ctrip.framework.apollo.biz.service.ItemService;
import com.ctrip.framework.apollo.biz.service.NamespaceService; import com.ctrip.framework.apollo.biz.service.NamespaceService;
import com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder; import com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.NotFoundException; import com.ctrip.framework.apollo.common.exception.NotFoundException;
@RestController @RestController
public class ItemController { public class ItemController {
......
...@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.ctrip.framework.apollo.adminservice.aop.PreAcquireNamespaceLock; import com.ctrip.framework.apollo.adminservice.aop.PreAcquireNamespaceLock;
import com.ctrip.framework.apollo.biz.service.ItemSetService; import com.ctrip.framework.apollo.biz.service.ItemSetService;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
@RestController @RestController
public class ItemSetController { public class ItemSetController {
......
...@@ -14,9 +14,9 @@ import com.ctrip.framework.apollo.biz.entity.Namespace; ...@@ -14,9 +14,9 @@ import com.ctrip.framework.apollo.biz.entity.Namespace;
import com.ctrip.framework.apollo.biz.service.NamespaceService; import com.ctrip.framework.apollo.biz.service.NamespaceService;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.common.utils.InputValidator; import com.ctrip.framework.apollo.common.utils.InputValidator;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.NotFoundException; import com.ctrip.framework.apollo.common.exception.NotFoundException;
@RestController @RestController
public class NamespaceController { public class NamespaceController {
......
...@@ -6,8 +6,8 @@ import com.ctrip.framework.apollo.biz.service.NamespaceLockService; ...@@ -6,8 +6,8 @@ import com.ctrip.framework.apollo.biz.service.NamespaceLockService;
import com.ctrip.framework.apollo.biz.service.NamespaceService; import com.ctrip.framework.apollo.biz.service.NamespaceService;
import com.ctrip.framework.apollo.biz.utils.ApolloSwitcher; import com.ctrip.framework.apollo.biz.utils.ApolloSwitcher;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.NamespaceLockDTO; import com.ctrip.framework.apollo.common.dto.NamespaceLockDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
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;
......
...@@ -10,8 +10,8 @@ import com.ctrip.framework.apollo.biz.service.NamespaceService; ...@@ -10,8 +10,8 @@ import com.ctrip.framework.apollo.biz.service.NamespaceService;
import com.ctrip.framework.apollo.biz.service.ReleaseService; import com.ctrip.framework.apollo.biz.service.ReleaseService;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import com.ctrip.framework.apollo.core.exception.NotFoundException; import com.ctrip.framework.apollo.common.exception.NotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
......
...@@ -7,8 +7,8 @@ import com.ctrip.framework.apollo.biz.service.ItemService; ...@@ -7,8 +7,8 @@ import com.ctrip.framework.apollo.biz.service.ItemService;
import com.ctrip.framework.apollo.biz.service.NamespaceLockService; import com.ctrip.framework.apollo.biz.service.NamespaceLockService;
import com.ctrip.framework.apollo.biz.service.NamespaceService; import com.ctrip.framework.apollo.biz.service.NamespaceService;
import com.ctrip.framework.apollo.biz.utils.ApolloSwitcher; import com.ctrip.framework.apollo.biz.utils.ApolloSwitcher;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
......
...@@ -12,7 +12,7 @@ import org.springframework.web.client.HttpClientErrorException; ...@@ -12,7 +12,7 @@ import org.springframework.web.client.HttpClientErrorException;
import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.common.entity.App;
import com.ctrip.framework.apollo.biz.repository.AppRepository; import com.ctrip.framework.apollo.biz.repository.AppRepository;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.AppDTO;
public class AppControllerTest extends AbstractControllerTest { public class AppControllerTest extends AbstractControllerTest {
......
...@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.adminservice.controller; ...@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.adminservice.controller;
import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.biz.repository.AppNamespaceRepository; import com.ctrip.framework.apollo.biz.repository.AppNamespaceRepository;
import com.ctrip.framework.apollo.core.dto.AppNamespaceDTO; import com.ctrip.framework.apollo.common.dto.AppNamespaceDTO;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
......
...@@ -19,9 +19,9 @@ import org.springframework.test.util.ReflectionTestUtils; ...@@ -19,9 +19,9 @@ import org.springframework.test.util.ReflectionTestUtils;
import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.common.entity.App;
import com.ctrip.framework.apollo.biz.service.AdminService; import com.ctrip.framework.apollo.biz.service.AdminService;
import com.ctrip.framework.apollo.biz.service.AppService; import com.ctrip.framework.apollo.biz.service.AppService;
import com.ctrip.framework.apollo.core.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.core.exception.NotFoundException; import com.ctrip.framework.apollo.common.exception.NotFoundException;
import com.ctrip.framework.apollo.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class ControllerExceptionTest { public class ControllerExceptionTest {
......
...@@ -19,7 +19,7 @@ import org.springframework.web.client.HttpStatusCodeException; ...@@ -19,7 +19,7 @@ import org.springframework.web.client.HttpStatusCodeException;
import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.common.entity.App;
import com.ctrip.framework.apollo.biz.service.AdminService; import com.ctrip.framework.apollo.biz.service.AdminService;
import com.ctrip.framework.apollo.biz.service.AppService; import com.ctrip.framework.apollo.biz.service.AppService;
import com.ctrip.framework.apollo.core.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.google.gson.Gson; import com.google.gson.Gson;
......
...@@ -14,11 +14,11 @@ import org.springframework.web.client.RestTemplate; ...@@ -14,11 +14,11 @@ import org.springframework.web.client.RestTemplate;
import com.ctrip.framework.apollo.biz.entity.Item; import com.ctrip.framework.apollo.biz.entity.Item;
import com.ctrip.framework.apollo.biz.repository.ItemRepository; import com.ctrip.framework.apollo.biz.repository.ItemRepository;
import com.ctrip.framework.apollo.core.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.core.dto.ClusterDTO; import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
public class ItemSetControllerTest extends AbstractControllerTest { public class ItemSetControllerTest extends AbstractControllerTest {
......
...@@ -10,11 +10,11 @@ import com.ctrip.framework.apollo.biz.repository.ReleaseRepository; ...@@ -10,11 +10,11 @@ import com.ctrip.framework.apollo.biz.repository.ReleaseRepository;
import com.ctrip.framework.apollo.biz.service.NamespaceService; import com.ctrip.framework.apollo.biz.service.NamespaceService;
import com.ctrip.framework.apollo.biz.service.ReleaseService; import com.ctrip.framework.apollo.biz.service.ReleaseService;
import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.core.dto.ClusterDTO; import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
...@@ -24,7 +24,6 @@ import org.springframework.http.HttpHeaders; ...@@ -24,7 +24,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase; import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
......
...@@ -11,7 +11,7 @@ import com.ctrip.framework.apollo.common.entity.AppNamespace; ...@@ -11,7 +11,7 @@ import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
...@@ -13,7 +13,7 @@ import com.ctrip.framework.apollo.common.entity.App; ...@@ -13,7 +13,7 @@ import com.ctrip.framework.apollo.common.entity.App;
import com.ctrip.framework.apollo.biz.entity.Audit; import com.ctrip.framework.apollo.biz.entity.Audit;
import com.ctrip.framework.apollo.biz.repository.AppRepository; import com.ctrip.framework.apollo.biz.repository.AppRepository;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
@Service @Service
public class AppService { public class AppService {
......
...@@ -13,7 +13,7 @@ import com.ctrip.framework.apollo.biz.entity.Cluster; ...@@ -13,7 +13,7 @@ import com.ctrip.framework.apollo.biz.entity.Cluster;
import com.ctrip.framework.apollo.biz.repository.ClusterRepository; import com.ctrip.framework.apollo.biz.repository.ClusterRepository;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
import com.google.common.base.Strings; import com.google.common.base.Strings;
......
...@@ -6,8 +6,8 @@ import com.ctrip.framework.apollo.biz.entity.Namespace; ...@@ -6,8 +6,8 @@ import com.ctrip.framework.apollo.biz.entity.Namespace;
import com.ctrip.framework.apollo.biz.repository.ItemRepository; import com.ctrip.framework.apollo.biz.repository.ItemRepository;
import com.ctrip.framework.apollo.biz.repository.NamespaceRepository; import com.ctrip.framework.apollo.biz.repository.NamespaceRepository;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.NotFoundException; import com.ctrip.framework.apollo.common.exception.NotFoundException;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
...@@ -10,9 +10,9 @@ import com.ctrip.framework.apollo.biz.entity.Commit; ...@@ -10,9 +10,9 @@ import com.ctrip.framework.apollo.biz.entity.Commit;
import com.ctrip.framework.apollo.biz.entity.Item; import com.ctrip.framework.apollo.biz.entity.Item;
import com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder; import com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.exception.NotFoundException; import com.ctrip.framework.apollo.common.exception.NotFoundException;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
......
...@@ -13,7 +13,7 @@ import com.ctrip.framework.apollo.biz.entity.Namespace; ...@@ -13,7 +13,7 @@ import com.ctrip.framework.apollo.biz.entity.Namespace;
import com.ctrip.framework.apollo.biz.repository.NamespaceRepository; import com.ctrip.framework.apollo.biz.repository.NamespaceRepository;
import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
@Service @Service
public class NamespaceService { public class NamespaceService {
......
...@@ -9,8 +9,8 @@ import com.ctrip.framework.apollo.biz.entity.Release; ...@@ -9,8 +9,8 @@ import com.ctrip.framework.apollo.biz.entity.Release;
import com.ctrip.framework.apollo.biz.repository.ItemRepository; import com.ctrip.framework.apollo.biz.repository.ItemRepository;
import com.ctrip.framework.apollo.biz.repository.ReleaseRepository; import com.ctrip.framework.apollo.biz.repository.ReleaseRepository;
import com.ctrip.framework.apollo.biz.utils.ReleaseKeyGenerator; import com.ctrip.framework.apollo.biz.utils.ReleaseKeyGenerator;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.NotFoundException; import com.ctrip.framework.apollo.common.exception.NotFoundException;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
...@@ -4,9 +4,6 @@ import com.google.gson.Gson; ...@@ -4,9 +4,6 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.ctrip.framework.apollo.biz.entity.Item; import com.ctrip.framework.apollo.biz.entity.Item;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO;
import java.util.Date; import java.util.Date;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -56,7 +53,7 @@ public class ConfigChangeContentBuilder { ...@@ -56,7 +53,7 @@ public class ConfigChangeContentBuilder {
return gson.toJson(this); return gson.toJson(this);
} }
class ItemPair { static class ItemPair {
Item oldItem; Item oldItem;
Item newItem; Item newItem;
......
...@@ -14,7 +14,7 @@ import com.ctrip.framework.apollo.biz.entity.Cluster; ...@@ -14,7 +14,7 @@ import com.ctrip.framework.apollo.biz.entity.Cluster;
import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.biz.entity.Namespace;
import com.ctrip.framework.apollo.biz.repository.AppRepository; import com.ctrip.framework.apollo.biz.repository.AppRepository;
import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
public class AdminServiceTest extends AbstractIntegrationTest{ public class AdminServiceTest extends AbstractIntegrationTest{
......
...@@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import com.ctrip.framework.apollo.biz.AbstractIntegrationTest; import com.ctrip.framework.apollo.biz.AbstractIntegrationTest;
import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.common.entity.App;
import com.ctrip.framework.apollo.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
public class ClusterServiceTest extends AbstractIntegrationTest { public class ClusterServiceTest extends AbstractIntegrationTest {
......
...@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.biz.service; ...@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.biz.service;
import com.ctrip.framework.apollo.biz.AbstractUnitTest; import com.ctrip.framework.apollo.biz.AbstractUnitTest;
import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.entity.Release;
import com.ctrip.framework.apollo.biz.repository.ReleaseRepository; import com.ctrip.framework.apollo.biz.repository.ReleaseRepository;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
......
...@@ -12,17 +12,12 @@ import org.springframework.web.bind.annotation.ControllerAdvice; ...@@ -12,17 +12,12 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.HttpStatusCodeException;
import com.ctrip.framework.apollo.core.exception.AbstractBaseException; import com.ctrip.framework.apollo.common.exception.AbstractApolloHttpException;
import com.ctrip.framework.apollo.core.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.NotFoundException;
import com.dianping.cat.Cat; import com.dianping.cat.Cat;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.LinkedHashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.servlet.ServletException; import javax.servlet.ServletException;
...@@ -30,49 +25,30 @@ import javax.servlet.http.HttpServletRequest; ...@@ -30,49 +25,30 @@ import javax.servlet.http.HttpServletRequest;
import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.UNAUTHORIZED; import static org.springframework.http.HttpStatus.UNAUTHORIZED;
import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.http.MediaType.APPLICATION_JSON;
@ControllerAdvice @ControllerAdvice
public class GlobalDefaultExceptionHandler { public class GlobalDefaultExceptionHandler {
private static final Logger logger = LoggerFactory.getLogger(GlobalDefaultExceptionHandler.class);
private Gson gson = new Gson();
private static Type mapType = new TypeToken<Map<String, Object>>() {}.getType(); private static final Logger logger = LoggerFactory.getLogger(GlobalDefaultExceptionHandler.class);
@ExceptionHandler(Exception.class) //处理系统内置的Exception
public ResponseEntity<Map<String, Object>> exception(HttpServletRequest request, Exception ex) { @ExceptionHandler(Throwable.class)
logger.error("internal server error", ex); public ResponseEntity<Map<String, Object>> exception(HttpServletRequest request, Throwable ex) {
return handleError(request, INTERNAL_SERVER_ERROR, ex); return handleError(request, INTERNAL_SERVER_ERROR, ex);
} }
@ExceptionHandler({HttpRequestMethodNotSupportedException.class, HttpMediaTypeException.class}) @ExceptionHandler({HttpRequestMethodNotSupportedException.class, HttpMediaTypeException.class})
public ResponseEntity<Map<String, Object>> badRequest(HttpServletRequest request, public ResponseEntity<Map<String, Object>> badRequest(HttpServletRequest request,
ServletException ex) { ServletException ex) {
return handleError(request, BAD_REQUEST, ex);
}
@ExceptionHandler({BadRequestException.class})
public ResponseEntity<Map<String, Object>> badRequest(HttpServletRequest request, BadRequestException ex) {
return handleError(request, BAD_REQUEST, ex); return handleError(request, BAD_REQUEST, ex);
} }
@ExceptionHandler(NotFoundException.class)
public ResponseEntity<Map<String, Object>> notFound(HttpServletRequest request,
NotFoundException ex) {
return handleError(request, NOT_FOUND, ex);
}
@ExceptionHandler(HttpStatusCodeException.class) @ExceptionHandler(HttpStatusCodeException.class)
public ResponseEntity<Map<String, Object>> restTemplateException(HttpServletRequest request, public ResponseEntity<Map<String, Object>> restTemplateException(HttpServletRequest request,
HttpStatusCodeException ex) { HttpStatusCodeException ex) {
logger.error("rest template exception", ex); return handleError(request, ex.getStatusCode(), ex);
Map<String, Object> errorAttributes = gson.fromJson(ex.getResponseBodyAsString(), mapType);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(APPLICATION_JSON);
return new ResponseEntity<>(errorAttributes, headers, ex.getStatusCode());
} }
@ExceptionHandler(AccessDeniedException.class) @ExceptionHandler(AccessDeniedException.class)
...@@ -81,39 +57,37 @@ public class GlobalDefaultExceptionHandler { ...@@ -81,39 +57,37 @@ public class GlobalDefaultExceptionHandler {
return handleError(request, UNAUTHORIZED, ex); return handleError(request, UNAUTHORIZED, ex);
} }
//处理自定义Exception
@ExceptionHandler({AbstractApolloHttpException.class})
public ResponseEntity<Map<String, Object>> badRequest(HttpServletRequest request, AbstractApolloHttpException ex) {
return handleError(request, ex);
}
private ResponseEntity<Map<String, Object>> handleError(HttpServletRequest request, private ResponseEntity<Map<String, Object>> handleError(HttpServletRequest request,
HttpStatus status, Throwable ex) { AbstractApolloHttpException ex) {
return handleError(request, status, ex, ex.getMessage()); return handleError(request, ex.getHttpStatus(), ex);
} }
private ResponseEntity<Map<String, Object>> handleError(HttpServletRequest request, private ResponseEntity<Map<String, Object>> handleError(HttpServletRequest request,
HttpStatus status, Throwable ex, String message) { HttpStatus status, Throwable ex) {
ex = resolveError(ex); String message = ex.getMessage();
if (ex.getCause() instanceof HttpStatusCodeException) {
return restTemplateException(request, (HttpStatusCodeException) ex.getCause());
}
logger.error(message, ex);
Cat.logError(ex); Cat.logError(ex);
Map<String, Object> errorAttributes = new LinkedHashMap<>(); Map<String, Object> errorAttributes = new HashMap<>();
errorAttributes.put("status", status.value()); errorAttributes.put("status", status.value());
errorAttributes.put("message", message); errorAttributes.put("message", message);
errorAttributes.put("timestamp", errorAttributes.put("timestamp",
LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
errorAttributes.put("exception", resolveError(ex).getClass().getName()); errorAttributes.put("exception", ex.getClass().getName());
// errorAttributes.put("stackTrace", ex.getStackTrace());
if (ex instanceof AbstractBaseException) {
errorAttributes.put("errorCode", ((AbstractBaseException) ex).getErrorCode());
}
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(APPLICATION_JSON); headers.setContentType(APPLICATION_JSON);
return new ResponseEntity<>(errorAttributes, headers, status); return new ResponseEntity<>(errorAttributes, headers, status);
} }
private Throwable resolveError(Throwable ex) {
while (ex instanceof ServletException && ex.getCause() != null) {
ex = ((ServletException) ex).getCause();
}
return ex;
}
} }
package com.ctrip.framework.apollo.core.dto; package com.ctrip.framework.apollo.common.dto;
public class AppDTO extends BaseDTO{ public class AppDTO extends BaseDTO{
......
package com.ctrip.framework.apollo.core.dto; package com.ctrip.framework.apollo.common.dto;
public class AppNamespaceDTO extends BaseDTO{ public class AppNamespaceDTO extends BaseDTO{
......
package com.ctrip.framework.apollo.core.dto; package com.ctrip.framework.apollo.common.dto;
import java.util.Date; import java.util.Date;
......
package com.ctrip.framework.apollo.core.dto; package com.ctrip.framework.apollo.common.dto;
public class ClusterDTO extends BaseDTO{ public class ClusterDTO extends BaseDTO{
......
package com.ctrip.framework.apollo.core.dto; package com.ctrip.framework.apollo.common.dto;
public class CommitDTO extends BaseDTO{ public class CommitDTO extends BaseDTO{
......
package com.ctrip.framework.apollo.core.dto; package com.ctrip.framework.apollo.common.dto;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
......
package com.ctrip.framework.apollo.core.dto; package com.ctrip.framework.apollo.common.dto;
public class ItemDTO extends BaseDTO{ public class ItemDTO extends BaseDTO{
......
package com.ctrip.framework.apollo.core.dto; package com.ctrip.framework.apollo.common.dto;
public class NamespaceDTO extends BaseDTO{ public class NamespaceDTO extends BaseDTO{
private long id; private long id;
......
package com.ctrip.framework.apollo.core.dto; package com.ctrip.framework.apollo.common.dto;
public class NamespaceLockDTO extends BaseDTO{ public class NamespaceLockDTO extends BaseDTO{
......
package com.ctrip.framework.apollo.core.dto; package com.ctrip.framework.apollo.common.dto;
public class ReleaseDTO extends BaseDTO{ public class ReleaseDTO extends BaseDTO{
private long id; private long id;
......
package com.ctrip.framework.apollo.portal.entity.vo; package com.ctrip.framework.apollo.common.entity;
public class EntityPair<E> { public class EntityPair<E> {
......
package com.ctrip.framework.apollo.common.exception;
import org.springframework.http.HttpStatus;
public abstract class AbstractApolloHttpException extends RuntimeException{
private static final long serialVersionUID = -1713129594004951820L;
protected HttpStatus httpStatus;
public AbstractApolloHttpException(String msg){
super(msg);
}
public AbstractApolloHttpException(String msg, Exception e){
super(msg,e);
}
protected void setHttpStatus(HttpStatus httpStatus){
this.httpStatus = httpStatus;
}
public HttpStatus getHttpStatus() {
return httpStatus;
}
}
package com.ctrip.framework.apollo.common.exception;
import org.springframework.http.HttpStatus;
public class BadRequestException extends AbstractApolloHttpException {
public BadRequestException(String str) {
super(str);
setHttpStatus(HttpStatus.BAD_REQUEST);
}
}
package com.ctrip.framework.apollo.common.exception;
public class BeanUtilsException extends RuntimeException{
public BeanUtilsException(Throwable e){
super(e);
}
}
package com.ctrip.framework.apollo.common.exception;
import org.springframework.http.HttpStatus;
public class NotFoundException extends AbstractApolloHttpException {
public NotFoundException(String str) {
super(str);
setHttpStatus(HttpStatus.NOT_FOUND);
}
}
package com.ctrip.framework.apollo.core.exception; package com.ctrip.framework.apollo.common.exception;
public class ServiceException extends AbstractBaseException { import org.springframework.http.HttpStatus;
/** public class ServiceException extends AbstractApolloHttpException {
*
*/
private static final long serialVersionUID = -6529123764065547791L;
public ServiceException(String str) { public ServiceException(String str) {
super(str); super(str);
setHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR);
} }
public ServiceException(String str, Exception e) { public ServiceException(String str, Exception e) {
super(str, e); super(str, e);
setHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR);
} }
} }
package com.ctrip.framework.apollo.common.utils; package com.ctrip.framework.apollo.common.utils;
import com.ctrip.framework.apollo.common.exception.BeanUtilsException;
import java.beans.PropertyDescriptor; import java.beans.PropertyDescriptor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -51,7 +53,7 @@ public class BeanUtils { ...@@ -51,7 +53,7 @@ public class BeanUtils {
try { try {
instance = clazz.newInstance(); instance = clazz.newInstance();
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new BeanUtilsException(e);
} }
org.springframework.beans.BeanUtils.copyProperties(src, instance, getNullPropertyNames(src)); org.springframework.beans.BeanUtils.copyProperties(src, instance, getNullPropertyNames(src));
return instance; return instance;
...@@ -95,7 +97,7 @@ public class BeanUtils { ...@@ -95,7 +97,7 @@ public class BeanUtils {
map.put((K) field.get(o), (V) o); map.put((K) field.get(o), (V) o);
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(); throw new BeanUtilsException(e);
} }
return map; return map;
} }
...@@ -127,7 +129,7 @@ public class BeanUtils { ...@@ -127,7 +129,7 @@ public class BeanUtils {
map.get(k).add((V) o); map.get(k).add((V) o);
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(); throw new BeanUtilsException(e);
} }
return map; return map;
} }
...@@ -155,7 +157,7 @@ public class BeanUtils { ...@@ -155,7 +157,7 @@ public class BeanUtils {
set.add((K)field.get(o)); set.add((K)field.get(o));
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new BeanUtilsException(e);
} }
return set; return set;
} }
...@@ -187,7 +189,7 @@ public class BeanUtils { ...@@ -187,7 +189,7 @@ public class BeanUtils {
return field.get(obj); return field.get(obj);
} }
} catch (Exception e) { } catch (Exception e) {
// ig throw new BeanUtilsException(e);
} }
return null; return null;
} }
...@@ -203,7 +205,7 @@ public class BeanUtils { ...@@ -203,7 +205,7 @@ public class BeanUtils {
field.set(obj, value); field.set(obj, value);
} }
} catch (Exception e) { } catch (Exception e) {
// ig throw new BeanUtilsException(e);
} }
} }
......
package com.ctrip.framework.apollo.common.utils; package com.ctrip.framework.apollo.common.utils;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
......
...@@ -21,7 +21,7 @@ import com.ctrip.framework.apollo.configservice.util.NamespaceUtil; ...@@ -21,7 +21,7 @@ import com.ctrip.framework.apollo.configservice.util.NamespaceUtil;
import com.ctrip.framework.apollo.configservice.util.WatchKeysUtil; import com.ctrip.framework.apollo.configservice.util.WatchKeysUtil;
import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.dto.ApolloConfigNotification; import com.ctrip.framework.apollo.core.dto.ApolloConfigNotification;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.dianping.cat.Cat; import com.dianping.cat.Cat;
import org.slf4j.Logger; import org.slf4j.Logger;
......
package com.ctrip.framework.apollo.core.exception;
public abstract class AbstractBaseException extends RuntimeException{
/**
*
*/
private static final long serialVersionUID = -1713129594004951820L;
private String errorCode;
public AbstractBaseException(){
}
public AbstractBaseException(String str){
super(str);
}
public AbstractBaseException(String str, Exception e){
super(str,e);
}
public AbstractBaseException(String str, String errorCode){
super(str);
this.setErrorCode(errorCode);
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
}
package com.ctrip.framework.apollo.core.exception;
public class BadRequestException extends AbstractBaseException {
/**
*
*/
private static final long serialVersionUID = 6060826407312134068L;
public BadRequestException(String str) {
super(str);
}
}
package com.ctrip.framework.apollo.core.exception;
public class NotFoundException extends AbstractBaseException {
/**
*
*/
private static final long serialVersionUID = 7611357629749481796L;
public NotFoundException(String str) {
super(str);
}
}
package com.ctrip.framework.apollo.portal.api; package com.ctrip.framework.apollo.portal.api;
import com.ctrip.framework.apollo.core.dto.AppNamespaceDTO; import com.ctrip.framework.apollo.common.dto.AppNamespaceDTO;
import com.ctrip.framework.apollo.core.dto.CommitDTO; import com.ctrip.framework.apollo.common.dto.CommitDTO;
import com.ctrip.framework.apollo.core.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.core.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.core.dto.ClusterDTO; import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.Health;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
......
...@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.portal.api; ...@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.portal.api;
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.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
import com.ctrip.framework.apollo.portal.constant.CatEventType; import com.ctrip.framework.apollo.portal.constant.CatEventType;
import com.dianping.cat.Cat; import com.dianping.cat.Cat;
import com.dianping.cat.message.Message; import com.dianping.cat.message.Message;
......
...@@ -6,7 +6,7 @@ import com.ctrip.framework.apollo.common.http.MultiResponseEntity; ...@@ -6,7 +6,7 @@ import com.ctrip.framework.apollo.common.http.MultiResponseEntity;
import com.ctrip.framework.apollo.common.http.RichResponseEntity; 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.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.portal.PortalSettings; import com.ctrip.framework.apollo.portal.PortalSettings;
import com.ctrip.framework.apollo.portal.entity.po.UserInfo; import com.ctrip.framework.apollo.portal.entity.po.UserInfo;
import com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo; import com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo;
......
package com.ctrip.framework.apollo.portal.controller; package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.common.utils.InputValidator; import com.ctrip.framework.apollo.common.utils.InputValidator;
import com.ctrip.framework.apollo.core.dto.ClusterDTO; import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.portal.auth.UserInfoHolder; import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.service.ClusterService; import com.ctrip.framework.apollo.portal.service.ClusterService;
......
package com.ctrip.framework.apollo.portal.controller; package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.common.utils.RequestPrecondition; import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
import com.ctrip.framework.apollo.core.dto.CommitDTO; import com.ctrip.framework.apollo.common.dto.CommitDTO;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.service.CommitService; import com.ctrip.framework.apollo.portal.service.CommitService;
......
package com.ctrip.framework.apollo.portal.controller; package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
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.form.NamespaceSyncModel; import com.ctrip.framework.apollo.portal.entity.form.NamespaceSyncModel;
......
...@@ -3,10 +3,10 @@ package com.ctrip.framework.apollo.portal.controller; ...@@ -3,10 +3,10 @@ package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.common.entity.App;
import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.common.utils.InputValidator; import com.ctrip.framework.apollo.common.utils.InputValidator;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
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.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
import com.ctrip.framework.apollo.portal.auth.UserInfoHolder; import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.entity.form.NamespaceCreationModel; import com.ctrip.framework.apollo.portal.entity.form.NamespaceCreationModel;
......
package com.ctrip.framework.apollo.portal.controller; package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.core.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.service.NamespaceLockService; import com.ctrip.framework.apollo.portal.service.NamespaceLockService;
......
...@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.portal.controller; ...@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.portal.controller;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.portal.auth.UserInfoHolder; import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.constant.RoleType; import com.ctrip.framework.apollo.portal.constant.RoleType;
import com.ctrip.framework.apollo.portal.entity.po.UserInfo; import com.ctrip.framework.apollo.portal.entity.po.UserInfo;
......
package com.ctrip.framework.apollo.portal.controller; package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.common.utils.RequestPrecondition; import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.entity.form.NamespaceReleaseModel; import com.ctrip.framework.apollo.portal.entity.form.NamespaceReleaseModel;
import com.ctrip.framework.apollo.portal.entity.vo.ReleaseCompareResult; import com.ctrip.framework.apollo.portal.entity.vo.ReleaseCompareResult;
......
package com.ctrip.framework.apollo.portal.entity.form; package com.ctrip.framework.apollo.portal.entity.form;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
public class NamespaceCreationModel { public class NamespaceCreationModel {
......
package com.ctrip.framework.apollo.portal.entity.form; package com.ctrip.framework.apollo.portal.entity.form;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifer; import com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifer;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
......
package com.ctrip.framework.apollo.portal.entity.vo; package com.ctrip.framework.apollo.portal.entity.vo;
import com.ctrip.framework.apollo.common.entity.EntityPair;
import com.ctrip.framework.apollo.portal.enums.ChangeType; import com.ctrip.framework.apollo.portal.enums.ChangeType;
public class Change { public class Change {
...@@ -24,8 +25,7 @@ public class Change { ...@@ -24,8 +25,7 @@ public class Change {
return entity; return entity;
} }
public void setEntity( public void setEntity(EntityPair<KVEntity> entity) {
EntityPair<KVEntity> entity) {
this.entity = entity; this.entity = entity;
} }
} }
package com.ctrip.framework.apollo.portal.entity.vo; package com.ctrip.framework.apollo.portal.entity.vo;
import com.ctrip.framework.apollo.core.dto.ClusterDTO; import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import java.util.List; import java.util.List;
......
package com.ctrip.framework.apollo.portal.entity.vo; package com.ctrip.framework.apollo.portal.entity.vo;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
public class ItemDiffs { public class ItemDiffs {
private NamespaceIdentifer namespace; private NamespaceIdentifer namespace;
......
package com.ctrip.framework.apollo.portal.entity.vo; package com.ctrip.framework.apollo.portal.entity.vo;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import java.util.List; import java.util.List;
......
package com.ctrip.framework.apollo.portal.entity.vo; package com.ctrip.framework.apollo.portal.entity.vo;
import com.ctrip.framework.apollo.common.entity.EntityPair;
import com.ctrip.framework.apollo.portal.enums.ChangeType; import com.ctrip.framework.apollo.portal.enums.ChangeType;
import java.util.LinkedList; import java.util.LinkedList;
......
package com.ctrip.framework.apollo.portal.entity.vo; package com.ctrip.framework.apollo.portal.entity.vo;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import java.util.Set; import java.util.Set;
......
package com.ctrip.framework.apollo.portal.listener; package com.ctrip.framework.apollo.portal.listener;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.core.dto.AppNamespaceDTO; import com.ctrip.framework.apollo.common.dto.AppNamespaceDTO;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.portal.PortalSettings; import com.ctrip.framework.apollo.portal.PortalSettings;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
......
...@@ -3,8 +3,8 @@ package com.ctrip.framework.apollo.portal.service; ...@@ -3,8 +3,8 @@ package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
import com.ctrip.framework.apollo.portal.auth.UserInfoHolder; import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.repository.AppNamespaceRepository; import com.ctrip.framework.apollo.portal.repository.AppNamespaceRepository;
......
...@@ -15,9 +15,9 @@ import org.springframework.web.client.HttpStatusCodeException; ...@@ -15,9 +15,9 @@ import org.springframework.web.client.HttpStatusCodeException;
import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.common.entity.App;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.common.utils.ExceptionUtils; import com.ctrip.framework.apollo.common.utils.ExceptionUtils;
import com.ctrip.framework.apollo.core.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.auth.UserInfoHolder; import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.constant.CatEventType; import com.ctrip.framework.apollo.portal.constant.CatEventType;
......
package com.ctrip.framework.apollo.portal.service; package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.core.dto.ClusterDTO; import com.ctrip.framework.apollo.common.dto.ClusterDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.portal.api.AdminServiceAPI; import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import com.ctrip.framework.apollo.portal.constant.CatEventType; import com.ctrip.framework.apollo.portal.constant.CatEventType;
import com.dianping.cat.Cat; import com.dianping.cat.Cat;
......
package com.ctrip.framework.apollo.portal.service; package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.core.dto.CommitDTO; import com.ctrip.framework.apollo.common.dto.CommitDTO;
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;
......
...@@ -9,18 +9,16 @@ import org.springframework.util.CollectionUtils; ...@@ -9,18 +9,16 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO;
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.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
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.auth.UserInfoHolder; import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
import com.ctrip.framework.apollo.portal.constant.CatEventType; import com.ctrip.framework.apollo.portal.constant.CatEventType;
import com.ctrip.framework.apollo.portal.entity.form.NamespaceReleaseModel;
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.NamespaceIdentifer; import com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifer;
import com.ctrip.framework.apollo.portal.entity.form.NamespaceTextModel; import com.ctrip.framework.apollo.portal.entity.form.NamespaceTextModel;
...@@ -77,7 +75,8 @@ public class ConfigService { ...@@ -77,7 +75,8 @@ public class ConfigService {
changeSets.setDataChangeLastModifiedBy(userInfoHolder.getUser().getUserId()); changeSets.setDataChangeLastModifiedBy(userInfoHolder.getUser().getUserId());
itemAPI.updateItemsByChangeSet(appId, env, clusterName, namespaceName, changeSets); itemAPI.updateItemsByChangeSet(appId, env, clusterName, namespaceName, changeSets);
Cat.logEvent(CatEventType.MODIFY_NAMESPACE_BY_TEXT, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName)); Cat.logEvent(CatEventType.MODIFY_NAMESPACE_BY_TEXT,
String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName));
Cat.logEvent(CatEventType.MODIFY_NAMESPACE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName)); Cat.logEvent(CatEventType.MODIFY_NAMESPACE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName));
} }
...@@ -128,7 +127,7 @@ public class ConfigService { ...@@ -128,7 +127,7 @@ public class ConfigService {
itemAPI.updateItemsByChangeSet(appId, env, clusterName, namespaceName, changeSets); itemAPI.updateItemsByChangeSet(appId, env, clusterName, namespaceName, changeSets);
Cat.logEvent(CatEventType.SYNC_NAMESPACE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName)); Cat.logEvent(CatEventType.SYNC_NAMESPACE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName));
} }
} }
public List<ItemDiffs> compare(List<NamespaceIdentifer> comparedNamespaces, List<ItemDTO> sourceItems) { public List<ItemDiffs> compare(List<NamespaceIdentifer> comparedNamespaces, List<ItemDTO> sourceItems) {
...@@ -212,7 +211,7 @@ public class ConfigService { ...@@ -212,7 +211,7 @@ public class ConfigService {
private ItemDTO buildItem(long namespaceId, int lineNum, ItemDTO sourceItem) { private ItemDTO buildItem(long namespaceId, int lineNum, ItemDTO sourceItem) {
ItemDTO createdItem = new ItemDTO(); ItemDTO createdItem = new ItemDTO();
BeanUtils.copyEntityProperties(sourceItem, createdItem); BeanUtils.copyEntityProperties(sourceItem, createdItem);
createdItem.setLineNum(lineNum++); createdItem.setLineNum(lineNum);
createdItem.setNamespaceId(namespaceId); createdItem.setNamespaceId(namespaceId);
return createdItem; return createdItem;
} }
......
package com.ctrip.framework.apollo.portal.service; package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.core.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;
......
...@@ -4,9 +4,9 @@ import com.google.gson.Gson; ...@@ -4,9 +4,9 @@ import com.google.gson.Gson;
import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
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.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
......
...@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.portal.service; ...@@ -3,7 +3,7 @@ package com.ctrip.framework.apollo.portal.service;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
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.auth.UserInfoHolder; import com.ctrip.framework.apollo.portal.auth.UserInfoHolder;
......
package com.ctrip.framework.apollo.portal.service.txtresolver; package com.ctrip.framework.apollo.portal.service.txtresolver;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import java.util.List; import java.util.List;
......
package com.ctrip.framework.apollo.portal.service.txtresolver; package com.ctrip.framework.apollo.portal.service.txtresolver;
import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.utils.StringUtils; import com.ctrip.framework.apollo.core.utils.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -37,6 +37,7 @@ public class FileTextResolver implements ConfigTextResolver { ...@@ -37,6 +37,7 @@ public class FileTextResolver implements ConfigTextResolver {
item.setId(itemId); item.setId(itemId);
item.setNamespaceId(namespaceId); item.setNamespaceId(namespaceId);
item.setValue(value); item.setValue(value);
item.setLineNum(1);
item.setKey(ConfigConsts.CONFIG_FILE_CONTENT_KEY); item.setKey(ConfigConsts.CONFIG_FILE_CONTENT_KEY);
return item; return item;
} }
......
package com.ctrip.framework.apollo.portal.service.txtresolver; package com.ctrip.framework.apollo.portal.service.txtresolver;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
......
...@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.portal; ...@@ -2,7 +2,7 @@ package com.ctrip.framework.apollo.portal;
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.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
import com.ctrip.framework.apollo.portal.api.AdminServiceAddressLocator; import com.ctrip.framework.apollo.portal.api.AdminServiceAddressLocator;
import com.ctrip.framework.apollo.portal.api.RetryableRestTemplate; import com.ctrip.framework.apollo.portal.api.RetryableRestTemplate;
......
...@@ -23,8 +23,8 @@ import org.springframework.web.client.HttpStatusCodeException; ...@@ -23,8 +23,8 @@ import org.springframework.web.client.HttpStatusCodeException;
import com.ctrip.framework.apollo.common.entity.App; import com.ctrip.framework.apollo.common.entity.App;
import com.ctrip.framework.apollo.common.utils.ExceptionUtils; import com.ctrip.framework.apollo.common.utils.ExceptionUtils;
import com.ctrip.framework.apollo.core.dto.AppDTO; import com.ctrip.framework.apollo.common.dto.AppDTO;
import com.ctrip.framework.apollo.core.exception.ServiceException; import com.ctrip.framework.apollo.common.exception.ServiceException;
import com.ctrip.framework.apollo.portal.controller.AppController; import com.ctrip.framework.apollo.portal.controller.AppController;
import com.ctrip.framework.apollo.portal.service.UserService; import com.ctrip.framework.apollo.portal.service.UserService;
...@@ -69,9 +69,8 @@ public class ServiceExceptionTest extends AbstractIntegrationTest { ...@@ -69,9 +69,8 @@ public class ServiceExceptionTest extends AbstractIntegrationTest {
} catch (HttpStatusCodeException e) { } catch (HttpStatusCodeException e) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, String> attr = new Gson().fromJson(e.getResponseBodyAsString(), Map.class); Map<String, String> attr = new Gson().fromJson(e.getResponseBodyAsString(), Map.class);
System.out.println(ExceptionUtils.toString(e)); Assert.assertEquals("500 admin server error", attr.get("message"));
Assert.assertEquals("No available admin service", attr.get("message")); Assert.assertEquals(500.0, attr.get("status"));
Assert.assertEquals("8848", attr.get("errorCode"));
} }
} }
......
...@@ -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.entity.AppNamespace; import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.enums.ConfigFileFormat; import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.portal.AbstractIntegrationTest; import com.ctrip.framework.apollo.portal.AbstractIntegrationTest;
import org.junit.Assert; import org.junit.Assert;
......
package com.ctrip.framework.apollo.portal.service; package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
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;
...@@ -12,7 +12,6 @@ import com.ctrip.framework.apollo.portal.entity.po.UserInfo; ...@@ -12,7 +12,6 @@ import com.ctrip.framework.apollo.portal.entity.po.UserInfo;
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.NamespaceIdentifer; import com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifer;
import com.ctrip.framework.apollo.portal.entity.form.NamespaceTextModel; import com.ctrip.framework.apollo.portal.entity.form.NamespaceTextModel;
import com.ctrip.framework.apollo.portal.service.ConfigService;
import com.ctrip.framework.apollo.portal.service.txtresolver.PropertyResolver; import com.ctrip.framework.apollo.portal.service.txtresolver.PropertyResolver;
import org.junit.Assert; import org.junit.Assert;
......
package com.ctrip.framework.apollo.portal.service; package com.ctrip.framework.apollo.portal.service;
import com.ctrip.framework.apollo.common.entity.AppNamespace; import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.dto.NamespaceDTO; import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import com.ctrip.framework.apollo.core.dto.ReleaseDTO; import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
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;
......
package com.ctrip.framework.apollo.portal.service.txtresolver; package com.ctrip.framework.apollo.portal.service.txtresolver;
import com.ctrip.framework.apollo.core.ConfigConsts; import com.ctrip.framework.apollo.core.ConfigConsts;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.portal.AbstractUnitTest; import com.ctrip.framework.apollo.portal.AbstractUnitTest;
import org.junit.Assert; import org.junit.Assert;
......
package com.ctrip.framework.apollo.portal.service.txtresolver; package com.ctrip.framework.apollo.portal.service.txtresolver;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets; import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO; import com.ctrip.framework.apollo.common.dto.ItemDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException; import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.portal.AbstractUnitTest; import com.ctrip.framework.apollo.portal.AbstractUnitTest;
import org.junit.Assert; import org.junit.Assert;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册