// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/db/DBStore.java
// public interface DBStore {
// 
//     int getNumProjects();
// 
//     List<String> getProjectNames();
// 
//     void setLatestVersionForProject(String project, int versionID);
// 
//     int getLatestVersionForProject(String project);
// 
//     void addURLIndexForProject(String projectName, String url, String path);
// 
//     void deleteFilesForProject(String project, String... files);
// 
//     String getPathForURLInProject(String projectName, String url);
// 
//     String getOldestUnswappedProject();
// 
//     int getNumUnswappedProjects();
// 
//     ProjectState getProjectState(String projectName);
// 
//     /**
//      * Sets the last accessed time for the given project name.
//      * @param projectName the project's name
//      * @param time the time, or null if the project is to be swapped
//      */
//     void setLastAccessedTime(String projectName, Timestamp time);
// 
// }
// 
// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/RepoStore.java
// public interface RepoStore {
// 
//     /* Still need to get rid of these two methods.
//        Main dependency: GitRepoStore needs a Repository which needs a directory.
//        Instead, use a visitor or something. */
//     String getRepoStorePath();
// 
//     File getRootDirectory();
// 
//     ProjectRepo initRepo(String project) throws IOException;
// 
//     ProjectRepo getExistingRepo(String project) throws IOException;
// 
//     ProjectRepo useJGitRepo(Repository repo, ObjectId commitId);
// 
//     void purgeNonexistentProjects(
//             Collection<String> existingProjectNames
//     );
// 
//     long totalSize();
// 
//     /**
//      * Tars and bzip2s the .git directory of the given project. Throws an
//      * IOException if the project doesn't exist. The returned stream is a copy
//      * of the original .git directory, which must be deleted using remove().
//      */
//     InputStream bzip2Project(
//             String projectName,
//             long[] sizePtr
//     ) throws IOException;
// 
//     default InputStream bzip2Project(
//             String projectName
//     ) throws IOException {
//         return bzip2Project(projectName, null);
//     }
// 
//     /**
//      * Called after {@link #bzip2Project(String, long[])}'s has been safely
//      * uploaded to the swap store. Removes all traces of the project from disk,
//      * i.e. not just its .git, but the whole project's git directory.
//      * @param projectName
//      * @throws IOException
//      */
//     void remove(String projectName) throws IOException;
// 
//     /**
//      * Unbzip2s the given data stream into a .git directory for projectName.
//      * Creates the project's git directory.
//      * If projectName already exists, throws an IOException.
//      * @param projectName the name of the project, e.g. abc123
//      * @param dataStream the data stream containing the bzipped contents.
//      */
//     void unbzip2Project(
//             String projectName,
//             InputStream dataStream
//     ) throws IOException;
// 
// }


import uk.ac.ic.wlgitbridge.bridge.db.DBStore;
import uk.ac.ic.wlgitbridge.bridge.lock.ProjectLock;
import uk.ac.ic.wlgitbridge.bridge.repo.RepoStore;
import uk.ac.ic.wlgitbridge.bridge.swap.store.SwapStore;
import java.io.IOException;
import java.util.Optional;
package uk.ac.ic.wlgitbridge.bridge.swap.job;



/**
 * Created by winston on 20/08/2016.
 */
public interface SwapJob {

    static SwapJob fromConfig(
            Optional<SwapJobConfig> cfg,
            ProjectLock lock,
// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/db/DBStore.java
// public interface DBStore {
// 
//     int getNumProjects();
// 
//     List<String> getProjectNames();
// 
//     void setLatestVersionForProject(String project, int versionID);
// 
//     int getLatestVersionForProject(String project);
// 
//     void addURLIndexForProject(String projectName, String url, String path);
// 
//     void deleteFilesForProject(String project, String... files);
// 
//     String getPathForURLInProject(String projectName, String url);
// 
//     String getOldestUnswappedProject();
// 
//     int getNumUnswappedProjects();
// 
//     ProjectState getProjectState(String projectName);
// 
//     /**
//      * Sets the last accessed time for the given project name.
//      * @param projectName the project's name
//      * @param time the time, or null if the project is to be swapped
//      */
//     void setLastAccessedTime(String projectName, Timestamp time);
// 
// }
// 
// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/RepoStore.java
// public interface RepoStore {
// 
//     /* Still need to get rid of these two methods.
//        Main dependency: GitRepoStore needs a Repository which needs a directory.
//        Instead, use a visitor or something. */
//     String getRepoStorePath();
// 
//     File getRootDirectory();
// 
//     ProjectRepo initRepo(String project) throws IOException;
// 
//     ProjectRepo getExistingRepo(String project) throws IOException;
// 
//     ProjectRepo useJGitRepo(Repository repo, ObjectId commitId);
// 
//     void purgeNonexistentProjects(
//             Collection<String> existingProjectNames
//     );
// 
//     long totalSize();
// 
//     /**
//      * Tars and bzip2s the .git directory of the given project. Throws an
//      * IOException if the project doesn't exist. The returned stream is a copy
//      * of the original .git directory, which must be deleted using remove().
//      */
//     InputStream bzip2Project(
//             String projectName,
//             long[] sizePtr
//     ) throws IOException;
// 
//     default InputStream bzip2Project(
//             String projectName
//     ) throws IOException {
//         return bzip2Project(projectName, null);
//     }
// 
//     /**
//      * Called after {@link #bzip2Project(String, long[])}'s has been safely
//      * uploaded to the swap store. Removes all traces of the project from disk,
//      * i.e. not just its .git, but the whole project's git directory.
//      * @param projectName
//      * @throws IOException
//      */
//     void remove(String projectName) throws IOException;
// 
//     /**
//      * Unbzip2s the given data stream into a .git directory for projectName.
//      * Creates the project's git directory.
//      * If projectName already exists, throws an IOException.
//      * @param projectName the name of the project, e.g. abc123
//      * @param dataStream the data stream containing the bzipped contents.
//      */
//     void unbzip2Project(
//             String projectName,
//             InputStream dataStream
//     ) throws IOException;
// 
// }


// Path: src/main/java/uk/ac/ic/wlgitbridge/bridge/swap/job/SwapJob.java
import uk.ac.ic.wlgitbridge.bridge.db.DBStore;
import uk.ac.ic.wlgitbridge.bridge.lock.ProjectLock;
import uk.ac.ic.wlgitbridge.bridge.repo.RepoStore;
import uk.ac.ic.wlgitbridge.bridge.swap.store.SwapStore;
import java.io.IOException;
import java.util.Optional;

package uk.ac.ic.wlgitbridge.bridge.swap.job;



/**
 * Created by winston on 20/08/2016.
 */
public interface SwapJob {

    static SwapJob fromConfig(
            Optional<SwapJobConfig> cfg,
            ProjectLock lock,
            RepoStore repoStore,