diff --git a/common/pom.xml b/common/pom.xml
index f09b1adf..0547f90e 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -53,12 +53,12 @@
${commons-text.version}
-
+
@@ -88,12 +88,12 @@
${fastjson.version}
-
+
+
@@ -136,11 +136,11 @@
commons-email
${commons-email.version}
-
+
@@ -210,7 +210,7 @@
${zxing.version}
-
+
org.apache.poi
poi
diff --git a/common/src/main/java/com/jeesite/common/io/FileUtils.java b/common/src/main/java/com/jeesite/common/io/FileUtils.java
index adcfb8c0..eeaf1a36 100644
--- a/common/src/main/java/com/jeesite/common/io/FileUtils.java
+++ b/common/src/main/java/com/jeesite/common/io/FileUtils.java
@@ -13,6 +13,9 @@ import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.util.Enumeration;
import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
import javax.activation.MimetypesFileTypeMap;
import javax.servlet.ServletOutputStream;
@@ -21,9 +24,6 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
-import org.apache.tools.zip.ZipEntry;
-import org.apache.tools.zip.ZipFile;
-import org.apache.tools.zip.ZipOutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
@@ -462,14 +462,18 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
}
}
+// public static void main(String[] args) {
+// zipFiles("target\\classes", "*", "target\\classes.zip");
+// unZipFiles("target\\classes.zip", "target\\classes2");
+// }
+
/**
* 压缩文件或目录
* @param srcDirName 压缩的根目录
* @param fileName 根目录下的待压缩的文件名或文件夹名,其中*或""表示跟目录下的全部文件
* @param descFileName 目标zip文件
*/
- public static void zipFiles(String srcDirName, String fileName,
- String descFileName) {
+ public static void zipFiles(String srcDirName, String fileName, String descFileName) {
// 判断目录是否存在
if (srcDirName == null) {
logger.debug("文件压缩失败,目录 " + srcDirName + " 不存在!");
@@ -483,8 +487,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
String dirPath = fileDir.getAbsolutePath();
File descFile = new File(descFileName);
try {
- ZipOutputStream zouts = new ZipOutputStream(new FileOutputStream(
- descFile));
+ ZipOutputStream zouts = new ZipOutputStream(new FileOutputStream(descFile));
if ("*".equals(fileName) || "".equals(fileName)) {
FileUtils.zipDirectoryToZipFile(dirPath, fileDir, zouts);
} else {
@@ -492,8 +495,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
if (file.isFile()) {
FileUtils.zipFilesToZipFile(dirPath, file, zouts);
} else {
- FileUtils
- .zipDirectoryToZipFile(dirPath, file, zouts);
+ FileUtils.zipDirectoryToZipFile(dirPath, file, zouts);
}
}
zouts.close();
@@ -525,7 +527,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
int readByte = 0;
// 获取ZIP文件里所有的entry
@SuppressWarnings("rawtypes")
- Enumeration enums = zipFile.getEntries();
+ Enumeration enums = zipFile.entries();
// 遍历所有entry
while (enums.hasMoreElements()) {
entry = (ZipEntry) enums.nextElement();
@@ -585,12 +587,10 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) {
// 如果是文件,则调用文件压缩方法
- FileUtils
- .zipFilesToZipFile(dirPath, files[i], zouts);
+ FileUtils.zipFilesToZipFile(dirPath, files[i], zouts);
} else {
// 如果是目录,则递归调用
- FileUtils.zipDirectoryToZipFile(dirPath, files[i],
- zouts);
+ FileUtils.zipDirectoryToZipFile(dirPath, files[i], zouts);
}
}
}
@@ -646,7 +646,6 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
filePath += "/";
}
int index = filePath.indexOf(dirPaths);
-
return filePath.substring(index + dirPaths.length());
}
diff --git a/common/src/main/java/com/jeesite/common/mapper/XmlMapper.java b/common/src/main/java/com/jeesite/common/mapper/XmlMapper.java
index a4b3de46..3361a461 100644
--- a/common/src/main/java/com/jeesite/common/mapper/XmlMapper.java
+++ b/common/src/main/java/com/jeesite/common/mapper/XmlMapper.java
@@ -4,21 +4,9 @@
package com.jeesite.common.mapper;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import java.util.TimeZone;
import org.apache.commons.lang3.StringUtils;
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
-import org.dom4j.Namespace;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
@@ -124,167 +112,167 @@ public class XmlMapper extends com.fasterxml.jackson.dataformat.xml.XmlMapper{
return (T) XmlMapper.getInstance().fromXmlString(jsonString, clazz);
}
- /**
- * xml转map 不带属性
- * @param xmlStr
- * @param needRootKey 是否需要在返回的map里加根节点键
- * @throws DocumentException
- */
- @SuppressWarnings("unchecked")
- public static Map xmlToMap(String xmlStr, boolean needRootKey) {
- try {
- Document doc = DocumentHelper.parseText(xmlStr);
- Element root = doc.getRootElement();
- Map map = (Map) xmlToMap(root);
- if (root.elements().size() == 0 && root.attributes().size() == 0) {
- return map;
- }
- if (needRootKey) {
- //在返回的map里加根节点键(如果需要)
- Map rootMap = new HashMap();
- rootMap.put(root.getName(), map);
- return rootMap;
- }
- return map;
- } catch (DocumentException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * xml转map 带属性
- * @param xmlStr
- * @param needRootKey 是否需要在返回的map里加根节点键
- * @return
- * @throws DocumentException
- */
- @SuppressWarnings("unchecked")
- public static Map xmlToMapWithAttr(String xmlStr, boolean needRootKey) {
- try {
- Document doc = DocumentHelper.parseText(xmlStr);
- Element root = doc.getRootElement();
- Map map = (Map) xmlToMapWithAttr(root);
- if (root.elements().size() == 0 && root.attributes().size() == 0) {
- return map; //根节点只有一个文本内容
- }
- if (needRootKey) {
- //在返回的map里加根节点键(如果需要)
- Map rootMap = new HashMap();
- rootMap.put(root.getName(), map);
- return rootMap;
- }
- return map;
- } catch (DocumentException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * xml转map 不带属性
- * @param element
- * @return
- */
- private static Object xmlToMap(Element element) {
- // System.out.println(element.getName());
- Map map = new LinkedHashMap();
- List elements = element.elements();
- if (elements.size() == 0) {
- map.put(element.getName(), element.getText());
- if (!element.isRootElement()) {
- return element.getText();
- }
- } else if (elements.size() == 1) {
- map.put(elements.get(0).getName(), xmlToMap(elements.get(0)));
- } else if (elements.size() > 1) {
- // 多个子节点的话就得考虑list的情况了,比如多个子节点有节点名称相同的
- // 构造一个map用来去重
- Map tempMap = new LinkedHashMap();
- for (Element ele : elements) {
- tempMap.put(ele.getName(), ele);
- }
- Set keySet = tempMap.keySet();
- for (String string : keySet) {
- Namespace namespace = tempMap.get(string).getNamespace();
- List elements2 = element.elements(new org.dom4j.QName(string, namespace));
- // 如果同名的数目大于1则表示要构建list
- if (elements2.size() > 1) {
- List
-
-