Files
VisualSapfor/src/Visual_DVM_2021/Passes/All/DownloadSapforTasksPackage.java

69 lines
2.4 KiB
Java
Raw Normal View History

2023-10-25 02:20:57 +03:00
package Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.Global;
2023-10-25 02:20:57 +03:00
import Common.Utils.Utils;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackageInterface;
2023-10-25 02:20:57 +03:00
import TestingSystem.TasksPackage.TasksPackageState;
import Visual_DVM_2021.Passes.PassCode_2021;
2023-10-25 02:20:57 +03:00
import Visual_DVM_2021.Passes.TestingSystemPass;
import org.apache.commons.io.FileUtils;
2023-10-25 02:20:57 +03:00
import java.io.File;
import java.util.Date;
2023-10-25 02:20:57 +03:00
public class DownloadSapforTasksPackage extends TestingSystemPass<SapforTasksPackage> {
@Override
public String getIconPath() {
return "/icons/DownloadBugReport.png";
2023-10-25 02:20:57 +03:00
}
@Override
public String getButtonText() {
return "";
}
File tmpArchive = null;
2023-10-25 02:20:57 +03:00
@Override
protected boolean canStart(Object... args) throws Exception {
if (args.length > 0) {
target = (SapforTasksPackage) args[0];
} else {
if (Current.Check(Log, Current.SapforTasksPackage))
target = Current.getSapforTasksPackage();
else return false;
}
//-
if (!target.state.equals(TasksPackageState.Done)) {
Log.Writeln_("Пакет не завершен.");
return false;
}
if (SapforTasksPackageInterface.isLoaded(target)) {
System.out.println("Пакет уже загружен");
return false;
2023-10-25 02:20:57 +03:00
}
return true;
2023-10-25 02:20:57 +03:00
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(ServerCode.DownloadSapforTasksPackage, Current.getAccount().email, target.id));
response.Unpack(tmpArchive = Utils.getTempFileName(target.id));
2023-10-25 02:20:57 +03:00
}
@Override
protected boolean validate() {
return tmpArchive != null && tmpArchive.exists();
}
@Override
protected void performDone() throws Exception {
super.performDone();
File packageWorkspace = new File(Global.SapforPackagesDirectory, target.id);
Utils.forceDeleteWithCheck(packageWorkspace);
if (passes.get(PassCode_2021.UnzipFolderPass).Do(
tmpArchive.getAbsolutePath(),
Global.SapforPackagesDirectory.getAbsolutePath(), false
)) {
FileUtils.writeStringToFile(SapforTasksPackageInterface.getLoadedSign(target), new Date().toString());
}
2023-10-25 02:20:57 +03:00
}
}