|
|
@ -1,15 +1,19 @@ |
|
|
|
package com.fr.start; |
|
|
|
package com.fr.start; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.common.report.ReportState; |
|
|
|
import com.fr.common.report.ReportState; |
|
|
|
|
|
|
|
import com.fr.common.util.Collections; |
|
|
|
import com.fr.design.RestartHelper; |
|
|
|
import com.fr.design.RestartHelper; |
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
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.StartErrorMessageCollector; |
|
|
|
import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; |
|
|
|
import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; |
|
|
|
import com.fr.env.detect.base.DetectorBridge; |
|
|
|
import com.fr.env.detect.base.DetectorBridge; |
|
|
|
import com.fr.env.detect.bean.DetectorResult; |
|
|
|
import com.fr.env.detect.bean.DetectorResult; |
|
|
|
import com.fr.env.detect.bean.DetectorStatus; |
|
|
|
import com.fr.env.detect.bean.DetectorStatus; |
|
|
|
import com.fr.env.detect.bean.DetectorType; |
|
|
|
import com.fr.env.detect.bean.DetectorType; |
|
|
|
|
|
|
|
import com.fr.env.detect.ui.DetectorErrorDialog; |
|
|
|
import com.fr.exit.DesignerExiter; |
|
|
|
import com.fr.exit.DesignerExiter; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.io.utils.ResourceIOUtils; |
|
|
|
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.CarryMessageEvent; |
|
|
|
import com.fr.process.engine.core.FineProcessContext; |
|
|
|
import com.fr.process.engine.core.FineProcessContext; |
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.lifecycle.ErrorType; |
|
|
|
import com.fr.stable.lifecycle.ErrorType; |
|
|
|
import com.fr.stable.lifecycle.ErrorTypeHelper; |
|
|
|
import com.fr.stable.lifecycle.ErrorTypeHelper; |
|
|
|
import com.fr.stable.lifecycle.FineLifecycleFatalError; |
|
|
|
import com.fr.stable.lifecycle.FineLifecycleFatalError; |
|
|
|
import com.fr.stable.project.ProjectConstants; |
|
|
|
import com.fr.stable.project.ProjectConstants; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.JOptionPane; |
|
|
|
import javax.swing.JOptionPane; |
|
|
|
|
|
|
|
import java.util.EnumMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author hades |
|
|
|
* @author hades |
|
|
@ -68,10 +77,30 @@ public class LifecycleFatalErrorHandler { |
|
|
|
* 自检测 |
|
|
|
* 自检测 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
SELF { |
|
|
|
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 |
|
|
|
@Override |
|
|
|
public void handle(FineLifecycleFatalError fatal) { |
|
|
|
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); |
|
|
|
|
|
|
|
// 如果还是异常,说明并不是 DB 的异常,抛出预期外的错误
|
|
|
|
|
|
|
|
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(), |
|
|
|
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.FINEDB_PROBLEM.getId(), |
|
|
|
DesignerErrorMessage.FINEDB_PROBLEM.getMessage(), |
|
|
|
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 呢。
|
|
|
|
String showText = StringUtils.EMPTY; |
|
|
|
DetectorResult detectorResult = DetectorBridge.getInstance().detect(DetectorType.FINE_DB_LOCKED, fatal); |
|
|
|
if (Collections.isEmpty(results)) { |
|
|
|
if (detectorResult.getStatus() == DetectorStatus.EXCEPTION) { |
|
|
|
showText = Toolkit.i18nText("Fine-Design_Error_Finedb_Backup_Reset"); |
|
|
|
return Toolkit.i18nText("Fine-Design_Error_Finedb_Locked_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; |
|
|
|
} |
|
|
|
} |
|
|
|
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"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return Toolkit.i18nText("Fine-Design_Error_Finedb_Backup_Reset"); |
|
|
|
return showText; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void afterBackupFailed() { |
|
|
|
private void afterBackupFailed() { |
|
|
|