Browse Source

Merge pull request #1170 in DESIGN/design from ~BRYANT/design:feature/10.0 to feature/10.0

* commit 'fdf29340a770451dd8bcb527a070a3facd6ed707':
  KERNEL-418 更新升级重构
  KERNEL-418 更新升级重构
  KERNEL-418 更新升级重构
  KERNEL-418 更新升级重构
research/11.0
Bryant 5 years ago
parent
commit
3d8ece2c7f
  1. 79
      designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java
  2. 56
      designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java
  3. 2
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java
  4. 40
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java
  5. 55
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  6. 20
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  7. 3
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

79
designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java

@ -0,0 +1,79 @@
package com.fr.design.update.actions;
import com.fr.decision.update.backup.Recover;
import com.fr.decision.update.data.UpdateConstants;
import com.fr.decision.update.exception.UpdateException;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import java.io.File;
import java.io.IOException;
/**
* @author Bryant
* @version 10.0
* Created by Bryant on 2019-10-09
*/
public class RecoverForDesigner implements Recover {
@Override
public boolean recover() {
try{
IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNERBACKUPPATH),
StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME));
return true;
} catch (IOException ignore) {
FineLoggerFactory.getLogger().error("Recover error for designer");
return false;
}
}
@Override
public boolean backup() {
String installHome = StableUtils.getInstallHome();
//jar包备份文件的目录为"backup/"+jar包当前版本号
String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, (GeneralUtils.readBuildNO()));
backupFilesFromInstallEnv(todayBackupDir);
backupFilesFromInstallLib(installHome, todayBackupDir);
try {
File file = new File(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOADPATH));
CommonUtils.mkdirs(file);
IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME),
StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH));
return true;
}catch (IOException e) {
UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage());
FineLoggerFactory.getLogger().error(exception.getMessage(),exception);
return false;
}
}
private void backupFilesFromInstallEnv(String todayBackupDir) {
try {
CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)));
IOUtils.copyFilesInDirByPath(
StableUtils.pathJoin(WorkContext.getCurrent().getPath(),ProjectConstants.LIB_NAME),
StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH));
} catch (IOException e) {
UpdateException exception = new UpdateException(e.getMessage());
FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in env failed");
}
}
private void backupFilesFromInstallLib(String installHome, String todayBackupDir) {
try {
CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)));
IOUtils.copyFilesInDirByPath(
StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME),
StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH));
} catch (IOException e) {
UpdateException exception = new UpdateException(e.getMessage());
FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in install failed");
}
}
}

56
designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java

@ -1,56 +0,0 @@
package com.fr.design.update.domain;
/**
* Created by XINZAI on 2018/8/21.
*/
import java.awt.Color;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* 更新升级的常量
*/
public interface UpdateConstants {
String APPS_FOLDER_NAME = "webapps";
int CONNECTION_TIMEOUT = 1000 * 5;
Color BAR_COLOR = new Color(0x3384F0);
String CHANGELOG_X_START = "2018-07-11";
String DEFAULT_APP_NAME = "FineReport";
String DESIGNER_BACKUP_DIR = "designerbackup";
String UPDATE_CACHE_CONFIG_X = "updateCacheConfig10";
String UPDATE_CACHE_INFO_X = "updateCacheInfo10";
String JXBROWSER = "jxbrowser";
List<String> JARS_FOR_SERVER_X = Collections.unmodifiableList(Arrays.asList(new String[]{
"fine-activator-10.0.jar",
"fine-core-10.0.jar",
"fine-report-engine-10.0.jar",
"fine-decision-10.0.jar",
"fine-decision-report-10.0.jar",
"fine-schedule-10.0.jar",
"fine-schedule-report-10.0.jar",
"fine-swift-log-adaptor-10.0.jar",
"fine-webui-10.0.jar",
"fine-datasource-10.0.jar",
"fine-third-10.0.jar",
"fine-accumulator-10.0.jar"
}));
List<String> JARS_FOR_DESIGNER_X = Collections.unmodifiableList(Arrays.asList(new String[]{
"fine-report-designer-10.0.jar",
"aspectjrt.jar"
}));
List<String> LOG_TYPE = Collections.unmodifiableList(Arrays.asList(new String[]{
"REPORT", "MOBILE", "CHART", "PFC", "BI"
}));
}

2
designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java

@ -1,9 +1,9 @@
package com.fr.design.update.ui.dialog; package com.fr.design.update.ui.dialog;
import com.fr.decision.update.data.UpdateConstants;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.update.factory.DirectoryOperationFactory; import com.fr.design.update.factory.DirectoryOperationFactory;
import com.fr.design.update.ui.widget.ColorfulCellRender; import com.fr.design.update.ui.widget.ColorfulCellRender;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;

40
designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java

