From 0d0c5458ddae3c6e20ffad01d261918ec87f4bed Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Mon, 7 Jan 2019 11:54:44 +0000 Subject: [PATCH 1/2] Handle when v1 is deprecated, print a message instead of an error --- .../snapshot/base/MissingRepositoryException.java | 7 +++++++ .../java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java index 320e3d192e..c3717b0afc 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java @@ -18,6 +18,13 @@ public class MissingRepositoryException extends SnapshotAPIException { "see https://www.overleaf.com/help/342 for more information." ); + public static final List OVERLEAF_V1_DEPRECATED_REASON = Arrays.asList( + "Overleaf v1 is deprecated, and you need to migrate this project to v2.", + "", + "If this is unexpected, please contact us at support@overleaf.com, or", + "see https://www.overleaf.com/help/342 for more information." + ); + static List buildExportedToV2Message(String remoteUrl) { if (remoteUrl == null) { return Arrays.asList( diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java index a7f994cce3..e9ef50114c 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java @@ -90,6 +90,10 @@ public abstract class Request { throw new MissingRepositoryException( MissingRepositoryException.buildExportedToV2Message(newRemote) ); + } else if ("Overleaf v1 is Deprecated".equals(message)) { + throw new MissingRepositoryException( + MissingRepositoryException.OVERLEAF_V1_DEPRECATED_REASON + ); } } catch (IllegalStateException | ClassCastException From 779778fdb1e436497197a3315c60f70805ac805a Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Tue, 8 Jan 2019 09:47:01 +0000 Subject: [PATCH 2/2] Use `newUrl` if supplied when v1 is deprecated --- .../base/MissingRepositoryException.java | 36 +++++++++++++++---- .../ic/wlgitbridge/snapshot/base/Request.java | 8 ++++- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java index c3717b0afc..9b0fef28ce 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/MissingRepositoryException.java @@ -18,12 +18,36 @@ public class MissingRepositoryException extends SnapshotAPIException { "see https://www.overleaf.com/help/342 for more information." ); - public static final List OVERLEAF_V1_DEPRECATED_REASON = Arrays.asList( - "Overleaf v1 is deprecated, and you need to migrate this project to v2.", - "", - "If this is unexpected, please contact us at support@overleaf.com, or", - "see https://www.overleaf.com/help/342 for more information." - ); + static List buildDeprecatedMessage(String newUrl) { + if (newUrl == null) { + return Arrays.asList( + "This project has not yet been moved into the new version of Overleaf. You will", + "need to move it in order to continue working on it. Please visit this project", + "online on www.overleaf.com to do this.", + "", + "After migrating this project to the new version of Overleaf, you will be", + "prompted to update your git remote to the project's new identifier.", + "", + "If this is unexpected, please contact us at support@overleaf.com, or", + "see https://www.overleaf.com/help/342 for more information." + ); + } else { + return Arrays.asList( + "This project has not yet been moved into the new version of Overleaf. You will", + "need to move it in order to continue working on it. Please visit this project", + "online to do this:", + "", + " " + newUrl, + "", + "After migrating this project to the new version of Overleaf, you will be", + "prompted to update your git remote to the project's new identifier.", + "", + "If this is unexpected, please contact us at support@overleaf.com, or", + "see https://www.overleaf.com/help/342 for more information." + ); + } + + } static List buildExportedToV2Message(String remoteUrl) { if (remoteUrl == null) { diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java index e9ef50114c..eeb40c8f35 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/base/Request.java @@ -91,8 +91,14 @@ public abstract class Request { MissingRepositoryException.buildExportedToV2Message(newRemote) ); } else if ("Overleaf v1 is Deprecated".equals(message)) { + String newUrl; + if (json.has("newUrl")) { + newUrl = json.get("newUrl").getAsString(); + } else { + newUrl = null; + } throw new MissingRepositoryException( - MissingRepositoryException.OVERLEAF_V1_DEPRECATED_REASON + MissingRepositoryException.buildDeprecatedMessage(newUrl) ); } } catch (IllegalStateException