|
|
@ -3,14 +3,14 @@ package com.fr.design.update.actions; |
|
|
|
import com.fr.decision.update.backup.Recover; |
|
|
|
import com.fr.decision.update.backup.Recover; |
|
|
|
import com.fr.decision.update.data.UpdateConstants; |
|
|
|
import com.fr.decision.update.data.UpdateConstants; |
|
|
|
import com.fr.decision.update.exception.UpdateException; |
|
|
|
import com.fr.decision.update.exception.UpdateException; |
|
|
|
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.ProjectLibrary; |
|
|
|
|
|
|
|
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; |
|
|
@ -22,82 +22,59 @@ 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(installHome, ProjectConstants.LOGS_NAME, |
|
|
|
CommonIOUtils.copyFilesInDirByPath(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNERBACKUPPATH), |
|
|
|
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 e) { |
|
|
|
} catch (IOException e) { |
|
|
|
FineLoggerFactory.getLogger().error("Recover error for designer", e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage() + "Recover error for designer"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@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())); |
|
|
|
String envHome = ProjectLibrary.getInstance().getLibHome(); |
|
|
|
backupFilesFromInstallEnv(todayBackupDir); |
|
|
|
backupFilesFromInstallEnv(envHome, todayBackupDir); |
|
|
|
|
|
|
|
backupFilesFromInstallLib(installHome, todayBackupDir); |
|
|
|
backupFilesFromInstallLib(installHome, todayBackupDir); |
|
|
|
try { |
|
|
|
try { |
|
|
|
String installBackup = StableUtils.pathJoin(installHome, ProjectConstants.LOGS_NAME, |
|
|
|
File file = new File(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOADPATH)); |
|
|
|
UpdateConstants.INSTALL_LIB); |
|
|
|
CommonUtils.mkdirs(file); |
|
|
|
File installLib = new File(installBackup); |
|
|
|
IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), |
|
|
|
CommonUtils.mkdirs(installLib); |
|
|
|
StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH)); |
|
|
|
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(); |
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} catch (IOException e) { |
|
|
|
}catch (IOException e) { |
|
|
|
UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); |
|
|
|
UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); |
|
|
|
FineLoggerFactory.getLogger().error(exception.getMessage(),exception); |
|
|
|
FineLoggerFactory.getLogger().error(exception.getMessage(),exception); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void backupFilesFromInstallEnv(String envHome, String todayBackupDir) { |
|
|
|
private void backupFilesFromInstallEnv(String todayBackupDir) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
File file = new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); |
|
|
|
CommonUtils.mkdirs(new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH))); |
|
|
|
CommonUtils.mkdirs(file); |
|
|
|
IOUtils.copyFilesInDirByPath( |
|
|
|
file = new File(StableUtils.pathJoin(envHome,ProjectConstants.LIB_NAME)); |
|
|
|
StableUtils.pathJoin(WorkContext.getCurrent().getPath(),ProjectConstants.LIB_NAME), |
|
|
|
File[] files = file.listFiles(); |
|
|
|
StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); |
|
|
|
File dir = new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.BACKUPPATH)); |
|
|
|
|
|
|
|
if (files != null) { |
|
|
|
|
|
|
|
for (File file1 : files) { |
|
|
|
|
|
|
|
if (file1.getName().startsWith(UpdateConstants.FINE) && file1.getName().endsWith(UpdateConstants.JAR_FILE_SUFFIX)) { |
|
|
|
|
|
|
|
CommonIOUtils.copy(file1, dir); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
UpdateException exception = new UpdateException(e.getMessage()); |
|
|
|
UpdateException exception = new UpdateException(e.getMessage()); |
|
|
|
FineLoggerFactory.getLogger().error(exception.getMessage() , "backup for Designer recover in env failed"); |
|
|
|
FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in env failed"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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))); |
|
|
|
File lib = new File(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME)); |
|
|
|
IOUtils.copyFilesInDirByPath( |
|
|
|
File[] files = lib.listFiles(); |
|
|
|
StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), |
|
|
|
File dir = new File(StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)); |
|
|
|
StableUtils.pathJoin(todayBackupDir,UpdateConstants.DESIGNERBACKUPPATH)); |
|
|
|
if (files != null) { |
|
|
|
|
|
|
|
for (File file : files) { |
|
|
|
|
|
|
|
if (file.getName().startsWith(UpdateConstants.FINE) || file.getName().contains(UpdateConstants.ASPECTJRT)) { |
|
|
|
|
|
|
|
CommonIOUtils.copy(file, dir); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
UpdateException exception = new UpdateException(e.getMessage()); |
|
|
|
UpdateException exception = new UpdateException(e.getMessage()); |
|
|
|
FineLoggerFactory.getLogger().error(exception.getMessage() , "backup for Designer recover in install failed"); |
|
|
|
FineLoggerFactory.getLogger().error(exception.getMessage() + "backup for Designer recover in install failed"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|