53 lines
2.1 KiB
Java
53 lines
2.1 KiB
Java
|
|
package Visual_DVM_2021.Passes.All;
|
||
|
|
import Common.Constants;
|
||
|
|
import Common.Global;
|
||
|
|
import Common.Utils.Utils;
|
||
|
|
import Repository.Server.ServerCode;
|
||
|
|
import Repository.Server.ServerExchangeUnit_2021;
|
||
|
|
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
||
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
||
|
|
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||
|
|
import javafx.util.Pair;
|
||
|
|
import org.apache.commons.io.FileUtils;
|
||
|
|
|
||
|
|
import java.io.File;
|
||
|
|
import java.util.Date;
|
||
|
|
import java.util.Vector;
|
||
|
|
public class DownloadDVMPackages extends TestingSystemPass<Vector<Integer>> {
|
||
|
|
@Override
|
||
|
|
public String getIconPath() {
|
||
|
|
return "/icons/DownloadBugReport.png";
|
||
|
|
}
|
||
|
|
@Override
|
||
|
|
public String getButtonText() {
|
||
|
|
return "";
|
||
|
|
}
|
||
|
|
@Override
|
||
|
|
protected boolean canStart(Object... args) throws Exception {
|
||
|
|
target = (Vector<Integer>) args[0];
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
@Override
|
||
|
|
protected void ServerAction() throws Exception {
|
||
|
|
Command(new ServerExchangeUnit_2021(ServerCode.DownloadDVMPackages, "", target));
|
||
|
|
}
|
||
|
|
@Override
|
||
|
|
protected void performDone() throws Exception {
|
||
|
|
Vector<Pair<Integer, Pair<byte[], byte[]>>> res = (Vector<Pair<Integer, Pair<byte[], byte[]>>>) response.object;
|
||
|
|
for (Pair<Integer, Pair<byte[], byte[]>> p : res) {
|
||
|
|
DVMPackage dvmPackage = Global.testingServer.db.dvmPackages.get(p.getKey());
|
||
|
|
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);
|
||
|
|
Pair<byte[], byte[]> packed = p.getValue();
|
||
|
|
//---
|
||
|
|
Utils.unpackFile(packed.getKey(), results_zip);
|
||
|
|
Utils.unpackFile(packed.getValue(), dvmPackage.getJsonFile());
|
||
|
|
passes.get(PassCode_2021.UnzipFolderPass).Do(results_zip.getAbsolutePath(), workspace.getAbsolutePath());
|
||
|
|
FileUtils.writeStringToFile(loaded, new Date().toString());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|