@ -1,16 +1,16 @@
package com.fr.design.update.ui.dialog; package com.fr.design.update.ui.dialog;
import com.fr.decision.update.data.UpdateConstants;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -45,7 +45,7 @@ public class RestoreResultDialog extends JDialog {
initCommonComponents(); initCommonComponents();
} }
public RestoreResultDialog(Frame parent, boolean modal, String jarDir) { RestoreResultDialog(Frame parent, boolean modal, String jarDir) {
super(parent, modal); super(parent, modal);
this.jarRestoreDir = jarDir; this.jarRestoreDir = jarDir;
if (ComparatorUtils.equals(jarDir, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Restore_Old_Version"))) { if (ComparatorUtils.equals(jarDir, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Restore_Old_Version"))) {
@ -100,7 +100,7 @@ public class RestoreResultDialog extends JDialog {
this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Jar_Restore")); this.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Updater_Jar_Restore"));
} }
public static boolean deletePreviousPropertyFile() { static boolean deletePreviousPropertyFile() {
File moveFile = new File(RestartHelper.MOVE_FILE); File moveFile = new File(RestartHelper.MOVE_FILE);
File delFile = new File(RestartHelper.RECORD_FILE); File delFile = new File(RestartHelper.RECORD_FILE);
if (StableUtils.mkdirs(moveFile) && StableUtils.mkdirs(delFile)) { if (StableUtils.mkdirs(moveFile) && StableUtils.mkdirs(delFile)) {
@ -159,7 +159,7 @@ public class RestoreResultDialog extends JDialog {
private void putJarBackupFiles() { private void putJarBackupFiles() {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
java.util.List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
String installHome = StableUtils.getInstallHome(); String installHome = StableUtils.getInstallHome();
putJarBackupFilesToInstallLib(installHome, map, list); putJarBackupFilesToInstallLib(installHome, map, list);
@ -168,23 +168,29 @@ public class RestoreResultDialog extends JDialog {
RestartHelper.saveFilesWhichToDelete(list.toArray(new String[list.size()])); RestartHelper.saveFilesWhichToDelete(list.toArray(new String[list.size()]));
} }
private void putJarBackupFilesToInstallLib(String installHome, Map<String, String> map, java.util.List<String> list) { private void putJarBackupFilesToInstallLib(String installHome, Map<String, String> map, List<String> list) {
List<String> files = UpdateConstants.JARS_FOR_DESIGNER_X;
String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR; String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR;
for (String file : files) { File installLib = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.DESIGNERBACKUPPATH));
map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file), File[] files = installLib.listFiles();
StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file)); if (files != null) {
list.add(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file)); for (File file : files) {
map.put(file.getAbsolutePath(),
StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file.getName()));
list.add(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file.getName()));
}
} }
} }
private void putJarBackupFilesToInstallEnv(String installHome, Map<String, String> map, java.util.List<String> list) { private void putJarBackupFilesToInstallEnv(String installHome, Map<String, String> map, List<String> list) {
List<String> files = UpdateConstants.JARS_FOR_SERVER_X;
String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR; String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR;
for (String file : files) { File installEnv = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.BACKUPPATH));
map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file), File[] files = installEnv.listFiles();
StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); if (files != null) {
list.add(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); for (File file : files) {
map.put(file.getAbsolutePath(),
StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, file.getName()));
list.add(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, file.getName()));
}
} }
} }
} }

55
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -1,5 +1,6 @@
package com.fr.design.update.ui.dialog; package com.fr.design.update.ui.dialog;
import com.fr.decision.update.data.UpdateConstants;
import com.fr.decision.update.info.UpdateCallBack; import com.fr.decision.update.info.UpdateCallBack;
import com.fr.decision.update.info.UpdateProgressCallBack; import com.fr.decision.update.info.UpdateProgressCallBack;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
@ -14,7 +15,6 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.update.actions.FileProcess; import com.fr.design.update.actions.FileProcess;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.update.domain.UpdateInfoCachePropertyManager; import com.fr.design.update.domain.UpdateInfoCachePropertyManager;
import com.fr.design.update.factory.DirectoryOperationFactory; import com.fr.design.update.factory.DirectoryOperationFactory;
import com.fr.design.update.ui.widget.LoadingLabel; import com.fr.design.update.ui.widget.LoadingLabel;
@ -29,13 +29,7 @@ import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.*;
import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.third.org.apache.http.ProtocolException;
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
import com.fr.third.org.apache.http.client.methods.HttpGet; import com.fr.third.org.apache.http.client.methods.HttpGet;
import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
@ -590,7 +584,6 @@ public class UpdateMainDialog extends UIDialog {
updateButton.addActionListener(new ActionListener() { updateButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
backup();
int a = JOptionPane.showConfirmDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Information"),Toolkit.i18nText("Fine-Design_Update_Info_Title"), JOptionPane.OK_CANCEL_OPTION); int a = JOptionPane.showConfirmDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Information"),Toolkit.i18nText("Fine-Design_Update_Info_Title"), JOptionPane.OK_CANCEL_OPTION);
if (a == 0) { if (a == 0) {
progressBar.setVisible(true); progressBar.setVisible(true);
@ -601,14 +594,15 @@ public class UpdateMainDialog extends UIDialog {
new FileProcess(callBack) { new FileProcess(callBack) {
@Override @Override
public void onDownloadSuccess() { public void onDownloadSuccess() {
updateButton.setEnabled(true);
progressBar.setVisible(false); progressBar.setVisible(false);
deleteForDesignerUpdate();
RestartHelper.restart(); RestartHelper.restart();
} }
@Override @Override
public void onDownloadFailed() { public void onDownloadFailed() {
progressBar.setVisible(false); progressBar.setVisible(false);
JOptionPane.showMessageDialog(getParent(),Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); deleteForDesignerUpdate();
JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message"));
RestartHelper.restart(); RestartHelper.restart();
} }
}.execute(); }.execute();
@ -617,40 +611,11 @@ public class UpdateMainDialog extends UIDialog {
}); });
} }
/** private void deleteForDesignerUpdate() {
* Jar还原按钮兼容 File designerBackup = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DESIGNERBACKUPPATH));
*/ CommonUtils.deleteFile(designerBackup);
private void backup() { File downloadForDesigner = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DOWNLOADPATH));
String installHome = StableUtils.getInstallHome(); CommonUtils.deleteFile(downloadForDesigner);
//jar包备份文件的目录为"backup/"+jar包当前版本号
String todayBackupDir = StableUtils.pathJoin(installHome, getBackupDirectory(), (GeneralUtils.readBuildNO()));
backupFilesFromInstallEnv(installHome, todayBackupDir);
backupFilesFromInstallLib(installHome, todayBackupDir);
jarCurrentLabel.setText(downloadFileConfig.optString("buildNO"));
}
private void backupFilesFromInstallEnv(String installHome, String todayBackupDir) {
for (String file : UpdateConstants.JARS_FOR_SERVER_X) {
try {
IOUtils.copy(
new File(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)),
new File(StableUtils.pathJoin(todayBackupDir)));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
}
private void backupFilesFromInstallLib(String installHome, String todayBackupDir) {
for (String file : UpdateConstants.JARS_FOR_DESIGNER_X) {
try {
IOUtils.copy(
new File(StableUtils.pathJoin(installHome, ProjectConstants.LIB_NAME, file)),
new File(StableUtils.pathJoin(todayBackupDir)));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
} }
//获取备份目录 //获取备份目录

20
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -4,14 +4,11 @@ import com.fr.base.FRContext;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.update.domain.UpdateConstants;
import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.WorkspaceEvent;
@ -56,18 +53,11 @@ public class UpmFinder {
} }
public static void showUPMDialog() { public static void showUPMDialog() {
boolean flag = false; boolean flag = true;
File file = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME)); try {
File[] files = file.listFiles(); Class.forName("com.teamdev.jxbrowser.chromium.Browser");
if (files != null) { } catch (ClassNotFoundException e) {
for (File file1 : files) { flag = false;
if (file1.getName().contains(UpdateConstants.JXBROWSER)) {
flag = true;
break;
}
}
}else {
FineLoggerFactory.getLogger().error("Designer lib can not be null");
} }
if (flag) { if (flag) {
UpmShowPane upmPane = new UpmShowPane(); UpmShowPane upmPane = new UpmShowPane();

3
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -8,6 +8,7 @@ import com.fr.base.passport.FinePassportManager;
import com.fr.base.process.ProcessOperator; import com.fr.base.process.ProcessOperator;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.decision.update.backup.RecoverManager;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.NewFormAction; import com.fr.design.actions.NewFormAction;
@ -57,6 +58,7 @@ import com.fr.design.module.DesignModuleFactory;
import com.fr.design.parameter.FormParameterReader; import com.fr.design.parameter.FormParameterReader;
import com.fr.design.parameter.ParameterPropertyPane; import com.fr.design.parameter.ParameterPropertyPane;
import com.fr.design.parameter.WorkBookParameterReader; import com.fr.design.parameter.WorkBookParameterReader;
import com.fr.design.update.actions.RecoverForDesigner;
import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane; import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane;
import com.fr.form.stable.ElementCaseThumbnailProcessor; import com.fr.form.stable.ElementCaseThumbnailProcessor;
import com.fr.general.xml.GeneralXMLTools; import com.fr.general.xml.GeneralXMLTools;
@ -128,6 +130,7 @@ public class DesignerActivator extends Activator {
UserInfoPane.getInstance().updateBBSUserInfo(); UserInfoPane.getInstance().updateBBSUserInfo();
storePassport(); storePassport();
AlphaFineHelper.switchConfig4Locale(); AlphaFineHelper.switchConfig4Locale();
RecoverManager.register(new RecoverForDesigner());
} }
@Override @Override

Loading…
Cancel
Save