diff --git a/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java b/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java
index be1036f0d8..4e4592dcde 100644
--- a/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java
+++ b/designer-base/src/main/java/com/fr/env/detect/base/DetectorConstants.java
@@ -8,4 +8,11 @@ public class DetectorConstants {
public static final String JAR_HELP_LINK = "https://help.fanruan.com/finereport/doc-view-4700.html?source=3";
public static final String FINE_DB_HELP_LINK = "https://help.fanruan.com/finereport/doc-view-4701.html?source=3";
+
+ public static final String SEPARATOR = "、";
+ public static final String BR_TAG = "
";
+
+ public static final String WEB_LIB_PATH = "%FR_HOME%\\webapps\\webroot\\WEB-INF\\lib:";
+
+ public static final String FR_HOME_LIB = "%FR_HOME%\\lib:";
}
diff --git a/designer-base/src/main/java/com/fr/env/detect/base/DetectorUtil.java b/designer-base/src/main/java/com/fr/env/detect/base/DetectorUtil.java
index fdfccf216f..fd6c33607c 100644
--- a/designer-base/src/main/java/com/fr/env/detect/base/DetectorUtil.java
+++ b/designer-base/src/main/java/com/fr/env/detect/base/DetectorUtil.java
@@ -1,6 +1,7 @@
package com.fr.env.detect.base;
import com.fr.base.function.ThrowableRunnable;
+import com.fr.common.util.Collections;
import com.fr.design.components.notification.NotificationAction;
import com.fr.design.components.notification.NotificationMessage;
import com.fr.design.components.notification.NotificationModel;
@@ -14,7 +15,7 @@ import com.fr.env.detect.bean.ExceptionTips;
import com.fr.env.detect.bean.Message;
import com.fr.env.detect.bean.SolutionAction;
import com.fr.general.build.BuildInfo;
-import com.fr.stable.StringUtils;
+import com.fr.third.org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import javax.swing.JComponent;
@@ -22,9 +23,15 @@ import java.awt.Desktop;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
+import static com.fr.env.detect.base.DetectorConstants.BR_TAG;
+import static com.fr.env.detect.base.DetectorConstants.FR_HOME_LIB;
+import static com.fr.env.detect.base.DetectorConstants.SEPARATOR;
+import static com.fr.env.detect.base.DetectorConstants.WEB_LIB_PATH;
+
/**
* created by Harrison on 2022/05/25
**/
@@ -124,4 +131,37 @@ public class DetectorUtil {
}
return new UILabel(LinkStrUtils.generateHtmlTag(message.get()));
}
+
+ /**
+ * 将 lib 转化成合适的格式
+ * %FR_HOME%/lib
+ * %FR_HOME%/webapps/webroot/WEB-INF/lib
+ *
+ * @param libMap jar 路径, key为前缀
+ * @return 信息
+ */
+ public static String concatLibFormatMsg(Map> libMap) {
+
+ String webLibPath = WEB_LIB_PATH;
+ String homeLibPath = FR_HOME_LIB;
+
+ StringBuilder sb = new StringBuilder();
+
+ List homeLibs = libMap.get(homeLibPath);
+ if (!Collections.isEmpty(homeLibs)) {
+ sb.append(homeLibPath);
+ sb.append(StringUtils.join(homeLibs, SEPARATOR));
+ }
+
+ List webLibs = libMap.get(webLibPath);
+ if (!Collections.isEmpty(webLibs)) {
+ if (sb.length() != 0) {
+ sb.append(BR_TAG);
+ }
+ sb.append(webLibPath);
+ sb.append(StringUtils.join(webLibs, SEPARATOR));
+ }
+ return sb.toString();
+ }
+
}
diff --git a/designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java b/designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java
index 82b9062702..322c15d501 100644
--- a/designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java
+++ b/designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java
@@ -27,16 +27,14 @@ import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
+import static com.fr.env.detect.base.DetectorConstants.FR_HOME_LIB;
+import static com.fr.env.detect.base.DetectorConstants.WEB_LIB_PATH;
+
/**
* created by Harrison on 2022/05/24
**/
public class JarLackDetector extends AbstractExceptionDetector {
- public static final String SEPARATOR = "、";
- public static final String BR_TAG = "
";
- public static final String WEB_LIB_PATH = "%FR_HOME%\\webapps\\webroot\\WEB-INF\\lib:";
- public static final String FR_HOME_LIB = "%FR_HOME%\\lib:";
-
public JarLackDetector() {
super(DetectorType.LACK_OF_JAR);
@@ -115,33 +113,12 @@ public class JarLackDetector extends AbstractExceptionDetector {
private Message tipsMessage(List infos) {
- String webLibPath = WEB_LIB_PATH;
- String homeLibPath = FR_HOME_LIB;
-
- Map> libMap = groupByPath(infos, homeLibPath, webLibPath);
-
- StringBuilder sb = new StringBuilder();
-
- List homeLibs = libMap.get(homeLibPath);
- if (!Collections.isEmpty(homeLibs)) {
- sb.append(homeLibPath);
- sb.append(StringUtils.join(homeLibs, SEPARATOR));
- }
-
- List webLibs = libMap.get(webLibPath);
- if (!Collections.isEmpty(webLibs)) {
- if (sb.length() != 0) {
- sb.append(BR_TAG);
- }
- sb.append(webLibPath);
- sb.append(StringUtils.join(webLibs, SEPARATOR));
- }
-
- String mainContent = sb.toString();
+ Map> libMap = groupByPath(infos, FR_HOME_LIB, WEB_LIB_PATH);
+ String content = DetectorUtil.concatLibFormatMsg(libMap);
DetectorType type = this.type();
String header = Toolkit.i18nText(type.getTipsLocale());
- return new Message.Simple(header + mainContent);
+ return new Message.Simple(header + content);
}
@NotNull
diff --git a/designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java b/designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java
index ab2b16ed9a..ef5be13398 100644
--- a/designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java
+++ b/designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java
@@ -2,6 +2,7 @@ package com.fr.env.detect.impl.converter;
import com.fr.design.i18n.Toolkit;
import com.fr.env.detect.base.DetectorConstants;
+import com.fr.env.detect.base.DetectorUtil;
import com.fr.env.detect.bean.DetectorResult;
import com.fr.env.detect.bean.DetectorType;
import com.fr.env.detect.bean.ExceptionLog;
@@ -9,7 +10,6 @@ import com.fr.env.detect.bean.ExceptionSolution;
import com.fr.env.detect.bean.ExceptionTips;
import com.fr.env.detect.thowable.ThrowableConverter;
import com.fr.stable.resource.ResourceLoader;
-import com.fr.third.org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import javax.el.MethodNotFoundException;
@@ -83,6 +83,10 @@ public class ClassConflictConvertor implements ThrowableConverter {
sign = sign.getCause();
}
+ Map> libMap = new HashMap<>();
+ libMap.put(DetectorConstants.FR_HOME_LIB, new ArrayList<>());
+ libMap.put(DetectorConstants.WEB_LIB_PATH, new ArrayList<>());
+
Set allPath = new HashSet<>();
for (String className : classNames) {
String classFile = convertClass2Path(className);
@@ -98,12 +102,14 @@ public class ClassConflictConvertor implements ThrowableConverter {
Matcher matcher = JAR_NAME_PATTERN.matcher(url.getFile());
if (matcher.find()) {
String jar = matcher.group();
- allPath.add(jar);
- } else {
- boolean containsClasses = file.contains(CLASSES);
- if (containsClasses) {
- allPath.add(CLASSES);
+ List libPath = null;
+ if (file.contains("WEB-INF")) {
+ libPath = libMap.get(DetectorConstants.WEB_LIB_PATH);
+ } else {
+ libPath = libMap.get(DetectorConstants.FR_HOME_LIB);
}
+ libPath.add(jar);
+ allPath.add(jar);
}
}
} catch (IOException ignore) {
@@ -115,7 +121,7 @@ public class ClassConflictConvertor implements ThrowableConverter {
return null;
}
- String msg = StringUtils.join(allPath, SEPARATOR);
+ String msg = DetectorUtil.concatLibFormatMsg(libMap);
DetectorType type = DetectorType.JAR_CONFLICT;
return DetectorResult.exception(type,