2024-10-14 12:14:01 +03:00
|
|
|
package _VisualDVM.Passes.All;
|
2024-10-11 00:00:30 +03:00
|
|
|
import Common.Utils.Utils_;
|
2024-10-09 22:01:19 +03:00
|
|
|
import _VisualDVM.Constants;
|
2024-10-07 00:58:29 +03:00
|
|
|
import _VisualDVM.Global;
|
2024-10-09 22:01:19 +03:00
|
|
|
import _VisualDVM.Utils;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.Repository.Server.ServerCode;
|
|
|
|
|
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
|
|
|
|
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
2024-10-14 12:14:01 +03:00
|
|
|
import _VisualDVM.Passes.PassCode;
|
2024-10-10 23:57:36 +03:00
|
|
|
import Common.Passes.Pass;
|
2024-10-14 12:14:01 +03:00
|
|
|
import _VisualDVM.Passes.Server.TestingSystemPass;
|
2023-12-17 19:19:59 +03:00
|
|
|
import javafx.util.Pair;
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.Vector;
|
2024-10-09 23:37:58 +03:00
|
|
|
public class DownloadDVMPackages extends Pass<Vector<Integer>> {
|
2023-12-17 20:04:15 +03:00
|
|
|
Vector<Pair<Integer, Pair<byte[], byte[]>>> packed_packages;
|
2023-12-17 19:19:59 +03:00
|
|
|
@Override
|
|
|
|
|
public String getIconPath() {
|
2024-03-01 21:25:46 +03:00
|
|
|
return "/icons/DownloadBugReport.png";
|
2023-12-17 19:19:59 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String getButtonText() {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
2023-12-17 20:04:15 +03:00
|
|
|
protected boolean needsAnimation() {
|
2023-12-17 19:19:59 +03:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
2023-12-17 20:04:15 +03:00
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
target = (Vector<Integer>) args[0];
|
|
|
|
|
packed_packages = null;
|
|
|
|
|
TestingSystemPass pass = new TestingSystemPass<Vector<Integer>>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
target = (Vector<Integer>) args[0];
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
return "Получение пакетов";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void ServerAction() throws Exception {
|
|
|
|
|
Command(new ServerExchangeUnit_2021(ServerCode.DownloadDVMPackages, "", target));
|
|
|
|
|
packed_packages = (Vector<Pair<Integer, Pair<byte[], byte[]>>>) response.object;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
if (!pass.Do(target)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2023-12-17 19:19:59 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
2023-12-17 20:04:15 +03:00
|
|
|
protected void body() throws Exception {
|
|
|
|
|
ShowMessage1("Распаковка пакета");
|
|
|
|
|
for (Pair<Integer, Pair<byte[], byte[]>> p : packed_packages) {
|
2023-12-17 19:19:59 +03:00
|
|
|
DVMPackage dvmPackage = Global.testingServer.db.dvmPackages.get(p.getKey());
|
2023-12-17 20:04:15 +03:00
|
|
|
ShowMessage2(String.valueOf(dvmPackage.id));
|
2023-12-17 19:19:59 +03:00
|
|
|
File workspace = dvmPackage.getLocalWorkspace();
|
|
|
|
|
Utils.CheckAndCleanDirectory(workspace);
|
|
|
|
|
File results_zip = new File(workspace, "results.zip");
|
|
|
|
|
File results = new File(workspace, "results");
|
|
|
|
|
File loaded = new File(workspace, Constants.LOADED);
|
2023-12-17 20:04:15 +03:00
|
|
|
Pair<byte[], byte[]> packed_package = p.getValue();
|
2023-12-17 19:19:59 +03:00
|
|
|
//---
|
2024-10-11 00:00:30 +03:00
|
|
|
Utils_.bytesToFile(packed_package.getKey(), results_zip);
|
|
|
|
|
Utils_.bytesToFile(packed_package.getValue(), dvmPackage.getJsonFile());
|
2024-10-13 23:55:03 +03:00
|
|
|
Global.mainModule.getPass(PassCode.UnzipFolderPass).Do(results_zip.getAbsolutePath(), workspace.getAbsolutePath());
|
2023-12-17 19:19:59 +03:00
|
|
|
FileUtils.writeStringToFile(loaded, new Date().toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|