package _VisualDVM.Passes.All;
import Common.Utils.Utils_;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.Global;
import _VisualDVM.Passes.Server.ComponentsServerPass;
import _VisualDVM.Repository.Server.ServerCode;
public class DownloadBugReport extends ComponentsServerPass<BugReport> {
    @Override
    protected boolean canStart(Object... args) {
        target = (BugReport) args[0];
        return !target.getArchiveFile().exists() && SendRequest(ServerCode.ReceiveBugReport, String.valueOf(target.id));
    }
    @Override
    protected void performPreparation() throws Exception {
        Utils_.CheckDirectory(Global.BugReportsDirectory);
    }
    @Override
    protected void body() throws Exception {
        Utils_.CheckAndCleanDirectory(target.getHome());
        Utils_.bytesToFile((byte[]) request.server_response.object, target.getArchiveFile());
    }
    @Override
    protected boolean validate() {
        return target.getArchiveFile().exists();
    }
}
