From 03d961e73f92d0a0855fbabf556aefa2be27a8f0 Mon Sep 17 00:00:00 2001 From: zhangdongxu Date: Thu, 30 Aug 2018 16:19:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=91=98=E8=A6=81=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=B7=A5=E5=85=B7=E8=8E=B7=E5=8F=96=E6=91=98=E8=A6=81?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=97=B6=EF=BC=8C=E5=A6=82=E6=9E=9C=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=9A=84=E4=BF=A1=E6=81=AF=E4=B8=BA=E7=A9=BA=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E6=98=AF=E5=B7=A5=E5=85=B7=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=EF=BC=8C=E7=BB=99=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8=E4=BF=A1=E6=81=AF=EF=BC=9B?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=9C=89=E8=BF=94=E5=9B=9E=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BD=86=E6=98=AF=E4=B8=8D=E5=8C=85=E5=90=AB=E6=91=98=E8=A6=81?= =?UTF-8?q?=E9=83=A8=E5=88=86=EF=BC=8C=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E4=B8=ADdigest=E5=B1=9E=E6=80=A7=E7=9A=84=E5=80=BC=E4=B8=BA""?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/restful/ConfigSourcesController.java | 4 ++-- .../com/nis/web/service/restful/ConfigSourcesService.java | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) 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];