Commit 1665f492 by lepdou

not found lock return null

parent e7d91c7d
...@@ -35,13 +35,13 @@ public class NamespaceLockController { ...@@ -35,13 +35,13 @@ public class NamespaceLockController {
} }
if (apolloSwitcher.isNamespaceLockSwitchOff()) { if (apolloSwitcher.isNamespaceLockSwitchOff()) {
throw new NotFoundException(namespaceName + " is not locked"); return null;
} }
NamespaceLock lock = namespaceLockService.findLock(namespace.getId()); NamespaceLock lock = namespaceLockService.findLock(namespace.getId());
if (lock == null) { if (lock == null) {
throw new NotFoundException(namespaceName + " is not locked"); return null;
} }
return BeanUtils.transfrom(NamespaceLockDTO.class, lock); return BeanUtils.transfrom(NamespaceLockDTO.class, lock);
......
...@@ -2,15 +2,12 @@ package com.ctrip.framework.apollo.portal.controller; ...@@ -2,15 +2,12 @@ package com.ctrip.framework.apollo.portal.controller;
import com.ctrip.framework.apollo.core.dto.NamespaceLockDTO; import com.ctrip.framework.apollo.core.dto.NamespaceLockDTO;
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.portal.service.NamespaceLockService; import com.ctrip.framework.apollo.portal.service.NamespaceLockService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.HttpClientErrorException;
@RestController @RestController
public class NamespaceLockController { public class NamespaceLockController {
...@@ -22,15 +19,7 @@ public class NamespaceLockController { ...@@ -22,15 +19,7 @@ public class NamespaceLockController {
public NamespaceLockDTO getNamespaceLock(@PathVariable String appId, @PathVariable String env, public NamespaceLockDTO getNamespaceLock(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName){ @PathVariable String clusterName, @PathVariable String namespaceName){
try {
return namespaceLockService.getNamespaceLock(appId, Env.valueOf(env), clusterName, namespaceName); return namespaceLockService.getNamespaceLock(appId, Env.valueOf(env), clusterName, namespaceName);
} catch (HttpClientErrorException e){
if (e.getStatusCode() == HttpStatus.NOT_FOUND){
return null;
}
throw new ServiceException("service error", e);
}
} }
} }
...@@ -13,7 +13,6 @@ public class NamespaceLockService { ...@@ -13,7 +13,6 @@ public class NamespaceLockService {
@Autowired @Autowired
private AdminServiceAPI.NamespaceLockAPI namespaceLockAPI; private AdminServiceAPI.NamespaceLockAPI namespaceLockAPI;
public NamespaceLockDTO getNamespaceLock(String appId, Env env, String clusterName, String namespaceName){ public NamespaceLockDTO getNamespaceLock(String appId, Env env, String clusterName, String namespaceName){
return namespaceLockAPI.getNamespaceLockOwner(appId, env, clusterName, namespaceName); return namespaceLockAPI.getNamespaceLockOwner(appId, env, clusterName, namespaceName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment