2023-12-18 00:04:44 +03:00
|
|
|
package Visual_DVM_2021.Passes.All;
|
2024-10-07 22:04:09 +03:00
|
|
|
import Common.Utils.CommonUtils;
|
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;
|
2023-12-18 00:04:44 +03:00
|
|
|
import Repository.Server.ServerCode;
|
|
|
|
|
import Repository.Server.ServerExchangeUnit_2021;
|
|
|
|
|
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
|
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
|
|
|
|
import Visual_DVM_2021.Passes.Pass_2021;
|
|
|
|
|
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
public class DownloadSapforPackage extends Pass_2021<SapforPackage> {
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean needsAnimation() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
File loaded;
|
|
|
|
|
byte[] packed;
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
target = (SapforPackage) args[0];
|
2024-09-25 01:27:02 +03:00
|
|
|
if (!target.state.isDone()){
|
2023-12-18 00:04:44 +03:00
|
|
|
Log.Writeln_("Возможно загрузить только завершенный пакет.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
int id = target.id;
|
|
|
|
|
loaded = new File(target.getLocalWorkspace(), Constants.LOADED);
|
|
|
|
|
if (!loaded.exists()){
|
|
|
|
|
Pass_2021 pass = new TestingSystemPass() {
|
|
|
|
|
@Override
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
return "Скачивание";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void ServerAction() throws Exception {
|
|
|
|
|
Command(new ServerExchangeUnit_2021(ServerCode.DownloadSapforPackage, "",id));
|
|
|
|
|
packed = (byte[]) response.object;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
return pass.Do();
|
|
|
|
|
};
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void body() throws Exception {
|
|
|
|
|
File workspace = target.getLocalWorkspace();
|
2023-12-18 15:44:48 +03:00
|
|
|
Utils.forceDeleteWithCheck(workspace);
|
2023-12-18 00:04:44 +03:00
|
|
|
File archive = Utils.getTempFileName(String.valueOf(target.id));
|
2024-10-07 22:04:09 +03:00
|
|
|
CommonUtils.bytesToFile(packed,archive);
|
2023-12-18 00:04:44 +03:00
|
|
|
passes.get(PassCode_2021.UnzipFolderPass).Do(archive.getAbsolutePath(), Global.SapforPackagesDirectory.getAbsolutePath());
|
|
|
|
|
FileUtils.writeStringToFile(loaded, new Date().toString());
|
|
|
|
|
}
|
|
|
|
|
}
|