Browse Source

KERNEL-418 更新升级重构

research/11.0
Bryant 5 years ago
parent
commit
31f6286347
  1. 56
      designer-base/src/main/java/com/fr/design/update/domain/UpdateConstants.java
  2. 2
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java
  3. 2
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java
  4. 86
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  5. 2
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

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;

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

@ -1,10 +1,10 @@
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.ProductConstants;

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

@ -1,5 +1,7 @@
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.exception.UpdateException;
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 +16,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 +30,8 @@ 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.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,43 +586,73 @@ 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(); if (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);
progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message")); progressBar.setString(Toolkit.i18nText("Fine-Design_Update_Info_Wait_Message"));
UpdateCallBack callBack = new UpdateProgressCallBack(progressBar); UpdateCallBack callBack = new UpdateProgressCallBack(progressBar);
updateButton.setEnabled(false); updateButton.setEnabled(false);
updateLabel.setVisible(false); updateLabel.setVisible(false);
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")); try {
RestartHelper.restart(); IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DESIGNERBACKUPPATH),
} StableUtils.pathJoin(StableUtils.getInstallHome(),ProjectConstants.LIB_NAME));
}.execute(); } catch (IOException e) {
UpdateException exception = new UpdateException(e.getMessage());
FineLoggerFactory.getLogger().error(exception.getMessage() + "recover for design failed");
} finally {
deleteForDesignerUpdate();
}
JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message"));
RestartHelper.restart();
}
}.execute();
}
} else {
JOptionPane.showMessageDialog(getParent(),Toolkit.i18nText("Fine-Design_Update_Info_Backup_Message"));
} }
} }
}); });
} }
private void deleteForDesignerUpdate() {
File designerBackup = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DESIGNERBACKUPPATH));
CommonUtils.deleteFile(designerBackup);
File downloadForDesigner = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DOWNLOADPATH));
CommonUtils.deleteFile(downloadForDesigner);
}
/** /**
* Jar还原按钮兼容 * Jar还原按钮兼容
*/ */
private void backup() { private boolean backup() {
String installHome = StableUtils.getInstallHome(); String installHome = StableUtils.getInstallHome();
//jar包备份文件的目录为"backup/"+jar包当前版本号 //jar包备份文件的目录为"backup/"+jar包当前版本号
String todayBackupDir = StableUtils.pathJoin(installHome, getBackupDirectory(), (GeneralUtils.readBuildNO())); String todayBackupDir = StableUtils.pathJoin(installHome, getBackupDirectory(), (GeneralUtils.readBuildNO()));
backupFilesFromInstallEnv(installHome, todayBackupDir); backupFilesFromInstallEnv(installHome, todayBackupDir);
backupFilesFromInstallLib(installHome, todayBackupDir); backupFilesFromInstallLib(installHome, todayBackupDir);
jarCurrentLabel.setText(downloadFileConfig.optString("buildNO")); jarCurrentLabel.setText(downloadFileConfig.optString("buildNO"));
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 installHome, String todayBackupDir) { private void backupFilesFromInstallEnv(String installHome, String todayBackupDir) {

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

@ -1,10 +1,10 @@
package com.fr.design.upm; package com.fr.design.upm;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.decision.update.data.UpdateConstants;
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;

Loading…
Cancel
Save