Initial large refactor.

This commit is contained in:
Winston Li 2015-02-22 22:49:02 +00:00
parent 79307923ad
commit 8993702f69
144 changed files with 377 additions and 549 deletions

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId> <groupId>uk.ac.ic.wlgitbridge</groupId>
<artifactId>writelatex-git-bridge</artifactId> <artifactId>writelatex-git-bridge</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<properties> <properties>

View file

@ -5,8 +5,8 @@ import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.util.MultiMap; import org.eclipse.jetty.util.MultiMap;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.WriteLatexAPI; import uk.ac.ic.wlgitbridge.bridge.BridgeAPI;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.InvalidPostbackKeyException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.InvalidPostbackKeyException;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -18,9 +18,9 @@ import java.io.IOException;
*/ */
public class AttsResourceHandler extends ResourceHandler { public class AttsResourceHandler extends ResourceHandler {
private final WriteLatexAPI writeLatexDataSource; private final BridgeAPI writeLatexDataSource;
public AttsResourceHandler(WriteLatexAPI writeLatexDataSource) { public AttsResourceHandler(BridgeAPI writeLatexDataSource) {
this.writeLatexDataSource = writeLatexDataSource; this.writeLatexDataSource = writeLatexDataSource;
} }

View file

@ -5,7 +5,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import uk.ac.ic.wlgitbridge.application.exception.InvalidConfigFileException; import uk.ac.ic.wlgitbridge.application.exception.InvalidConfigFileException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.JSONSource; import uk.ac.ic.wlgitbridge.snapshot.base.JSONSource;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;

View file

@ -1,28 +0,0 @@
package uk.ac.ic.wlgitbridge.application;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.JSONSource;
/**
* Created by Winston on 05/01/15.
*/
public class SSLConfig implements JSONSource {
private boolean enabled;
public SSLConfig(JsonObject ssl) {
fromJSON(ssl);
}
@Override
public void fromJSON(JsonElement json) {
JsonObject obj = json.getAsJsonObject();
enabled = obj.get("enabled").getAsJsonPrimitive().getAsBoolean();
}
public boolean isEnabled() {
return enabled;
}
}

View file

@ -3,11 +3,11 @@ package uk.ac.ic.wlgitbridge.application;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import uk.ac.ic.wlgitbridge.bridge.WriteLatexDataSource; import uk.ac.ic.wlgitbridge.bridge.BridgeAPI;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.JSONSource; import uk.ac.ic.wlgitbridge.snapshot.base.JSONSource;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.UnexpectedPostbackException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.UnexpectedPostbackException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostExceptionBuilder; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostExceptionBuilder;
/** /**
* Created by Winston on 17/11/14. * Created by Winston on 17/11/14.
@ -16,7 +16,7 @@ public class SnapshotPushPostbackContents implements JSONSource {
private static final String CODE_SUCCESS = "upToDate"; private static final String CODE_SUCCESS = "upToDate";
private final WriteLatexDataSource writeLatexDataSource; private final BridgeAPI bridgeAPI;
private final String projectName; private final String projectName;
private final String postbackKey; private final String postbackKey;
@ -25,8 +25,8 @@ public class SnapshotPushPostbackContents implements JSONSource {
private int versionID; private int versionID;
private SnapshotPostException exception; private SnapshotPostException exception;
public SnapshotPushPostbackContents(WriteLatexDataSource writeLatexDataSource, String projectName, String postbackKey, String contents) { public SnapshotPushPostbackContents(BridgeAPI bridgeAPI, String projectName, String postbackKey, String contents) {
this.writeLatexDataSource = writeLatexDataSource; this.bridgeAPI = bridgeAPI;
this.projectName = projectName; this.projectName = projectName;
this.postbackKey = postbackKey; this.postbackKey = postbackKey;
snapshotPostExceptionBuilder = new SnapshotPostExceptionBuilder(); snapshotPostExceptionBuilder = new SnapshotPostExceptionBuilder();
@ -42,9 +42,9 @@ public class SnapshotPushPostbackContents implements JSONSource {
public void processPostback() throws UnexpectedPostbackException { public void processPostback() throws UnexpectedPostbackException {
if (exception == null) { if (exception == null) {
writeLatexDataSource.postbackReceivedSuccessfully(projectName, postbackKey, versionID); bridgeAPI.postbackReceivedSuccessfully(projectName, postbackKey, versionID);
} else { } else {
writeLatexDataSource.postbackReceivedWithException(projectName, postbackKey, exception); bridgeAPI.postbackReceivedWithException(projectName, postbackKey, exception);
} }
} }

View file

@ -4,9 +4,9 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.handler.AbstractHandler;
import uk.ac.ic.wlgitbridge.bridge.WriteLatexDataSource; import uk.ac.ic.wlgitbridge.bridge.BridgeAPI;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.UnexpectedPostbackException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.UnexpectedPostbackException;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -18,10 +18,10 @@ import java.io.IOException;
*/ */
public class SnapshotPushPostbackHandler extends AbstractHandler { public class SnapshotPushPostbackHandler extends AbstractHandler {
private final WriteLatexDataSource writeLatexDataSource; private final BridgeAPI bridgeAPI;
public SnapshotPushPostbackHandler(WriteLatexDataSource writeLatexDataSource) { public SnapshotPushPostbackHandler(BridgeAPI bridgeAPI) {
this.writeLatexDataSource = writeLatexDataSource; this.bridgeAPI = bridgeAPI;
} }
@Override @Override
@ -38,7 +38,7 @@ public class SnapshotPushPostbackHandler extends AbstractHandler {
String projectName = parts[1]; String projectName = parts[1];
String postbackKey = parts[2]; String postbackKey = parts[2];
Util.sout(baseRequest.getMethod() + " <- " + baseRequest.getUri()); Util.sout(baseRequest.getMethod() + " <- " + baseRequest.getUri());
SnapshotPushPostbackContents postbackContents = new SnapshotPushPostbackContents(writeLatexDataSource, projectName, postbackKey, contents); SnapshotPushPostbackContents postbackContents = new SnapshotPushPostbackContents(bridgeAPI, projectName, postbackKey, contents);
JsonObject body = new JsonObject(); JsonObject body = new JsonObject();
try { try {

View file

@ -26,7 +26,7 @@ public class WLGitBridgeApplication {
/** /**
* Constructs an instance of the WriteLatex-Git Bridge application. * 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 [config_file]
*/ */
public WLGitBridgeApplication(String[] args) { public WLGitBridgeApplication(String[] args) {
try { try {

View file

@ -8,13 +8,12 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import uk.ac.ic.wlgitbridge.application.jetty.NullLogger; import uk.ac.ic.wlgitbridge.application.jetty.NullLogger;
import uk.ac.ic.wlgitbridge.bridge.WriteLatexDataSource; import uk.ac.ic.wlgitbridge.bridge.BridgeAPI;
import uk.ac.ic.wlgitbridge.git.exception.InvalidRootDirectoryPathException; import uk.ac.ic.wlgitbridge.git.exception.InvalidRootDirectoryPathException;
import uk.ac.ic.wlgitbridge.git.servlet.WLGitServlet; import uk.ac.ic.wlgitbridge.git.servlet.WLGitServlet;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.WriteLatexAPI; import uk.ac.ic.wlgitbridge.snapshot.base.SnapshotAPIRequest;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.SnapshotAPIRequest; import uk.ac.ic.wlgitbridge.data.model.DataStore;
import uk.ac.ic.wlgitbridge.writelatex.model.DataStore;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import java.io.File; import java.io.File;
@ -86,7 +85,7 @@ public class WLGitBridgeServer {
private void configureJettyServer() throws ServletException, InvalidRootDirectoryPathException { private void configureJettyServer() throws ServletException, InvalidRootDirectoryPathException {
HandlerCollection handlers = new HandlerCollection(); HandlerCollection handlers = new HandlerCollection();
WriteLatexAPI writeLatexDataSource = new WriteLatexAPI(new DataStore(rootGitDirectoryPath)); BridgeAPI writeLatexDataSource = new BridgeAPI(new DataStore(rootGitDirectoryPath));
handlers.setHandlers(new Handler[] { handlers.setHandlers(new Handler[] {
initResourceHandler(writeLatexDataSource), initResourceHandler(writeLatexDataSource),
new SnapshotPushPostbackHandler(writeLatexDataSource), new SnapshotPushPostbackHandler(writeLatexDataSource),
@ -95,18 +94,18 @@ public class WLGitBridgeServer {
jettyServer.setHandler(handlers); jettyServer.setHandler(handlers);
} }
private Handler initGitHandler(WriteLatexDataSource writeLatexDataSource) throws ServletException, InvalidRootDirectoryPathException { private Handler initGitHandler(BridgeAPI bridgeAPI) throws ServletException, InvalidRootDirectoryPathException {
final ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); final ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
servletContextHandler.setContextPath("/"); servletContextHandler.setContextPath("/");
servletContextHandler.addServlet( servletContextHandler.addServlet(
new ServletHolder( new ServletHolder(
new WLGitServlet(servletContextHandler, writeLatexDataSource, rootGitDirectoryPath)), new WLGitServlet(servletContextHandler, bridgeAPI, rootGitDirectoryPath)),
"/*" "/*"
); );
return servletContextHandler; return servletContextHandler;
} }
private Handler initResourceHandler(WriteLatexAPI writeLatexDataSource) { private Handler initResourceHandler(BridgeAPI writeLatexDataSource) {
ResourceHandler resourceHandler = new AttsResourceHandler(writeLatexDataSource); ResourceHandler resourceHandler = new AttsResourceHandler(writeLatexDataSource);
resourceHandler.setResourceBase(new File(rootGitDirectoryPath, ".wlgb/atts").getAbsolutePath()); resourceHandler.setResourceBase(new File(rootGitDirectoryPath, ".wlgb/atts").getAbsolutePath());
return resourceHandler; return resourceHandler;

View file

@ -1,49 +1,48 @@
package uk.ac.ic.wlgitbridge.writelatex; package uk.ac.ic.wlgitbridge.bridge;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.ServiceMayNotContinueException; import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import uk.ac.ic.wlgitbridge.bridge.RawDirectory; import uk.ac.ic.wlgitbridge.data.CandidateSnapshot;
import uk.ac.ic.wlgitbridge.bridge.WriteLatexDataSource; import uk.ac.ic.wlgitbridge.data.ProjectLock;
import uk.ac.ic.wlgitbridge.data.ShutdownHook;
import uk.ac.ic.wlgitbridge.data.model.DataStore;
import uk.ac.ic.wlgitbridge.data.filestore.RawDirectory;
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.snapshot.getdoc.SnapshotGetDocRequest;
import uk.ac.ic.wlgitbridge.snapshot.getdoc.exception.InvalidProjectException;
import uk.ac.ic.wlgitbridge.snapshot.push.PostbackManager;
import uk.ac.ic.wlgitbridge.snapshot.push.SnapshotPushRequest;
import uk.ac.ic.wlgitbridge.snapshot.push.SnapshotPushRequestResult;
import uk.ac.ic.wlgitbridge.snapshot.push.exception.*;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.SnapshotGetDocRequest;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.PostbackManager;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.SnapshotPushRequest;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.SnapshotPushRequestResult;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.*;
import uk.ac.ic.wlgitbridge.writelatex.model.DataStore;
import java.io.IOException; import java.io.IOException;
/** /**
* Created by Winston on 16/11/14. * Created by Winston on 16/11/14.
*/ */
public class WriteLatexAPI implements WriteLatexDataSource { public class BridgeAPI {
private final DataStore dataModel; private final DataStore dataModel;
private final PostbackManager postbackManager; private final PostbackManager postbackManager;
private final ProjectLock mainProjectLock; private final ProjectLock mainProjectLock;
public WriteLatexAPI(DataStore dataModel) { public BridgeAPI(DataStore dataModel) {
this.dataModel = dataModel; this.dataModel = dataModel;
postbackManager = new PostbackManager(); postbackManager = new PostbackManager();
mainProjectLock = new ProjectLock(); mainProjectLock = new ProjectLock();
Runtime.getRuntime().addShutdownHook(new ShutdownHook(mainProjectLock)); Runtime.getRuntime().addShutdownHook(new ShutdownHook(mainProjectLock));
} }
@Override
public void lockForProject(String projectName) { public void lockForProject(String projectName) {
mainProjectLock.lockForProject(projectName); mainProjectLock.lockForProject(projectName);
} }
@Override
public void unlockForProject(String projectName) { public void unlockForProject(String projectName) {
mainProjectLock.unlockForProject(projectName); mainProjectLock.unlockForProject(projectName);
} }
@Override
public boolean repositoryExists(String projectName) throws ServiceMayNotContinueException { public boolean repositoryExists(String projectName) throws ServiceMayNotContinueException {
lockForProject(projectName); lockForProject(projectName);
SnapshotGetDocRequest snapshotGetDocRequest = new SnapshotGetDocRequest(projectName); SnapshotGetDocRequest snapshotGetDocRequest = new SnapshotGetDocRequest(projectName);
@ -62,13 +61,11 @@ public class WriteLatexAPI implements WriteLatexDataSource {
return true; return true;
} }
@Override
public void getWritableRepositories(String projectName, Repository repository) throws IOException, SnapshotPostException, GitAPIException { public void getWritableRepositories(String projectName, Repository repository) throws IOException, SnapshotPostException, GitAPIException {
Util.sout("Fetching project: " + projectName); Util.sout("Fetching project: " + projectName);
dataModel.updateProjectWithName(projectName, repository); dataModel.updateProjectWithName(projectName, repository);
} }
@Override
public void putDirectoryContentsToProjectWithName(String projectName, RawDirectory directoryContents, RawDirectory oldDirectoryContents, String hostname) throws SnapshotPostException, IOException { public void putDirectoryContentsToProjectWithName(String projectName, RawDirectory directoryContents, RawDirectory oldDirectoryContents, String hostname) throws SnapshotPostException, IOException {
mainProjectLock.lockForProject(projectName); mainProjectLock.lockForProject(projectName);
CandidateSnapshot candidate = null; CandidateSnapshot candidate = null;
@ -99,18 +96,15 @@ public class WriteLatexAPI implements WriteLatexDataSource {
} }
} }
@Override
public void checkPostbackKey(String projectName, String postbackKey) throws InvalidPostbackKeyException { public void checkPostbackKey(String projectName, String postbackKey) throws InvalidPostbackKeyException {
postbackManager.checkPostbackKey(projectName, postbackKey); postbackManager.checkPostbackKey(projectName, postbackKey);
} }
/* Called by postback thread. */ /* Called by postback thread. */
@Override
public void postbackReceivedSuccessfully(String projectName, String postbackKey, int versionID) throws UnexpectedPostbackException { public void postbackReceivedSuccessfully(String projectName, String postbackKey, int versionID) throws UnexpectedPostbackException {
postbackManager.postVersionIDForProject(projectName, versionID, postbackKey); postbackManager.postVersionIDForProject(projectName, versionID, postbackKey);
} }
@Override
public void postbackReceivedWithException(String projectName, String postbackKey, SnapshotPostException exception) throws UnexpectedPostbackException { public void postbackReceivedWithException(String projectName, String postbackKey, SnapshotPostException exception) throws UnexpectedPostbackException {
postbackManager.postExceptionForProject(projectName, exception, postbackKey); postbackManager.postExceptionForProject(projectName, exception, postbackKey);
} }

View file

@ -1,12 +0,0 @@
package uk.ac.ic.wlgitbridge.bridge;
import uk.ac.ic.wlgitbridge.writelatex.CandidateSnapshot;
/**
* Created by Winston on 16/11/14.
*/
public interface CandidateSnapshotCallback {
public void approveSnapshot(int versionID, CandidateSnapshot candidateSnapshot);
}

View file

@ -1,11 +0,0 @@
package uk.ac.ic.wlgitbridge.bridge;
import java.util.Map;
/**
* Created by Winston on 16/11/14.
*/
public interface RawDirectory {
public Map<String, RawFile> getFileTable();
}

View file

@ -1,16 +0,0 @@
package uk.ac.ic.wlgitbridge.bridge;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import java.io.File;
/**
* Created by Winston on 03/11/14.
*/
public interface RepositorySource {
public Repository getRepositoryWithNameAtRootDirectory(String name, File rootDirectory) throws RepositoryNotFoundException, ServiceMayNotContinueException;
}

View file

@ -1,18 +1,13 @@
package uk.ac.ic.wlgitbridge.bridge; package uk.ac.ic.wlgitbridge.bridge;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.ServiceMayNotContinueException; import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.snapshot.getdoc.exception.InvalidProjectException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import java.util.TimeZone;
/** /**
* Created by Winston on 05/11/14. * Created by Winston on 05/11/14.
@ -21,16 +16,16 @@ public class WLBridgedProject {
private final Repository repository; private final Repository repository;
private final String name; private final String name;
private final WriteLatexDataSource writeLatexDataSource; private final BridgeAPI bridgeAPI;
public WLBridgedProject(Repository repository, String name, WriteLatexDataSource writeLatexDataSource) { public WLBridgedProject(Repository repository, String name, BridgeAPI bridgeAPI) {
this.repository = repository; this.repository = repository;
this.name = name; this.name = name;
this.writeLatexDataSource = writeLatexDataSource; this.bridgeAPI = bridgeAPI;
} }
public void buildRepository() throws RepositoryNotFoundException, ServiceMayNotContinueException { public void buildRepository() throws RepositoryNotFoundException, ServiceMayNotContinueException {
writeLatexDataSource.lockForProject(name); bridgeAPI.lockForProject(name);
try { try {
if (repository.getObjectDatabase().exists()) { if (repository.getObjectDatabase().exists()) {
updateRepositoryFromSnapshots(repository); updateRepositoryFromSnapshots(repository);
@ -41,13 +36,13 @@ public class WLBridgedProject {
e.printStackTrace(); e.printStackTrace();
throw new ServiceMayNotContinueException(e); throw new ServiceMayNotContinueException(e);
} finally { } finally {
writeLatexDataSource.unlockForProject(name); bridgeAPI.unlockForProject(name);
} }
} }
private void updateRepositoryFromSnapshots(Repository repository) throws RepositoryNotFoundException, ServiceMayNotContinueException { private void updateRepositoryFromSnapshots(Repository repository) throws RepositoryNotFoundException, ServiceMayNotContinueException {
try { try {
writeLatexDataSource.getWritableRepositories(name, repository); bridgeAPI.getWritableRepositories(name, repository);
} catch (InvalidProjectException e) { } catch (InvalidProjectException e) {
throw new RepositoryNotFoundException(name); throw new RepositoryNotFoundException(name);
} catch (SnapshotPostException e) { } catch (SnapshotPostException e) {
@ -60,7 +55,7 @@ public class WLBridgedProject {
} }
private void buildRepositoryFromScratch(Repository repository) throws RepositoryNotFoundException, ServiceMayNotContinueException { private void buildRepositoryFromScratch(Repository repository) throws RepositoryNotFoundException, ServiceMayNotContinueException {
if (!writeLatexDataSource.repositoryExists(name)) { if (!bridgeAPI.repositoryExists(name)) {
throw new RepositoryNotFoundException(name); throw new RepositoryNotFoundException(name);
} }
try { try {

View file

@ -1,23 +0,0 @@
package uk.ac.ic.wlgitbridge.bridge;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
import java.io.File;
import java.io.IOException;
import java.util.Date;
/**
* Created by Winston on 14/11/14.
*/
public interface WritableRepositoryContents {
public void write() throws IOException, FailedConnectionException;
public File getDirectory();
public String getUserName();
public String getUserEmail();
public String getCommitMessage();
public Date getWhen();
}

View file

@ -1,33 +0,0 @@
package uk.ac.ic.wlgitbridge.bridge;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.InvalidPostbackKeyException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.UnexpectedPostbackException;
import java.io.IOException;
/**
* Created by Winston on 03/11/14.
*/
public interface WriteLatexDataSource {
void lockForProject(String projectName);
void unlockForProject(String projectName);
/* Called by request thread. */
public boolean repositoryExists(String projectName) throws ServiceMayNotContinueException;
public void getWritableRepositories(String projectName, Repository repository) throws IOException, SnapshotPostException, GitAPIException;
public void putDirectoryContentsToProjectWithName(String projectName, RawDirectory directoryContents, RawDirectory oldDirectoryContents, String hostname) throws SnapshotPostException, IOException, FailedConnectionException;
void checkPostbackKey(String projectName, String postbackKey) throws InvalidPostbackKeyException;
/* Called by postback thread. */
public void postbackReceivedSuccessfully(String projectName, String postbackKey, int versionID) throws UnexpectedPostbackException;
public void postbackReceivedWithException(String projectName, String postbackKey, SnapshotPostException exception) throws UnexpectedPostbackException;
}

View file

@ -1,10 +1,10 @@
package uk.ac.ic.wlgitbridge.writelatex; package uk.ac.ic.wlgitbridge.data;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import uk.ac.ic.wlgitbridge.bridge.RawDirectory; import uk.ac.ic.wlgitbridge.data.filestore.RawFile;
import uk.ac.ic.wlgitbridge.bridge.RawFile; import uk.ac.ic.wlgitbridge.data.filestore.RawDirectory;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import java.io.File; import java.io.File;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex; package uk.ac.ic.wlgitbridge.data;
/** /**
* Created by Winston on 21/02/15. * Created by Winston on 21/02/15.

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex; package uk.ac.ic.wlgitbridge.data;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.writelatex; package uk.ac.ic.wlgitbridge.data;
import uk.ac.ic.wlgitbridge.bridge.RawFile; import uk.ac.ic.wlgitbridge.data.filestore.RawFile;
/** /**
* Created by Winston on 21/02/15. * Created by Winston on 21/02/15.

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex; package uk.ac.ic.wlgitbridge.data;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;

View file

@ -1,14 +1,14 @@
package uk.ac.ic.wlgitbridge.writelatex; package uk.ac.ic.wlgitbridge.data;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.SnapshotGetDocRequest; import uk.ac.ic.wlgitbridge.snapshot.getdoc.SnapshotGetDocRequest;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.SnapshotGetDocResult; import uk.ac.ic.wlgitbridge.snapshot.getdoc.SnapshotGetDocResult;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotData; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotData;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotGetForVersionRequest; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotGetForVersionRequest;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.SnapshotGetSavedVersRequest; import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.SnapshotGetSavedVersRequest;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.SnapshotInfo; import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.SnapshotInfo;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot; import uk.ac.ic.wlgitbridge.data.model.Snapshot;
import java.util.*; import java.util.*;

View file

@ -1,14 +1,13 @@
package uk.ac.ic.wlgitbridge.writelatex; package uk.ac.ic.wlgitbridge.data;
import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.transport.ServiceMayNotContinueException; import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import uk.ac.ic.wlgitbridge.bridge.RepositorySource;
import uk.ac.ic.wlgitbridge.bridge.WLBridgedProject; import uk.ac.ic.wlgitbridge.bridge.WLBridgedProject;
import uk.ac.ic.wlgitbridge.bridge.WriteLatexDataSource; import uk.ac.ic.wlgitbridge.bridge.BridgeAPI;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.InternalErrorException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.InternalErrorException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -16,17 +15,16 @@ import java.io.IOException;
/** /**
* Created by Winston on 03/11/14. * Created by Winston on 03/11/14.
*/ */
public class SnapshotRepositoryBuilder implements RepositorySource { public class SnapshotRepositoryBuilder {
private final WriteLatexDataSource writeLatexDataSource; private final BridgeAPI bridgeAPI;
public SnapshotRepositoryBuilder(WriteLatexDataSource writeLatexDataSource) { public SnapshotRepositoryBuilder(BridgeAPI bridgeAPI) {
this.writeLatexDataSource = writeLatexDataSource; this.bridgeAPI = bridgeAPI;
} }
@Override
public Repository getRepositoryWithNameAtRootDirectory(String name, File rootDirectory) throws RepositoryNotFoundException, ServiceMayNotContinueException { public Repository getRepositoryWithNameAtRootDirectory(String name, File rootDirectory) throws RepositoryNotFoundException, ServiceMayNotContinueException {
if (!writeLatexDataSource.repositoryExists(name)) { if (!bridgeAPI.repositoryExists(name)) {
throw new RepositoryNotFoundException(name); throw new RepositoryNotFoundException(name);
} }
File repositoryDirectory = new File(rootDirectory, name); File repositoryDirectory = new File(rootDirectory, name);
@ -34,7 +32,7 @@ public class SnapshotRepositoryBuilder implements RepositorySource {
Repository repository = null; Repository repository = null;
try { try {
repository = new FileRepositoryBuilder().setWorkTree(repositoryDirectory).build(); repository = new FileRepositoryBuilder().setWorkTree(repositoryDirectory).build();
new WLBridgedProject(repository, name, writeLatexDataSource).buildRepository(); new WLBridgedProject(repository, name, bridgeAPI).buildRepository();
} catch (IOException e) { } catch (IOException e) {
Util.printStackTrace(e); Util.printStackTrace(e);
throw new ServiceMayNotContinueException(new InternalErrorException().getDescriptionLines().get(0)); throw new ServiceMayNotContinueException(new InternalErrorException().getDescriptionLines().get(0));

View file

@ -1,9 +1,7 @@
package uk.ac.ic.wlgitbridge.writelatex.filestore; package uk.ac.ic.wlgitbridge.data.filestore;
import uk.ac.ic.wlgitbridge.bridge.RawFile; import uk.ac.ic.wlgitbridge.data.model.Snapshot;
import uk.ac.ic.wlgitbridge.bridge.WritableRepositoryContents;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -13,7 +11,7 @@ import java.util.List;
/** /**
* Created by Winston on 14/11/14. * Created by Winston on 14/11/14.
*/ */
public class GitDirectoryContents implements WritableRepositoryContents { public class GitDirectoryContents {
private final List<RawFile> files; private final List<RawFile> files;
private final File gitDirectory; private final File gitDirectory;
@ -31,7 +29,6 @@ public class GitDirectoryContents implements WritableRepositoryContents {
when = snapshot.getCreatedAt(); when = snapshot.getCreatedAt();
} }
@Override
public void write() throws IOException { public void write() throws IOException {
Util.deleteInDirectoryApartFrom(gitDirectory, ".git"); Util.deleteInDirectoryApartFrom(gitDirectory, ".git");
for (RawFile fileNode : files) { for (RawFile fileNode : files) {
@ -39,27 +36,22 @@ public class GitDirectoryContents implements WritableRepositoryContents {
} }
} }
@Override
public File getDirectory() { public File getDirectory() {
return gitDirectory; return gitDirectory;
} }
@Override
public String getUserName() { public String getUserName() {
return userName; return userName;
} }
@Override
public String getUserEmail() { public String getUserEmail() {
return userEmail; return userEmail;
} }
@Override
public String getCommitMessage() { public String getCommitMessage() {
return commitMessage; return commitMessage;
} }
@Override
public Date getWhen() { public Date getWhen() {
return when; return when;
} }

View file

@ -0,0 +1,20 @@
package uk.ac.ic.wlgitbridge.data.filestore;
import java.util.Map;
/**
* Created by Winston on 16/11/14.
*/
public class RawDirectory {
private final Map<String, RawFile> fileTable;
public RawDirectory(Map<String, RawFile> fileTable) {
this.fileTable = fileTable;
}
public Map<String, RawFile> getFileTable() {
return fileTable;
}
}

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.bridge; package uk.ac.ic.wlgitbridge.data.filestore;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;

View file

@ -1,6 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.filestore; package uk.ac.ic.wlgitbridge.data.filestore;
import uk.ac.ic.wlgitbridge.bridge.RawFile;
import java.util.Map.Entry; import java.util.Map.Entry;

View file

@ -1,20 +1,19 @@
package uk.ac.ic.wlgitbridge.writelatex.model; package uk.ac.ic.wlgitbridge.data.model;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import uk.ac.ic.wlgitbridge.bridge.CandidateSnapshotCallback; import uk.ac.ic.wlgitbridge.data.filestore.RawFile;
import uk.ac.ic.wlgitbridge.bridge.RawDirectory; import uk.ac.ic.wlgitbridge.data.CandidateSnapshot;
import uk.ac.ic.wlgitbridge.bridge.RawFile; import uk.ac.ic.wlgitbridge.data.SnapshotFetcher;
import uk.ac.ic.wlgitbridge.data.filestore.GitDirectoryContents;
import uk.ac.ic.wlgitbridge.data.model.db.PersistentStore;
import uk.ac.ic.wlgitbridge.data.filestore.RawDirectory;
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotAttachment;
import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.CandidateSnapshot;
import uk.ac.ic.wlgitbridge.writelatex.SnapshotFetcher;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotAttachment;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException;
import uk.ac.ic.wlgitbridge.writelatex.filestore.GitDirectoryContents;
import uk.ac.ic.wlgitbridge.writelatex.model.db.PersistentStore;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -26,7 +25,7 @@ import java.util.TimeZone;
/** /**
* Created by Winston on 06/11/14. * Created by Winston on 06/11/14.
*/ */
public class DataStore implements CandidateSnapshotCallback { public class DataStore {
private final File rootGitDirectory; private final File rootGitDirectory;
private final PersistentStore persistentStore; private final PersistentStore persistentStore;
@ -87,7 +86,6 @@ public class DataStore implements CandidateSnapshotCallback {
return candidateSnapshot; return candidateSnapshot;
} }
@Override
public void approveSnapshot(int versionID, CandidateSnapshot candidateSnapshot) { public void approveSnapshot(int versionID, CandidateSnapshot candidateSnapshot) {
List<String> deleted = candidateSnapshot.getDeleted(); List<String> deleted = candidateSnapshot.getDeleted();
persistentStore.setLatestVersionForProject(candidateSnapshot.getProjectName(), versionID); persistentStore.setLatestVersionForProject(candidateSnapshot.getProjectName(), versionID);

View file

@ -1,15 +1,15 @@
package uk.ac.ic.wlgitbridge.writelatex.model; package uk.ac.ic.wlgitbridge.data.model;
import com.ning.http.client.AsyncCompletionHandler; import com.ning.http.client.AsyncCompletionHandler;
import com.ning.http.client.HttpResponseBodyPart; import com.ning.http.client.HttpResponseBodyPart;
import com.ning.http.client.Response; import com.ning.http.client.Response;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import uk.ac.ic.wlgitbridge.bridge.RawFile; import uk.ac.ic.wlgitbridge.data.filestore.RawFile;
import uk.ac.ic.wlgitbridge.data.filestore.RepositoryFile;
import uk.ac.ic.wlgitbridge.git.util.RepositoryObjectTreeWalker; import uk.ac.ic.wlgitbridge.git.util.RepositoryObjectTreeWalker;
import uk.ac.ic.wlgitbridge.snapshot.base.Request;
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.Request;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.writelatex.filestore.RepositoryFile;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;

View file

@ -1,12 +1,12 @@
package uk.ac.ic.wlgitbridge.writelatex.model; package uk.ac.ic.wlgitbridge.data.model;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotAttachment; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotAttachment;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotData; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotData;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotFile; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotFile;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.SnapshotInfo; import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.SnapshotInfo;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.WLUser; import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.WLUser;
import java.util.*; import java.util.*;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.model; package uk.ac.ic.wlgitbridge.data.model;
/** /**
* Created by Winston on 21/02/15. * Created by Winston on 21/02/15.

View file

@ -1,7 +1,7 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db; package uk.ac.ic.wlgitbridge.data.model.db;
import uk.ac.ic.wlgitbridge.writelatex.model.URLIndexStore; import uk.ac.ic.wlgitbridge.data.model.URLIndexStore;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLiteWLDatabase; import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLiteWLDatabase;
import java.io.File; import java.io.File;
import java.sql.SQLException; import java.sql.SQLException;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql; package uk.ac.ic.wlgitbridge.data.model.db.sql;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql; package uk.ac.ic.wlgitbridge.data.model.db.sql;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;

View file

@ -1,14 +1,14 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql; package uk.ac.ic.wlgitbridge.data.model.db.sql;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.query.GetLatestVersionForProjectSQLQuery; import uk.ac.ic.wlgitbridge.data.model.db.sql.query.GetLatestVersionForProjectSQLQuery;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.query.GetPathForURLInProjectSQLQuery; import uk.ac.ic.wlgitbridge.data.model.db.sql.query.GetPathForURLInProjectSQLQuery;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.query.GetProjectNamesSQLQuery; import uk.ac.ic.wlgitbridge.data.model.db.sql.query.GetProjectNamesSQLQuery;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.create.CreateIndexURLIndexStore; import uk.ac.ic.wlgitbridge.data.model.db.sql.update.create.CreateIndexURLIndexStore;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.create.CreateProjectsTableSQLUpdate; import uk.ac.ic.wlgitbridge.data.model.db.sql.update.create.CreateProjectsTableSQLUpdate;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.create.CreateURLIndexStoreSQLUpdate; import uk.ac.ic.wlgitbridge.data.model.db.sql.update.create.CreateURLIndexStoreSQLUpdate;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.delete.DeleteFilesForProjectSQLUpdate; import uk.ac.ic.wlgitbridge.data.model.db.sql.update.delete.DeleteFilesForProjectSQLUpdate;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.insert.AddURLIndexSQLUpdate; import uk.ac.ic.wlgitbridge.data.model.db.sql.update.insert.AddURLIndexSQLUpdate;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.insert.SetProjectSQLUpdate; import uk.ac.ic.wlgitbridge.data.model.db.sql.update.insert.SetProjectSQLUpdate;
import java.io.File; import java.io.File;
import java.sql.*; import java.sql.*;

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql.query; package uk.ac.ic.wlgitbridge.data.model.db.sql.query;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLQuery; import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLQuery;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql.query; package uk.ac.ic.wlgitbridge.data.model.db.sql.query;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLQuery; import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLQuery;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql.query; package uk.ac.ic.wlgitbridge.data.model.db.sql.query;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLQuery; import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLQuery;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.create; package uk.ac.ic.wlgitbridge.data.model.db.sql.update.create;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLUpdate; import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLUpdate;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.create; package uk.ac.ic.wlgitbridge.data.model.db.sql.update.create;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLUpdate; import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLUpdate;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.create; package uk.ac.ic.wlgitbridge.data.model.db.sql.update.create;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLUpdate; import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLUpdate;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.delete; package uk.ac.ic.wlgitbridge.data.model.db.sql.update.delete;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLUpdate; import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLUpdate;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.insert; package uk.ac.ic.wlgitbridge.data.model.db.sql.update.insert;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLUpdate; import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLUpdate;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;

View file

@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.writelatex.model.db.sql.update.insert; package uk.ac.ic.wlgitbridge.data.model.db.sql.update.insert;
import uk.ac.ic.wlgitbridge.writelatex.model.db.sql.SQLUpdate; import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLUpdate;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;

View file

@ -5,7 +5,7 @@ import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.resolver.ReceivePackFactory; import org.eclipse.jgit.transport.resolver.ReceivePackFactory;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import uk.ac.ic.wlgitbridge.bridge.WriteLatexDataSource; import uk.ac.ic.wlgitbridge.bridge.BridgeAPI;
import uk.ac.ic.wlgitbridge.git.handler.hook.WriteLatexPutHook; import uk.ac.ic.wlgitbridge.git.handler.hook.WriteLatexPutHook;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
@ -17,10 +17,10 @@ import javax.servlet.http.HttpServletRequest;
/* */ /* */
public class WLReceivePackFactory implements ReceivePackFactory<HttpServletRequest> { public class WLReceivePackFactory implements ReceivePackFactory<HttpServletRequest> {
private final WriteLatexDataSource writeLatexDataSource; private final BridgeAPI bridgeAPI;
public WLReceivePackFactory(WriteLatexDataSource writeLatexDataSource) { public WLReceivePackFactory(BridgeAPI bridgeAPI) {
this.writeLatexDataSource = writeLatexDataSource; this.bridgeAPI = bridgeAPI;
} }
@Override @Override
@ -30,7 +30,7 @@ public class WLReceivePackFactory implements ReceivePackFactory<HttpServletReque
if (hostname == null) { if (hostname == null) {
hostname = httpServletRequest.getLocalName(); hostname = httpServletRequest.getLocalName();
} }
receivePack.setPreReceiveHook(new WriteLatexPutHook(writeLatexDataSource, hostname)); receivePack.setPreReceiveHook(new WriteLatexPutHook(bridgeAPI, hostname));
return receivePack; return receivePack;
} }

View file

@ -6,10 +6,9 @@ import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import org.eclipse.jgit.transport.resolver.RepositoryResolver; import org.eclipse.jgit.transport.resolver.RepositoryResolver;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import uk.ac.ic.wlgitbridge.bridge.RepositorySource; import uk.ac.ic.wlgitbridge.data.SnapshotRepositoryBuilder;
import uk.ac.ic.wlgitbridge.git.exception.InvalidRootDirectoryPathException; import uk.ac.ic.wlgitbridge.git.exception.InvalidRootDirectoryPathException;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.SnapshotRepositoryBuilder;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.File; import java.io.File;
@ -20,17 +19,17 @@ import java.io.File;
public class WLRepositoryResolver implements RepositoryResolver<HttpServletRequest> { public class WLRepositoryResolver implements RepositoryResolver<HttpServletRequest> {
private File rootGitDirectory; private File rootGitDirectory;
private RepositorySource repositorySource; private SnapshotRepositoryBuilder snapshotRepositoryBuilder;
public WLRepositoryResolver(String rootGitDirectoryPath, SnapshotRepositoryBuilder repositorySource) throws InvalidRootDirectoryPathException { public WLRepositoryResolver(String rootGitDirectoryPath, SnapshotRepositoryBuilder repositorySource) throws InvalidRootDirectoryPathException {
this.repositorySource = repositorySource; this.snapshotRepositoryBuilder = repositorySource;
initRootGitDirectory(rootGitDirectoryPath); initRootGitDirectory(rootGitDirectoryPath);
} }
@Override @Override
public Repository open(HttpServletRequest httpServletRequest, String name) throws RepositoryNotFoundException, ServiceNotAuthorizedException, ServiceNotEnabledException, ServiceMayNotContinueException { public Repository open(HttpServletRequest httpServletRequest, String name) throws RepositoryNotFoundException, ServiceNotAuthorizedException, ServiceNotEnabledException, ServiceMayNotContinueException {
try { try {
return repositorySource.getRepositoryWithNameAtRootDirectory(Util.removeAllSuffixes(name, "/", ".git"), rootGitDirectory); return snapshotRepositoryBuilder.getRepositoryWithNameAtRootDirectory(Util.removeAllSuffixes(name, "/", ".git"), rootGitDirectory);
} catch (RepositoryNotFoundException e) { } catch (RepositoryNotFoundException e) {
Util.printStackTrace(e); Util.printStackTrace(e);
throw e; throw e;

View file

@ -5,16 +5,16 @@ import org.eclipse.jgit.transport.PreReceiveHook;
import org.eclipse.jgit.transport.ReceiveCommand; import org.eclipse.jgit.transport.ReceiveCommand;
import org.eclipse.jgit.transport.ReceiveCommand.Result; import org.eclipse.jgit.transport.ReceiveCommand.Result;
import org.eclipse.jgit.transport.ReceivePack; import org.eclipse.jgit.transport.ReceivePack;
import uk.ac.ic.wlgitbridge.bridge.RawDirectory; import uk.ac.ic.wlgitbridge.bridge.BridgeAPI;
import uk.ac.ic.wlgitbridge.bridge.WriteLatexDataSource;
import uk.ac.ic.wlgitbridge.git.handler.hook.exception.ForcedPushException; import uk.ac.ic.wlgitbridge.git.handler.hook.exception.ForcedPushException;
import uk.ac.ic.wlgitbridge.git.handler.hook.exception.WrongBranchException; import uk.ac.ic.wlgitbridge.git.handler.hook.exception.WrongBranchException;
import uk.ac.ic.wlgitbridge.data.filestore.RawDirectory;
import uk.ac.ic.wlgitbridge.git.util.RepositoryObjectTreeWalker; import uk.ac.ic.wlgitbridge.git.util.RepositoryObjectTreeWalker;
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.snapshot.push.exception.InternalErrorException;
import uk.ac.ic.wlgitbridge.snapshot.push.exception.OutOfDateException;
import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.InternalErrorException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.OutOfDateException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
@ -24,11 +24,11 @@ import java.util.Collection;
*/ */
public class WriteLatexPutHook implements PreReceiveHook { public class WriteLatexPutHook implements PreReceiveHook {
private final WriteLatexDataSource writeLatexDataSource; private final BridgeAPI bridgeAPI;
private final String hostname; private final String hostname;
public WriteLatexPutHook(WriteLatexDataSource writeLatexDataSource, String hostname) { public WriteLatexPutHook(BridgeAPI bridgeAPI, String hostname) {
this.writeLatexDataSource = writeLatexDataSource; this.bridgeAPI = bridgeAPI;
this.hostname = hostname; this.hostname = hostname;
} }
@ -63,7 +63,7 @@ public class WriteLatexPutHook implements PreReceiveHook {
private void handleReceiveCommand(Repository repository, ReceiveCommand receiveCommand) throws IOException, SnapshotPostException, FailedConnectionException { private void handleReceiveCommand(Repository repository, ReceiveCommand receiveCommand) throws IOException, SnapshotPostException, FailedConnectionException {
checkBranch(receiveCommand); checkBranch(receiveCommand);
checkForcedPush(receiveCommand); checkForcedPush(receiveCommand);
writeLatexDataSource.putDirectoryContentsToProjectWithName(repository.getWorkTree().getName(), bridgeAPI.putDirectoryContentsToProjectWithName(repository.getWorkTree().getName(),
getPushedDirectoryContents(repository, getPushedDirectoryContents(repository,
receiveCommand), receiveCommand),
getOldDirectoryContents(repository), getOldDirectoryContents(repository),

View file

@ -2,7 +2,7 @@ package uk.ac.ic.wlgitbridge.git.handler.hook.exception;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View file

@ -1,7 +1,7 @@
package uk.ac.ic.wlgitbridge.git.handler.hook.exception; package uk.ac.ic.wlgitbridge.git.handler.hook.exception;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View file

@ -6,8 +6,8 @@ import uk.ac.ic.wlgitbridge.git.exception.InvalidRootDirectoryPathException;
import uk.ac.ic.wlgitbridge.git.handler.WLReceivePackFactory; import uk.ac.ic.wlgitbridge.git.handler.WLReceivePackFactory;
import uk.ac.ic.wlgitbridge.git.handler.WLRepositoryResolver; import uk.ac.ic.wlgitbridge.git.handler.WLRepositoryResolver;
import uk.ac.ic.wlgitbridge.git.handler.WLUploadPackFactory; import uk.ac.ic.wlgitbridge.git.handler.WLUploadPackFactory;
import uk.ac.ic.wlgitbridge.writelatex.SnapshotRepositoryBuilder; import uk.ac.ic.wlgitbridge.data.SnapshotRepositoryBuilder;
import uk.ac.ic.wlgitbridge.bridge.WriteLatexDataSource; import uk.ac.ic.wlgitbridge.bridge.BridgeAPI;
import javax.servlet.ServletException; import javax.servlet.ServletException;
@ -16,9 +16,9 @@ import javax.servlet.ServletException;
*/ */
public class WLGitServlet extends GitServlet { public class WLGitServlet extends GitServlet {
public WLGitServlet(ServletContextHandler servletContextHandler, WriteLatexDataSource writeLatexDataSource, String rootGitDirectoryPath) throws ServletException, InvalidRootDirectoryPathException { public WLGitServlet(ServletContextHandler servletContextHandler, BridgeAPI bridgeAPI, String rootGitDirectoryPath) throws ServletException, InvalidRootDirectoryPathException {
setRepositoryResolver(new WLRepositoryResolver(rootGitDirectoryPath, new SnapshotRepositoryBuilder(writeLatexDataSource))); setRepositoryResolver(new WLRepositoryResolver(rootGitDirectoryPath, new SnapshotRepositoryBuilder(bridgeAPI)));
setReceivePackFactory(new WLReceivePackFactory(writeLatexDataSource)); setReceivePackFactory(new WLReceivePackFactory(bridgeAPI));
setUploadPackFactory(new WLUploadPackFactory()); setUploadPackFactory(new WLUploadPackFactory());
init(new WLGitServletConfig(servletContextHandler)); init(new WLGitServletConfig(servletContextHandler));
} }

View file

@ -1,24 +0,0 @@
package uk.ac.ic.wlgitbridge.git.util;
import uk.ac.ic.wlgitbridge.bridge.RawDirectory;
import uk.ac.ic.wlgitbridge.bridge.RawFile;
import java.util.Map;
/**
* Created by Winston on 16/11/14.
*/
public class FileDirectory implements RawDirectory {
private final Map<String, RawFile> fileTable;
public FileDirectory(Map<String, RawFile> fileTable) {
this.fileTable = fileTable;
}
@Override
public Map<String, RawFile> getFileTable() {
return fileTable;
}
}

View file

@ -4,9 +4,9 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.TreeWalk;
import uk.ac.ic.wlgitbridge.bridge.RawDirectory; import uk.ac.ic.wlgitbridge.data.filestore.RawDirectory;
import uk.ac.ic.wlgitbridge.bridge.RawFile; import uk.ac.ic.wlgitbridge.data.filestore.RawFile;
import uk.ac.ic.wlgitbridge.writelatex.filestore.RepositoryFile; import uk.ac.ic.wlgitbridge.data.filestore.RepositoryFile;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -34,7 +34,7 @@ public class RepositoryObjectTreeWalker {
} }
public RawDirectory getDirectoryContents() throws IOException { public RawDirectory getDirectoryContents() throws IOException {
return new FileDirectory(walkGitObjectTree()); return new RawDirectory(walkGitObjectTree());
} }
private TreeWalk initTreeWalk(Repository repository, ObjectId objectId) throws IOException { private TreeWalk initTreeWalk(Repository repository, ObjectId objectId) throws IOException {

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.base; package uk.ac.ic.wlgitbridge.snapshot.base;
/** /**
* Created by Winston on 16/11/14. * Created by Winston on 16/11/14.

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.base; package uk.ac.ic.wlgitbridge.snapshot.base;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.base; package uk.ac.ic.wlgitbridge.snapshot.base;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
@ -7,8 +7,8 @@ import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.AsyncHttpClient.BoundRequestBuilder; import com.ning.http.client.AsyncHttpClient.BoundRequestBuilder;
import com.ning.http.client.Realm; import com.ning.http.client.Realm;
import com.ning.http.client.Response; import com.ning.http.client.Response;
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.base; package uk.ac.ic.wlgitbridge.snapshot.base;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.base; package uk.ac.ic.wlgitbridge.snapshot.base;
import com.ning.http.client.Realm; import com.ning.http.client.Realm;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.exception; package uk.ac.ic.wlgitbridge.snapshot.exception;
import org.eclipse.jgit.transport.ServiceMayNotContinueException; import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;

View file

@ -1,9 +1,9 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc; package uk.ac.ic.wlgitbridge.snapshot.getdoc;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.HTTPMethod; import uk.ac.ic.wlgitbridge.snapshot.base.HTTPMethod;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.SnapshotAPIRequest; import uk.ac.ic.wlgitbridge.snapshot.base.SnapshotAPIRequest;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
/** /**
* Created by Winston on 06/11/14. * Created by Winston on 06/11/14.

View file

@ -1,13 +1,13 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc; package uk.ac.ic.wlgitbridge.snapshot.getdoc;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.Request; import uk.ac.ic.wlgitbridge.snapshot.base.Result;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.Result; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.snapshot.getdoc.exception.InvalidProjectException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.ProtectedProjectException; import uk.ac.ic.wlgitbridge.snapshot.base.Request;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException; import uk.ac.ic.wlgitbridge.snapshot.getdoc.exception.ProtectedProjectException;
/** /**
* Created by Winston on 06/11/14. * Created by Winston on 06/11/14.

View file

@ -1,9 +1,9 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception; package uk.ac.ic.wlgitbridge.snapshot.getdoc.exception;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;

View file

@ -1,7 +1,7 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception; package uk.ac.ic.wlgitbridge.snapshot.getdoc.exception;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View file

@ -1,9 +1,9 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion; package uk.ac.ic.wlgitbridge.snapshot.getforversion;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.JSONSource; import uk.ac.ic.wlgitbridge.snapshot.base.JSONSource;
/** /**
* Created by Winston on 06/11/14. * Created by Winston on 06/11/14.

View file

@ -1,9 +1,9 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion; package uk.ac.ic.wlgitbridge.snapshot.getforversion;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.JSONSource; import uk.ac.ic.wlgitbridge.snapshot.base.JSONSource;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;

View file

@ -1,10 +1,10 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion; package uk.ac.ic.wlgitbridge.snapshot.getforversion;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import uk.ac.ic.wlgitbridge.bridge.RawFile; import uk.ac.ic.wlgitbridge.data.filestore.RawFile;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.JSONSource; import uk.ac.ic.wlgitbridge.snapshot.base.JSONSource;
/** /**
* Created by Winston on 06/11/14. * Created by Winston on 06/11/14.

View file

@ -1,9 +1,9 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion; package uk.ac.ic.wlgitbridge.snapshot.getforversion;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.HTTPMethod; import uk.ac.ic.wlgitbridge.snapshot.base.HTTPMethod;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.SnapshotAPIRequest; import uk.ac.ic.wlgitbridge.snapshot.base.SnapshotAPIRequest;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
/** /**
* Created by Winston on 06/11/14. * Created by Winston on 06/11/14.

View file

@ -1,8 +1,8 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion; package uk.ac.ic.wlgitbridge.snapshot.getforversion;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.Request; import uk.ac.ic.wlgitbridge.snapshot.base.Request;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.Result; import uk.ac.ic.wlgitbridge.snapshot.base.Result;
/** /**
* Created by Winston on 06/11/14. * Created by Winston on 06/11/14.

View file

@ -1,9 +1,9 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers; package uk.ac.ic.wlgitbridge.snapshot.getsavedvers;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.HTTPMethod; import uk.ac.ic.wlgitbridge.snapshot.base.SnapshotAPIRequest;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.SnapshotAPIRequest; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.snapshot.base.HTTPMethod;
/** /**
* Created by Winston on 06/11/14. * Created by Winston on 06/11/14.

View file

@ -1,12 +1,12 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers; package uk.ac.ic.wlgitbridge.snapshot.getsavedvers;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.Request; import uk.ac.ic.wlgitbridge.snapshot.base.Result;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.Result; import uk.ac.ic.wlgitbridge.snapshot.base.Request;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers; package uk.ac.ic.wlgitbridge.snapshot.getsavedvers;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers; package uk.ac.ic.wlgitbridge.snapshot.getsavedvers;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;

View file

@ -1,9 +1,9 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push; package uk.ac.ic.wlgitbridge.snapshot.push;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.InternalErrorException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.InternalErrorException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.InvalidPostbackKeyException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.PostbackTimeoutException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.PostbackTimeoutException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.InvalidPostbackKeyException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Condition;

View file

@ -1,8 +1,8 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push; package uk.ac.ic.wlgitbridge.snapshot.push;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.InvalidPostbackKeyException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.InvalidPostbackKeyException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.SnapshotPostException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException;
import uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception.UnexpectedPostbackException; import uk.ac.ic.wlgitbridge.snapshot.push.exception.UnexpectedPostbackException;
import java.math.BigInteger; import java.math.BigInteger;
import java.security.SecureRandom; import java.security.SecureRandom;

View file

@ -1,10 +1,10 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push; package uk.ac.ic.wlgitbridge.snapshot.push;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import uk.ac.ic.wlgitbridge.writelatex.CandidateSnapshot; import uk.ac.ic.wlgitbridge.data.CandidateSnapshot;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.HTTPMethod; import uk.ac.ic.wlgitbridge.snapshot.base.HTTPMethod;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.SnapshotAPIRequest; import uk.ac.ic.wlgitbridge.snapshot.base.SnapshotAPIRequest;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
/** /**
* Created by Winston on 16/11/14. * Created by Winston on 16/11/14.

View file

@ -1,10 +1,10 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push; package uk.ac.ic.wlgitbridge.snapshot.push;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.Request; import uk.ac.ic.wlgitbridge.snapshot.base.Result;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.Result; import uk.ac.ic.wlgitbridge.snapshot.base.Request;
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
/** /**
* Created by Winston on 16/11/14. * Created by Winston on 16/11/14.

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception; package uk.ac.ic.wlgitbridge.snapshot.push.exception;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception; package uk.ac.ic.wlgitbridge.snapshot.push.exception;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception; package uk.ac.ic.wlgitbridge.snapshot.push.exception;
/** /**
* Created by Winston on 04/12/14. * Created by Winston on 04/12/14.

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception; package uk.ac.ic.wlgitbridge.snapshot.push.exception;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception; package uk.ac.ic.wlgitbridge.snapshot.push.exception;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception; package uk.ac.ic.wlgitbridge.snapshot.push.exception;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.util.Util;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception; package uk.ac.ic.wlgitbridge.snapshot.push.exception;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;

View file

@ -1,7 +1,7 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception; package uk.ac.ic.wlgitbridge.snapshot.push.exception;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import uk.ac.ic.wlgitbridge.writelatex.api.request.base.JSONSource; import uk.ac.ic.wlgitbridge.snapshot.base.JSONSource;
import java.util.List; import java.util.List;

View file

@ -1,7 +1,6 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception; package uk.ac.ic.wlgitbridge.snapshot.push.exception;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException;
/** /**
* Created by Winston on 17/11/14. * Created by Winston on 17/11/14.
@ -19,7 +18,7 @@ public class SnapshotPostExceptionBuilder {
} else if (errorCode.equals(CODE_ERROR_INVALID_FILES)) { } else if (errorCode.equals(CODE_ERROR_INVALID_FILES)) {
return new InvalidFilesException(json); return new InvalidFilesException(json);
} else if (errorCode.equals(CODE_ERROR_INVALID_PROJECT)) { } else if (errorCode.equals(CODE_ERROR_INVALID_PROJECT)) {
return new InvalidProjectException(json); return new uk.ac.ic.wlgitbridge.snapshot.getdoc.exception.InvalidProjectException(json);
} else if (errorCode.equals(CODE_ERROR_UNKNOWN)) { } else if (errorCode.equals(CODE_ERROR_UNKNOWN)) {
return new UnexpectedErrorException(json); return new UnexpectedErrorException(json);
} else { } else {

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception; package uk.ac.ic.wlgitbridge.snapshot.push.exception;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.writelatex.api.request.push.exception; package uk.ac.ic.wlgitbridge.snapshot.push.exception;
/** /**
* Created by Winston on 17/11/14. * Created by Winston on 17/11/14.

View file

@ -1,7 +1,7 @@
package uk.ac.ic.wlgitbridge.test; package uk.ac.ic.wlgitbridge.snapshot.servermock;
import uk.ac.ic.wlgitbridge.test.server.MockSnapshotServer; import uk.ac.ic.wlgitbridge.snapshot.servermock.server.MockSnapshotServer;
import uk.ac.ic.wlgitbridge.test.state.SnapshotAPIStateBuilder; import uk.ac.ic.wlgitbridge.snapshot.servermock.state.SnapshotAPIStateBuilder;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.test.exception; package uk.ac.ic.wlgitbridge.snapshot.servermock.exception;
/** /**
* Created by Winston on 09/01/15. * Created by Winston on 09/01/15.

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.test.response; package uk.ac.ic.wlgitbridge.snapshot.servermock.response;
/** /**
* Created by Winston on 09/01/15. * Created by Winston on 09/01/15.

View file

@ -1,11 +1,11 @@
package uk.ac.ic.wlgitbridge.test.response; package uk.ac.ic.wlgitbridge.snapshot.servermock.response;
import uk.ac.ic.wlgitbridge.test.exception.InvalidAPICallException; import uk.ac.ic.wlgitbridge.snapshot.servermock.exception.InvalidAPICallException;
import uk.ac.ic.wlgitbridge.test.response.getdoc.SnapshotGetDocResponse; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.getdoc.SnapshotGetDocResponse;
import uk.ac.ic.wlgitbridge.test.response.getforver.SnapshotGetForVerResponse; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.getforver.SnapshotGetForVerResponse;
import uk.ac.ic.wlgitbridge.test.response.getsavedver.SnapshotGetSavedVersResponse; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.getsavedver.SnapshotGetSavedVersResponse;
import uk.ac.ic.wlgitbridge.test.response.push.SnapshotPushResponse; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.SnapshotPushResponse;
import uk.ac.ic.wlgitbridge.test.state.SnapshotAPIState; import uk.ac.ic.wlgitbridge.snapshot.servermock.state.SnapshotAPIState;
/** /**
* Created by Winston on 09/01/15. * Created by Winston on 09/01/15.

View file

@ -1,7 +1,7 @@
package uk.ac.ic.wlgitbridge.test.response.getdoc; package uk.ac.ic.wlgitbridge.snapshot.servermock.response.getdoc;
import uk.ac.ic.wlgitbridge.test.response.SnapshotResponse; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.SnapshotResponse;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.SnapshotGetDocResult; import uk.ac.ic.wlgitbridge.snapshot.getdoc.SnapshotGetDocResult;
/** /**
* Created by Winston on 09/01/15. * Created by Winston on 09/01/15.

View file

@ -1,7 +1,7 @@
package uk.ac.ic.wlgitbridge.test.response.getforver; package uk.ac.ic.wlgitbridge.snapshot.servermock.response.getforver;
import uk.ac.ic.wlgitbridge.test.response.SnapshotResponse; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.SnapshotResponse;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotGetForVersionResult; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotGetForVersionResult;
/** /**
* Created by Winston on 09/01/15. * Created by Winston on 09/01/15.

View file

@ -1,7 +1,7 @@
package uk.ac.ic.wlgitbridge.test.response.getsavedver; package uk.ac.ic.wlgitbridge.snapshot.servermock.response.getsavedver;
import uk.ac.ic.wlgitbridge.test.response.SnapshotResponse; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.SnapshotResponse;
import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.SnapshotGetSavedVersResult; import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.SnapshotGetSavedVersResult;
/** /**
* Created by Winston on 09/01/15. * Created by Winston on 09/01/15.

View file

@ -1,8 +1,8 @@
package uk.ac.ic.wlgitbridge.test.response.push; package uk.ac.ic.wlgitbridge.snapshot.servermock.response.push;
import uk.ac.ic.wlgitbridge.test.response.SnapshotResponse; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.SnapshotResponse;
import uk.ac.ic.wlgitbridge.test.response.push.postback.SnapshotPostbackRequest; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.postback.SnapshotPostbackRequest;
import uk.ac.ic.wlgitbridge.test.response.push.data.SnapshotPushResult; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.data.SnapshotPushResult;
/** /**
* Created by Winston on 09/01/15. * Created by Winston on 09/01/15.

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.test.response.push.data; package uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.data;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.test.response.push.data; package uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.data;
/** /**
* Created by Winston on 09/01/15. * Created by Winston on 09/01/15.

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.test.response.push.data; package uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.data;
/** /**
* Created by Winston on 09/01/15. * Created by Winston on 09/01/15.

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.test.response.push.postback; package uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.postback;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.test.response.push.postback; package uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.postback;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;

View file

@ -1,8 +1,8 @@
package uk.ac.ic.wlgitbridge.test.response.push.postback; package uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.postback;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import uk.ac.ic.wlgitbridge.test.response.push.postback.invalidfile.InvalidFileError; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.postback.invalidfile.InvalidFileError;
import java.util.List; import java.util.List;

View file

@ -1,4 +1,4 @@
package uk.ac.ic.wlgitbridge.test.response.push.postback; package uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.postback;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;

Some files were not shown because too many files have changed in this diff Show more