diff --git a/services/git-bridge/.idea/workspace.xml b/services/git-bridge/.idea/workspace.xml
index e785e1fdda..08f125445d 100644
--- a/services/git-bridge/.idea/workspace.xml
+++ b/services/git-bridge/.idea/workspace.xml
@@ -7,20 +7,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -44,101 +34,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -157,10 +57,6 @@
@@ -243,7 +143,6 @@
-
@@ -494,6 +393,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -688,6 +609,7 @@
+
@@ -721,16 +643,17 @@
+
+
+
+
-
-
-
@@ -783,6 +706,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -810,19 +746,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -957,7 +880,7 @@
-
+
@@ -1012,20 +935,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1279,15 +1188,6 @@
-
-
-
-
-
-
-
-
-
@@ -1307,6 +1207,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1315,22 +1247,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1339,58 +1255,66 @@
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/application/WLGitBridgeApplication.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/application/WLGitBridgeApplication.java
index 41572b0653..c6e19745f6 100644
--- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/application/WLGitBridgeApplication.java
+++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/application/WLGitBridgeApplication.java
@@ -22,7 +22,7 @@ public class WLGitBridgeApplication {
/**
* Constructs an instance of the WriteLatex-Git Bridge application.
- * @param args args from main, which should be in the format "port root_git_directory_path"
+ * @param args args from main, which should be in the format [port, root_git_directory_path]
*/
public WLGitBridgeApplication(String[] args) {
try {
diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/WLRepositoryResolver.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/WLRepositoryResolver.java
index b17a5267da..66ce449aeb 100644
--- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/WLRepositoryResolver.java
+++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/git/handler/WLRepositoryResolver.java
@@ -12,6 +12,8 @@ import org.eclipse.jgit.transport.resolver.RepositoryResolver;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import uk.ac.ic.wlgitbridge.git.exception.InvalidRootDirectoryPathException;
+import uk.ac.ic.wlgitbridge.writelatex.RepositorySource;
+import uk.ac.ic.wlgitbridge.writelatex.SnapshotRepositorySource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
@@ -23,25 +25,16 @@ import java.io.IOException;
public class WLRepositoryResolver implements RepositoryResolver {
private File rootGitDirectory;
+ private RepositorySource repositorySource;
public WLRepositoryResolver(String rootGitDirectoryPath) throws InvalidRootDirectoryPathException {
initRootGitDirectory(rootGitDirectoryPath);
+ repositorySource = new SnapshotRepositorySource();
}
@Override
public Repository open(HttpServletRequest httpServletRequest, String name) throws RepositoryNotFoundException, ServiceNotAuthorizedException, ServiceNotEnabledException, ServiceMayNotContinueException {
- File repositoryRoot = new File(rootGitDirectory.getAbsolutePath(), name);
-
- Repository repository = null;
- try {
- repository = new FileRepositoryBuilder().setWorkTree(repositoryRoot).build();
- } catch (IOException e) {
- throw new RepositoryNotFoundException(name);
- }
- if (!repository.getObjectDatabase().exists()) {
- throw new RepositoryNotFoundException(name);
- }
- return repository;
+ return repositorySource.getRepositoryWithNameAtRootDirectory(name, rootGitDirectory);
}
private void initRootGitDirectory(String rootGitDirectoryPath) throws InvalidRootDirectoryPathException {
diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/RepositorySource.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/RepositorySource.java
new file mode 100644
index 0000000000..409d14c1f8
--- /dev/null
+++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/RepositorySource.java
@@ -0,0 +1,15 @@
+package uk.ac.ic.wlgitbridge.writelatex;
+
+import org.eclipse.jgit.errors.RepositoryNotFoundException;
+import org.eclipse.jgit.lib.Repository;
+
+import java.io.File;
+
+/**
+ * Created by Winston on 03/11/14.
+ */
+public interface RepositorySource {
+
+ public Repository getRepositoryWithNameAtRootDirectory(String name, File rootDirectory) throws RepositoryNotFoundException;
+
+}
diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/SnapshotRepositorySource.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/SnapshotRepositorySource.java
new file mode 100644
index 0000000000..019e391504
--- /dev/null
+++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/SnapshotRepositorySource.java
@@ -0,0 +1,31 @@
+package uk.ac.ic.wlgitbridge.writelatex;
+
+import org.eclipse.jgit.errors.RepositoryNotFoundException;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Created by Winston on 03/11/14.
+ */
+public class SnapshotRepositorySource implements RepositorySource {
+
+ @Override
+ public Repository getRepositoryWithNameAtRootDirectory(String name, File rootDirectory) throws RepositoryNotFoundException {
+ File repositoryRoot = new File(rootDirectory.getAbsolutePath(), name);
+
+ Repository repository = null;
+ try {
+ repository = new FileRepositoryBuilder().setWorkTree(repositoryRoot).build();
+ } catch (IOException e) {
+ throw new RepositoryNotFoundException(name);
+ }
+ if (!repository.getObjectDatabase().exists()) {
+ throw new RepositoryNotFoundException(name);
+ }
+ return repository;
+ }
+
+}
diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/exception/InvalidProgramArgumentsExceptionTests.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/exception/InvalidProgramArgumentsExceptionTests.java
index a5f96076a7..8c12756679 100644
--- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/exception/InvalidProgramArgumentsExceptionTests.java
+++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/application/exception/InvalidProgramArgumentsExceptionTests.java
@@ -1,7 +1,15 @@
package uk.ac.ic.wlgitbridge.test.application.exception;
+import org.junit.Test;
+
/**
* Created by Winston on 03/11/14.
*/
public class InvalidProgramArgumentsExceptionTests {
+
+ @Test
+ public void nothingToTest() {
+
+ }
+
}
diff --git a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/exception/InvalidRootDirectoryPathException.java b/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/exception/InvalidRootDirectoryPathException.java
index 7adcac4ddb..f8ce1770d5 100644
--- a/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/exception/InvalidRootDirectoryPathException.java
+++ b/services/git-bridge/test/uk/ac/ic/wlgitbridge/test/git/exception/InvalidRootDirectoryPathException.java
@@ -1,7 +1,15 @@
package uk.ac.ic.wlgitbridge.test.git.exception;
+import org.junit.Test;
+
/**
* Created by Winston on 03/11/14.
*/
public class InvalidRootDirectoryPathException {
+
+ @Test
+ public void nothingToTest() {
+
+ }
+
}