Showing
1 changed file
with
15 additions
and
9 deletions
@@ -195,17 +195,20 @@ public class MObjectInfoCtrl { | @@ -195,17 +195,20 @@ public class MObjectInfoCtrl { | ||
195 | 195 | ||
196 | DEBUG.debug("Add mObject: {}", request); | 196 | DEBUG.debug("Add mObject: {}", request); |
197 | 197 | ||
198 | - BaseResponse response = null; | 198 | + BaseResponse response = new BaseResponse(); |
199 | 199 | ||
200 | try { | 200 | try { |
201 | if (null != request) { | 201 | if (null != request) { |
202 | 202 | ||
203 | - response = checkHost(request.getMoHostIp()); | 203 | + if (!checkHost(request.getMoHostIp())) { |
204 | 204 | ||
205 | - if (null != response) { | 205 | + response.setCode(400); |
206 | + | ||
207 | + response.setMessage("Host " + request.getMoHostIp() + " does not exist..."); | ||
206 | 208 | ||
207 | return response; | 209 | return response; |
208 | } | 210 | } |
211 | + | ||
209 | MObjectInfo info = new MObjectInfo(); | 212 | MObjectInfo info = new MObjectInfo(); |
210 | 213 | ||
211 | info.setMoName(request.getMoName()); | 214 | info.setMoName(request.getMoName()); |
@@ -261,17 +264,20 @@ public class MObjectInfoCtrl { | @@ -261,17 +264,20 @@ public class MObjectInfoCtrl { | ||
261 | 264 | ||
262 | DEBUG.debug("Update mObject: {}", request); | 265 | DEBUG.debug("Update mObject: {}", request); |
263 | 266 | ||
264 | - BaseResponse response = null; | 267 | + BaseResponse response = new BaseResponse(); |
265 | 268 | ||
266 | try { | 269 | try { |
267 | if (null != request) { | 270 | if (null != request) { |
268 | 271 | ||
269 | - response = checkHost(request.getMoHostIp()); | 272 | + if (!checkHost(request.getMoHostIp())) { |
270 | 273 | ||
271 | - if (null != response) { | 274 | + response.setCode(400); |
275 | + | ||
276 | + response.setMessage("Host " + request.getMoHostIp() + " does not exist..."); | ||
272 | 277 | ||
273 | return response; | 278 | return response; |
274 | } | 279 | } |
280 | + | ||
275 | MObjectInfo info = new MObjectInfo(); | 281 | MObjectInfo info = new MObjectInfo(); |
276 | 282 | ||
277 | info.setMoId(request.getMoId()); | 283 | info.setMoId(request.getMoId()); |
@@ -300,12 +306,12 @@ public class MObjectInfoCtrl { | @@ -300,12 +306,12 @@ public class MObjectInfoCtrl { | ||
300 | return response; | 306 | return response; |
301 | } | 307 | } |
302 | 308 | ||
303 | - private BaseResponse checkHost(String hostIp) { | 309 | + private boolean checkHost(String hostIp) { |
304 | 310 | ||
305 | if (null == hostInfoService.getHostInfoByHostIp(hostIp)) { | 311 | if (null == hostInfoService.getHostInfoByHostIp(hostIp)) { |
306 | 312 | ||
307 | - return new BaseResponse(400, "Host " + hostIp + " does not exist..."); | 313 | + return false; |
308 | } | 314 | } |
309 | - return new BaseResponse(); | 315 | + return true; |
310 | } | 316 | } |
311 | } | 317 | } |
-
Please register or login to post a comment