diff --git a/src/main/java/com/nis/web/controller/restful/ConfigSourcesController.java b/src/main/java/com/nis/web/controller/restful/ConfigSourcesController.java index aeadd46..be2f50b 100644 --- a/src/main/java/com/nis/web/controller/restful/ConfigSourcesController.java +++ b/src/main/java/com/nis/web/controller/restful/ConfigSourcesController.java @@ -360,7 +360,7 @@ public class ConfigSourcesController extends BaseRestController { logger.info("摘要获取开始:---------------"); String digestStr = configSourcesService.getDigestGen(request.getRealPath(File.separator), tempFilePath); logger.info("摘要获取结束:---------------:"+digestStr); - resultObject.put("digest", digestStr); + resultObject.put("digest", null==digestStr?"":digestStr); resultObject.put("rawLen", file.getSize()); FileUtils.deleteFile(tempFilePath); } catch (Exception e) { @@ -368,7 +368,7 @@ public class ConfigSourcesController extends BaseRestController { e.printStackTrace(); logger.error(RestBusinessCode.GetFileDigestFailure.getValue()+":"+e.getMessage()+",请检查摘要获取工具是否安装成功"); thread.setExceptionInfo("摘要获取过程中出现异常:"+e.getMessage()+",请检查摘要获取工具是否安装成功"); - throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start, RestBusinessCode.GetFileDigestFailure.getValue()+":"+e.getMessage()+",请检查摘要获取工具是否安装成功", + throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start, RestBusinessCode.GetFileDigestFailure.getErrorReason()+":"+e.getMessage()+",请检查摘要获取工具是否安装成功", RestBusinessCode.GetFileDigestFailure.getValue()); } return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "摘要获取成功", resultObject); diff --git a/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java b/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java index 95d9c8b..de09f1b 100644 --- a/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java +++ b/src/main/java/com/nis/web/service/restful/ConfigSourcesService.java @@ -759,7 +759,7 @@ public class ConfigSourcesService extends BaseService { // System.out.println("----------------chmodCommod:"+chmodCommond); String commondStr = realPath + digestGenToolPath + " -f " + filePath; // 执行 // 执行摘要获取命令 digest -f /home/aa.txt - // System.out.println("------------commondStr:"+commondStr); + logger.info("------------commondStr:"+commondStr); Runtime.getRuntime().exec(chmodCommond); Process p = Runtime.getRuntime().exec(commondStr); byte[] b = new byte[1024]; @@ -771,7 +771,10 @@ public class ConfigSourcesService extends BaseService { if (!StringUtil.isBlank(content)) { content = StringUtil.stripAll(content); } - // System.out.println("-------------------->>"+content); + logger.info("摘要工具获取到的内容-------------------->>"+content); + if (StringUtil.isEmpty(content)) { + throw new Exception("调用摘要工具获取到的内容为空"); + } String[] digestGenReslt = content.split(" "); if (digestGenReslt.length >= 4 && !StringUtil.isEmpty(digestGenReslt[3])) { return digestGenReslt[3];