59 lines
2.2 KiB
Java
59 lines
2.2 KiB
Java
package _VisualDVM.Passes.All;
|
|
import Common.CommonConstants;
|
|
import Common.Passes.Pass;
|
|
import Common.Utils.Utils_;
|
|
import _VisualDVM.Global;
|
|
import _VisualDVM.Passes.PassCode;
|
|
import _VisualDVM.Passes.Server.TestingSystemPass_OLD;
|
|
import _VisualDVM.Repository.Server.ServerCode;
|
|
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
|
import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
|
import _VisualDVM.Utils;
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
import java.io.File;
|
|
import java.util.Date;
|
|
public class DownloadSapforPackage extends Pass<SapforPackage> {
|
|
File loaded;
|
|
byte[] packed;
|
|
@Override
|
|
protected boolean needsAnimation() {
|
|
return true;
|
|
}
|
|
@Override
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
target = (SapforPackage) args[0];
|
|
if (!target.state.isDone()) {
|
|
Log.Writeln_("Возможно загрузить только завершенный пакет.");
|
|
return false;
|
|
}
|
|
int id = target.id;
|
|
loaded = new File(target.getLocalWorkspace(), CommonConstants.LOADED);
|
|
if (!loaded.exists()) {
|
|
Pass pass = new TestingSystemPass_OLD() {
|
|
@Override
|
|
public String getDescription() {
|
|
return "Скачивание";
|
|
}
|
|
@Override
|
|
protected void ServerAction() throws Exception {
|
|
Command(new ServerExchangeUnit_2021(ServerCode.DownloadSapforPackage, "", id));
|
|
packed = (byte[]) server_response.object;
|
|
}
|
|
};
|
|
return pass.Do();
|
|
}
|
|
;
|
|
return false;
|
|
}
|
|
@Override
|
|
protected void body() throws Exception {
|
|
File workspace = target.getLocalWorkspace();
|
|
Utils_.forceDeleteWithCheck(workspace);
|
|
File archive = Utils.getTempFileName(String.valueOf(target.id));
|
|
Utils_.bytesToFile(packed, archive);
|
|
Global.mainModule.getPass(PassCode.UnzipFolderPass).Do(archive.getAbsolutePath(), Global.SapforPackagesDirectory.getAbsolutePath());
|
|
FileUtils.writeStringToFile(loaded, new Date().toString());
|
|
}
|
|
}
|