|
|
|
@ -2,11 +2,15 @@ package com.fr.start;
|
|
|
|
|
|
|
|
|
|
import com.fr.common.report.ReportState; |
|
|
|
|
import com.fr.design.RestartHelper; |
|
|
|
|
import com.fr.design.dialog.ErrorDialog; |
|
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector; |
|
|
|
|
import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; |
|
|
|
|
import com.fr.env.detect.EnvDetectorCenter; |
|
|
|
|
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.exit.DesignerExiter; |
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
import com.fr.io.utils.ResourceIOUtils; |
|
|
|
@ -19,7 +23,7 @@ import com.fr.stable.lifecycle.ErrorTypeHelper;
|
|
|
|
|
import com.fr.stable.lifecycle.FineLifecycleFatalError; |
|
|
|
|
import com.fr.stable.project.ProjectConstants; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import javax.swing.JOptionPane; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
@ -60,16 +64,22 @@ public class LifecycleFatalErrorHandler {
|
|
|
|
|
* finedb处理 |
|
|
|
|
*/ |
|
|
|
|
enum FineDBHandler implements Handler { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 自检测 |
|
|
|
|
*/ |
|
|
|
|
SELF { |
|
|
|
|
@Override |
|
|
|
|
public void handle(FineLifecycleFatalError fatal) { |
|
|
|
|
|
|
|
|
|
String showText = generateShowText(fatal); |
|
|
|
|
|
|
|
|
|
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.FINEDB_PROBLEM.getId(), |
|
|
|
|
DesignerErrorMessage.FINEDB_PROBLEM.getMessage(), |
|
|
|
|
fatal.getMessage()); |
|
|
|
|
FineLoggerFactory.getLogger().error(DesignerErrorMessage.FINEDB_PROBLEM.getId() + ": " + DesignerErrorMessage.FINEDB_PROBLEM.getMessage()); |
|
|
|
|
int result = FineJOptionPane.showOptionDialog(null, |
|
|
|
|
Toolkit.i18nText("Fine-Design_Error_Finedb_Backup_Reset"), |
|
|
|
|
showText, |
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Error_Tittle"), |
|
|
|
|
JOptionPane.YES_NO_OPTION, |
|
|
|
|
JOptionPane.ERROR_MESSAGE, |
|
|
|
@ -95,8 +105,45 @@ public class LifecycleFatalErrorHandler {
|
|
|
|
|
DesignerExiter.getInstance().execute(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 生成展示信息 |
|
|
|
|
* |
|
|
|
|
* @param fatal 异常 |
|
|
|
|
* @return 文本 |
|
|
|
|
*/ |
|
|
|
|
private String generateShowText(FineLifecycleFatalError fatal) { |
|
|
|
|
|
|
|
|
|
// todo 其实这里的交互还是有问题, 为什么在锁住和没权限的场景下,要重置 FineDB 呢。
|
|
|
|
|
DetectorResult detectorResult = DetectorBridge.getInstance().detect(DetectorType.FINE_DB_LOCKED, fatal); |
|
|
|
|
if (detectorResult.getStatus() == DetectorStatus.NORMAL) { |
|
|
|
|
detectorResult = DetectorBridge.getInstance().detect(DetectorType.FINE_DB_PERMISSION, fatal); |
|
|
|
|
} |
|
|
|
|
if (detectorResult.getStatus() == DetectorStatus.NORMAL) { |
|
|
|
|
detectorResult = DetectorBridge.getInstance().detect(DetectorType.FINE_DB_DIRTY, fatal); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String message; |
|
|
|
|
|
|
|
|
|
DetectorType type = detectorResult.getType(); |
|
|
|
|
switch (type) { |
|
|
|
|
case FINE_DB_LOCKED: |
|
|
|
|
message = Toolkit.i18nText("Fine-Design_Error_Finedb_Locked_Backup_Reset"); |
|
|
|
|
break; |
|
|
|
|
case FINE_DB_PERMISSION: |
|
|
|
|
message = Toolkit.i18nText("Fine-Design_Error_Finedb_Permission_Backup_Reset"); |
|
|
|
|
break; |
|
|
|
|
case FINE_DB_DIRTY: |
|
|
|
|
message = Toolkit.i18nText("Fine-Design_Error_Finedb_Dirty_Backup_Reset"); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
message = Toolkit.i18nText("Fine-Design_Error_Finedb_Backup_Reset"); |
|
|
|
|
} |
|
|
|
|
return message; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void afterBackupFailed() { |
|
|
|
|
|
|
|
|
|
FineJOptionPane.showMessageDialog(null, |
|
|
|
|
Toolkit.i18nText("Fine-Design_Error_Finedb_Backup_Reset_Result", |
|
|
|
|
ResourceIOUtils.getRealPath(StableUtils.pathJoin(ProjectConstants.EMBED_DB_DIRECTORY, ProjectConstants.FINE_DB_NAME))), |
|
|
|
@ -111,29 +158,15 @@ public class LifecycleFatalErrorHandler {
|
|
|
|
|
* 默认处理 |
|
|
|
|
*/ |
|
|
|
|
enum DefaultHandler implements Handler { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 自处理 |
|
|
|
|
*/ |
|
|
|
|
SELF { |
|
|
|
|
@Override |
|
|
|
|
public void handle(FineLifecycleFatalError fatal) { |
|
|
|
|
FineLoggerFactory.getLogger().error(fatal.getMessage(), fatal); |
|
|
|
|
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.UNEXCEPTED_START_FAILED.getId(), |
|
|
|
|
DesignerErrorMessage.UNEXCEPTED_START_FAILED.getMessage(), |
|
|
|
|
fatal.getMessage()); |
|
|
|
|
ErrorDialog dialog = new ErrorDialog(null, Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message"), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Error_Start_Report"), |
|
|
|
|
fatal.getMessage()) { |
|
|
|
|
@Override |
|
|
|
|
protected void okEvent() { |
|
|
|
|
dispose(); |
|
|
|
|
DesignerExiter.getInstance().execute(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void restartEvent() { |
|
|
|
|
dispose(); |
|
|
|
|
RestartHelper.restart(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
dialog.setVisible(true); |
|
|
|
|
|
|
|
|
|
EnvDetectorCenter.getInstance().terminate(fatal); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|