2024-10-14 12:14:01 +03:00
|
|
|
package _VisualDVM.Passes.All;
|
2024-10-14 15:19:13 +03:00
|
|
|
import Common.Passes.PassException;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
|
2025-02-04 16:24:32 +03:00
|
|
|
import _VisualDVM.Passes.Server.TestingSystemPass_OLD;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.Repository.Server.ServerCode;
|
|
|
|
|
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
2024-10-14 15:19:13 +03:00
|
|
|
import _VisualDVM.Utils;
|
2024-10-17 17:22:33 +03:00
|
|
|
import _VisualDVM.Visual.Windows.ReadOnlyMultilineTextForm;
|
2024-05-18 23:31:45 +03:00
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Vector;
|
2025-02-04 16:24:32 +03:00
|
|
|
public class ShowTestingServerFile extends TestingSystemPass_OLD<RemoteFile> {
|
2024-05-18 23:31:45 +03:00
|
|
|
String title;
|
|
|
|
|
File localFile;
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
|
|
|
|
title = (String) args[0];
|
|
|
|
|
target = (RemoteFile) args[1];
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void ServerAction() throws Exception {
|
|
|
|
|
Command(new ServerExchangeUnit_2021(ServerCode.ReceiveFile, target.full_name));
|
|
|
|
|
localFile = Utils.getTempFileName(target.name);
|
2025-02-03 15:19:53 +03:00
|
|
|
if (server_response.object != null)
|
|
|
|
|
server_response.Unpack(localFile);
|
2024-05-18 23:31:45 +03:00
|
|
|
else throw new PassException("Файл не найден");
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean validate() {
|
|
|
|
|
return localFile.exists();
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void showDone() throws Exception {
|
|
|
|
|
ReadOnlyMultilineTextForm ff = new ReadOnlyMultilineTextForm();
|
|
|
|
|
List<String> lines = FileUtils.readLines(localFile);
|
|
|
|
|
Vector<String> res = new Vector<>();
|
|
|
|
|
for (int i = lines.size() - 1; i >= 0; i--)
|
|
|
|
|
res.add(lines.get(i));
|
|
|
|
|
ff.ShowDialog(title,
|
|
|
|
|
String.join("\n", res)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|