package _VisualDVM.Passes.All;
import _VisualDVM.Global;
import _VisualDVM.Passes.Server.ComponentsServerPass;
import _VisualDVM.Repository.Server.ServerCode;

import java.io.File;
import java.util.Vector;
public class GetComponentsBackupsFromServer extends ComponentsServerPass<Vector<File>> {
    @Override
    protected boolean isSafe() {
        return false;
    }
    @Override
    protected boolean canStart(Object... args) throws Exception {
        target = new Vector<>();
        return Global.components.getUI().CheckCurrent(Log) &&
                SendRequest(ServerCode.GetComponentsBackups,
                        Global.components.getUI().getCurrent().getComponentType().toString());
    }
    @Override
    protected void body() throws Exception {
        target = (Vector<File>) request.server_response.object;
    }
    @Override
    protected boolean validate() {
        if (target.isEmpty()) {
            Log.Writeln_("Не найдено резервных копий на сервере для компонента "
                    + Global.components.getUI().getCurrent().getComponentType().getDescription());
            return false;
        }
        return true;
    }
}
