Browse Source

REPORT-73396【设计器环境监测】删除fine-decision-11.0,触发的是重置finedb

当遇到 finedb 异常却是缺少 JAR 导致的时候,交互补充处理
feature/x
Harrison 3 years ago
parent
commit
293fd4ff87
  1. 62
      designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java

62
designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java

@ -1,15 +1,19 @@
package com.fr.start;
import com.fr.common.report.ReportState;
import com.fr.common.util.Collections;
import com.fr.design.RestartHelper;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector;
import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage;
import com.fr.env.detect.base.DetectorBridge;
import com.fr.env.detect.bean.DetectorResult;
import com.fr.env.detect.bean.DetectorStatus;
import com.fr.env.detect.bean.DetectorType;
import com.fr.env.detect.ui.DetectorErrorDialog;
import com.fr.exit.DesignerExiter;
import com.fr.general.IOUtils;
import com.fr.io.utils.ResourceIOUtils;
@ -17,14 +21,19 @@ import com.fr.log.FineLoggerFactory;
import com.fr.process.engine.core.CarryMessageEvent;
import com.fr.process.engine.core.FineProcessContext;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.lifecycle.ErrorType;
import com.fr.stable.lifecycle.ErrorTypeHelper;
import com.fr.stable.lifecycle.FineLifecycleFatalError;
import com.fr.stable.project.ProjectConstants;
import javax.swing.JOptionPane;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author hades
@ -68,10 +77,30 @@ public class LifecycleFatalErrorHandler {
* 自检测
*/
SELF {
final EnumMap<DetectorType, String> solutionMap = new EnumMap<>(DetectorType.class);
{
solutionMap.put(DetectorType.FINE_DB_LOCKED, "Fine-Design_Error_Finedb_Dirty_Backup_Reset");
solutionMap.put(DetectorType.FINE_DB_PERMISSION, "Fine-Design_Error_Finedb_Permission_Backup_Reset");
solutionMap.put(DetectorType.FINE_DB_DIRTY, "Fine-Design_Error_Finedb_Dirty_Backup_Reset");
}
@Override
public void handle(FineLifecycleFatalError fatal) {
String showText = generateShowText(fatal);
Stream<DetectorResult> resultStream = DetectorBridge.getInstance().detect(fatal);
List<DetectorResult> results = resultStream
.filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION)
.collect(Collectors.toList());
String showText = generateShowText(results);
// 如果还是异常,则抛出预期外的错误
if (StringUtils.isEmpty(showText)) {
DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
DetectorErrorDialog errorDialog = new DetectorErrorDialog(designerFrame, results);
errorDialog.setVisible(true);
return;
}
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.FINEDB_PROBLEM.getId(),
DesignerErrorMessage.FINEDB_PROBLEM.getMessage(),
@ -107,26 +136,23 @@ public class LifecycleFatalErrorHandler {
/**
* 生成展示信息
*
* @param fatal 异常
* @return 文本
*/
private String generateShowText(FineLifecycleFatalError fatal) {
private String generateShowText(List<DetectorResult> results) {
// todo 其实这里的交互还是有问题, 为什么在锁住和没权限的场景下,要重置 FineDB 呢。
DetectorResult detectorResult = DetectorBridge.getInstance().detect(DetectorType.FINE_DB_LOCKED, fatal);
if (detectorResult.getStatus() == DetectorStatus.EXCEPTION) {
return Toolkit.i18nText("Fine-Design_Error_Finedb_Locked_Backup_Reset");
}
detectorResult = DetectorBridge.getInstance().detect(DetectorType.FINE_DB_PERMISSION, fatal);
if (detectorResult.getStatus() == DetectorStatus.EXCEPTION) {
return Toolkit.i18nText("Fine-Design_Error_Finedb_Permission_Backup_Reset");
}
detectorResult = DetectorBridge.getInstance().detect(DetectorType.FINE_DB_DIRTY, fatal);
if (detectorResult.getStatus() == DetectorStatus.EXCEPTION) {
return Toolkit.i18nText("Fine-Design_Error_Finedb_Dirty_Backup_Reset");
String showText = StringUtils.EMPTY;
if (Collections.isEmpty(results)) {
showText = Toolkit.i18nText("Fine-Design_Error_Finedb_Backup_Reset");
} else {
for (DetectorResult result : results) {
DetectorType type = result.getType();
String solutionLocale = solutionMap.get(type);
if (StringUtils.isNotEmpty(solutionLocale)) {
showText = Toolkit.i18nText(solutionLocale);
break;
}
}
}
return Toolkit.i18nText("Fine-Design_Error_Finedb_Backup_Reset");
return showText;
}
private void afterBackupFailed() {

Loading…
Cancel
Save