|
|
@@ -5,11 +5,9 @@ import org.eclipse.jgit.api.errors.GitAPIException;
|
|
|
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
|
|
import org.eclipse.jgit.lib.Repository;
|
|
|
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
|
|
|
-import uk.ac.ic.wlgitbridge.writelatex.api.SnapshotDBAPI;
|
|
|
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
|
|
|
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException;
|
|
|
|
|
|
-import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -20,14 +18,12 @@ public class WLBridgedProject {
|
|
|
|
|
|
private final Repository repository;
|
|
|
private final String name;
|
|
|
- private final File repositoryDirectory;
|
|
|
- private final SnapshotDBAPI snapshotDBAPI;
|
|
|
+ private final WriteLatexDataSource writeLatexDataSource;
|
|
|
|
|
|
- public WLBridgedProject(Repository repository, String name, File repositoryDirectory, SnapshotDBAPI snapshotDBAPI) {
|
|
|
+ public WLBridgedProject(Repository repository, String name, WriteLatexDataSource writeLatexDataSource) {
|
|
|
this.repository = repository;
|
|
|
this.name = name;
|
|
|
- this.repositoryDirectory = repositoryDirectory;
|
|
|
- this.snapshotDBAPI = snapshotDBAPI;
|
|
|
+ this.writeLatexDataSource = writeLatexDataSource;
|
|
|
}
|
|
|
|
|
|
public void buildRepository() throws RepositoryNotFoundException, ServiceNotEnabledException, FailedConnectionException {
|
|
|
@@ -41,7 +37,7 @@ public class WLBridgedProject {
|
|
|
private void updateRepositoryFromSnapshots(Repository repository) throws ServiceNotEnabledException, RepositoryNotFoundException, FailedConnectionException {
|
|
|
List<WritableRepositoryContents> writableRepositories;
|
|
|
try {
|
|
|
- writableRepositories = snapshotDBAPI.getWritableRepositories(name);
|
|
|
+ writableRepositories = writeLatexDataSource.getWritableRepositories(name);
|
|
|
} catch (InvalidProjectException e) {
|
|
|
throw new RepositoryNotFoundException(name);
|
|
|
}
|
|
|
@@ -63,13 +59,13 @@ public class WLBridgedProject {
|
|
|
}
|
|
|
|
|
|
private void buildRepositoryFromScratch(Repository repository) throws RepositoryNotFoundException, ServiceNotEnabledException, FailedConnectionException {
|
|
|
- if (!snapshotDBAPI.repositoryExists(name)) {
|
|
|
+ if (!writeLatexDataSource.repositoryExists(name)) {
|
|
|
throw new RepositoryNotFoundException(name);
|
|
|
}
|
|
|
try {
|
|
|
repository.create();
|
|
|
} catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ throw new ServiceNotEnabledException();
|
|
|
}
|
|
|
updateRepositoryFromSnapshots(repository);
|
|
|
}
|