Authored by jack.xue

fix ip validate

... ... @@ -195,17 +195,20 @@ public class MObjectInfoCtrl {
DEBUG.debug("Add mObject: {}", request);
BaseResponse response = null;
BaseResponse response = new BaseResponse();
try {
if (null != request) {
response = checkHost(request.getMoHostIp());
if (!checkHost(request.getMoHostIp())) {
if (null != response) {
response.setCode(400);
response.setMessage("Host " + request.getMoHostIp() + " does not exist...");
return response;
}
MObjectInfo info = new MObjectInfo();
info.setMoName(request.getMoName());
... ... @@ -261,17 +264,20 @@ public class MObjectInfoCtrl {
DEBUG.debug("Update mObject: {}", request);
BaseResponse response = null;
BaseResponse response = new BaseResponse();
try {
if (null != request) {
response = checkHost(request.getMoHostIp());
if (!checkHost(request.getMoHostIp())) {
if (null != response) {
response.setCode(400);
response.setMessage("Host " + request.getMoHostIp() + " does not exist...");
return response;
}
MObjectInfo info = new MObjectInfo();
info.setMoId(request.getMoId());
... ... @@ -300,12 +306,12 @@ public class MObjectInfoCtrl {
return response;
}
private BaseResponse checkHost(String hostIp) {
private boolean checkHost(String hostIp) {
if (null == hostInfoService.getHostInfoByHostIp(hostIp)) {
return new BaseResponse(400, "Host " + hostIp + " does not exist...");
return false;
}
return new BaseResponse();
return true;
}
}
... ...