2023-10-25 02:20:57 +03:00
|
|
|
package Visual_DVM_2021.Passes.All;
|
2023-10-26 21:40:37 +03:00
|
|
|
import Common.Constants;
|
2023-10-25 02:20:57 +03:00
|
|
|
import Common.Current;
|
2023-10-25 02:33:59 +03:00
|
|
|
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 TestingSystem.TasksPackage.TasksPackageState;
|
2023-10-25 02:33:59 +03:00
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
2023-10-25 02:20:57 +03:00
|
|
|
import Visual_DVM_2021.Passes.TestingSystemPass;
|
2023-10-26 21:40:37 +03:00
|
|
|
import org.apache.commons.io.FileUtils;
|
2023-10-25 02:20:57 +03:00
|
|
|
|
|
|
|
|
import java.io.File;
|
2023-10-26 21:40:37 +03:00
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.util.Date;
|
2023-10-25 02:20:57 +03:00
|
|
|
public class DownloadSapforTasksPackage extends TestingSystemPass<SapforTasksPackage> {
|
|
|
|
|
@Override
|
|
|
|
|
public String getIconPath() {
|
2023-10-25 02:33:59 +03:00
|
|
|
return "/icons/DownloadBugReport.png";
|
2023-10-25 02:20:57 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String getButtonText() {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2023-10-25 16:33:02 +03:00
|
|
|
File tmpArchive = null;
|
2023-10-26 21:40:37 +03:00
|
|
|
File getLoaded() {
|
|
|
|
|
return Paths.get(Global.SapforPackagesDirectory.getAbsolutePath(), target.id, Constants.LOADED).toFile();
|
|
|
|
|
}
|
2023-10-25 02:20:57 +03:00
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
if (Current.Check(Log, Current.SapforTasksPackage)) {
|
|
|
|
|
target = Current.getSapforTasksPackage();
|
2023-10-26 21:40:37 +03:00
|
|
|
if (!target.state.equals(TasksPackageState.Done)) {
|
|
|
|
|
Log.Writeln_("Пакет не завершен.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (getLoaded().exists()) {
|
|
|
|
|
System.out.println("Пакет уже загружен");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2023-10-25 02:20:57 +03:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void ServerAction() throws Exception {
|
|
|
|
|
Command(new ServerExchangeUnit_2021(ServerCode.DownloadSapforTasksPackage, Current.getAccount().email, target.id));
|
2023-10-25 16:33:02 +03:00
|
|
|
response.Unpack(tmpArchive = Utils.getTempFileName(target.id));
|
2023-10-25 02:20:57 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean validate() {
|
2023-10-25 16:33:02 +03:00
|
|
|
return tmpArchive != null && tmpArchive.exists();
|
2023-10-25 02:33:59 +03:00
|
|
|
}
|
|
|
|
|
@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(
|
2023-10-25 16:33:02 +03:00
|
|
|
tmpArchive.getAbsolutePath(),
|
2023-10-25 02:33:59 +03:00
|
|
|
Global.SapforPackagesDirectory.getAbsolutePath(), false
|
2023-10-26 21:40:37 +03:00
|
|
|
)) {
|
|
|
|
|
System.out.println("LOADED=" + Utils.Brackets(getLoaded().getAbsolutePath()));
|
|
|
|
|
FileUtils.writeStringToFile(getLoaded(), new Date().toString());
|
|
|
|
|
}
|
2023-10-25 02:20:57 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|