diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/Bridge.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/Bridge.java index f01a9fb792..f448024e9a 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/Bridge.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/Bridge.java @@ -370,52 +370,18 @@ public class Bridge { Optional oauth2, String projectName, GetDocResult doc - ) throws IOException, GitUserException, CannotAcquireLockException { + ) throws IOException, GitUserException { ProjectRepo repo; ProjectState state = dbStore.getProjectState(projectName); switch (state) { case NOT_PRESENT: Log.info("[{}] Repo not present", projectName); - String migratedFromID = doc.getMigratedFromID(); - if (migratedFromID != null) { - Log.info("[{}] Has a migratedFromId: {}", projectName, migratedFromID); - try (LockGuard __ = lock.lockGuard(migratedFromID)) { - ProjectState sourceState = dbStore.getProjectState(migratedFromID); - switch (sourceState) { - case NOT_PRESENT: - // Normal init-repo - Log.info("[{}] migrated-from project not present, proceed as normal", - projectName - ); - repo = repoStore.initRepo(projectName); - break; - case SWAPPED: - // Swap back and then copy - swapJob.restore(migratedFromID); - /* Fallthrough */ - default: - // Copy data, and set version to zero - Log.info("[{}] Init from other project: {}", - projectName, - migratedFromID - ); - repo = repoStore.initRepoFromExisting(projectName, migratedFromID); - dbStore.setLatestVersionForProject(migratedFromID, 0); - dbStore.setLastAccessedTime( - migratedFromID, - Timestamp.valueOf(LocalDateTime.now()) - - ); - } - } - break; - } else { - repo = repoStore.initRepo(projectName); - break; - } + repo = repoStore.initRepo(projectName); + break; case SWAPPED: swapJob.restore(projectName); - /* Fallthrough */ + repo = repoStore.getExistingRepo(projectName); + break; default: repo = repoStore.getExistingRepo(projectName); } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/FSGitRepoStore.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/FSGitRepoStore.java index 229083c169..e2fadc05a0 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/FSGitRepoStore.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/FSGitRepoStore.java @@ -75,27 +75,6 @@ public class FSGitRepoStore implements RepoStore { ret, Optional.of(maxFileSize), Optional.empty()); } - @Override - public ProjectRepo initRepoFromExisting( - String project, String fromProject - ) throws IOException { - String repoRoot = getRepoStorePath(); - String sourcePath = repoRoot + "/" + fromProject; - String destinationPath = repoRoot + "/" + project; - Log.debug("[{}] Init repo by copying data from: {}, to: {}", - project, - sourcePath, - destinationPath - ); - File source = new File(sourcePath); - File destination = new File(destinationPath); - FileUtils.copyDirectory(source, destination); - GitProjectRepo ret = GitProjectRepo.fromName(project); - ret.useExistingRepository(this); - return new WalkOverrideGitRepo( - ret, Optional.of(maxFileSize), Optional.empty()); - } - @Override public ProjectRepo getExistingRepo(String project) throws IOException { GitProjectRepo ret = GitProjectRepo.fromName(project); diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/RepoStore.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/RepoStore.java index 9aba00f477..23bd294693 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/RepoStore.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/RepoStore.java @@ -22,8 +22,6 @@ public interface RepoStore { ProjectRepo initRepo(String project) throws IOException; - ProjectRepo initRepoFromExisting(String project, String fromProject) throws IOException; - ProjectRepo getExistingRepo(String project) throws IOException; ProjectRepo useJGitRepo(Repository repo, ObjectId commitId); diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/GetDocResult.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/GetDocResult.java index 085bd41e07..ac93c08ca8 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/GetDocResult.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/getdoc/GetDocResult.java @@ -19,7 +19,6 @@ public class GetDocResult extends Result { private int error; private int versionID; - private String migratedFromID; private String createdAt; private WLUser user; @@ -38,8 +37,7 @@ public class GetDocResult extends Result { int versionID, String createdAt, String email, - String name, - String migratedFromID + String name ) { if (error == null) { this.error = -1; @@ -49,7 +47,6 @@ public class GetDocResult extends Result { this.versionID = versionID; this.createdAt = createdAt; this.user = new WLUser(name, email); - this.migratedFromID = migratedFromID; } @Override @@ -62,9 +59,6 @@ public class GetDocResult extends Result { latestVerBy.addProperty("email", getEmail()); latestVerBy.addProperty("name", getName()); jsonThis.add("latestVerBy", latestVerBy); - if (migratedFromID != null) { - jsonThis.addProperty("migratedFromId", migratedFromID); - } } else { jsonThis.addProperty("status", error); String message; @@ -106,11 +100,6 @@ public class GetDocResult extends Result { } else { createdAt = null; } - if (jsonObject.has("migratedFromId")) { - migratedFromID = jsonObject.get("migratedFromId").getAsString(); - } else { - migratedFromID = null; - } String name = null; String email = null; JsonElement latestVerBy = jsonObject.get("latestVerBy"); @@ -144,6 +133,4 @@ public class GetDocResult extends Result { return user.getEmail(); } - public String getMigratedFromID() { return migratedFromID; } - } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIState.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIState.java index b3095874f9..02f8e19a8b 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIState.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIState.java @@ -48,8 +48,7 @@ public class SnapshotAPIState { 243, "2014-11-30T18:40:58Z", "jdleesmiller+1@gmail.com", - "John+1", - null + "John+1" ) ); 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 502a67aaa8..99f13239f4 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 @@ -87,7 +87,6 @@ public class SnapshotAPIStateBuilder { String createdAt = null; String email = null; String name = null; - String migratedFromId = null; if (jsonGetDoc.has("createdAt")) { createdAt = jsonGetDoc.get("createdAt").getAsString(); } @@ -97,9 +96,6 @@ public class SnapshotAPIStateBuilder { if (jsonGetDoc.has("name")) { name = jsonGetDoc.get("name").getAsString(); } - if (jsonGetDoc.has("migratedFromId")) { - migratedFromId = jsonGetDoc.get("migratedFromId").getAsString(); - } getDoc.put( projectName, new GetDocResult( @@ -107,8 +103,7 @@ public class SnapshotAPIStateBuilder { versionID, createdAt, email, - name, - migratedFromId + name ) ); }