/*
 * Decompiled with CFR 0_123.
 */
package com.zakscode.FormulaManager;

import com.zakscode.FormulaManager.Configuration;
import com.zakscode.FormulaManager.Logger;
import com.zakscode.FormulaManager.Main;
import it.sauronsoftware.ftp4j.FTPClient;
import java.io.File;

public class FTPManager {
    private String url;
    private int port;
    private String user;
    private String password;
    private FTPClient client;

    public FTPManager(String url, int port, String user, String password) {
        this.url = url;
        this.port = port;
        this.user = user;
        this.password = password;
        this.client = new FTPClient();
        try {
            this.client.connect(this.url, this.port);
            this.client.login(this.user, this.password);
        }
        catch (Exception e) {
            Logger.write(e);
        }
    }

    public String getUrl() {
        return this.url;
    }

    public int getPort() {
        return this.port;
    }

    public String getUser() {
        return this.user;
    }

    public String getPassword() {
        return this.password;
    }

    public FTPClient getClient() {
        return this.client;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setClient(FTPClient client) {
        this.client = client;
    }

    public void writeFiles() {
        try {
            this.client.changeDirectory(Main.conf.getProperty("data-URL"));
            this.client.upload(new File(Main.baseDir + Main.conf.getProperty("data-path") + "vendors.data"));
            this.client.upload(new File(Main.baseDir + Main.conf.getProperty("data-path") + "components.data"));
            this.client.upload(new File(Main.baseDir + Main.conf.getProperty("data-path") + "formulas.data"));
        }
        catch (Exception e) {
            Logger.write(e);
        }
    }

    public void disconnect() {
        try {
            this.client.disconnect(false);
        }
        catch (Exception e) {
            Logger.write(e);
        }
    }
}

