|
@@ -2,6 +2,7 @@ package uk.ac.ic.wlgitbridge.snapshot.base;
|
|
|
|
|
|
|
|
import com.google.api.client.http.*;
|
|
import com.google.api.client.http.*;
|
|
|
import com.google.gson.JsonElement;
|
|
import com.google.gson.JsonElement;
|
|
|
|
|
+import com.google.gson.JsonObject;
|
|
|
import com.ning.http.client.AsyncHttpClient;
|
|
import com.ning.http.client.AsyncHttpClient;
|
|
|
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
|
|
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
|
|
|
import uk.ac.ic.wlgitbridge.util.Instance;
|
|
import uk.ac.ic.wlgitbridge.util.Instance;
|
|
@@ -74,13 +75,22 @@ public abstract class Request<T extends Result> {
|
|
|
if (sc == HttpServletResponse.SC_UNAUTHORIZED || sc == HttpServletResponse.SC_FORBIDDEN) {
|
|
if (sc == HttpServletResponse.SC_UNAUTHORIZED || sc == HttpServletResponse.SC_FORBIDDEN) {
|
|
|
throw new ForbiddenException();
|
|
throw new ForbiddenException();
|
|
|
} else if (sc == HttpServletResponse.SC_NOT_FOUND) {
|
|
} else if (sc == HttpServletResponse.SC_NOT_FOUND) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ JsonObject json = Instance.gson.fromJson(httpCause.getContent(), JsonObject.class);
|
|
|
|
|
+ String message = json.get("message").getAsString();
|
|
|
|
|
+
|
|
|
|
|
+ if ("Exported to v2".equals(message)) {
|
|
|
|
|
+ throw new MissingRepositoryException(MissingRepositoryException.EXPORTED_TO_V2);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IllegalStateException
|
|
|
|
|
+ | ClassCastException
|
|
|
|
|
+ | NullPointerException _) {
|
|
|
|
|
+ // disregard any errors that arose while handling the JSON
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
throw new MissingRepositoryException();
|
|
throw new MissingRepositoryException();
|
|
|
} else if (sc >= 400 && sc < 500) {
|
|
} else if (sc >= 400 && sc < 500) {
|
|
|
- throw new MissingRepositoryException(
|
|
|
|
|
- "This project is currently inaccessible over Git.\n" +
|
|
|
|
|
- "\n" +
|
|
|
|
|
- "If you think this is an error, contact support at support@overleaf.com."
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ throw new MissingRepositoryException(MissingRepositoryException.GENERIC_REASON);
|
|
|
}
|
|
}
|
|
|
throw new FailedConnectionException(cause);
|
|
throw new FailedConnectionException(cause);
|
|
|
} else {
|
|
} else {
|