package com.atlassian.stash.internal.maintenance.backup;

import com.atlassian.stash.internal.db.DatabaseHandle;
import de.schlichtherle.truezip.zip.ZipOutputStream;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;

/**
 * Represents the state about a backup step/phase that is shared between the various steps in the backup process.
 */
public interface BackupState {

    String ACTIVE_OBJECTS_BACKUP_FILE = "active-objects-data.xml";
    String CHANGELOGS_BACKUP_FILE = "changelogs.zip";
    String LIQUIBASE_BACKUP_FILE = "stash-data.xml";

    /**
     * @return handle for the database that needs to be backed up
     */
    @Nonnull
    DatabaseHandle getSourceDatabase();

    /**
     * @return the {@link File} where the backup is to be written to. Can be {@code null}, in which case no backup file
     *         has been created (yet).
     */
    @Nullable
    File getBackupFile();

    /**
     * @return the {@link ZipOutputStream} of the backup file that is being written. Can be {@code null}, in which case
     *         no backup file has been created (yet).
     */
    @Nullable
    ZipOutputStream getBackupZipStream();

    void setBackupFile(@Nonnull File backupFile);
    void setBackupZipStream(@Nonnull ZipOutputStream zipOutputStream);
}
