Browse Source

REPORT-23486 修复bug以及更改文件夹

feature/big-screen
Bryant 5 years ago
parent
commit
8f4880cd6d
  1. 31
      designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java
  2. 2
      designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java
  3. 14
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

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

@ -6,12 +6,10 @@ import com.fr.decision.update.exception.UpdateException;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.general.CommonIOUtils; import com.fr.general.CommonIOUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils; import com.fr.stable.CommonUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -23,10 +21,13 @@ import java.io.IOException;
*/ */
public class RecoverForDesigner implements Recover { public class RecoverForDesigner implements Recover {
private final String installHome = StableUtils.getInstallHome();
@Override @Override
public boolean recover() { public boolean recover() {
try{ try{
CommonIOUtils.copyFilesInDirByPath(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNERBACKUPPATH), CommonIOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome, ProjectConstants.LOGS_NAME,
UpdateConstants.INSTALL_LIB, UpdateConstants.DESIGNERBACKUPPATH),
StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME)); StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LIB_NAME));
return true; return true;
} catch (IOException ignore) { } catch (IOException ignore) {
@ -37,16 +38,20 @@ public class RecoverForDesigner implements Recover {
@Override @Override
public boolean backup() { public boolean backup() {
String installHome = StableUtils.getInstallHome();
//jar包备份文件的目录为"backup/"+jar包当前版本号 //jar包备份文件的目录为"backup/"+jar包当前版本号
String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, (GeneralUtils.readBuildNO())); String todayBackupDir = StableUtils.pathJoin(installHome, UpdateConstants.DESIGNER_BACKUP_DIR, (GeneralUtils.readBuildNO()));
backupFilesFromInstallEnv(todayBackupDir); String envHome = StableUtils.pathJoin(installHome, UpdateConstants.WEBAPPS, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME);
backupFilesFromInstallEnv(envHome, todayBackupDir);
backupFilesFromInstallLib(installHome, todayBackupDir); backupFilesFromInstallLib(installHome, todayBackupDir);
try { try {
File file = new File(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOADPATH)); String installBackup = StableUtils.pathJoin(installHome, ProjectConstants.LOGS_NAME,
CommonUtils.mkdirs(file); UpdateConstants.INSTALL_LIB);
IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), File installLib = new File(installBackup);
StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH)); CommonUtils.mkdirs(installLib);
File download = new File(StableUtils.pathJoin(installBackup,UpdateConstants.DOWNLOADPATH));
CommonUtils.mkdirs(download);
CommonIOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME),
StableUtils.pathJoin(installBackup,UpdateConstants.DESIGNERBACKUPPATH));
DesignerContext.getDesignerFrame().prepareForExit(); DesignerContext.getDesignerFrame().prepareForExit();
return true; return true;
} catch (IOException e) { } catch (IOException e) {
@ -56,11 +61,11 @@ public class RecoverForDesigner implements Recover {
} }
} }
private void backupFilesFromInstallEnv(String todayBackupDir) { private void backupFilesFromInstallEnv(String envHome, String todayBackupDir) {
try { try {
CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH))); CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)));
IOUtils.copyFilesInDirByPath( CommonIOUtils.copyFilesInDirByPath(
StableUtils.pathJoin(WorkContext.getCurrent().getPath(),ProjectConstants.LIB_NAME), StableUtils.pathJoin(envHome,ProjectConstants.LIB_NAME),
StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH));
} catch (IOException e) { } catch (IOException e) {
UpdateException exception = new UpdateException(e.getMessage()); UpdateException exception = new UpdateException(e.getMessage());
@ -71,7 +76,7 @@ public class RecoverForDesigner implements Recover {
private void backupFilesFromInstallLib(String installHome, String todayBackupDir) { private void backupFilesFromInstallLib(String installHome, String todayBackupDir) {
try { try {
CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH))); CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)));
IOUtils.copyFilesInDirByPath( CommonIOUtils.copyFilesInDirByPath(
StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME),
StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)); StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH));
} catch (IOException e) { } catch (IOException e) {

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

@ -169,7 +169,7 @@ public class RestoreResultDialog extends JDialog {
private void filesToMove(String installHome, Map<String, String> map) { private void filesToMove(String installHome, Map<String, String> map) {
String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR; String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR;
String envHome = WorkContext.getCurrent().getPath(); String envHome = StableUtils.pathJoin(installHome, UpdateConstants.WEBAPPS, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME);
File installLib = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.DESIGNERBACKUPPATH)); File installLib = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.DESIGNERBACKUPPATH));
File envLib = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.BACKUPPATH)); File envLib = new File(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, UpdateConstants.BACKUPPATH));
File[] files; File[] files;

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

@ -30,6 +30,7 @@ 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.*; import com.fr.stable.*;
import com.fr.stable.project.ProjectConstants;
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;
@ -593,19 +594,20 @@ public class UpdateMainDialog extends UIDialog {
updateButton.setEnabled(false); updateButton.setEnabled(false);
updateLabel.setVisible(false); updateLabel.setVisible(false);
RestoreResultDialog.deletePreviousPropertyFile(); RestoreResultDialog.deletePreviousPropertyFile();
final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB);
final JFrame frame = DesignerContext.getDesignerFrame(); final JFrame frame = DesignerContext.getDesignerFrame();
final RestartHelper helper = new RestartHelper(); final RestartHelper helper = new RestartHelper();
new FileProcess(callBack) { new FileProcess(callBack) {
@Override @Override
public void onDownloadSuccess() { public void onDownloadSuccess() {
progressBar.setVisible(false); progressBar.setVisible(false);
deleteForDesignerUpdate(); deleteForDesignerUpdate(installLib);
helper.restartForUpdate(frame); helper.restartForUpdate(frame);
} }
@Override @Override
public void onDownloadFailed() { public void onDownloadFailed() {
progressBar.setVisible(false); progressBar.setVisible(false);
deleteForDesignerUpdate(); deleteForDesignerUpdate(installLib);
JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message"));
helper.restartForUpdate(frame); helper.restartForUpdate(frame);
} }
@ -615,11 +617,9 @@ public class UpdateMainDialog extends UIDialog {
}); });
} }
private void deleteForDesignerUpdate() { private void deleteForDesignerUpdate(String installLib) {
File designerBackup = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DESIGNERBACKUPPATH)); File dir = new File(installLib);
CommonUtils.deleteFile(designerBackup); CommonUtils.deleteFile(dir);
File downloadForDesigner = new File(StableUtils.pathJoin(StableUtils.getInstallHome(),UpdateConstants.DOWNLOADPATH));
CommonUtils.deleteFile(downloadForDesigner);
} }
//获取备份目录 //获取备份目录

Loading…
Cancel
Save