2023-11-19 02:12:44 +03:00
|
|
|
|
package Visual_DVM_2021.Passes.All;
|
2023-11-17 00:58:58 +03:00
|
|
|
|
import Common.Constants;
|
|
|
|
|
|
import Common.Global;
|
|
|
|
|
|
import Common.Utils.Utils;
|
2023-11-17 00:04:21 +03:00
|
|
|
|
import ProjectData.Project.db_project_info;
|
2023-11-19 02:12:44 +03:00
|
|
|
|
import Repository.Server.ServerCode;
|
|
|
|
|
|
import Repository.Server.ServerExchangeUnit_2021;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.PassException;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
2023-11-17 00:58:58 +03:00
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
|
public class PublishTestProject extends TestingSystemPass<db_project_info> {
|
|
|
|
|
|
Object test_id;
|
|
|
|
|
|
byte[] bytes = null;
|
2023-11-17 00:04:21 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
2023-11-17 00:58:58 +03:00
|
|
|
|
target = (db_project_info) args[0];
|
|
|
|
|
|
test_id = args[1];
|
|
|
|
|
|
bytes = null;
|
2023-11-17 00:04:21 +03:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-11-17 00:58:58 +03:00
|
|
|
|
protected void performPreparation() throws Exception {
|
|
|
|
|
|
File src = new File(Global.TempDirectory, String.valueOf(test_id));
|
|
|
|
|
|
Utils.CheckAndCleanDirectory(src);
|
|
|
|
|
|
target.Clone(src, false);
|
2023-11-20 20:17:59 +03:00
|
|
|
|
//--
|
2023-11-17 00:58:58 +03:00
|
|
|
|
FileUtils.copyFile(target.db.getFile(),
|
|
|
|
|
|
Paths.get(src.getAbsolutePath(), Constants.data, target.db.getFile().getName()).toFile());
|
2023-11-20 20:17:59 +03:00
|
|
|
|
//--
|
2023-11-17 00:58:58 +03:00
|
|
|
|
//архивация.
|
|
|
|
|
|
File archive = Utils.getTempFileName(String.valueOf(test_id));
|
|
|
|
|
|
//---
|
|
|
|
|
|
if (passes.get(PassCode_2021.ZipFolderPass).Do(src.getAbsolutePath(), archive.getAbsolutePath())) {
|
|
|
|
|
|
bytes = Utils.packFile(archive);
|
|
|
|
|
|
} else throw new PassException("Не удалось создать архив проекта");
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-11-17 00:04:21 +03:00
|
|
|
|
protected void ServerAction() throws Exception {
|
2023-11-17 00:58:58 +03:00
|
|
|
|
Command(new ServerExchangeUnit_2021(ServerCode.PublishTestProject, String.valueOf(test_id), bytes));
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void performFail() throws Exception {
|
|
|
|
|
|
super.performFail();
|
|
|
|
|
|
passes.get(PassCode_2021.SynchronizeTests).Do();
|
2023-11-17 00:04:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|