2024-10-14 12:14:01 +03:00
|
|
|
package _VisualDVM.Passes.All;
|
2024-10-16 00:40:45 +03:00
|
|
|
import Common.CommonConstants;
|
2024-10-11 00:00:30 +03:00
|
|
|
import Common.Utils.Utils_;
|
2024-10-07 00:58:29 +03:00
|
|
|
import _VisualDVM.Global;
|
2024-10-14 15:19:13 +03:00
|
|
|
import _VisualDVM.Passes.PassCode;
|
2025-02-04 21:37:07 +03:00
|
|
|
import _VisualDVM.Passes.Server.TestingServerPass;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.Repository.Server.ServerCode;
|
|
|
|
|
import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
2024-10-14 15:19:13 +03:00
|
|
|
import _VisualDVM.Utils;
|
2023-12-18 00:04:44 +03:00
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Date;
|
2025-02-04 21:37:07 +03:00
|
|
|
public class DownloadSapforPackage extends TestingServerPass<SapforPackage> {
|
2024-10-14 15:19:13 +03:00
|
|
|
File loaded;
|
|
|
|
|
byte[] packed;
|
2023-12-18 00:04:44 +03:00
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
target = (SapforPackage) args[0];
|
2024-10-14 15:19:13 +03:00
|
|
|
if (!target.state.isDone()) {
|
2023-12-18 00:04:44 +03:00
|
|
|
Log.Writeln_("Возможно загрузить только завершенный пакет.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
int id = target.id;
|
2024-10-16 00:40:45 +03:00
|
|
|
loaded = new File(target.getLocalWorkspace(), CommonConstants.LOADED);
|
2025-02-15 23:30:48 +03:00
|
|
|
return !loaded.exists()&&SendRequest(ServerCode.DownloadSapforPackage, "", id);
|
2023-12-18 00:04:44 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void body() throws Exception {
|
2025-02-04 21:37:07 +03:00
|
|
|
packed = (byte[]) request.server_response.object;
|
2023-12-18 00:04:44 +03:00
|
|
|
File workspace = target.getLocalWorkspace();
|
2024-10-14 12:54:52 +03:00
|
|
|
Utils_.forceDeleteWithCheck(workspace);
|
2023-12-18 00:04:44 +03:00
|
|
|
File archive = Utils.getTempFileName(String.valueOf(target.id));
|
2024-10-14 15:19:13 +03:00
|
|
|
Utils_.bytesToFile(packed, archive);
|
2024-10-13 23:55:03 +03:00
|
|
|
Global.mainModule.getPass(PassCode.UnzipFolderPass).Do(archive.getAbsolutePath(), Global.SapforPackagesDirectory.getAbsolutePath());
|
2023-12-18 00:04:44 +03:00
|
|
|
FileUtils.writeStringToFile(loaded, new Date().toString());
|
|
|
|
|
}
|
|
|
|
|
}
|