From 5a00c84359bd0a9f2c0a280d740145ee3c5d8045 Mon Sep 17 00:00:00 2001 From: Winston Li Date: Sun, 22 Feb 2015 23:42:01 +0000 Subject: [PATCH] Refactor with deletion and tests. --- .../main/java/uk/ac/ic/wlgitbridge/Main.java | 4 +- .../ac/ic/wlgitbridge/application/Config.java | 6 +-- ...idgeApplication.java => GitBridgeApp.java} | 28 ++++++----- ...mentsException.java => ArgsException.java} | 2 +- ...xception.java => ConfigFileException.java} | 5 +- .../ac/ic/wlgitbridge/bridge/BridgeAPI.java | 30 +++++------ .../ac/ic/wlgitbridge/data/ServletFile.java | 2 - .../ic/wlgitbridge/data/SnapshotFetcher.java | 24 ++++----- .../data/model/ResourceFetcher.java | 11 ++-- .../ic/wlgitbridge/data/model/Snapshot.java | 15 +----- .../wlgitbridge/data/model/URLIndexStore.java | 11 ---- .../data/model/db/PersistentStore.java | 6 +-- .../FileServlet.java} | 6 +-- .../GitBridgeServer.java} | 39 ++++++++------- .../PostbackContents.java} | 6 +-- .../PostbackHandler.java} | 10 ++-- ...tGetDocRequest.java => GetDocRequest.java} | 8 +-- ...hotGetDocResult.java => GetDocResult.java} | 6 +-- ...Request.java => GetForVersionRequest.java} | 8 +-- ...onResult.java => GetForVersionResult.java} | 6 +-- ...sRequest.java => GetSavedVersRequest.java} | 8 +-- ...ersResult.java => GetSavedVersResult.java} | 6 +-- .../snapshot/push/PostbackManager.java | 10 ++-- ...backContents.java => PostbackPromise.java} | 4 +- ...pshotPushRequest.java => PushRequest.java} | 8 +-- ...PushRequestResult.java => PushResult.java} | 4 +- .../getdoc/SnapshotGetDocResponse.java | 6 +-- .../getforver/SnapshotGetForVerResponse.java | 6 +-- .../SnapshotGetSavedVersResponse.java | 6 +-- .../servermock/state/SnapshotAPIState.java | 50 +++++++++---------- .../state/SnapshotAPIStateBuilder.java | 20 ++++---- .../WLGitBridgeIntegrationTest.java | 12 ++--- .../servermock/util/FileUtilTest.java | 28 +++++------ 33 files changed, 189 insertions(+), 212 deletions(-) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/{WLGitBridgeApplication.java => GitBridgeApp.java} (70%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/{InvalidProgramArgumentsException.java => ArgsException.java} (59%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/{InvalidConfigFileException.java => ConfigFileException.java} (68%) delete mode 100644 services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/URLIndexStore.java rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/{application/AttsResourceHandler.java => server/FileServlet.java} (90%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/{application/WLGitBridgeServer.java => server/GitBridgeServer.java} (74%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/{application/SnapshotPushPostbackContents.java => server/PostbackContents.java} (90%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/{application/SnapshotPushPostbackHandler.java => server/PostbackHandler.java} (88%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/{SnapshotGetDocRequest.java => GetDocRequest.java} (63%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/{SnapshotGetDocResult.java => GetDocResult.java} (92%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getforversion/{SnapshotGetForVersionRequest.java => GetForVersionRequest.java} (66%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getforversion/{SnapshotGetForVersionResult.java => GetForVersionResult.java} (76%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getsavedvers/{SnapshotGetSavedVersRequest.java => GetSavedVersRequest.java} (62%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getsavedvers/{SnapshotGetSavedVersResult.java => GetSavedVersResult.java} (87%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/{PostbackContents.java => PostbackPromise.java} (96%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/{SnapshotPushRequest.java => PushRequest.java} (73%) rename services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/{SnapshotPushRequestResult.java => PushResult.java} (85%) diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/Main.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/Main.java index 5dd5a7e941..ec7596cab8 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/Main.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/Main.java @@ -1,6 +1,6 @@ package uk.ac.ic.wlgitbridge; -import uk.ac.ic.wlgitbridge.application.WLGitBridgeApplication; +import uk.ac.ic.wlgitbridge.application.GitBridgeApp; /** * Created by Winston on 01/11/14. @@ -8,7 +8,7 @@ import uk.ac.ic.wlgitbridge.application.WLGitBridgeApplication; public class Main { public static void main(String[] args) { - new WLGitBridgeApplication(args).run(); + new GitBridgeApp(args).run(); } } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/Config.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/Config.java index abdaa86261..70ab5f2042 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/Config.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/Config.java @@ -4,7 +4,7 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -import uk.ac.ic.wlgitbridge.application.exception.InvalidConfigFileException; +import uk.ac.ic.wlgitbridge.application.exception.ConfigFileException; import uk.ac.ic.wlgitbridge.snapshot.base.JSONSource; import java.io.FileReader; @@ -23,7 +23,7 @@ public class Config implements JSONSource { private String postbackURL; private String serviceName; - public Config(String configFilePath) throws InvalidConfigFileException, IOException { + public Config(String configFilePath) throws ConfigFileException, IOException { try { fromJSON(new Gson().fromJson(new FileReader(configFilePath), JsonElement.class)); } catch (JsonParseException e) { @@ -73,7 +73,7 @@ public class Config implements JSONSource { private JsonElement getElement(JsonObject configObject, String name) { JsonElement element = configObject.get(name); if (element == null) { - throw new RuntimeException(new InvalidConfigFileException(name)); + throw new RuntimeException(new ConfigFileException(name)); } return element; } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeApplication.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/GitBridgeApp.java similarity index 70% rename from services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeApplication.java rename to services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/GitBridgeApp.java index 49c8d4ae83..063b95e5a8 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeApplication.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/GitBridgeApp.java @@ -1,8 +1,9 @@ package uk.ac.ic.wlgitbridge.application; -import uk.ac.ic.wlgitbridge.application.exception.InvalidConfigFileException; -import uk.ac.ic.wlgitbridge.application.exception.InvalidProgramArgumentsException; +import uk.ac.ic.wlgitbridge.application.exception.ConfigFileException; +import uk.ac.ic.wlgitbridge.application.exception.ArgsException; import uk.ac.ic.wlgitbridge.git.exception.InvalidRootDirectoryPathException; +import uk.ac.ic.wlgitbridge.server.GitBridgeServer; import uk.ac.ic.wlgitbridge.util.Util; import javax.servlet.ServletException; @@ -15,27 +16,27 @@ import java.io.IOException; /** * Class that represents the application. Parses arguments and gives them to the server, or dies with a usage message. */ -public class WLGitBridgeApplication { +public class GitBridgeApp implements Runnable { public static final int EXIT_CODE_FAILED = 1; private static final String USAGE_MESSAGE = "usage: writelatex-git-bridge config_file"; private String configFilePath; private Config config; - private WLGitBridgeServer server; + private GitBridgeServer server; /** * Constructs an instance of the WriteLatex-Git Bridge application. * @param args args from main, which should be in the format [config_file] */ - public WLGitBridgeApplication(String[] args) { + public GitBridgeApp(String[] args) { try { parseArguments(args); loadConfigFile(); - } catch (InvalidProgramArgumentsException e) { + } catch (ArgsException e) { printUsage(); System.exit(EXIT_CODE_FAILED); - } catch (InvalidConfigFileException e) { + } catch (ConfigFileException e) { System.err.println("The property for " + e.getMissingMember() + " is invalid. Check your config file."); System.exit(EXIT_CODE_FAILED); } catch (IOException e) { @@ -43,7 +44,7 @@ public class WLGitBridgeApplication { System.exit(EXIT_CODE_FAILED); } try { - server = new WLGitBridgeServer(config); + server = new GitBridgeServer(config); } catch (ServletException e) { Util.printStackTrace(e); } catch (InvalidRootDirectoryPathException e) { @@ -55,6 +56,7 @@ public class WLGitBridgeApplication { /** * Starts the server with the port number and root directory path given in the command-line arguments. */ + @Override public void run() { server.start(); } @@ -65,22 +67,22 @@ public class WLGitBridgeApplication { /* Helper methods */ - private void parseArguments(String[] args) throws InvalidProgramArgumentsException { + private void parseArguments(String[] args) throws ArgsException { checkArgumentsLength(args); parseConfigFilePath(args); } - private void checkArgumentsLength(String[] args) throws InvalidProgramArgumentsException { + private void checkArgumentsLength(String[] args) throws ArgsException { if (args.length < 1) { - throw new InvalidProgramArgumentsException(); + throw new ArgsException(); } } - private void parseConfigFilePath(String[] args) throws InvalidProgramArgumentsException { + private void parseConfigFilePath(String[] args) throws ArgsException { configFilePath = args[0]; } - private void loadConfigFile() throws InvalidConfigFileException, IOException { + private void loadConfigFile() throws ConfigFileException, IOException { config = new Config(configFilePath); } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/InvalidProgramArgumentsException.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/ArgsException.java similarity index 59% rename from services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/InvalidProgramArgumentsException.java rename to services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/ArgsException.java index 6885a5f2b0..882a3f633e 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/InvalidProgramArgumentsException.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/ArgsException.java @@ -3,5 +3,5 @@ package uk.ac.ic.wlgitbridge.application.exception; /** * Created by Winston on 03/11/14. */ -public class InvalidProgramArgumentsException extends Throwable { +public class ArgsException extends Exception { } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/InvalidConfigFileException.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/ConfigFileException.java similarity index 68% rename from services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/InvalidConfigFileException.java rename to services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/ConfigFileException.java index 9e69917047..bbe9671dc2 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/InvalidConfigFileException.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/exception/ConfigFileException.java @@ -3,12 +3,11 @@ package uk.ac.ic.wlgitbridge.application.exception; /** * Created by Winston on 05/12/14. */ -public class InvalidConfigFileException extends Exception { +public class ConfigFileException extends Exception { private final String missingMember; - public InvalidConfigFileException(String missingMember) { - + public ConfigFileException(String missingMember) { this.missingMember = missingMember; } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/BridgeAPI.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/BridgeAPI.java index dd3fc9bbab..997185a595 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/BridgeAPI.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/BridgeAPI.java @@ -9,11 +9,11 @@ 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.GetDocRequest; 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.PushRequest; +import uk.ac.ic.wlgitbridge.snapshot.push.PushResult; import uk.ac.ic.wlgitbridge.snapshot.push.exception.*; import uk.ac.ic.wlgitbridge.util.Util; @@ -24,12 +24,12 @@ import java.io.IOException; */ public class BridgeAPI { - private final DataStore dataModel; + private final DataStore dataStore; private final PostbackManager postbackManager; private final ProjectLock mainProjectLock; - public BridgeAPI(DataStore dataModel) { - this.dataModel = dataModel; + public BridgeAPI(String rootGitDirectoryPath) { + dataStore = new DataStore(rootGitDirectoryPath); postbackManager = new PostbackManager(); mainProjectLock = new ProjectLock(); Runtime.getRuntime().addShutdownHook(new ShutdownHook(mainProjectLock)); @@ -45,10 +45,10 @@ public class BridgeAPI { public boolean repositoryExists(String projectName) throws ServiceMayNotContinueException { lockForProject(projectName); - SnapshotGetDocRequest snapshotGetDocRequest = new SnapshotGetDocRequest(projectName); - snapshotGetDocRequest.request(); + GetDocRequest getDocRequest = new GetDocRequest(projectName); + getDocRequest.request(); try { - snapshotGetDocRequest.getResult().getVersionID(); + getDocRequest.getResult().getVersionID(); } catch (InvalidProjectException e) { return false; } catch (FailedConnectionException e) { @@ -63,7 +63,7 @@ public class BridgeAPI { public void getWritableRepositories(String projectName, Repository repository) throws IOException, SnapshotPostException, GitAPIException { Util.sout("Fetching project: " + projectName); - dataModel.updateProjectWithName(projectName, repository); + dataStore.updateProjectWithName(projectName, repository); } public void putDirectoryContentsToProjectWithName(String projectName, RawDirectory directoryContents, RawDirectory oldDirectoryContents, String hostname) throws SnapshotPostException, IOException { @@ -72,12 +72,12 @@ public class BridgeAPI { try { Util.sout("Pushing project: " + projectName); String postbackKey = postbackManager.makeKeyForProject(projectName); - candidate = dataModel.createCandidateSnapshotFromProjectWithContents(projectName, directoryContents, oldDirectoryContents); - SnapshotPushRequest snapshotPushRequest = new SnapshotPushRequest(candidate, postbackKey); - snapshotPushRequest.request(); - SnapshotPushRequestResult result = snapshotPushRequest.getResult(); + candidate = dataStore.createCandidateSnapshotFromProjectWithContents(projectName, directoryContents, oldDirectoryContents); + PushRequest pushRequest = new PushRequest(candidate, postbackKey); + pushRequest.request(); + PushResult result = pushRequest.getResult(); if (result.wasSuccessful()) { - dataModel.approveSnapshot(postbackManager.getVersionID(projectName), candidate); + dataStore.approveSnapshot(postbackManager.getVersionID(projectName), candidate); } else { throw new OutOfDateException(); } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/ServletFile.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/ServletFile.java index 9c14c6cb89..100e1f45c7 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/ServletFile.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/ServletFile.java @@ -8,12 +8,10 @@ import uk.ac.ic.wlgitbridge.data.filestore.RawFile; public class ServletFile extends RawFile { private final RawFile file; - private final RawFile oldFile; private final boolean changed; public ServletFile(RawFile file, RawFile oldFile) { this.file = file; - this.oldFile = oldFile; changed = !equals(oldFile); } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/SnapshotFetcher.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/SnapshotFetcher.java index 5ecdcd6b20..dde1f8c441 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/SnapshotFetcher.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/SnapshotFetcher.java @@ -1,11 +1,11 @@ package uk.ac.ic.wlgitbridge.data; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException; -import uk.ac.ic.wlgitbridge.snapshot.getdoc.SnapshotGetDocRequest; -import uk.ac.ic.wlgitbridge.snapshot.getdoc.SnapshotGetDocResult; +import uk.ac.ic.wlgitbridge.snapshot.getdoc.GetDocRequest; +import uk.ac.ic.wlgitbridge.snapshot.getdoc.GetDocResult; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotData; -import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotGetForVersionRequest; -import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.SnapshotGetSavedVersRequest; +import uk.ac.ic.wlgitbridge.snapshot.getforversion.GetForVersionRequest; +import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.GetSavedVersRequest; import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.SnapshotInfo; import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostException; import uk.ac.ic.wlgitbridge.data.model.Snapshot; @@ -26,11 +26,11 @@ public class SnapshotFetcher { private List getSnapshotInfosAfterVersion(String projectName, int version) throws FailedConnectionException, SnapshotPostException { SortedSet versions = new TreeSet(); - SnapshotGetDocRequest getDoc = new SnapshotGetDocRequest(projectName); - SnapshotGetSavedVersRequest getSavedVers = new SnapshotGetSavedVersRequest(projectName); + GetDocRequest getDoc = new GetDocRequest(projectName); + GetSavedVersRequest getSavedVers = new GetSavedVersRequest(projectName); getDoc.request(); getSavedVers.request(); - SnapshotGetDocResult latestDoc = getDoc.getResult(); + GetDocResult latestDoc = getDoc.getResult(); int latest = latestDoc.getVersionID(); if (latest > version) { for (SnapshotInfo snapshotInfo : getSavedVers.getResult().getSavedVers()) { @@ -45,18 +45,18 @@ public class SnapshotFetcher { } private List getMatchingSnapshotData(String projectName, List snapshotInfos) throws FailedConnectionException { - List firedRequests = fireDataRequests(projectName, snapshotInfos); + List firedRequests = fireDataRequests(projectName, snapshotInfos); List snapshotDataList = new LinkedList(); - for (SnapshotGetForVersionRequest fired : firedRequests) { + for (GetForVersionRequest fired : firedRequests) { snapshotDataList.add(fired.getResult().getSnapshotData()); } return snapshotDataList; } - private List fireDataRequests(String projectName, List snapshotInfos) { - List requests = new LinkedList(); + private List fireDataRequests(String projectName, List snapshotInfos) { + List requests = new LinkedList(); for (SnapshotInfo snapshotInfo : snapshotInfos) { - SnapshotGetForVersionRequest request = new SnapshotGetForVersionRequest(projectName, snapshotInfo.getVersionId()); + GetForVersionRequest request = new GetForVersionRequest(projectName, snapshotInfo.getVersionId()); requests.add(request); request.request(); } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java index dca41fed63..52a19c1f2c 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/ResourceFetcher.java @@ -6,6 +6,7 @@ import com.ning.http.client.Response; import org.eclipse.jgit.lib.Repository; import uk.ac.ic.wlgitbridge.data.filestore.RawFile; import uk.ac.ic.wlgitbridge.data.filestore.RepositoryFile; +import uk.ac.ic.wlgitbridge.data.model.db.PersistentStore; import uk.ac.ic.wlgitbridge.git.util.RepositoryObjectTreeWalker; import uk.ac.ic.wlgitbridge.snapshot.base.Request; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException; @@ -20,14 +21,14 @@ import java.util.concurrent.ExecutionException; */ public class ResourceFetcher { - private final URLIndexStore urlIndexStore; + private final PersistentStore persistentStore; - public ResourceFetcher(URLIndexStore urlIndexStore) { - this.urlIndexStore = urlIndexStore; + public ResourceFetcher(PersistentStore persistentStore) { + this.persistentStore = persistentStore; } public RawFile get(String projectName, String url, String newPath, Repository repository) throws IOException { - String path = urlIndexStore.getPathForURLInProject(projectName, url); + String path = persistentStore.getPathForURLInProject(projectName, url); byte[] contents; if (path == null) { path = newPath; @@ -70,7 +71,7 @@ public class ResourceFetcher { Util.printStackTrace(e); throw new FailedConnectionException(); } - urlIndexStore.addURLIndexForProject(projectName, url, path); + persistentStore.addURLIndexForProject(projectName, url, path); return contents; } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/Snapshot.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/Snapshot.java index 06463bcc02..467691997c 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/Snapshot.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/Snapshot.java @@ -1,14 +1,14 @@ package uk.ac.ic.wlgitbridge.data.model; import org.joda.time.DateTime; -import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotAttachment; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotData; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotFile; import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.SnapshotInfo; import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.WLUser; -import java.util.*; +import java.util.Date; +import java.util.List; /** * Created by Winston on 03/11/14. @@ -36,17 +36,6 @@ public class Snapshot implements Comparable { atts = data.getAtts(); } - public Snapshot(int versionID) { - this.versionID = versionID; - comment = "Most recent update"; - userName = "Anonymous"; - userEmail = "anonymous@" + Util.getServiceName() + ".com"; - createdAt = new Date(); - - srcs = new LinkedList(); - atts = new LinkedList(); - } - public int getVersionID() { return versionID; } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/URLIndexStore.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/URLIndexStore.java deleted file mode 100644 index 4d89162d3d..0000000000 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/URLIndexStore.java +++ /dev/null @@ -1,11 +0,0 @@ -package uk.ac.ic.wlgitbridge.data.model; - -/** - * Created by Winston on 21/02/15. - */ -public interface URLIndexStore { - - public void addURLIndexForProject(String projectName, String url, String path); - public String getPathForURLInProject(String projectName, String url); - -} diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/PersistentStore.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/PersistentStore.java index 1da9abeabe..310a75f099 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/PersistentStore.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/data/model/db/PersistentStore.java @@ -1,6 +1,5 @@ package uk.ac.ic.wlgitbridge.data.model.db; -import uk.ac.ic.wlgitbridge.data.model.URLIndexStore; import uk.ac.ic.wlgitbridge.data.model.db.sql.SQLiteWLDatabase; import java.io.File; @@ -10,7 +9,7 @@ import java.util.List; /** * Created by Winston on 19/11/14. */ -public class PersistentStore implements URLIndexStore { +public class PersistentStore { private final SQLiteWLDatabase database; @@ -47,7 +46,6 @@ public class PersistentStore implements URLIndexStore { } } - @Override public void addURLIndexForProject(String projectName, String url, String path) { try { database.addURLIndex(projectName, url, path); @@ -63,8 +61,6 @@ public class PersistentStore implements URLIndexStore { throw new RuntimeException(e); } } - - @Override public String getPathForURLInProject(String projectName, String url) { try { return database.getPathForURLInProject(projectName, url); diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/AttsResourceHandler.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/FileServlet.java similarity index 90% rename from services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/AttsResourceHandler.java rename to services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/FileServlet.java index 8005076334..48a2f21c8b 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/AttsResourceHandler.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/FileServlet.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.application; +package uk.ac.ic.wlgitbridge.server; import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.server.Request; @@ -16,11 +16,11 @@ import java.io.IOException; /** * Created by Winston on 04/12/14. */ -public class AttsResourceHandler extends ResourceHandler { +public class FileServlet extends ResourceHandler { private final BridgeAPI writeLatexDataSource; - public AttsResourceHandler(BridgeAPI writeLatexDataSource) { + public FileServlet(BridgeAPI writeLatexDataSource) { this.writeLatexDataSource = writeLatexDataSource; } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeServer.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/GitBridgeServer.java similarity index 74% rename from services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeServer.java rename to services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/GitBridgeServer.java index 67ae60703a..3172788e82 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeServer.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/GitBridgeServer.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.application; +package uk.ac.ic.wlgitbridge.server; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; @@ -7,13 +7,13 @@ import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.util.log.Log; +import uk.ac.ic.wlgitbridge.application.Config; import uk.ac.ic.wlgitbridge.application.jetty.NullLogger; import uk.ac.ic.wlgitbridge.bridge.BridgeAPI; import uk.ac.ic.wlgitbridge.git.exception.InvalidRootDirectoryPathException; import uk.ac.ic.wlgitbridge.git.servlet.WLGitServlet; -import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.snapshot.base.SnapshotAPIRequest; -import uk.ac.ic.wlgitbridge.data.model.DataStore; +import uk.ac.ic.wlgitbridge.util.Util; import javax.servlet.ServletException; import java.io.File; @@ -26,12 +26,15 @@ import java.net.BindException; /** * Class for the actual server. */ -public class WLGitBridgeServer { +public class GitBridgeServer { + + private final BridgeAPI bridgeAPI; private final Server jettyServer; + private final int port; private String rootGitDirectoryPath; - private String writeLatexHostname; + private String apiBaseURL; /** * Constructs an instance of the server. @@ -39,19 +42,20 @@ public class WLGitBridgeServer { * @param rootGitDirectoryPath the root directory path containing the git repositories * @throws ServletException if the servlet throws an exception */ - private WLGitBridgeServer(final int port, String rootGitDirectoryPath) throws ServletException, InvalidRootDirectoryPathException { + private GitBridgeServer(final int port, String rootGitDirectoryPath) throws ServletException, InvalidRootDirectoryPathException { + Log.setLog(new NullLogger()); this.port = port; this.rootGitDirectoryPath = rootGitDirectoryPath; - Log.setLog(new NullLogger()); + bridgeAPI = new BridgeAPI(rootGitDirectoryPath); jettyServer = new Server(port); configureJettyServer(); } - public WLGitBridgeServer(Config config) throws ServletException, InvalidRootDirectoryPathException { + public GitBridgeServer(Config config) throws ServletException, InvalidRootDirectoryPathException { this(config.getPort(), config.getRootGitDirectory()); SnapshotAPIRequest.setBasicAuth(config.getUsername(), config.getPassword()); - writeLatexHostname = config.getAPIBaseURL(); - SnapshotAPIRequest.setBaseURL(writeLatexHostname); + apiBaseURL = config.getAPIBaseURL(); + SnapshotAPIRequest.setBaseURL(apiBaseURL); Util.setServiceName(config.getServiceName()); Util.setPostbackURL(config.getPostbackURL()); Util.setPort(config.getPort()); @@ -65,7 +69,7 @@ public class WLGitBridgeServer { jettyServer.start(); Util.sout(Util.getServiceName() + "-Git Bridge server started"); Util.sout("Listening on port: " + port); - Util.sout("Bridged to: " + writeLatexHostname); + Util.sout("Bridged to: " + apiBaseURL); Util.sout("Postback base URL: " + Util.getPostbackURL()); Util.sout("Root git directory path: " + rootGitDirectoryPath); } catch (BindException e) { @@ -85,16 +89,15 @@ public class WLGitBridgeServer { private void configureJettyServer() throws ServletException, InvalidRootDirectoryPathException { HandlerCollection handlers = new HandlerCollection(); - BridgeAPI writeLatexDataSource = new BridgeAPI(new DataStore(rootGitDirectoryPath)); handlers.setHandlers(new Handler[] { - initResourceHandler(writeLatexDataSource), - new SnapshotPushPostbackHandler(writeLatexDataSource), - initGitHandler(writeLatexDataSource) + initResourceHandler(), + new PostbackHandler(bridgeAPI), + initGitHandler() }); jettyServer.setHandler(handlers); } - private Handler initGitHandler(BridgeAPI bridgeAPI) throws ServletException, InvalidRootDirectoryPathException { + private Handler initGitHandler() throws ServletException, InvalidRootDirectoryPathException { final ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); servletContextHandler.setContextPath("/"); servletContextHandler.addServlet( @@ -105,8 +108,8 @@ public class WLGitBridgeServer { return servletContextHandler; } - private Handler initResourceHandler(BridgeAPI writeLatexDataSource) { - ResourceHandler resourceHandler = new AttsResourceHandler(writeLatexDataSource); + private Handler initResourceHandler() { + ResourceHandler resourceHandler = new FileServlet(bridgeAPI); resourceHandler.setResourceBase(new File(rootGitDirectoryPath, ".wlgb/atts").getAbsolutePath()); return resourceHandler; } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/SnapshotPushPostbackContents.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/PostbackContents.java similarity index 90% rename from services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/SnapshotPushPostbackContents.java rename to services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/PostbackContents.java index 75e98f8472..0582165a84 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/SnapshotPushPostbackContents.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/PostbackContents.java @@ -1,4 +1,4 @@ -package uk.ac.ic.wlgitbridge.application; +package uk.ac.ic.wlgitbridge.server; import com.google.gson.Gson; import com.google.gson.JsonElement; @@ -12,7 +12,7 @@ import uk.ac.ic.wlgitbridge.snapshot.push.exception.SnapshotPostExceptionBuilder /** * Created by Winston on 17/11/14. */ -public class SnapshotPushPostbackContents implements JSONSource { +public class PostbackContents implements JSONSource { private static final String CODE_SUCCESS = "upToDate"; @@ -25,7 +25,7 @@ public class SnapshotPushPostbackContents implements JSONSource { private int versionID; private SnapshotPostException exception; - public SnapshotPushPostbackContents(BridgeAPI bridgeAPI, String projectName, String postbackKey, String contents) { + public PostbackContents(BridgeAPI bridgeAPI, String projectName, String postbackKey, String contents) { this.bridgeAPI = bridgeAPI; this.projectName = projectName; this.postbackKey = postbackKey; diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/SnapshotPushPostbackHandler.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/PostbackHandler.java similarity index 88% rename from services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/SnapshotPushPostbackHandler.java rename to services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/PostbackHandler.java index e0e772f070..5e0a9a4236 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/SnapshotPushPostbackHandler.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/PostbackHandler.java @@ -1,12 +1,12 @@ -package uk.ac.ic.wlgitbridge.application; +package uk.ac.ic.wlgitbridge.server; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.AbstractHandler; import uk.ac.ic.wlgitbridge.bridge.BridgeAPI; -import uk.ac.ic.wlgitbridge.util.Util; import uk.ac.ic.wlgitbridge.snapshot.push.exception.UnexpectedPostbackException; +import uk.ac.ic.wlgitbridge.util.Util; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -16,11 +16,11 @@ import java.io.IOException; /** * Created by Winston on 16/11/14. */ -public class SnapshotPushPostbackHandler extends AbstractHandler { +public class PostbackHandler extends AbstractHandler { private final BridgeAPI bridgeAPI; - public SnapshotPushPostbackHandler(BridgeAPI bridgeAPI) { + public PostbackHandler(BridgeAPI bridgeAPI) { this.bridgeAPI = bridgeAPI; } @@ -38,7 +38,7 @@ public class SnapshotPushPostbackHandler extends AbstractHandler { String projectName = parts[1]; String postbackKey = parts[2]; Util.sout(baseRequest.getMethod() + " <- " + baseRequest.getUri()); - SnapshotPushPostbackContents postbackContents = new SnapshotPushPostbackContents(bridgeAPI, projectName, postbackKey, contents); + PostbackContents postbackContents = new PostbackContents(bridgeAPI, projectName, postbackKey, contents); JsonObject body = new JsonObject(); try { diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/SnapshotGetDocRequest.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/GetDocRequest.java similarity index 63% rename from services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/SnapshotGetDocRequest.java rename to services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/GetDocRequest.java index 7a8197ace3..dcfb4f2ff7 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/SnapshotGetDocRequest.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/GetDocRequest.java @@ -8,11 +8,11 @@ import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException; /** * Created by Winston on 06/11/14. */ -public class SnapshotGetDocRequest extends SnapshotAPIRequest { +public class GetDocRequest extends SnapshotAPIRequest { public static final String API_CALL = ""; - public SnapshotGetDocRequest(String projectName) { + public GetDocRequest(String projectName) { super(projectName, API_CALL); } @@ -22,8 +22,8 @@ public class SnapshotGetDocRequest extends SnapshotAPIRequest { +public class GetForVersionRequest extends SnapshotAPIRequest { public static final String API_CALL = "/snapshots"; private int versionID; - public SnapshotGetForVersionRequest(String projectName, int versionID) { + public GetForVersionRequest(String projectName, int versionID) { super(projectName, API_CALL + "/" + versionID); this.versionID = versionID; } @@ -25,8 +25,8 @@ public class SnapshotGetForVersionRequest extends SnapshotAPIRequest { +public class GetSavedVersRequest extends SnapshotAPIRequest { public static final String API_CALL = "/saved_vers"; - public SnapshotGetSavedVersRequest(String projectName) { + public GetSavedVersRequest(String projectName) { super(projectName, API_CALL); } @@ -22,8 +22,8 @@ public class SnapshotGetSavedVersRequest extends SnapshotAPIRequest savedVers; - public SnapshotGetSavedVersResult(Request request, JsonElement json) throws FailedConnectionException { + public GetSavedVersResult(Request request, JsonElement json) throws FailedConnectionException { super(request, json); } - public SnapshotGetSavedVersResult(List savedVers) { + public GetSavedVersResult(List savedVers) { this.savedVers = savedVers; } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PostbackManager.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PostbackManager.java index f9cfc2ae72..6c85f20a95 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PostbackManager.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PostbackManager.java @@ -15,11 +15,11 @@ import java.util.Map; public class PostbackManager { private final SecureRandom random; - private final Map postbackContentsTable; + private final Map postbackContentsTable; public PostbackManager() { random = new SecureRandom(); - postbackContentsTable = new HashMap(); + postbackContentsTable = new HashMap(); } public int getVersionID(String projectName) throws SnapshotPostException { @@ -40,8 +40,8 @@ public class PostbackManager { getPostbackForProject(projectName).receivedException(exception, postbackKey); } - private PostbackContents getPostbackForProject(String projectName) throws UnexpectedPostbackException { - PostbackContents contents = postbackContentsTable.remove(projectName); + private PostbackPromise getPostbackForProject(String projectName) throws UnexpectedPostbackException { + PostbackPromise contents = postbackContentsTable.remove(projectName); if (contents == null) { throw new UnexpectedPostbackException(); } @@ -50,7 +50,7 @@ public class PostbackManager { public String makeKeyForProject(String projectName) { String key = System.currentTimeMillis() + randomString(); - PostbackContents contents = new PostbackContents(key); + PostbackPromise contents = new PostbackPromise(key); postbackContentsTable.put(projectName, contents); return key; } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PostbackContents.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PostbackPromise.java similarity index 96% rename from services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PostbackContents.java rename to services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PostbackPromise.java index 3a476eb33b..185f627004 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PostbackContents.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PostbackPromise.java @@ -12,7 +12,7 @@ import java.util.concurrent.locks.ReentrantLock; /** * Created by Winston on 17/11/14. */ -public class PostbackContents { +public class PostbackPromise { private final String postbackKey; private final ReentrantLock lock; @@ -22,7 +22,7 @@ public class PostbackContents { private int versionID; private SnapshotPostException exception; - public PostbackContents(String postbackKey) { + public PostbackPromise(String postbackKey) { this.postbackKey = postbackKey; lock = new ReentrantLock(); cond = lock.newCondition(); diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/SnapshotPushRequest.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PushRequest.java similarity index 73% rename from services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/SnapshotPushRequest.java rename to services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PushRequest.java index 657128fa2b..ef33b5449d 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/SnapshotPushRequest.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PushRequest.java @@ -9,14 +9,14 @@ import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException; /** * Created by Winston on 16/11/14. */ -public class SnapshotPushRequest extends SnapshotAPIRequest { +public class PushRequest extends SnapshotAPIRequest { private static final String API_CALL = "/snapshots"; private final CandidateSnapshot candidateSnapshot; private final String postbackKey; - public SnapshotPushRequest(CandidateSnapshot candidateSnapshot, String postbackKey) { + public PushRequest(CandidateSnapshot candidateSnapshot, String postbackKey) { super(candidateSnapshot.getProjectName(), API_CALL); this.candidateSnapshot = candidateSnapshot; this.postbackKey = postbackKey; @@ -33,8 +33,8 @@ public class SnapshotPushRequest extends SnapshotAPIRequest getDoc; - private Map getSavedVers; - private Map> getForVers; + private Map getDoc; + private Map getSavedVers; + private Map> getForVers; private Map push; private Map postback; - public SnapshotAPIState(Map getDoc, - Map getSavedVers, - Map> getForVers, + public SnapshotAPIState(Map getDoc, + Map getSavedVers, + Map> getForVers, Map push, Map postback) { @@ -40,10 +40,10 @@ public class SnapshotAPIState { public SnapshotAPIState() { - getDoc = new HashMap(); - getDoc.put("1826rqgsdb", new SnapshotGetDocResult(null, 243, "2014-11-30T18:40:58Z", "jdleesmiller+1@gmail.com", "John+1")); + getDoc = new HashMap(); + getDoc.put("1826rqgsdb", new GetDocResult(null, 243, "2014-11-30T18:40:58Z", "jdleesmiller+1@gmail.com", "John+1")); - getSavedVers = new HashMap(); + getSavedVers = new HashMap(); List savedVers = new LinkedList(); savedVers.add(new SnapshotInfo(243, "added more info on doc GET and error details", "jdleesmiller+1@gmail.com", "John+1", "2014-11-30T18:47:01Z")); savedVers.add(new SnapshotInfo(185, "with more details on POST request", "jdleesmiller+1@gmail.com", "John+1", "2014-11-11T17:18:40Z")); @@ -52,47 +52,47 @@ public class SnapshotAPIState { savedVers.add(new SnapshotInfo(74, "with example output", "jdleesmiller@gmail.com", "John Lees-Miller", "2014-11-05T18:09:41Z")); savedVers.add(new SnapshotInfo(39, "with more files", "jdleesmiller@gmail.com", "John Lees-Miller", "2014-11-05T18:02:19Z")); savedVers.add(new SnapshotInfo(24, "first draft", "jdleesmiller@gmail.com", "John Lees-Miller", "2014-11-05T17:56:58Z")); - getSavedVers.put("1826rqgsdb", new SnapshotGetSavedVersResult(savedVers)); + getSavedVers.put("1826rqgsdb", new GetSavedVersResult(savedVers)); - getForVers = new HashMap>() {{ - put("1826rqgsdb", new HashMap() {{ - put(243, new SnapshotGetForVersionResult(new SnapshotData(Arrays.asList( + getForVers = new HashMap>() {{ + put("1826rqgsdb", new HashMap() {{ + put(243, new GetForVersionResult(new SnapshotData(Arrays.asList( new SnapshotFile("\\\\documentclass[a4paper]{article}\\n\\n\\\\usepackage[english]{babel}\\n\\\\usepackage[utf8]{inputenc}\\n\\\\usepackage{graphicx}\\n\\\\usepackage{fullpage}\\n\\\\usepackage{listings}\\n\\\\usepackage{courier}\\n\\\\usepackage{url}\\n\\n\\\\lstset{basicstyle=\\\\ttfamily,breaklines=true}\\n\\n\\\\begin{document}\\n\\\\title{API for the writeLaTeX-Git Bridge}\\n\\\\author{JLM}\\n\\\\date{\\\\today}\\n\\\\maketitle\\n\\n\\\\section{Fetching a Project from WriteLaTeX}\\n\\nThere are three API calls that will likely be of interest. You can run them against this server, \\\\url{radiant-wind-3058.herokuapp.com}, but they're not on the production server yet.\\n\\n\\\\subsection{Get Doc}\\n\\nA ``doc'' is our internal term for a ``project''. This endpoint returns the latest version id, when the latest version was created (ISO8601), and the user that last edited the project (if any, otherwise null).\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb\\n# => {\\n \\\"latestVerId\\\": 39,\\n \\\"latestVerAt\\\": \\\"2014-11-30T18:35:27Z\\\",\\n \\\"latestVerBy\\\": {\\n \\\"email\\\": \\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\": \\\"John Lees-Miller\\\"\\n }}\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Saved Vers}\\n\\nA ``saved ver'' is a version of a doc, saved by via the versions menu. Note that this query is not currently paginated.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/saved_vers\\n# => [\\n {\\\"versionId\\\":39,\\n \\\"comment\\\":\\\"with more files\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T18:02:19Z\\\"},\\n {\\\"versionId\\\":24,\\n \\\"comment\\\":\\\"first draft\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T17:56:58Z\\\"}]\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Snapshot for Version}\\n\\nA snapshot contains the content of a project in the given version. You can safely request a snapshot of any version that is, or was at any point in the last 24 hours, (1) a saved version, or (2) the current version. (Older versions may or may not have been moved to cold storage.)\\n\\nThe srcs array contains (content, file name) pairs; the atts array contains (URL, file name) pairs.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/snapshots/39\\n# => {\\n \\\"srcs\\\":[\\n [\\\"This text is from another file.\\\",\\\"foo/bar/servermock.tex\\\"],\\n [\\\"\\\\\\\\documentclass[a4paper]{article}\\\\n...\\\",\\\"main.tex\\\"]],\\n \\\"atts\\\":[\\n [\\\"https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png\\\",\\\"min_mean_wait_evm_7_eps_150dpi.png\\\"]]}\\n\\\\end{lstlisting}\\n\\n\\\\section{Pushing a Project to WriteLaTeX}\\n\\n\\\\subsection{Push a Project}\\n\\n\\\\begin{lstlisting}\\n# NB: JLM originally said PUT, but he now thinks POST is better\\n# NB: you must set a Content-Type: application/json header for this request\\n# in order to specify the data as JSON in the request body\\nPOST https://.../api/v0/docs/1826rqgsdb/snapshots\\nData:\\n{\\n latestVerId: integer,\\n files: [\\n {\\n name: string path (forward slashes, relative to root)\\n url: string (but only if the file is modified; else no url given)\\n }, ...\\n ]\\n postbackUrl: url to post result back to\\n}\\nResponse on success:\\n{\\n status: 202,\\n code: \\\"accepted\\\",\\n message: \\\"Accepted\\\"\\n}\\nResponse on out of date:\\n{\\n status: 409, # Conflict\\n code: \\\"outOfDate\\\",\\n message: \\\"Out of Date\\\"\\n}\\n\\nPostback Data (METHOD POST):\\nOn success:\\n{\\n code: \\\"upToDate\\\",\\n latestVerId: integer\\n}\\nOn out of date:\\n{\\n code: \\\"outOfDate\\\",\\n message: \\\"Out of Date\\\"\\n}\\nOn error with the files list (e.g. file extension not allowed):\\n{\\n code: \\\"invalidFiles\\\",\\n errors: [ {\\n file: the file name from the snapshot,\\n state: \\\"error\\\"|\\\"disallowed\\\"|\\\"unclean_name\\\"\\n }, ... ]\\n}\\nIf the file's error state is unclean_name, the error object will alsocontain a property cleanFile that contains the name of the file after it has been \\\"cleaned\\\" to meet our file naming requirements; for other file error states, this property is not present.\\nOn error with the project as a whole (e.g. over quota):\\n{\\n code: \\\"invalidProject\\\",\\n message: short string message for debugging\\n errors: [ array of zero or more string messages for the user ]\\n}\\nOn unexpected error (bug):\\n{\\n code: \\\"error\\\",\\n message: \\\"Unexpected Error\\\"\\n}\\n\\\\end{lstlisting}\\n\\n\\\\section{Test Data}\\n\\nYou can use this project as one of your servermock projects. I've added an attachment and a file in a subfolder to make it a bit more interesting.\\n\\n\\\\input{foo/bar/servermock}\\n\\n\\\\includegraphics[width=\\\\linewidth]{min_mean_wait_evm_7_eps_150dpi}\\n\\n\\\\end{document}", "main.tex"), new SnapshotFile("This text is from another file.", "foo/bar/servermock.tex") ), Arrays.asList( new SnapshotAttachment("https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png", "min_mean_wait_evm_7_eps_150dpi.png") )))); - put(185, new SnapshotGetForVersionResult(new SnapshotData(Arrays.asList( + put(185, new GetForVersionResult(new SnapshotData(Arrays.asList( new SnapshotFile("\\\\documentclass[a4paper]{article}\\n\\n\\\\usepackage[english]{babel}\\n\\\\usepackage[utf8]{inputenc}\\n\\\\usepackage{graphicx}\\n\\\\usepackage{fullpage}\\n\\\\usepackage{listings}\\n\\\\usepackage{courier}\\n\\\\usepackage{url}\\n\\n\\\\lstset{basicstyle=\\\\ttfamily,breaklines=true}\\n\\n\\\\begin{document}\\n\\\\title{API for the writeLaTeX-Git Bridge}\\n\\\\author{JLM}\\n\\\\date{\\\\today}\\n\\\\maketitle\\n\\n\\\\section{Fetching a Project from WriteLaTeX}\\n\\nThere are three API calls that will likely be of interest. You can run them against this server, \\\\url{radiant-wind-3058.herokuapp.com}, but they're not on the production server yet.\\n\\n\\\\subsection{Get Doc}\\n\\nA ``doc'' is our internal term for a ``project''. At present, this just returns the latest version number.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb\\n# => { latestVerId: 39 }\\nTODO will also include updatedAt time and user (if it was not anonymous)\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Saved Vers}\\n\\nA ``saved ver'' is a version of a doc, saved by via the versions menu. Note that this query is not currently paginated.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/saved_vers\\n# => [\\n {\\\"versionId\\\":39,\\n \\\"comment\\\":\\\"with more files\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T18:02:19Z\\\"},\\n {\\\"versionId\\\":24,\\n \\\"comment\\\":\\\"first draft\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T17:56:58Z\\\"}]\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Snapshot for Version}\\n\\nA snapshot contains the content of a project in the given version. You can safely request a snapshot of any version that is, or was at any point in the last 24 hours, (1) a saved version, or (2) the current version. (Older versions may or may not have been moved to cold storage.)\\n\\nThe srcs array contains (content, file name) pairs; the atts array contains (URL, file name) pairs.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/snapshots/39\\n# => {\\n \\\"srcs\\\":[\\n [\\\"This text is from another file.\\\",\\\"foo/bar/servermock.tex\\\"],\\n [\\\"\\\\\\\\documentclass[a4paper]{article}\\\\n...\\\",\\\"main.tex\\\"]],\\n \\\"atts\\\":[\\n [\\\"https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png\\\",\\\"min_mean_wait_evm_7_eps_150dpi.png\\\"]]}\\n\\\\end{lstlisting}\\n\\n\\\\section{Pushing a Project to WriteLaTeX}\\n\\n\\\\subsection{Push a Project}\\n\\n\\\\begin{lstlisting}\\n# NB: JLM originally said PUT, but he now thinks POST is better\\n# NB: you must set a Content-Type: application/json header for this request\\n# in order to specify the data as JSON in the request body\\nPOST https://.../api/v0/docs/1826rqgsdb/snapshots\\nData:\\n{\\n latestVerId: integer,\\n files: [\\n {\\n name: string path (forward slashes, relative to root)\\n url: string (but only if the file is modified; else no url given)\\n }, ...\\n ]\\n postbackUrl: url to post result back to\\n}\\nResponse on success:\\n{\\n status: 202,\\n code: \\\"accepted\\\",\\n message: \\\"Accepted\\\"\\n}\\nResponse on out of date:\\n{\\n status: 409, # Conflict\\n code: \\\"outOfDate\\\",\\n message: \\\"Out of Date\\\"\\n}\\n\\nPostback Data (METHOD POST):\\nOn success:\\n{\\n code: \\\"upToDate\\\",\\n latestVerId: integer\\n}\\nOn out of date:\\n{\\n code: \\\"outOfDate\\\",\\n message: \\\"Out of Date\\\"\\n}\\nOn error with the files list (e.g. file extension not allowed):\\n{\\n code: \\\"invalidFiles\\\",\\n errors: TODO\\n}\\nOn error with the project as a whole (e.g. over quota):\\n{\\n code: \\\"invalidProject\\\",\\n errors: TODO\\n}\\nOn unexpected error (bug):\\n{\\n code: \\\"error\\\",\\n message: \\\"Unexpected Error\\\"\\n}\\n\\\\end{lstlisting}\\n\\n\\\\section{Test Data}\\n\\nYou can use this project as one of your servermock projects. I've added an attachment and a file in a subfolder to make it a bit more interesting.\\n\\n\\\\input{foo/bar/servermock}\\n\\n\\\\includegraphics[width=\\\\linewidth]{min_mean_wait_evm_7_eps_150dpi}\\n\\n\\\\end{document}", "main.tex"), new SnapshotFile("This text is from another file.", "foo/bar/servermock.tex") ), Arrays.asList( new SnapshotAttachment("https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png", "min_mean_wait_evm_7_eps_150dpi.png") )))); - put(175, new SnapshotGetForVersionResult(new SnapshotData(Arrays.asList( + put(175, new GetForVersionResult(new SnapshotData(Arrays.asList( new SnapshotFile("\\\\documentclass[a4paper]{article}\\n\\n\\\\usepackage[english]{babel}\\n\\\\usepackage[utf8]{inputenc}\\n\\\\usepackage{graphicx}\\n\\\\usepackage{fullpage}\\n\\\\usepackage{listings}\\n\\\\usepackage{courier}\\n\\\\usepackage{url}\\n\\n\\\\lstset{basicstyle=\\\\ttfamily,breaklines=true}\\n\\n\\\\begin{document}\\n\\\\title{API for the writeLaTeX-Git Bridge}\\n\\\\author{JLM}\\n\\\\date{\\\\today}\\n\\\\maketitle\\n\\n\\\\section{Fetching a Project from WriteLaTeX}\\n\\nThere are three API calls that will likely be of interest. You can run them against this server, \\\\url{radiant-wind-3058.herokuapp.com}, but they're not on the production server yet.\\n\\n\\\\subsection{Get Doc}\\n\\nA ``doc'' is our internal term for a ``project''. At present, this just returns the latest version number.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb\\n# => { latestVerId: 39 }\\nTODO will also include updatedAt time and user (if it was not anonymous)\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Saved Vers}\\n\\nA ``saved ver'' is a version of a doc, saved by via the versions menu. Note that this query is not currently paginated.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/saved_vers\\n# => [\\n {\\\"versionId\\\":39,\\n \\\"comment\\\":\\\"with more files\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T18:02:19Z\\\"},\\n {\\\"versionId\\\":24,\\n \\\"comment\\\":\\\"first draft\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T17:56:58Z\\\"}]\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Snapshot for Version}\\n\\nA snapshot contains the content of a project in the given version. You can safely request a snapshot of any version that is, or was at any point in the last 24 hours, (1) a saved version, or (2) the current version. (Older versions may or may not have been moved to cold storage.)\\n\\nThe srcs array contains (content, file name) pairs; the atts array contains (URL, file name) pairs.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/snapshots/39\\n# => {\\n \\\"srcs\\\":[\\n [\\\"This text is from another file.\\\",\\\"foo/bar/servermock.tex\\\"],\\n [\\\"\\\\\\\\documentclass[a4paper]{article}\\\\n...\\\",\\\"main.tex\\\"]],\\n \\\"atts\\\":[\\n [\\\"https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png\\\",\\\"min_mean_wait_evm_7_eps_150dpi.png\\\"]]}\\n\\\\end{lstlisting}\\n\\n\\\\section{Pushing a Project to WriteLaTeX}\\n\\n\\\\subsection{Push a Project}\\n\\n\\\\begin{lstlisting}\\n# NB: JLM originally said PUT, but he now thinks POST is better\\n# NB: you must set a Content-Type: application/json header for this request\\n# in order to specify the data as JSON in the request body\\nPOST https://.../api/v0/docs/1826rqgsdb/snapshots\\nData:\\n{\\n latestVerId: integer,\\n files: [\\n {\\n name: string path (forward slashes, relative to root)\\n url: string (but only if the file is modified; else no url given)\\n }, ...\\n ]\\n postbackUrl: url to post result back to\\n}\\nResponse on success:\\n{\\n status: 202,\\n code: \\\"accepted\\\",\\n message: \\\"Accepted\\\"\\n}\\nResponse on out of date:\\n{\\n status: 409, # Conflict\\n code: \\\"outOfDate\\\",\\n message: \\\"Out of Date\\\"\\n}\\n\\nPostback Data (METHOD POST):\\nOn success:\\n{\\n code: \\\"upToDate\\\",\\n latestVerId: integer\\n}\\nOn out of date:\\n{\\n code: \\\"outOfDate\\\",\\n message: \\\"Out of Date\\\"\\n}\\nOn error:\\n{\\n code: \\\"invalidFile\\\",\\n TODO\\n}\\n\\\\end{lstlisting}\\n\\n\\\\section{Test Data}\\n\\nYou can use this project as one of your servermock projects. I've added an attachment and a file in a subfolder to make it a bit more interesting.\\n\\n\\\\input{foo/bar/servermock}\\n\\n\\\\includegraphics[width=\\\\linewidth]{min_mean_wait_evm_7_eps_150dpi}\\n\\n\\\\end{document}", "main.tex"), new SnapshotFile("This text is from another file.", "foo/bar/servermock.tex") ), Arrays.asList( new SnapshotAttachment("https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png", "min_mean_wait_evm_7_eps_150dpi.png") )))); - put(146, new SnapshotGetForVersionResult(new SnapshotData(Arrays.asList( + put(146, new GetForVersionResult(new SnapshotData(Arrays.asList( new SnapshotFile("\\\\documentclass[a4paper]{article}\\n\\n\\\\usepackage[english]{babel}\\n\\\\usepackage[utf8]{inputenc}\\n\\\\usepackage{graphicx}\\n\\\\usepackage{fullpage}\\n\\\\usepackage{listings}\\n\\\\usepackage{courier}\\n\\\\usepackage{url}\\n\\n\\\\lstset{basicstyle=\\\\ttfamily,breaklines=true}\\n\\n\\\\begin{document}\\n\\\\title{API for the writeLaTeX-Git Bridge}\\n\\\\author{JLM}\\n\\\\date{\\\\today}\\n\\\\maketitle\\n\\n\\\\section{Fetching a Project from WriteLaTeX}\\n\\nThere are three API calls that will likely be of interest. You can run them against this server, \\\\url{radiant-wind-3058.herokuapp.com}, but they're not on the production server yet.\\n\\n\\\\subsection{Get Doc}\\n\\nA ``doc'' is our internal term for a ``project''. At present, this just returns the latest version number.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb\\n# => { latestVerId: 39 }\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Saved Vers}\\n\\nA ``saved ver'' is a version of a doc, saved by via the versions menu. Note that this query is not currently paginated.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/saved_vers\\n# => [\\n {\\\"versionId\\\":39,\\n \\\"comment\\\":\\\"with more files\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T18:02:19Z\\\"},\\n {\\\"versionId\\\":24,\\n \\\"comment\\\":\\\"first draft\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T17:56:58Z\\\"}]\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Snapshot for Version}\\n\\nA snapshot contains the content of a project in the given version. You can safely request a snapshot of any version that is, or was at any point in the last 24 hours, (1) a saved version, or (2) the current version. (Older versions may or may not have been moved to cold storage.)\\n\\nThe srcs array contains (content, file name) pairs; the atts array contains (URL, file name) pairs.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/snapshots/39\\n# => {\\n \\\"srcs\\\":[\\n [\\\"This text is from another file.\\\",\\\"foo/bar/servermock.tex\\\"],\\n [\\\"\\\\\\\\documentclass[a4paper]{article}\\\\n...\\\",\\\"main.tex\\\"]],\\n \\\"atts\\\":[\\n [\\\"https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png\\\",\\\"min_mean_wait_evm_7_eps_150dpi.png\\\"]]}\\n\\\\end{lstlisting}\\n\\n\\\\section{Pushing a Project to WriteLaTeX}\\n\\n\\\\subsection{Push a Project}\\n\\n\\\\begin{lstlisting}\\nPUT https://.../api/v0/docs/1826rqgsdb/snapshots\\nData:\\n{\\n latestVerId: integer,\\n files: [\\n {\\n name: string path (forward slashes, relative to root)\\n url: string (but only if the file is modified; else no url given)\\n }, ...\\n ]\\n postbackUrl: url to post result back to\\n}\\nResponse on success:\\n{\\n status: 20x,\\n}\\nResponse on out of date:\\n{\\n status: 40x,\\n code: \\\"outOfDate\\\",\\n message: \\\"Out of Date\\\"\\n}\\n\\nPostback Data (METHOD POST):\\nOn success:\\n{\\n code: \\\"upToDate\\\",\\n latestVerId: integer\\n}\\nOn out of date:\\n{\\n code: \\\"outOfDate\\\",\\n message: \\\"Out of Date\\\"\\n}\\nOn error:\\n{\\n code: \\\"invalidFile\\\",\\n TODO\\n}\\n\\\\end{lstlisting}\\n\\n\\\\section{Test Data}\\n\\nYou can use this project as one of your servermock projects. I've added an attachment and a file in a subfolder to make it a bit more interesting.\\n\\n\\\\input{foo/bar/servermock}\\n\\n\\\\includegraphics[width=\\\\linewidth]{min_mean_wait_evm_7_eps_150dpi}\\n\\n\\\\end{document}", "main.tex"), new SnapshotFile("This text is from another file.", "foo/bar/servermock.tex") ), Arrays.asList( new SnapshotAttachment("https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png", "min_mean_wait_evm_7_eps_150dpi.png") )))); - put(74, new SnapshotGetForVersionResult(new SnapshotData(Arrays.asList( + put(74, new GetForVersionResult(new SnapshotData(Arrays.asList( new SnapshotFile("\\\\documentclass[a4paper]{article}\\n\\n\\\\usepackage[english]{babel}\\n\\\\usepackage[utf8]{inputenc}\\n\\\\usepackage{graphicx}\\n\\\\usepackage{fullpage}\\n\\\\usepackage{listings}\\n\\\\usepackage{courier}\\n\\\\usepackage{url}\\n\\n\\\\lstset{basicstyle=\\\\ttfamily,breaklines=true}\\n\\n\\\\begin{document}\\n\\\\title{API for the writeLaTeX-Git Bridge}\\n\\\\author{JLM}\\n\\\\date{\\\\today}\\n\\\\maketitle\\n\\n\\\\section{Fetching a Project from WriteLaTeX}\\n\\nThere are three API calls that will likely be of interest. You can run them against this server, \\\\url{radiant-wind-3058.herokuapp.com}, but they're not on the production server yet.\\n\\n\\\\subsection{Get Doc}\\n\\nA ``doc'' is our internal term for a ``project''. At present, this just returns the latest version number.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb\\n# => { latestVerId: 39 }\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Saved Vers}\\n\\nA ``saved ver'' is a version of a doc, saved by via the versions menu. Note that this query is not currently paginated.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/saved_vers\\n# => [\\n {\\\"versionId\\\":39,\\n \\\"comment\\\":\\\"with more files\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T18:02:19Z\\\"},\\n {\\\"versionId\\\":24,\\n \\\"comment\\\":\\\"first draft\\\",\\n \\\"user\\\":{\\n \\\"email\\\":\\\"jdleesmiller@gmail.com\\\",\\n \\\"name\\\":\\\"John Lees-Miller\\\"},\\n \\\"createdAt\\\":\\\"2014-11-05T17:56:58Z\\\"}]\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Snapshot for Version}\\n\\nA snapshot contains the content of a project in the given version. You can safely request a snapshot of any version that is, or was at any point in the last 24 hours, (1) a saved version, or (2) the current version. (Older versions may or may not have been moved to cold storage.)\\n\\nThe srcs array contains (content, file name) pairs; the atts array contains (URL, file name) pairs.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/snapshots/39\\n# => {\\n \\\"srcs\\\":[\\n [\\\"This text is from another file.\\\",\\\"foo/bar/servermock.tex\\\"],\\n [\\\"\\\\\\\\documentclass[a4paper]{article}\\\\n...\\\",\\\"main.tex\\\"]],\\n \\\"atts\\\":[\\n [\\\"https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png\\\",\\\"min_mean_wait_evm_7_eps_150dpi.png\\\"]]}\\n\\\\end{lstlisting}\\n\\n\\\\section{Pushing a Project to WriteLaTeX}\\n\\nTODO still working on this part\\n\\n\\\\section{Test Data}\\n\\nYou can use this project as a servermock project. I've added an attachment and a file in a subfolder to make it a bit more interesting.\\n\\n\\\\input{foo/bar/servermock}\\n\\n\\\\includegraphics[width=\\\\linewidth]{min_mean_wait_evm_7_eps_150dpi}\\n\\n\\\\end{document}", "main.tex"), new SnapshotFile("This text is from another file.", "foo/bar/servermock.tex") ), Arrays.asList( new SnapshotAttachment("https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png", "min_mean_wait_evm_7_eps_150dpi.png") )))); - put(39, new SnapshotGetForVersionResult(new SnapshotData(Arrays.asList( + put(39, new GetForVersionResult(new SnapshotData(Arrays.asList( new SnapshotFile("\\\\documentclass[a4paper]{article}\\n\\n\\\\usepackage[english]{babel}\\n\\\\usepackage[utf8]{inputenc}\\n\\\\usepackage{graphicx}\\n\\\\usepackage{fullpage}\\n\\\\usepackage{listings}\\n\\\\usepackage{courier}\\n\\\\usepackage{url}\\n\\n\\\\lstset{basicstyle=\\\\ttfamily,breaklines=true}\\n\\n\\\\begin{document}\\n\\\\title{API for the writeLaTeX-Git Bridge}\\n\\\\author{JLM}\\n\\\\date{\\\\today}\\n\\\\maketitle\\n\\n\\\\section{Fetching a Project from WriteLaTeX}\\n\\nThere are three API calls that will likely be of interest. You can run them against this server, \\\\url{radiant-wind-3058.herokuapp.com}, but they're not on the production server yet.\\n\\n\\\\subsection{Get Doc}\\n\\nA ``doc'' is our internal term for a ``project''. At present, this just returns the latest version number.\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Saved Vers}\\n\\nA ``saved ver'' is a version of a doc, saved by via the versions menu. To list saved versions for a doc:\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/saved_vers\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Snapshot for Version}\\n\\nA snapshot contains the content of a project in the given version. You can safely request a snapshot of any version that is, or was at any point in the last 24 hours, (1) a saved version, or (2) the current version. (Older versions may or may not have been moved to cold storage.)\\n\\n\\\\begin{lstlisting}\\nGET https://.../api/v0/docs/1826rqgsdb/snapshots/1\\n\\\\end{lstlisting}\\n\\n\\\\section{Pushing a Project to WriteLaTeX}\\n\\nTODO still working on this part\\n\\n\\\\section{Test Data}\\n\\nYou can use this project as a servermock project. I've added an attachment and a file in a subfolder to make it a bit more interesting.\\n\\n\\\\input{foo/bar/servermock}\\n\\n\\\\includegraphics[width=\\\\linewidth]{min_mean_wait_evm_7_eps_150dpi}\\n\\n\\\\end{document}", "main.tex"), new SnapshotFile("This text is from another file.", "foo/bar/servermock.tex") ), Arrays.asList( new SnapshotAttachment("https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png", "min_mean_wait_evm_7_eps_150dpi.png") )))); - put(24, new SnapshotGetForVersionResult(new SnapshotData(Arrays.asList( + put(24, new GetForVersionResult(new SnapshotData(Arrays.asList( new SnapshotFile("\\\\documentclass[a4paper]{article}\\n\\n\\\\usepackage[english]{babel}\\n\\\\usepackage[utf8]{inputenc}\\n\\\\usepackage{graphicx}\\n\\\\usepackage{fullpage}\\n\\\\usepackage{listings}\\n\\\\usepackage{courier}\\n\\\\usepackage{url}\\n\\n\\\\lstset{basicstyle=\\\\ttfamily,breaklines=true}\\n\\n\\\\begin{document}\\n\\\\title{API for the writeLaTeX-Git Bridge}\\n\\\\author{JLM}\\n\\\\date{\\\\today}\\n\\\\maketitle\\n\\n\\\\section{Fetching a Project from WriteLaTeX}\\n\\nThere are three API calls that will likely be of interest. You can run them against this server (radiant-wind-3058.herokuapp.com).\\n\\n\\\\subsection{Get Doc}\\n\\nA ``doc'' is our internal term for a ``project''. At present, this just returns the latest version number.\\n\\n\\\\begin{lstlisting}\\nGET https://radiant-wind.....com/api/v0/docs/1826rqgsdb\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Saved Vers}\\n\\nA ``saved ver'' is a version of a doc, saved by via the versions menu. To list saved versions for a doc:\\n\\n\\\\begin{lstlisting}\\nGET https://radiant-wind.....com/api/v0/docs/1826rqgsdb/saved_vers\\n\\\\end{lstlisting}\\n\\n\\\\subsection{Get Snapshot for Version}\\n\\nA snapshot contains the content of a project in the given version. You can safely request a snapshot of any version that is, or was at any point in the last 24 hours, (1) a saved version, or (2) the current version. (Older versions may or may not have been moved to cold storage.)\\n\\n\\\\begin{lstlisting}\\nGET https://radiant-wind.....com/api/v0/docs/1826rqgsdb/snapshots/1\\n\\\\end{lstlisting}\\n\\n\\\\section{Pushing a Project to WriteLaTeX}\\n\\nTODO still working on this part\\n\\n\\\\section{Test Data}\\n\\nYou can use this project as a servermock project. Here is an extra file to make it a bit more interesting.\\n\\n\\\\includegraphics[width=\\\\linewidth]{min_mean_wait_evm_7_eps_150dpi}\\n\\n\\\\end{document}", "main.tex") ), Arrays.asList( new SnapshotAttachment("https://writelatex-staging.s3.amazonaws.com/filepicker/1ENnu6zJSGyslI3DuNZD_min_mean_wait_evm_7.eps.150dpi.png", "min_mean_wait_evm_7_eps_150dpi.png") @@ -112,15 +112,15 @@ public class SnapshotAPIState { }}; } - public SnapshotGetDocResult getStateForGetDoc(String projectName) { + public GetDocResult getStateForGetDoc(String projectName) { return getDoc.get(projectName); } - public SnapshotGetSavedVersResult getStateForGetSavedVers(String projectName) { + public GetSavedVersResult getStateForGetSavedVers(String projectName) { return getSavedVers.get(projectName); } - public SnapshotGetForVersionResult getStateForGetForVers(String projectName, int versionID) { + public GetForVersionResult getStateForGetForVers(String projectName, int versionID) { return getForVers.get(projectName).get(versionID); } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIStateBuilder.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIStateBuilder.java index 52a1433eba..5e6a44561c 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIStateBuilder.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIStateBuilder.java @@ -9,12 +9,12 @@ import uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.data.SnapshotPushR import uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.data.SnapshotPushResultSuccess; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.postback.*; import uk.ac.ic.wlgitbridge.snapshot.servermock.response.push.postback.invalidfile.InvalidFileError; -import uk.ac.ic.wlgitbridge.snapshot.getdoc.SnapshotGetDocResult; +import uk.ac.ic.wlgitbridge.snapshot.getdoc.GetDocResult; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotAttachment; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotData; import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotFile; -import uk.ac.ic.wlgitbridge.snapshot.getforversion.SnapshotGetForVersionResult; -import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.SnapshotGetSavedVersResult; +import uk.ac.ic.wlgitbridge.snapshot.getforversion.GetForVersionResult; +import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.GetSavedVersResult; import uk.ac.ic.wlgitbridge.snapshot.getsavedvers.SnapshotInfo; import java.io.InputStream; @@ -31,9 +31,9 @@ public class SnapshotAPIStateBuilder { private final JsonArray projects; - private Map getDoc = new HashMap(); - private Map getSavedVers = new HashMap(); - private Map> getForVers = new HashMap>(); + private Map getDoc = new HashMap(); + private Map getSavedVers = new HashMap(); + private Map> getForVers = new HashMap>(); private Map push = new HashMap(); private Map postback = new HashMap(); @@ -59,7 +59,7 @@ public class SnapshotAPIStateBuilder { private void addGetDocForProject(String projectName, JsonObject jsonGetDoc) { getDoc.put(projectName, - new SnapshotGetDocResult(jsonGetDoc.get("error"), + new GetDocResult(jsonGetDoc.get("error"), jsonGetDoc.get("versionID").getAsInt(), jsonGetDoc.get("createdAt").getAsString(), jsonGetDoc.get("email").getAsString(), @@ -71,7 +71,7 @@ public class SnapshotAPIStateBuilder { for (JsonElement ver : jsonGetSavedVers) { savedVers.add(getSnapshotInfo(ver.getAsJsonObject())); } - getSavedVers.put(projectName, new SnapshotGetSavedVersResult(savedVers)); + getSavedVers.put(projectName, new GetSavedVersResult(savedVers)); } private SnapshotInfo getSnapshotInfo(JsonObject jsonSnapshotInfo) { @@ -83,11 +83,11 @@ public class SnapshotAPIStateBuilder { } private void addGetForVersForProject(String projectName, JsonArray jsonGetForVers) { - Map forVers = new HashMap(); + Map forVers = new HashMap(); for (JsonElement forVer : jsonGetForVers) { JsonObject forVerObj = forVer.getAsJsonObject(); forVers.put(forVerObj.get("versionID").getAsInt(), - new SnapshotGetForVersionResult(new SnapshotData(getSrcs(forVerObj.get("srcs").getAsJsonArray()), + new GetForVersionResult(new SnapshotData(getSrcs(forVerObj.get("srcs").getAsJsonArray()), getAtts(forVerObj.get("atts").getAsJsonArray())))); } getForVers.put(projectName, forVers); diff --git a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest.java b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest.java index 3d9e99a717..9fdc473d70 100644 --- a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest.java +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest.java @@ -4,7 +4,7 @@ import org.eclipse.jgit.api.errors.GitAPIException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import uk.ac.ic.wlgitbridge.application.WLGitBridgeApplication; +import uk.ac.ic.wlgitbridge.application.GitBridgeApp; import uk.ac.ic.wlgitbridge.snapshot.servermock.server.MockSnapshotServer; import uk.ac.ic.wlgitbridge.snapshot.servermock.state.SnapshotAPIState; import uk.ac.ic.wlgitbridge.snapshot.servermock.state.SnapshotAPIStateBuilder; @@ -52,7 +52,7 @@ public class WLGitBridgeIntegrationTest { MockSnapshotServer server = new MockSnapshotServer(3857, getResource("/canCloneARepository").toFile()); server.start(); server.setState(states.get("canCloneARepository").get("state")); - WLGitBridgeApplication wlgb = new WLGitBridgeApplication(new String[] { + GitBridgeApp wlgb = new GitBridgeApp(new String[] { makeConfigFile(33857, 3857) }); wlgb.run(); @@ -70,7 +70,7 @@ public class WLGitBridgeIntegrationTest { MockSnapshotServer server = new MockSnapshotServer(3858, getResource("/canCloneMultipleRepositories").toFile()); server.start(); server.setState(states.get("canCloneMultipleRepositories").get("state")); - WLGitBridgeApplication wlgb = new WLGitBridgeApplication(new String[] { + GitBridgeApp wlgb = new GitBridgeApp(new String[] { makeConfigFile(33858, 3858) }); wlgb.run(); @@ -93,7 +93,7 @@ public class WLGitBridgeIntegrationTest { MockSnapshotServer server = new MockSnapshotServer(3860, getResource("/canPullADeletedTexFile").toFile()); server.start(); server.setState(states.get("canPullADeletedTexFile").get("base")); - WLGitBridgeApplication wlgb = new WLGitBridgeApplication(new String[] { + GitBridgeApp wlgb = new GitBridgeApp(new String[] { makeConfigFile(33860, 3860) }); wlgb.run(); @@ -120,7 +120,7 @@ public class WLGitBridgeIntegrationTest { MockSnapshotServer server = new MockSnapshotServer(3861, getResource("/cannotCloneAProtectedProject").toFile()); server.start(); server.setState(states.get("cannotCloneAProtectedProject").get("state")); - WLGitBridgeApplication wlgb = new WLGitBridgeApplication(new String[] { + GitBridgeApp wlgb = new GitBridgeApp(new String[] { makeConfigFile(33861, 3861) }); wlgb.run(); @@ -151,7 +151,7 @@ public class WLGitBridgeIntegrationTest { } private Path getResource(String path) { - return Paths.get("src/servermock/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest" + path); + return Paths.get("src/test/resources/uk/ac/ic/wlgitbridge/WLGitBridgeIntegrationTest" + path); } private InputStream getResourceAsStream(String path) { diff --git a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest.java b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest.java index 4b26b25640..6218e0464d 100644 --- a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest.java +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest.java @@ -11,50 +11,50 @@ public class FileUtilTest { @Test public void returnsTrueWhenFilesAreEqualInBothDirectories() throws URISyntaxException { - Path eq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsTrueWhenFilesAreEqualInBothDirectories/eq1").toURI()); - Path eq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsTrueWhenFilesAreEqualInBothDirectories/eq2").toURI()); + Path eq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsTrueWhenFilesAreEqualInBothDirectories/eq1").toURI()); + Path eq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsTrueWhenFilesAreEqualInBothDirectories/eq2").toURI()); Assert.assertTrue(FileUtil.gitDirectoriesAreEqual(eq1, eq2)); } @Test public void returnsTrueWhenRecursiveFilesAreEqualInBothDirectores() throws URISyntaxException { - Path eq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsTrueWhenRecursiveFilesAreEqualInBothDirectories/eq1").toURI()); - Path eq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsTrueWhenRecursiveFilesAreEqualInBothDirectories/eq2").toURI()); + Path eq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsTrueWhenRecursiveFilesAreEqualInBothDirectories/eq1").toURI()); + Path eq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsTrueWhenRecursiveFilesAreEqualInBothDirectories/eq2").toURI()); Assert.assertTrue(FileUtil.gitDirectoriesAreEqual(eq1, eq2)); } @Test public void returnsFalseWhenFilesAreNotEqualInBothDirectories() throws URISyntaxException { - Path neq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsFalseWhenFilesAreNotEqualInBothDirectories/neq1").toURI()); - Path neq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsFalseWhenFilesAreNotEqualInBothDirectories/neq2").toURI()); + Path neq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsFalseWhenFilesAreNotEqualInBothDirectories/neq1").toURI()); + Path neq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsFalseWhenFilesAreNotEqualInBothDirectories/neq2").toURI()); Assert.assertFalse(FileUtil.gitDirectoriesAreEqual(neq1, neq2)); } @Test public void returnsFalseWhenRecursiveFilesAreNotEqualInBothDirectories() throws URISyntaxException { - Path neq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsFalseWhenRecursiveFilesAreNotEqualInBothDirectories/neq1").toURI()); - Path neq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsFalseWhenRecursiveFilesAreNotEqualInBothDirectories/neq2").toURI()); + Path neq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsFalseWhenRecursiveFilesAreNotEqualInBothDirectories/neq1").toURI()); + Path neq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsFalseWhenRecursiveFilesAreNotEqualInBothDirectories/neq2").toURI()); Assert.assertFalse(FileUtil.gitDirectoriesAreEqual(neq1, neq2)); } @Test public void returnsTrueEvenIfGitDirectoriesAreNotEqual() throws URISyntaxException { - Path neq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsTrueEvenIfGitDirectoriesAreNotEqual/eq1").toURI()); - Path neq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsTrueEvenIfGitDirectoriesAreNotEqual/eq2").toURI()); + Path neq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsTrueEvenIfGitDirectoriesAreNotEqual/eq1").toURI()); + Path neq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsTrueEvenIfGitDirectoriesAreNotEqual/eq2").toURI()); Assert.assertTrue(FileUtil.gitDirectoriesAreEqual(neq1, neq2)); } @Test public void returnsFalseIfFileNamesAreNotEqual() throws URISyntaxException { - Path neq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsFalseIfFileNamesAreNotEqual/neq1").toURI()); - Path neq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsFalseIfFileNamesAreNotEqual/neq2").toURI()); + Path neq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsFalseIfFileNamesAreNotEqual/neq1").toURI()); + Path neq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsFalseIfFileNamesAreNotEqual/neq2").toURI()); Assert.assertFalse(FileUtil.gitDirectoriesAreEqual(neq1, neq2)); } @Test public void returnsFalseIfInnerDirectoryNamesAreNotEqual() throws URISyntaxException { - Path neq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsFalseIfInnerDirectoryNamesAreNotEqual/neq1").toURI()); - Path neq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/servermock/util/FileUtilTest/returnsFalseIfInnerDirectoryNamesAreNotEqual/neq2").toURI()); + Path neq1 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsFalseIfInnerDirectoryNamesAreNotEqual/neq1").toURI()); + Path neq2 = Paths.get(getClass().getResource("/uk/ac/ic/wlgitbridge/snapshot/servermock/util/FileUtilTest/returnsFalseIfInnerDirectoryNamesAreNotEqual/neq2").toURI()); Assert.assertFalse(FileUtil.gitDirectoriesAreEqual(neq1, neq2)); }