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 list = new ArrayList(); - for (Element ele : elements2) { - list.add(xmlToMap(ele)); - } - map.put(string, list); - } else { - // 同名的数量不大于1则直接递归去 - map.put(string, xmlToMap(elements2.get(0))); - } - } - } - - return map; - } - - /** - * xml转map 带属性 - * @param element - * @return - */ - private static Object xmlToMapWithAttr(Element element) { - // System.out.println(element.getName()); - Map map = new LinkedHashMap(); - List elements = element.elements(); - - List listAttr = element.attributes(); // 当前节点的所有属性的list - boolean hasAttributes = false; - for (Attribute attr : listAttr) { - hasAttributes = true; - map.put("@" + attr.getName(), attr.getValue()); - } - - if (elements.size() == 0) { - // map.put(element.getName(), element.getText()); - if (hasAttributes) { - map.put("#text", element.getText()); - } else { - map.put(element.getName(), element.getText()); - } - - if (!element.isRootElement()) { - // return element.getText(); - if (!hasAttributes) { - return element.getText(); - } - } - } else if (elements.size() == 1) { - map.put(elements.get(0).getName(), xmlToMapWithAttr(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 list = new ArrayList(); - for (Element ele : elements2) { - list.add(xmlToMapWithAttr(ele)); - } - map.put(string, list); - } else { - // 同名的数量不大于1则直接递归去 - map.put(string, xmlToMapWithAttr(elements2.get(0))); - } - } - } - - return map; - } +// /** +// * 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 list = new ArrayList(); +// for (Element ele : elements2) { +// list.add(xmlToMap(ele)); +// } +// map.put(string, list); +// } else { +// // 同名的数量不大于1则直接递归去 +// map.put(string, xmlToMap(elements2.get(0))); +// } +// } +// } +// +// return map; +// } +// +// /** +// * xml转map 带属性 +// * @param element +// * @return +// */ +// private static Object xmlToMapWithAttr(Element element) { +// // System.out.println(element.getName()); +// Map map = new LinkedHashMap(); +// List elements = element.elements(); +// +// List listAttr = element.attributes(); // 当前节点的所有属性的list +// boolean hasAttributes = false; +// for (Attribute attr : listAttr) { +// hasAttributes = true; +// map.put("@" + attr.getName(), attr.getValue()); +// } +// +// if (elements.size() == 0) { +// // map.put(element.getName(), element.getText()); +// if (hasAttributes) { +// map.put("#text", element.getText()); +// } else { +// map.put(element.getName(), element.getText()); +// } +// +// if (!element.isRootElement()) { +// // return element.getText(); +// if (!hasAttributes) { +// return element.getText(); +// } +// } +// } else if (elements.size() == 1) { +// map.put(elements.get(0).getName(), xmlToMapWithAttr(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 list = new ArrayList(); +// for (Element ele : elements2) { +// list.add(xmlToMapWithAttr(ele)); +// } +// map.put(string, list); +// } else { +// // 同名的数量不大于1则直接递归去 +// map.put(string, xmlToMapWithAttr(elements2.get(0))); +// } +// } +// } +// +// return map; +// } // public static void main(String[] args) throws Exception { // diff --git a/common/src/main/java/com/jeesite/common/msg/EmailUtils.java b/common/src/main/java/com/jeesite/common/msg/EmailUtils.java index 48c12eae..d6dd7131 100644 --- a/common/src/main/java/com/jeesite/common/msg/EmailUtils.java +++ b/common/src/main/java/com/jeesite/common/msg/EmailUtils.java @@ -77,4 +77,9 @@ public class EmailUtils { return false; } +// public static void main(String[] args) { +// EmailUtils.send("jeesite_demo@163.com", "jeesitedemo1234", "smtp.163.com", +// "false", "465", "jeesite_demo@163.com", "测试邮件", "测试邮件的内容"); +// } + } \ No newline at end of file diff --git a/common/src/main/java/com/jeesite/common/reflect/ReflectUtils.java b/common/src/main/java/com/jeesite/common/reflect/ReflectUtils.java index 80183f66..03b1c968 100644 --- a/common/src/main/java/com/jeesite/common/reflect/ReflectUtils.java +++ b/common/src/main/java/com/jeesite/common/reflect/ReflectUtils.java @@ -296,7 +296,8 @@ public class ReflectUtils { * 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 */ public static void makeAccessible(Method method) { - if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) + if ((!Modifier.isPublic(method.getModifiers()) + || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) && !method.isAccessible()) { method.setAccessible(true); } @@ -306,8 +307,9 @@ public class ReflectUtils { * 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 */ public static void makeAccessible(Field field) { - if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) || Modifier - .isFinal(field.getModifiers())) && !field.isAccessible()) { + if ((!Modifier.isPublic(field.getModifiers()) + || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) + || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) { field.setAccessible(true); } } @@ -333,16 +335,12 @@ public class ReflectUtils { * @return the index generic declaration, or Object.class if cannot be determined */ public static Class getClassGenricType(final Class clazz, final int index) { - Type genType = clazz.getGenericSuperclass(); - if (!(genType instanceof ParameterizedType)) { logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType"); return Object.class; } - Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); - if (index >= params.length || index < 0) { logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " + params.length); @@ -352,7 +350,6 @@ public class ReflectUtils { logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter"); return Object.class; } - return (Class) params[index]; } diff --git a/parent/pom.xml b/parent/pom.xml index 19207a1a..516c5ea6 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -21,22 +21,22 @@ - 2.6 + 2.7 1.4 1.9.4 - 1.8 - 1.10.7 + 1.9 + 2.57 - 1.2.70 - 2.11.0 - 2.1.1 - 1.12.2 + 1.2.73 + 2.11.2 + + 1.5 1.1.1 1.21 - 0.4.11 - 3.5 + 0.4.12 + 3.6 1.1.2 0.1.5 3.4.0 @@ -47,8 +47,8 @@ 3.5.5 2.0.5 - 3.1 - 1.1.22 + 3.2 + 1.1.23 1.6.0 2.8.0-release 3.1-SNAPSHOT diff --git a/web/pom.xml b/web/pom.xml index 7af3547f..e1b32acf 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -47,14 +47,14 @@ ${project.parent.version} - -