From b803b3825c23da5b8b27ef60ae96d12fec7f9944 Mon Sep 17 00:00:00 2001 From: chenlw <874313221@qq.com> Date: Wed, 28 Sep 2016 16:44:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=95=B0=E6=8D=AE=EF=BC=8C?= =?UTF-8?q?=E5=8F=AA=E5=88=A0=E9=99=A4=E8=AF=A5=E6=9D=A1=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=9A=84=E7=89=88=E6=9C=AC=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=88=A0=E9=99=A4=E7=B3=BB=E7=BB=9F=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/service/DataInfoServiceImp.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/com/platform/service/DataInfoServiceImp.java b/src/com/platform/service/DataInfoServiceImp.java index 4baf7db0..f947f72f 100644 --- a/src/com/platform/service/DataInfoServiceImp.java +++ b/src/com/platform/service/DataInfoServiceImp.java @@ -3,9 +3,12 @@ package com.platform.service; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.annotation.Resource; +import org.apache.log4j.Logger; import org.springframework.stereotype.Service; import org.springframework.ui.ModelMap; @@ -13,12 +16,20 @@ import com.base.CustomException; import com.platform.dao.DataInfoDao; import com.platform.entities.DataInfoEntity; import com.platform.entities.PagerOptions; +import com.platform.glusterfs.RemoveData; import com.platform.utils.Bean2MapUtils; +import com.platform.utils.Configs; @Service(value = "dataInfoService") public class DataInfoServiceImp implements DataInfoService { + + /** log4j */ + public static Logger log = Configs.DAILY_ROLLING_LOGGER; + @Resource(name = "dataInfoDao") private DataInfoDao dfdDao; + + private RemoveData removedata = new RemoveData(); public void setDfdDao(DataInfoDao dfdDao) { this.dfdDao = dfdDao; @@ -70,9 +81,24 @@ public class DataInfoServiceImp implements DataInfoService { //数据在不在? List paths = dfdDao.getIdIsExist(ids); if(paths.size()>0){ - //删除文件操作 + //TODO 删除文件操作 + Pattern pattern = Pattern + .compile("\\/$"); for (int i = 0; i < paths.size(); i++) { - System.out.println(paths.get(i)); + String folderPath = paths.get(i); + Matcher matcher = pattern.matcher(folderPath); + String tailPath = ""; + if (matcher.find()) { + tailPath = matcher.group(); + } + folderPath = folderPath.substring(0, folderPath.length()-tailPath.length()); + int res = removedata.deleteFolder(folderPath); + if (res != 1) { + log.error( folderPath+ " 删除失败!\n"); + } + else { + log.info( folderPath+ " 删除成功!\n"); + } } //删除数据库记录 dfdDao.removes(ids);